feat(shipping-notice): 升级货代发货流程为五阶段,完善业务校验

将货代发货流程从四阶段扩展为五阶段,拆分上传相关逻辑至独立的货代上传阶段;
统一多语言文案修正客户状态语义,将"客户尚未识别"调整为符合业务的"客户尚未确认";
新增严格的上传成功验证谓词,需同时满足任务状态、全部预约单上传成功、存在有效成功上传尝试三个条件方可标记为完成;
新增坐标取值模型配置,支持Legacy冻结绝对坐标和锚点框架受限平移两种模式;
更新全链路相关文档、前端组件、后端服务与测试用例,确保业务逻辑对齐新业务规则。
This commit is contained in:
hugo committed 2026-08-21 09:20:47 +08:00
1 parent 1b6483a4ea
commit 935bf26fa6
86 files changed
+2743 -311

No files matched your search

@@ -21,6 +21,7 @@ import {
retryWorkspaceShippingOrderStpAutoCreate,
retryWorkspaceShippingTask,
retryWorkspaceShippingTaskLine,
retryShippingNoticeIntake,
} from '@/features/chat/api/shipping.api';
const { downloadWorkspaceShippingLineInventoryFileMock } = vi.hoisted(() => ({
@@ -111,6 +112,7 @@ const shippingProcessingProjection = ref<Record<string, any> | null>(null);
/** 正式任务投影的请求中状态;用于覆盖 Case 先到、Projection 后到的过渡窗口。 */
const shippingProcessingLoading = ref(false);
const intakeParseContext = ref<Record<string, any> | null>(null);
const requestedCaseNo = ref<string | null>(null);
/** 每个用例必须从独立的 Case 图快照开始,避免嵌套 schema/draft 被浅拷贝污染。 */
function createActiveCaseFixture() {
@@ -177,6 +179,7 @@ vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
job_id: 901,
case: null,
}),
retryShippingNoticeIntake: vi.fn().mockResolvedValue({ intake_no: 'SNI-RETRY-1', parse_status: 'queued' }),
getWorkspaceShippingTask: vi.fn().mockResolvedValue({
task_no: 'SN-MOCK',
status: 'created',
@@ -229,7 +232,7 @@ function createReviewComposableMock() {
loadFailed: ref(false),
caseSwitchLoading: ref(false),
caseSwitchFailed: ref(false),
requestedCaseNo: ref(null),
requestedCaseNo,
saving: ref(false),
validationInProgress: ref(false),
saveFailed: ref(false),
@@ -587,6 +590,7 @@ async function mountView(query: Record<string, string> = {}) {
intake_parse: '接收解析',
order_review: '订单复核',
fulfillment_prep: '通知准备',
freight_upload: '货代上传',
upload_complete: '通知完成',
},
prepare: {
@@ -665,6 +669,7 @@ async function mountView(query: Record<string, string> = {}) {
/** 将共享 Case fixture 恢复为可编辑草稿,避免跨用例污染确认恢复态。 */
function resetActiveCaseFixture() {
activeCase.value = createActiveCaseFixture();
requestedCaseNo.value = null;
shippingProcessingProjection.value = null;
shippingProcessingLoading.value = false;
intakeParseContext.value = null;
@@ -679,6 +684,20 @@ describe('ShippingOrderReviewView layout phase 1', () => {
reviewProgressContext.value = null;
});
it('keeps the requested replacement Case when the loaded Run updates the URL', async () => {
// 关键断言:新版 Run 先到而旧 URL Case 仍在时,不能拼出 RUN-NEW + CASE-OLD。
const wrapper = await mountView({ case_no: 'CASE-OLD' });
requestedCaseNo.value = 'CASE-NEW';
reviewRun.value = {
...reviewRun.value,
run_no: 'RUN-NEW',
};
await flushPromises();
expect((wrapper.vm as any).$route.query.run_no).toBe('RUN-NEW');
expect((wrapper.vm as any).$route.query.case_no).toBe('CASE-NEW');
});
it('uses the current-task card as the only Gate action entry for every formal-OT Gate', async () => {
activeCase.value = {
...activeCase.value,
@@ -1031,7 +1050,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
const shell = wrapper.get('[data-testid="review-workbench-ot-shell"]');
const navigation = wrapper.get('[data-testid="review-document-navigation"]');
// 2–4 文件不浪费一列宽度,但必须在四阶段前完成文件选择。
// 2–4 文件不浪费一列宽度,但必须在五阶段前完成文件选择。
expect(navigation.attributes('data-nav-mode')).toBe('tabs');
expect(shell.classes()).toContain('contents');
expect(wrapper.html().indexOf('review-document-navigation'))
@@ -1082,6 +1101,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
lifecycleEntries: [
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
},
@@ -1115,7 +1135,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
const wrapper = await mountView({ lifecycle_stage: 'order_review' });
await flushPromises();
for (const code of ['order_review', 'fulfillment_prep', 'upload_complete']) {
for (const code of ['order_review', 'fulfillment_prep', 'freight_upload', 'upload_complete']) {
const stage = wrapper.get(`[data-testid="review-lifecycle-stage-${code}"]`);
expect(stage.findAll('button')[1].attributes('disabled')).toBeDefined();
}
@@ -1136,6 +1156,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
{ code: 'intake_parse', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
}],
@@ -1151,6 +1172,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
{ code: 'intake_parse', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
}],
@@ -1178,6 +1200,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
{ code: 'intake_parse', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
}],
@@ -1193,6 +1216,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
{ code: 'intake_parse', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
}],
@@ -1236,6 +1260,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
{ code: 'intake_parse', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
}],
@@ -1322,6 +1347,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
{ code: 'intake_parse', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'order_review', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
},
@@ -1506,6 +1532,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
lifecycleEntries: [
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
blocking_reason: null,
@@ -1587,7 +1614,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.get('[data-testid="review-lifecycle-fulfillment-prep"]').text()).toContain('3');
expect(wrapper.find('[data-testid="review-fulfillment-prep-workspace"]').exists()).toBe(true);
expect(messageMocks.warning).not.toHaveBeenCalledWith('处理结果尚未生成');
// 通知准备工作区必须属于四阶段导航的下方主区,不能仍停留在导航之前的状态摘要区。
// 通知准备工作区必须属于五阶段导航的下方主区,不能仍停留在导航之前的状态摘要区。
expect(wrapper.html().indexOf('review-lifecycle-workbench-header'))
.toBeLessThan(wrapper.html().indexOf('review-fulfillment-prep-workspace'));
});
@@ -1760,6 +1787,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
lifecycle_entries: [
{ code: 'order_review', state: 'available', target_surface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'current', target_surface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', target_surface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', target_surface: 'order_lifecycle_workbench' },
],
},
@@ -1802,7 +1830,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.get('[data-testid="review-footer-actions"]').text()).toContain('保存订单并校验');
});
it('keeps backend-authorized manual upload registration out of the upload main area', async () => {
it('keeps notification completion read-only even when an obsolete manual-upload action arrives', async () => {
const originalQueue = reviewQueue.value;
try {
activeCase.value = {
@@ -1817,6 +1845,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
{ code: 'intake_parse', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'current', targetSurface: 'order_lifecycle_workbench' },
],
}],
@@ -1836,7 +1865,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
actions: {
primary: {
code: 'mark_manual_uploaded', kind: 'forward', enabled: true,
target_surface: 'upload_complete',
target_surface: 'freight_upload',
target_anchor: 'manual_upload',
requires_confirmation: false,
},
@@ -1847,8 +1876,9 @@ describe('ShippingOrderReviewView layout phase 1', () => {
} as any);
const withAuthorization = await mountView({ lifecycle_stage: 'upload_complete' });
await flushPromises();
// Gate 写操作只在右侧“当前任务”显示;主区只保留上传事实与审计摘要。
// 完成面必须屏蔽迟到的 Gate 写操作;主区只保留验证成功事实与审计摘要。
expect(withAuthorization.find('[data-testid="review-lifecycle-upload-manual"]').exists()).toBe(false);
expect(withAuthorization.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
// 正式动作直接提交当前 Gate,不允许无界面 TaskTodoPanel 作为隐藏执行器。
expect((withAuthorization.vm as { formalTodoPanelRef?: unknown }).formalTodoPanelRef).toBeUndefined();
} finally {
@@ -1856,7 +1886,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
}
});
it('opens the page-level evidence dialog when the authorized current-task action is manual upload', async () => {
it('opens the page-level evidence dialog from freight upload when the current-task action is manual upload', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-UPLOAD-DIALOG', confirmed_task_id: 19, has_formal_ot: true,
@@ -1869,7 +1899,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
primary: {
code: 'mark_manual_uploaded', kind: 'forward', enabled: true,
dispatch: 'dialog', ui_handler: 'manual_upload_evidence',
target_surface: 'upload_complete', target_anchor: 'manual_upload',
target_surface: 'freight_upload', target_anchor: 'manual_upload',
requires_confirmation: false,
},
secondary: [],
@@ -1878,7 +1908,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'upload_complete' });
const wrapper = await mountView({ lifecycle_stage: 'freight_upload' });
await flushPromises();
await wrapper.get('[data-testid="review-current-task-primary-action"]').trigger('click');
await flushPromises();
@@ -1886,7 +1916,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.find('[data-testid="manual-upload-evidence-dialog"]').exists()).toBe(true);
});
it('renders the authorized Excel download in every upload-complete order line instead of the task rail', async () => {
it('renders the authorized Excel download in every freight-upload order line instead of the task rail', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-DOWNLOAD-DISPATCH', confirmed_task_id: 20, has_formal_ot: true,
@@ -1926,26 +1956,26 @@ describe('ShippingOrderReviewView layout phase 1', () => {
secondary: [{
code: 'download_excel', label: '下载 Excel', kind: 'view', enabled: true,
dispatch: 'view', ui_handler: 'excel_download',
target_surface: 'upload_complete', target_anchor: 'excel_artifact',
target_surface: 'freight_upload', target_anchor: 'excel_artifact',
requires_confirmation: false,
}],
},
lifecycle_stage: 'upload_complete',
lifecycle_entries: [{ code: 'upload_complete', state: 'current' }],
lifecycle_stage: 'freight_upload',
lifecycle_entries: [{ code: 'freight_upload', state: 'current' }],
process_gate: { execution_no: 'EXEC-DOWNLOAD-DISPATCH' }, summary: {}, steps: [],
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'upload_complete' });
const wrapper = await mountView({ lifecycle_stage: 'freight_upload' });
await flushPromises();
const rows = wrapper.findAll('[data-testid="review-upload-complete-line"]');
const rows = wrapper.findAll('[data-testid="review-freight-upload-line"]');
expect(rows).toHaveLength(2);
expect(rows[0].text()).toContain('PN-ONE');
expect(rows[1].text()).toContain('PN-TWO');
expect(wrapper.find('[data-testid="review-current-task-recovery-download_excel"]').exists()).toBe(false);
await wrapper.get('[data-testid="review-upload-complete-download-LINE-1"]').trigger('click');
await wrapper.get('[data-testid="review-freight-upload-download-LINE-1"]').trigger('click');
await flushPromises();
// 下载是 Artifact 只读操作;订单行不按 PO 聚合,且不得伪装成 Gate mutation。
@@ -1969,6 +1999,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
{ code: 'intake_parse', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
}],
@@ -2103,6 +2134,104 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.find('[data-testid="review-lifecycle-upload-download"]').exists()).toBe(false);
});
it('retries the server-authorized failed Intake from the current lifecycle card and refreshes projections', async () => {
const originalQueue = reviewQueue.value;
try {
activeCase.value = {
...activeCase.value,
available_actions: ['retry_parse'],
intake_no: 'SNI-RETRY-1',
};
reviewQueue.value = {
...reviewQueue.value,
items: [{
...reviewQueue.value.items[0],
lifecycle_stage: 'intake_parse',
lifecycle_entries: [],
intake_parse_authorized: true,
available_actions: ['retry_parse'],
intake_no: 'SNI-RETRY-1',
}],
};
const wrapper = await mountView({ lifecycle_stage: 'intake_parse' });
// 关键断言:已发送 EML 的恢复从当前阶段卡执行,并且使用服务端下发的原 SNI。
await wrapper.get('[data-testid="review-lifecycle-stage-retry-parse"]').trigger('click');
await flushPromises();
expect(retryShippingNoticeIntake).toHaveBeenCalledWith('SNI-RETRY-1');
expect(reloadLatestDraftMock).toHaveBeenCalled();
expect(refreshShippingProcessingMock).toHaveBeenCalled();
} finally {
reviewQueue.value = originalQueue;
}
});
it('does not show intake retry while parsing or after cancellation', async () => {
const originalQueue = reviewQueue.value;
try {
reviewQueue.value = {
...reviewQueue.value,
items: [{
...reviewQueue.value.items[0], lifecycle_stage: 'intake_parse', lifecycle_entries: [], intake_parse_authorized: true,
}],
};
for (const status of ['parsing', 'cancelled']) {
activeCase.value = { ...activeCase.value, status, available_actions: [], intake_no: null };
const wrapper = await mountView({ lifecycle_stage: 'intake_parse' });
// 关键断言:运行中等待超时回收,取消态不可复活,均无 retry_parse 入口。
expect(wrapper.find('[data-testid="review-lifecycle-stage-retry-parse"]').exists()).toBe(false);
}
} finally {
reviewQueue.value = originalQueue;
}
});
it('renders completion evidence only from the verified succeeded attempt', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-VERIFIED-EVIDENCE', confirmed_task_id: 22, has_formal_ot: true,
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-VERIFIED-EVIDENCE', status: 'completed', upload_status: 'uploaded', lines: [], events: [],
ui_state: {
lifecycle_stage: 'upload_complete',
lifecycle_entries: [
{ code: 'intake_parse', state: 'available' },
{ code: 'order_review', state: 'available' },
{ code: 'fulfillment_prep', state: 'available' },
{ code: 'freight_upload', state: 'available' },
{ code: 'upload_complete', state: 'current' },
],
actions: {
primary: {
code: 'mark_manual_uploaded', kind: 'forward', enabled: true,
dispatch: 'dialog', ui_handler: 'manual_upload_evidence',
},
secondary: [],
},
stage_context: {
upload: {
latest_attempt: { status: 'failed', mode: 'rpa', freight_ref_no: 'LATEST-FAILED' },
succeeded_attempt: { status: 'succeeded', mode: 'manual', freight_ref_no: 'VERIFIED-REF' },
},
},
summary: {}, steps: [],
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'upload_complete' });
await flushPromises();
const evidence = wrapper.get('[data-testid="review-lifecycle-upload-complete"]');
expect(evidence.text()).toContain('VERIFIED-REF');
expect(evidence.text()).toContain('succeeded');
expect(evidence.text()).not.toContain('LATEST-FAILED');
expect(evidence.text()).not.toContain('failed');
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
});
it('renders empty optional schema fields as editable line columns', async () => {
const wrapper = await mountView();
const inputs = wrapper.findAll('[data-testid="review-line-field-input"]');