feat(shipping-notice): 实现滚动履约功能,优化发货通知流程与代码清理

清理废弃的ShippingCase相关代码与依赖,统一使用ShippingNotice直接关联客户数据。调整库存网关依赖规则,支持仅对库存满足或已人工放行的订单行生成发货Excel,实现滚动履约逻辑。
This commit is contained in:
hugo committed 2026-08-26 02:47:07 +08:00
1 parent 7cfd5d167e
commit 1e5aedb9ed
235 files changed
+11394 -9613

No files matched your search

@@ -19,9 +19,11 @@ const i18n = createI18n({
shippingNotice: {
processGate: {
actionCodes: {
reload_inventory_result: '重新读取库存结果',
retry_inventory_preparation: '重新获取库存',
},
inventoryActions: {
reloadInventoryResult: '重新读取库存结果',
retryInventoryMatching: '重新库存匹配',
retryInventoryPreparation: '重新获取库存',
},
@@ -80,6 +82,18 @@ describe('ReviewCurrentProcessingCard', () => {
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(true);
});
it('renders reload inventory result as the timeout primary action', () => {
const wrapper = mount(ReviewCurrentProcessingCard, {
props: {
stageCode: 'inventory_preparation', userStatus: 'retryable', retryable: true,
primaryAction: { code: 'reload_inventory_result' },
},
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').text()).toBe('重新读取库存结果');
});
it('hides the order-review entry when the user is already in the lifecycle workbench', () => {
const wrapper = mount(ReviewCurrentProcessingCard, {
props: {
@@ -352,7 +352,18 @@ type ReviewCurrentUserStatus =
</div>
<div class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.currentProcessing.status') }}</dt>
<dd data-testid="review-current-task-status" :class="loading ? 'animate-pulse' : ''">{{ statusLabel }}</dd>
<dd
class="inline-flex items-center gap-1"
data-testid="review-current-task-status"
:class="loading ? 'animate-pulse' : ''"
>
<RefreshCw
v-if="userStatus === 'running' && !loading"
class="h-3 w-3 animate-spin"
aria-hidden="true"
/>
{{ statusLabel }}
</dd>
</div>
<div
v-if="hasFormalOt && shippingNoticeNo"
@@ -1,275 +1,30 @@
<!--
features/chat/components/shipping-review/ReviewFulfillmentDecisionPanel.vue
用途:复核工作台行级履约决定(等待补货 / 完整行先行 / 关闭)。
依赖:vue-i18n、decide/wave line-fulfillment API、showReviewResumeOutcome。
逻辑:分列展示料号/需求数量/可用数量/预约单号/状态;禁止 part_number 回退预约单号;
逐行决定;选中 fulfill 行可确认波次;关闭 emit open-close-dialog。
-->
<!-- 履约摘要侧栏;完整明细与批量出单统一由主库存表承载。 -->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { BusinessError, resolveLocalizedErrorMessage } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import {
decideWorkspaceShippingOrderReviewLineFulfillment,
waveWorkspaceShippingOrderReviewLineFulfillment,
} from '@/features/chat/api/shipping.api';
import { showReviewResumeOutcome } from '@/features/chat/shipping-review/showReviewResumeOutcome';
import type {
ShippingOrderReviewLineFulfillment,
ShippingOrderReviewLineFulfillmentDecisionCode,
ShippingOrderReviewLineFulfillmentLine,
} from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
caseNo: string;
draftVersion: number | null | undefined;
lineFulfillment: ShippingOrderReviewLineFulfillment | null | undefined;
editable: boolean;
}>();
const emit = defineEmits<{
refreshed: [];
'open-close-dialog': [lineKeys: string[]];
}>();
const { t, te } = useI18n();
const msg = useMessage();
const busyKey = ref<string | null>(null);
const selectedFulfillKeys = ref<string[]>([]);
const waveBusy = ref(false);
import type { ShippingOrderReviewLineFulfillment } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{ caseNo: string; draftVersion: number | null | undefined; lineFulfillment: ShippingOrderReviewLineFulfillment | null | undefined; editable: boolean }>();
const emit = defineEmits<{ refreshed: []; 'open-close-dialog': [lineKeys: string[]] }>();
const { t } = useI18n();
const TERMINAL_STATUSES = new Set(['task_created', 'fulfilled', 'closed_unfulfillable']);
const visible = computed(() => Boolean(
props.lineFulfillment?.has_open_lines
|| props.lineFulfillment?.has_shortage,
));
const openLines = computed(() => (props.lineFulfillment?.lines || []).filter(
(line) => !TERMINAL_STATUSES.has(String(line.line_status || '')),
));
/**
* 行状态本地化。
*/
function lineStatusLabel(status: string | null | undefined): string {
const normalized = String(status || 'pending_decision').trim();
const key = `chat.shippingOrderReview.fulfillmentDecision.lineStatus.${normalized}`;
return te(key) ? t(key) : normalized;
}
/**
* 切换 fulfill 波次选中行。
*/
function toggleFulfillSelection(lineKey: string, checked: boolean) {
const set = new Set(selectedFulfillKeys.value);
if (checked) set.add(lineKey);
else set.delete(lineKey);
selectedFulfillKeys.value = [...set];
}
/**
* 行是否可选入 fulfill 波次。
*/
function canSelectForWave(line: ShippingOrderReviewLineFulfillmentLine): boolean {
if (TERMINAL_STATUSES.has(String(line.line_status || ''))) return false;
return Boolean(line.can_fulfill_complete_line);
}
/**
* 写入单行履约决定。
*/
async function onDecide(
line: ShippingOrderReviewLineFulfillmentLine,
decisionCode: ShippingOrderReviewLineFulfillmentDecisionCode,
) {
if (!props.caseNo || !props.editable || busyKey.value) return;
if (decisionCode === 'close_unfulfillable') {
emit('open-close-dialog', [line.line_key]);
return;
}
busyKey.value = line.line_key;
try {
const result = await decideWorkspaceShippingOrderReviewLineFulfillment(props.caseNo, {
line_key: line.line_key,
decision_code: decisionCode,
expected_draft_version: props.draftVersion ?? undefined,
});
showReviewResumeOutcome(
result.resume_outcome,
msg,
t,
t('chat.shippingOrderReview.fulfillmentDecision.decideSuccess'),
);
emit('refreshed');
} catch (error: unknown) {
const message = error instanceof BusinessError
? resolveLocalizedErrorMessage(error.code, error.message)
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.fulfillmentDecision.decideFailed'));
msg.warning(message);
} finally {
busyKey.value = null;
}
}
/**
* 为选中完整行创建履约波次 Task。
*/
async function onConfirmWave() {
if (!props.caseNo || props.draftVersion == null || waveBusy.value || !selectedFulfillKeys.value.length) return;
waveBusy.value = true;
try {
const idempotencyKey = `review-wave-${props.caseNo}-${Date.now()}-${selectedFulfillKeys.value.sort().join(',')}`;
const result = await waveWorkspaceShippingOrderReviewLineFulfillment(props.caseNo, {
line_keys: [...selectedFulfillKeys.value],
expected_draft_version: props.draftVersion,
idempotency_key: idempotencyKey,
});
showReviewResumeOutcome(
result.resume_outcome,
msg,
t,
t('chat.shippingOrderReview.fulfillmentDecision.waveSuccess', {
taskNo: result.task_no || '',
}),
);
selectedFulfillKeys.value = [];
emit('refreshed');
} catch (error: unknown) {
const message = error instanceof BusinessError
? resolveLocalizedErrorMessage(error.code, error.message)
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.fulfillmentDecision.waveFailed'));
msg.warning(message);
} finally {
waveBusy.value = false;
}
}
/**
* 打开关闭剩余行对话框(全部开放行)。
*/
function onCloseRemaining() {
const keys = openLines.value.map((line) => line.line_key);
emit('open-close-dialog', keys);
}
const openLines = computed(() => (props.lineFulfillment?.lines || []).filter((line) => !TERMINAL_STATUSES.has(String(line.line_status || ''))));
const visible = computed(() => Boolean(props.lineFulfillment?.has_open_lines || props.lineFulfillment?.has_shortage));
function onCloseRemaining() { emit('open-close-dialog', openLines.value.map((line) => line.line_key)); }
</script>
<template>
<section
v-if="visible"
class="rounded-xl border border-sky-200 bg-sky-50/70 p-3 shadow-sm dark:border-sky-900 dark:bg-sky-950/40"
data-testid="review-fulfillment-decision-panel"
>
<section v-if="visible" class="rounded-xl border border-sky-200 bg-sky-50/70 p-3 shadow-sm dark:border-sky-900 dark:bg-sky-950/40" data-testid="review-fulfillment-decision-panel">
<header class="flex flex-wrap items-start justify-between gap-2">
<div>
<h2 class="text-sm font-semibold text-sky-950 dark:text-sky-50">
{{ t('chat.shippingOrderReview.fulfillmentDecision.title') }}
</h2>
<p class="mt-0.5 text-xs text-sky-900 dark:text-sky-200">
{{ t('chat.shippingOrderReview.fulfillmentDecision.subtitle') }}
</p>
</div>
<span class="rounded-full bg-sky-100 px-2.5 py-1 text-xs font-medium text-sky-900 dark:bg-sky-950 dark:text-sky-100">
{{ t('chat.shippingOrderReview.fulfillmentDecision.openCount', { count: lineFulfillment?.open_count ?? openLines.length }) }}
</span>
<div><h2 class="text-sm font-semibold text-sky-950 dark:text-sky-50">{{ t('chat.shippingOrderReview.fulfillmentDecision.title') }}</h2><p class="mt-0.5 text-xs text-sky-900 dark:text-sky-200">{{ t('chat.shippingOrderReview.fulfillmentDecision.railHint') }}</p></div>
<span class="rounded-full bg-sky-100 px-2.5 py-1 text-xs font-medium text-sky-900 dark:bg-sky-950 dark:text-sky-100">{{ t('chat.shippingOrderReview.fulfillmentDecision.openCount', { count: lineFulfillment?.open_count ?? openLines.length }) }}</span>
</header>
<div class="mt-2 overflow-x-auto">
<table class="min-w-full text-left text-xs">
<thead class="text-muted">
<tr>
<th v-if="editable" class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.waveSelect') }}</th>
<th class="px-1 py-1 font-medium">#</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.partNumber') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.requiredQty') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.reservationId') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.status') }}</th>
<th v-if="editable" class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.actions') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="line in lineFulfillment?.lines || []"
:key="line.line_key"
class="border-t border-sky-100 dark:border-sky-900"
>
<td v-if="editable" class="px-1 py-1">
<input
v-if="canSelectForWave(line)"
type="checkbox"
class="rounded border-default"
:checked="selectedFulfillKeys.includes(line.line_key)"
:data-testid="`review-fulfill-select-${line.line_key}`"
@change="toggleFulfillSelection(line.line_key, ($event.target as HTMLInputElement).checked)"
>
</td>
<td class="px-1 py-1">{{ (line.line_index ?? 0) + 1 }}</td>
<td class="px-1 py-1 font-mono" data-testid="review-fulfill-part-number">
{{ line.part_number || t('chat.shippingOrderReview.fulfillmentDecision.partUnrecognized') }}
</td>
<td class="px-1 py-1">{{ line.required_qty ?? '—' }}</td>
<td class="px-1 py-1">{{ line.available_qty ?? '—' }}</td>
<td class="px-1 py-1 font-mono">{{ line.reservation_id || '—' }}</td>
<td class="px-1 py-1">{{ lineStatusLabel(line.line_status) }}</td>
<td v-if="editable && !TERMINAL_STATUSES.has(String(line.line_status || ''))" class="px-1 py-1">
<div class="flex flex-wrap gap-1">
<button
type="button"
class="rounded border border-sky-300 px-2 py-1 text-xs hover:bg-sky-100 disabled:opacity-50 dark:border-sky-800 dark:hover:bg-sky-950"
:disabled="busyKey != null"
@click="onDecide(line, 'wait_inventory')"
>
{{ t('chat.shippingOrderReview.fulfillmentDecision.waitInventory') }}
</button>
<button
v-if="line.can_fulfill_complete_line"
type="button"
class="rounded border border-emerald-300 px-2 py-1 text-xs hover:bg-emerald-50 disabled:opacity-50 dark:border-emerald-800 dark:hover:bg-emerald-950"
:disabled="busyKey != null"
@click="onDecide(line, 'fulfill_complete_line_now')"
>
{{ t('chat.shippingOrderReview.fulfillmentDecision.fulfillNow') }}
</button>
<button
type="button"
class="rounded border border-rose-300 px-2 py-1 text-xs text-rose-800 hover:bg-rose-50 disabled:opacity-50 dark:border-rose-800 dark:text-rose-200 dark:hover:bg-rose-950"
:disabled="busyKey != null"
@click="onDecide(line, 'close_unfulfillable')"
>
{{ t('chat.shippingOrderReview.fulfillmentDecision.closeLine') }}
</button>
</div>
</td>
<td v-else-if="editable" class="px-1 py-1 text-muted">—</td>
</tr>
</tbody>
</table>
</div>
<div v-if="editable" class="mt-3 flex flex-wrap gap-2">
<button
type="button"
class="rounded-xl bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-60"
data-testid="review-fulfillment-confirm-wave"
:disabled="waveBusy || !selectedFulfillKeys.length || draftVersion == null"
@click="onConfirmWave"
>
{{ waveBusy
? t('chat.shippingOrderReview.fulfillmentDecision.waving')
: t('chat.shippingOrderReview.fulfillmentDecision.confirmWave', { count: selectedFulfillKeys.length }) }}
</button>
<button
v-if="openLines.length"
type="button"
class="rounded-xl border border-rose-300 bg-white px-3 py-1.5 text-sm text-rose-800 hover:bg-rose-50 disabled:opacity-60 dark:border-rose-800 dark:bg-slate-900 dark:text-rose-200"
data-testid="review-fulfillment-close-remaining"
:disabled="waveBusy || busyKey != null"
@click="onCloseRemaining"
>
{{ t('chat.shippingOrderReview.fulfillmentDecision.closeRemaining') }}
</button>
<div class="mt-2 grid grid-cols-2 gap-2 text-xs sm:grid-cols-4">
<div class="rounded-lg bg-white/70 px-2.5 py-2 dark:bg-slate-900/50">{{ t('chat.shippingOrderReview.fulfillmentDecision.readyCount', { count: lineFulfillment?.ready_count ?? 0 }) }}</div>
<div class="rounded-lg bg-white/70 px-2.5 py-2 dark:bg-slate-900/50">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortageCount', { count: lineFulfillment?.manual_pending_count ?? 0 }) }}</div>
<div class="rounded-lg bg-white/70 px-2.5 py-2 dark:bg-slate-900/50">{{ t('chat.shippingOrderReview.fulfillmentDecision.autoProgressCount', { count: lineFulfillment?.auto_progress_count ?? 0 }) }}</div>
<div class="rounded-lg bg-white/70 px-2.5 py-2 dark:bg-slate-900/50">{{ t('chat.shippingOrderReview.fulfillmentDecision.summaryHint') }}</div>
</div>
<div v-if="editable && openLines.length" class="mt-3"><button type="button" class="rounded-xl border border-rose-300 bg-white px-3 py-1.5 text-sm text-rose-800 hover:bg-rose-50 dark:border-rose-800 dark:bg-slate-900 dark:text-rose-200" data-testid="review-fulfillment-close-remaining" @click="onCloseRemaining">{{ t('chat.shippingOrderReview.fulfillmentDecision.closeRemaining') }}</button></div>
</section>
</template>
@@ -22,6 +22,7 @@ const i18n = createI18n({
lifecycle: {
navigation: '订单生命周期阶段',
current: '当前可处理',
processing: '处理中',
completed: '已完成,可查看',
blocked: '前置未完成',
},
@@ -41,7 +42,7 @@ const stages: ReviewLifecycleStageItem[] = [
/** 挂载导航,复用真实 i18n 以覆盖状态文案渲染。 */
function mountNavigation() {
return mount(ReviewLifecycleStageNavigation, {
props: { stages, activeCode: 'fulfillment_prep' },
props: { stages, activeCode: 'fulfillment_prep', processingCode: 'fulfillment_prep' },
global: { plugins: [i18n] },
});
}
@@ -102,6 +103,14 @@ describe('ReviewLifecycleStageNavigation', () => {
expect(wrapper.emitted('select')).toEqual([['order_review']]);
});
it('shows a spinner and processing label on the active stage while automation runs', () => {
const wrapper = mountNavigation();
const stage = wrapper.get('[data-testid="review-lifecycle-stage-fulfillment_prep"]');
expect(stage.attributes('data-processing')).toBe('1');
expect(stage.text()).toContain('处理中');
expect(stage.find('[data-testid="review-lifecycle-stage-spinner"]').exists()).toBe(true);
});
it('disables a future stage and does not emit a selection', async () => {
const wrapper = mountNavigation();
const future = wrapper.get('[data-testid="review-lifecycle-stage-upload_complete"]');
@@ -5,7 +5,7 @@
逻辑:用户可打开当前或已完成阶段查看;后续阶段由父级传入 blocked 并禁用,本组件不写业务状态。
-->
<script setup lang="ts">
import { Check, LockKeyhole } from 'lucide-vue-next';
import { Check, LockKeyhole, RefreshCw } from 'lucide-vue-next';
export type ReviewLifecycleStageCode = 'intake_parse' | 'order_review' | 'fulfillment_prep' | 'freight_upload' | 'upload_complete';
export type ReviewLifecycleStageState = 'current' | 'completed' | 'blocked';
@@ -23,6 +23,8 @@ const props = defineProps<{
activeCode: ReviewLifecycleStageCode | null;
/** 仅消费当前对象后端下发的恢复动作,禁止按阶段或状态由前端猜测。 */
availableActions?: string[];
/** 当前阶段正在执行自动推进时的技术阶段码;只影响展示,不授权动作。 */
processingCode?: ReviewLifecycleStageCode | null;
/** retry_parse 请求中的互斥状态,避免用户重复提交。 */
retrying?: boolean;
}>();
@@ -67,8 +69,15 @@ function selectStage(stage: ReviewLifecycleStageItem) {
stage.state === 'blocked' ? 'opacity-60' : '',
]"
:data-testid="`review-lifecycle-stage-${stage.code}`"
:data-processing="stage.code === props.processingCode ? '1' : '0'"
>
<span class="flex items-center gap-2 text-sm font-semibold">
<RefreshCw
v-if="stage.code === props.processingCode"
class="h-4 w-4 shrink-0 animate-spin text-brand-600"
data-testid="review-lifecycle-stage-spinner"
aria-hidden="true"
/>
<Check v-if="stage.state === 'completed'" class="h-4 w-4 shrink-0 text-emerald-600" />
<LockKeyhole v-else-if="stage.state === 'blocked'" class="h-4 w-4 shrink-0 text-muted" />
<span v-else class="h-2 w-2 shrink-0 rounded-full bg-brand-600" aria-hidden="true" />
@@ -88,7 +97,9 @@ function selectStage(stage: ReviewLifecycleStageItem) {
@click="selectStage(stage)"
>
{{ stage.state === 'current'
? $t('chat.shippingOrderReview.lifecycle.current')
? (stage.code === props.processingCode
? $t('chat.shippingOrderReview.lifecycle.processing')
: $t('chat.shippingOrderReview.lifecycle.current'))
: stage.state === 'completed'
? $t('chat.shippingOrderReview.lifecycle.completed')
: (stage.reason || $t('chat.shippingOrderReview.lifecycle.blocked')) }}
@@ -18,6 +18,7 @@ const i18n = createI18n({
title: '文档模板匹配', subtitle: '摘要', selected: '命中模板', noSelected: '未选定模板',
expandCandidates: '查看候选模板({count})', collapseCandidates: '收起候选模板',
routeType: '路由类型', executionMode: '执行模式',
extractionBlocked: '模板已命中,但字段提取仍被安全门禁阻断', extractionBlockedReason: '阻断原因:{reasons}',
coordinateModel: {
anchorFrame: '锚点坐标框架', status: '变换状态', translateX: '横向平移',
translateY: '纵向平移', reasonCodes: '原因码',
@@ -102,6 +103,27 @@ describe('ReviewProfileMatchPanel', () => {
expect(wrapper.get('[data-testid="review-profile-match-candidates"]').text()).not.toContain('ODP-A');
});
it('唯一命中时仍展示下游字段提取门禁的阻断原因', () => {
const wrapper = mount(ReviewProfileMatchPanel, {
props: {
profileMatch: {
available: true,
visibility: 'admin',
status: 'unique_match',
needs_review: true,
selected_profile: { profile_code: 'ODP-A', display_name: '客户订单模板', version: 1 },
candidates: [{ profile_code: 'ODP-A', display_name: '客户订单模板', score: 0.99 }],
fallback_reason_codes: ['PARSE_STRATEGY_ROW_MODE_AMBIGUOUS'],
},
},
global: { plugins: [i18n] },
});
// 关键断言:唯一模板命中不等于字段已提取,必须明确暴露下游阻断原因。
expect(wrapper.get('[data-testid="review-profile-match-extraction-blocked"]').text())
.toContain('PARSE_STRATEGY_ROW_MODE_AMBIGUOUS');
});
it('管理员技术详情展示锚点框架平移和稳定原因码,不展示原始正文或完整坐标', async () => {
const wrapper = mountAnchorFramePanel();
@@ -43,6 +43,10 @@ const selectedCoordinateTransform = computed(() => {
const coordinateTransformReasonCodes = computed(() => (
selectedCoordinateTransform.value?.reason_codes || []
));
/** 唯一命中仅证明版式身份;下游字段/明细恢复若受门禁阻断,必须在同卡明确说明。 */
const extractionBlockReasons = computed(() => (
(props.profileMatch?.fallback_reason_codes || []).filter((code) => String(code).trim())
));
watch(
() => `${props.profileMatch?.status || ''}:${props.profileMatch?.selected_profile?.profile_code || ''}:${candidateCount.value}`,
@@ -108,6 +112,17 @@ const selectedLabel = computed(() => {
</div>
</dl>
<div
v-if="extractionBlockReasons.length"
class="mt-3 rounded-lg border border-amber-200 bg-amber-50 px-2.5 py-2 text-xs text-amber-900 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100"
data-testid="review-profile-match-extraction-blocked"
>
<p class="font-medium">{{ t('chat.shippingOrderReview.profileMatch.extractionBlocked') }}</p>
<p class="mt-1 text-amber-800 dark:text-amber-200">
{{ t('chat.shippingOrderReview.profileMatch.extractionBlockedReason', { reasons: extractionBlockReasons.join(', ') }) }}
</p>
</div>
<template v-if="isAdminView && candidateCount">
<button
type="button"
@@ -0,0 +1,59 @@
/**
* features/chat/components/shipping-review/ReviewReservationPanel.spec.ts
* 用途:验证 Reservation 校验面板只展示问题与重新校验入口,不重复提供明细编辑入口。
* 依赖:Vue Test Utils、vue-i18n、Reservation 重校验 API。
* 逻辑:挂载存在异常的 Reservation 面板,确认问题文案与重新校验按钮保留,编辑按钮不再出现。
*/
import { mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
import { describe, expect, it, vi } from 'vitest';
import chatZhCn from '@/locales/zh-CN/chat.json';
import ReviewReservationPanel from './ReviewReservationPanel.vue';
vi.mock('@/features/chat/api/shipping.api', () => ({
revalidateWorkspaceShippingOrderReviewReservation: vi.fn(),
}));
vi.mock('@/shared/composables/useMessage', () => ({
useMessage: () => ({ success: vi.fn(), warning: vi.fn(), error: vi.fn(), info: vi.fn() }),
}));
vi.mock('@/features/chat/shipping-review/showReviewResumeOutcome', () => ({
showReviewResumeOutcome: vi.fn(),
}));
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: { 'zh-CN': { chat: chatZhCn } },
});
describe('ReviewReservationPanel', () => {
it('只保留校验提示和重新校验入口,不重复提供明细编辑按钮', () => {
const wrapper = mount(ReviewReservationPanel, {
props: {
caseNo: 'CASE-1',
draftVersion: 3,
editable: true,
reservation: {
needs_attention: true,
status: 'needs_attention',
issues: [{ code: 'reservation_missing', severity: 'blocking', line_index: 0 }],
lines: [{
line_key: 'line-1',
line_index: 0,
effective_reservation_id: null,
needs_attention: true,
block_reason: 'reservation_missing',
}],
},
},
global: { plugins: [i18n] },
});
expect(wrapper.text()).toContain('缺少预约单号');
expect(wrapper.get('[data-testid="review-reservation-revalidate"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-reservation-focus-line"]').exists()).toBe(false);
expect(wrapper.text()).not.toContain('编辑此行');
});
});
@@ -2,7 +2,7 @@
features/chat/components/shipping-review/ReviewReservationPanel.vue
用途:复核工作台 Reservation 校验摘要;展示行级有效预约号与阻断 issue。
依赖:vue-i18n、revalidateWorkspaceShippingOrderReviewReservation、showReviewResumeOutcome。
逻辑:needs_attention 时展示;编辑聚焦明细行;重校验后 emit refreshed 并展示 resume 提示。
逻辑:needs_attention 时展示问题;左侧订单明细是唯一编辑位置;重校验后 emit refreshed 并展示 resume 提示。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
@@ -20,10 +20,7 @@ const props = defineProps<{
editable: boolean;
}>();
const emit = defineEmits<{
refreshed: [];
'focus-line': [lineIndex: number];
}>();
const emit = defineEmits<{ refreshed: [] }>();
const { t, te } = useI18n();
const msg = useMessage();
@@ -55,14 +52,6 @@ function issueLabel(code: string | null | undefined): string {
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 / 建单资格。
*/
@@ -128,13 +117,16 @@ async function onRevalidate() {
</li>
</ul>
<p v-if="editable" class="mt-2 text-xs text-violet-900 dark:text-violet-200">
{{ t('chat.shippingOrderReview.reservation.editHint') }}
</p>
<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>
@@ -151,17 +143,6 @@ async function onRevalidate() {
{{ 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>
@@ -171,6 +171,16 @@ const canWriteCaseActions = computed(() => props.actionsExecutable && !props.isR
{{ autoGateHint || t('chat.shippingOrderReview.buildEligibility.autoGateWaitingHint') }}
</p>
<template v-if="!automating && canWriteCaseActions">
<button
v-if="showStpRetry && hasAction('retry_stp_auto_create')"
type="button"
:disabled="controlsBusy"
class="inline-flex items-center gap-1 rounded border border-sky-300 px-3 py-2 text-sm text-sky-700 hover:bg-sky-50 disabled:opacity-50 dark:border-sky-700 dark:text-sky-300 dark:hover:bg-sky-950/40"
data-testid="review-retry-stp-auto-create"
@click="emit('retry-stp')"
>
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.automation.retryStp') }}
</button>
<button
v-if="showValidate && hasAction('validate')"
type="button"
@@ -23,9 +23,9 @@ const messages = {
subtitle: 'Advances through freight upload',
polling: 'Refreshing…',
progressUnavailable: 'Progress unavailable — refresh the page.',
openTaskWorkbench: 'Open Task Center to register',
openTaskWorkbench: 'Open Task Center to confirm upload',
nextStepsManualUpload:
'Next: download Excel → upload on freight platform → submit evidence and receipt',
'Next: download Excel → upload on freight platform → confirm uploaded',
nextStepsGeneric: 'Manual action required — follow the system prompt.',
},
},
@@ -194,7 +194,7 @@ describe('ReviewWorkflowProgressPanel', () => {
});
expect(wrapper.get('[data-testid="review-manual-upload-next-steps"]').text()).toContain('download Excel');
const link = wrapper.get('[data-testid="review-open-task-workbench"]');
expect(link.text()).toContain('Open Task Center to register');
expect(link.text()).toContain('Open Task Center to confirm upload');
expect(link.attributes('href')).toContain('workspace-shipping-my-tasks');
expect(link.attributes('href')).toContain('SN-1');
});