feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
@@ -0,0 +1,182 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewReservationPanel.vue
|
||||
用途:复核工作台 Reservation 校验摘要;展示行级有效预约号与阻断 issue。
|
||||
依赖:vue-i18n、revalidateWorkspaceShippingOrderReviewReservation、showReviewResumeOutcome。
|
||||
逻辑:needs_attention 时展示;编辑聚焦明细行;重校验后 emit refreshed 并展示 resume 提示。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError, resolveLocalizedErrorMessage } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { revalidateWorkspaceShippingOrderReviewReservation } from '@/features/chat/api/shipping.api';
|
||||
import { showReviewResumeOutcome } from '@/features/chat/shipping-review/showReviewResumeOutcome';
|
||||
import type { ShippingOrderReviewReservation } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
caseNo: string;
|
||||
draftVersion: number | null | undefined;
|
||||
reservation: ShippingOrderReviewReservation | null | undefined;
|
||||
editable: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
refreshed: [];
|
||||
'focus-line': [lineIndex: number];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
const busy = ref(false);
|
||||
|
||||
const visible = computed(() => Boolean(props.reservation?.needs_attention || props.reservation?.issues?.length));
|
||||
const lines = computed(() => props.reservation?.lines || []);
|
||||
const issues = computed(() => props.reservation?.issues || []);
|
||||
|
||||
/**
|
||||
* Reservation 状态本地化。
|
||||
*/
|
||||
const statusLabel = computed(() => {
|
||||
const status = String(props.reservation?.status || '').trim();
|
||||
const key = `chat.shippingOrderReview.reservation.status.${status}`;
|
||||
if (status && te(key)) return t(key);
|
||||
return props.reservation?.needs_attention
|
||||
? t('chat.shippingOrderReview.reservation.status.needs_attention')
|
||||
: t('chat.shippingOrderReview.reservation.status.ok');
|
||||
});
|
||||
|
||||
/**
|
||||
* issue / block_reason 本地化文案。
|
||||
*/
|
||||
function issueLabel(code: string | null | undefined): string {
|
||||
const normalized = String(code || '').trim();
|
||||
if (!normalized) return t('chat.shippingOrderReview.reservation.unknownIssue');
|
||||
const key = `chat.shippingOrderReview.reservation.issues.${normalized}`;
|
||||
return te(key) ? t(key) : normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* 聚焦明细行以便编辑 reservation_id。
|
||||
*/
|
||||
function onFocusLine(lineIndex: number | null | undefined) {
|
||||
if (lineIndex == null || !Number.isFinite(Number(lineIndex))) return;
|
||||
emit('focus-line', Number(lineIndex));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显式重校验 Reservation 并刷新 Case / 建单资格。
|
||||
*/
|
||||
async function onRevalidate() {
|
||||
if (!props.caseNo || props.draftVersion == null || !props.editable || busy.value) return;
|
||||
busy.value = true;
|
||||
try {
|
||||
const result = await revalidateWorkspaceShippingOrderReviewReservation(props.caseNo, {
|
||||
expected_draft_version: props.draftVersion,
|
||||
});
|
||||
showReviewResumeOutcome(
|
||||
result.resume_outcome,
|
||||
msg,
|
||||
t,
|
||||
t('chat.shippingOrderReview.reservation.revalidateDone'),
|
||||
);
|
||||
emit('refreshed');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof BusinessError
|
||||
? resolveLocalizedErrorMessage(error.code, error.message)
|
||||
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.reservation.revalidateFailed'));
|
||||
msg.warning(message);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
v-if="visible"
|
||||
class="rounded-xl border border-violet-200 bg-violet-50/70 p-3 shadow-sm dark:border-violet-900 dark:bg-violet-950/40"
|
||||
data-testid="review-reservation-panel"
|
||||
>
|
||||
<header class="flex flex-wrap items-start justify-between gap-2">
|
||||
<div>
|
||||
<h2 class="text-sm font-semibold text-violet-950 dark:text-violet-50">
|
||||
{{ t('chat.shippingOrderReview.reservation.title') }}
|
||||
</h2>
|
||||
<p class="mt-0.5 text-xs text-violet-900 dark:text-violet-200">
|
||||
{{ t('chat.shippingOrderReview.reservation.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
<span
|
||||
class="rounded-full px-2.5 py-1 text-xs font-medium"
|
||||
:class="reservation?.needs_attention
|
||||
? 'bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-100'
|
||||
: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-100'"
|
||||
data-testid="review-reservation-badge"
|
||||
>
|
||||
{{ statusLabel }}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<ul v-if="issues.length" class="mt-2 space-y-1 text-xs text-violet-950 dark:text-violet-100">
|
||||
<li
|
||||
v-for="(issue, idx) in issues"
|
||||
:key="`${issue.code}-${issue.line_index}-${idx}`"
|
||||
class="rounded border border-violet-200 bg-white/90 px-2 py-1 dark:border-violet-900 dark:bg-slate-900"
|
||||
>
|
||||
<span v-if="issue.line_index != null">#{{ issue.line_index + 1 }} · </span>
|
||||
{{ issue.message || issueLabel(issue.code) }}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div v-if="lines.length" class="mt-2 overflow-x-auto">
|
||||
<table class="min-w-full text-left text-xs">
|
||||
<thead class="text-muted">
|
||||
<tr>
|
||||
<th class="px-1 py-1 font-medium">#</th>
|
||||
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.reservation.reservationId') }}</th>
|
||||
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.reservation.action') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="line in lines"
|
||||
:key="String(line.line_key || line.line_index)"
|
||||
class="border-t border-violet-100 dark:border-violet-900"
|
||||
:class="line.needs_attention ? 'bg-amber-50/80 dark:bg-amber-950/20' : ''"
|
||||
>
|
||||
<td class="px-1 py-1">{{ (line.line_index ?? 0) + 1 }}</td>
|
||||
<td class="px-1 py-1 font-mono">
|
||||
{{ line.effective_reservation_id || '—' }}
|
||||
<span v-if="line.block_reason" class="ml-1 text-[10px] text-rose-600 dark:text-rose-400">
|
||||
{{ issueLabel(line.block_reason) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-1 py-1">
|
||||
<button
|
||||
v-if="editable && line.line_index != null"
|
||||
type="button"
|
||||
class="text-[11px] text-primary underline-offset-2 hover:underline"
|
||||
data-testid="review-reservation-focus-line"
|
||||
@click="onFocusLine(line.line_index)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.reservation.editLine') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-if="editable" class="mt-3 flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-violet-300 bg-white px-3 py-1.5 text-sm text-violet-950 hover:bg-violet-100 disabled:opacity-60 dark:border-violet-800 dark:bg-slate-900 dark:text-violet-100 dark:hover:bg-violet-950"
|
||||
data-testid="review-reservation-revalidate"
|
||||
:disabled="busy || draftVersion == null"
|
||||
@click="onRevalidate"
|
||||
>
|
||||
{{ busy ? t('chat.shippingOrderReview.reservation.revalidating') : t('chat.shippingOrderReview.reservation.revalidate') }}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
Reference in new issue
Block a user