feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码

This commit is contained in:
hugo committed 2026-08-23 00:27:18 +08:00
1 parent 935bf26fa6
commit 7cfd5d167e
230 files changed
+9337 -10989

No files matched your search

@@ -19,8 +19,6 @@ import {
getWorkspaceShippingTask,
decideWorkspaceShippingOrderReviewLineFulfillment,
retryWorkspaceShippingOrderStpAutoCreate,
retryWorkspaceShippingTask,
retryWorkspaceShippingTaskLine,
retryShippingNoticeIntake,
} from '@/features/chat/api/shipping.api';
@@ -171,8 +169,6 @@ vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
...actual,
auditWorkspaceShippingOrderReviewVersionHistory: vi.fn().mockResolvedValue({ audited: true, case_no: 'CASE-1' }),
auditWorkspaceShippingOrderReviewEligibilityDetails: vi.fn().mockResolvedValue({ audited: true, case_no: 'CASE-1' }),
retryWorkspaceShippingTask: vi.fn().mockResolvedValue({ status: 'ok' }),
retryWorkspaceShippingTaskLine: vi.fn().mockResolvedValue({ status: 'ok' }),
decideWorkspaceShippingOrderReviewLineFulfillment: vi.fn().mockResolvedValue({ status: 'ok' }),
retryWorkspaceShippingOrderStpAutoCreate: vi.fn().mockResolvedValue({
status: 'queued',
@@ -449,7 +445,8 @@ async function mountView(query: Record<string, string> = {}) {
markQualityIssue: '质量异常',
reparse: '重新识别',
saveNow: '保存并校验',
saveOrderAndValidate: '保存订单并校验',
saveOrderAndValidate: '提交订单',
submitOrderHint: '提交后自动校验,满足条件将自动建单。',
confirmCreate: '确认并建单',
restoreMachine: '恢复',
moreFields: '更多 {count}',
@@ -466,9 +463,18 @@ async function mountView(query: Record<string, string> = {}) {
auditTrail: { open: '查看审计' },
customerResolution: {
title: '客户确认',
subtitle: '建单前确认标准客户',
unresolved: '未确认',
confirmed: '已确认',
status: {
unmatched: '未匹配',
confirmed: '已确认',
},
standardCustomer: '标准客户',
select: '选择客户',
selectCustomer: '选择客户',
retryCustomer: '重新匹配客户',
pdfReparseHint: '重新识别 PDF 不会确认客户',
search: '搜索',
empty: '无候选',
confirm: '确认',
@@ -555,6 +561,19 @@ async function mountView(query: Record<string, string> = {}) {
inventory_matching: '库存匹配',
},
},
currentTask: {
title: '当前任务',
labelStage: '当前门禁',
labelFormalSn: '正式 OT',
statusRunning: '系统处理中',
statusWaitingHuman: '待人工处理',
statusRetryable: '可重试',
statusFailed: '自动处理失败',
statusCompleted: '已完成',
statusCancelled: '已取消',
nextStepTitle: '下一步',
nextStepUnknown: '状态待确认',
},
automation: {
waitingPreOt: '等待自动建单',
waitingPostOt: '等待系统启动自动推进',
@@ -604,6 +623,15 @@ async function mountView(query: Record<string, string> = {}) {
shortage: '库存不足',
pending: '库存匹配或通知文件尚未生成。',
},
uploadComplete: {
title: '通知完成',
subtitle: '上传成功证据已核验。',
},
upload: {
receipt: '货代回执:{value}',
attempt: '最近上传尝试:{mode} · {status}',
},
completed: '已完成,可查看',
},
},
shippingProcessing: {
@@ -615,6 +643,9 @@ async function mountView(query: Record<string, string> = {}) {
waiting_system_start: '等待系统启动',
},
},
shippingSessionWorkItem: {
versionLabel: 'V{version}',
},
},
errors: { generic: '错误' },
},
@@ -698,6 +729,36 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect((wrapper.vm as any).$route.query.case_no).toBe('CASE-NEW');
});
it('loads a cross-Run file once through the route watcher', async () => {
const originalQueue = reviewQueue.value;
try {
reviewQueue.value = {
...reviewQueue.value,
summary: { total: 2, needs_action: 2, processing: 0, completed: 0 },
items: [
...reviewQueue.value.items,
{
case_no: 'CASE-RUN-2', source_run_no: 'RUN-2', document_id: 2, file_name: 'po-2.pdf',
status: 'draft', issue_count: 0, available_actions: ['validate'],
},
],
};
const wrapper = await mountView();
load.mockClear();
await wrapper.get('[data-testid="review-doc-nav-CASE-RUN-2"]').trigger('click');
await flushPromises();
// 路由变更是唯一加载所有者,不能在 select 中再次请求相同 Run/Case。
expect(load).toHaveBeenCalledTimes(1);
expect(load).toHaveBeenCalledWith('RUN-2', 'CASE-RUN-2', {
conversationId: 'conv-1', itemNo: undefined,
});
} finally {
reviewQueue.value = originalQueue;
}
});
it('uses the current-task card as the only Gate action entry for every formal-OT Gate', async () => {
activeCase.value = {
...activeCase.value,
@@ -1391,11 +1452,13 @@ describe('ShippingOrderReviewView layout phase 1', () => {
const orderWrapper = await mountView({ lifecycle_stage: 'order_review' });
// 关键断言:订单复核底栏保留 validate,但不再承载四个接收解析处置入口。
expect(orderWrapper.find('[data-testid="intake-parse-panel"]').exists()).toBe(false);
expect(orderWrapper.text()).not.toContain('非订单');
expect(orderWrapper.text()).not.toContain('质量异常');
expect(orderWrapper.text()).not.toContain('重新识别');
expect(orderWrapper.text()).not.toContain('替换 PDF');
expect(orderWrapper.text()).toContain('保存订单并校验');
const orderFooter = orderWrapper.get('[data-testid="review-footer-actions"]');
// 客户确认说明可提及“重新识别 PDF”;这里只裁决底栏是否错误挂接了解析处置动作。
expect(orderFooter.text()).not.toContain('非订单');
expect(orderFooter.text()).not.toContain('质量异常');
expect(orderFooter.text()).not.toContain('重新识别');
expect(orderFooter.text()).not.toContain('替换 PDF');
expect(orderFooter.text()).toContain('提交订单');
});
it('does not request intake context when its lifecycle entry is missing or unavailable', async () => {
@@ -1686,7 +1749,13 @@ describe('ShippingOrderReviewView layout phase 1', () => {
await wrapper.get('[data-testid="review-fulfillment-line-download-line-frozen"]').trigger('click');
expect(downloadWorkspaceShippingLineInventoryFileMock).toHaveBeenCalledWith('SN-FROZEN', 'SIF-LINE-DBS');
await wrapper.get('[data-testid="review-fulfillment-line-retry-preparation-line-frozen"]').trigger('click');
expect(retryWorkspaceShippingTaskLine).toHaveBeenCalledWith('SN-FROZEN', 'line-frozen');
expect(submitProcessGatePrimaryActionMock).toHaveBeenCalledWith(
expect.any(Object),
expect.objectContaining({
actionCode: 'retry_inventory_preparation',
payload: { line_key: 'line-frozen' },
}),
);
await wrapper.get('[data-testid="review-fulfillment-line-release-line-frozen"]').trigger('click');
expect(wrapper.get('[data-testid="review-release-inventory-dialog"]').text()).toContain('ODM ID');
expect(wrapper.get('[data-testid="review-release-inventory-dialog"]').text()).toContain('ODM-001');
@@ -1827,7 +1896,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
// 关键断言:接收解析才需新 entry 授权;旧投影不能因此丢失订单复核编辑和校验入口。
expect(wrapper.find('[data-testid="intake-parse-panel"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-editor-body"]').exists()).toBe(true);
expect(wrapper.get('[data-testid="review-footer-actions"]').text()).toContain('保存订单并校验');
expect(wrapper.get('[data-testid="review-footer-actions"]').text()).toContain('提交订单');
});
it('keeps notification completion read-only even when an obsolete manual-upload action arrives', async () => {
@@ -2412,9 +2481,9 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
expect(wrapper.find('[data-testid="review-current-processing-ot"]').text()).toContain('SN-RECOVER-1');
}, 15000);
it('does not call legacy retry before the formal OT Gate projection arrives (UI-01)', async () => {
// 关键断言:刷新后无实时 Gate 时,不能用 confirmed_task_no 调旧 /retry。
vi.mocked(retryWorkspaceShippingTask).mockClear();
it('does not submit an action before the formal OT Gate projection arrives (UI-01)', async () => {
// 关键断言:刷新后无实时 Gate 时,不得用任务号推断或提交重试。
submitProcessGatePrimaryActionMock.mockClear();
activeCase.value = {
...activeCase.value,
status: 'confirmed',
@@ -2440,7 +2509,7 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
await flushPromises();
const retryBtn = wrapper.find('[data-testid="review-current-processing-retry"]');
expect(retryBtn.exists()).toBe(false);
expect(retryWorkspaceShippingTask).not.toHaveBeenCalled();
expect(submitProcessGatePrimaryActionMock).not.toHaveBeenCalled();
}, 15000);
it('disables the formal Gate retry while inventory preparation is waiting for RPA callback', async () => {