perf(shipping-notice): 优化发货任务性能,修复上传流程与终态问题

This commit is contained in:
hugo committed 2026-08-27 19:25:16 +08:00
1 parent 434c04ed2d
commit bcdd8285ae
29 files changed
+1074 -128

No files matched your search

@@ -663,6 +663,8 @@ async function mountView(query: Record<string, string> = {}) {
uploadComplete: {
title: '通知完成',
subtitle: '上传成功证据已核验。',
uploadModeManual: '人工确认',
uploadModeRpa: 'RPA 上传',
},
upload: {
receipt: '货代回执:{value}',
@@ -2830,7 +2832,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
vi.mocked(taskApi.getWorkspaceShippingFreightNoticeGroups).mockResolvedValue({
po_number: 'PO-100',
items: [
{ business_no: 'WYC26082401', po_number: 'PO-100', upload_status: 'uploaded', export_file_name: 'WYC26082401.xlsx', lines: [
{ business_no: 'WYC26082401', po_number: 'PO-100', upload_status: 'uploaded', upload_mode: 'manual', export_file_name: 'WYC26082401.xlsx', lines: [
{ line_no: '00010', part_number: 'PART-A', reservation_id: 'RSV-A', qty: '2' },
] },
{ business_no: 'WYC26082402', po_number: 'PO-100', upload_status: 'pending', export_file_name: 'WYC26082402.xlsx', lines: [] },
@@ -2847,8 +2849,44 @@ describe('ShippingOrderReviewView layout phase 1', () => {
// 人工确认不再展示或依赖货代回执号,即使历史投影仍带有 freight_ref_no。
expect(evidence.text()).not.toContain('LEGACY-REF-MUST-NOT-BE-SHOWN');
expect(evidence.text()).not.toContain('LATEST-FAILED');
// 上传来源徽标:成功事实取自 ShippingUploadAttempt 的 mode=manual。
expect(wrapper.find('[data-testid="review-upload-complete-mode"]').text()).toContain(
'人工确认',
);
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);
expect(wrapper.get('[data-testid="review-current-processing-card"]').text()).toContain('已完成');
expect(wrapper.get('[data-testid="review-current-processing-card"]').text()).not.toContain('状态待确认');
expect(wrapper.find('[data-testid="review-current-task-next-step-section"]').exists()).toBe(false);
});
it('allows inspecting a completed order-review stage without allowing edits', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-COMPLETED-REVIEW', confirmed_task_id: 23, has_formal_ot: true,
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-COMPLETED-REVIEW', 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: null, secondary: [] }, summary: {}, steps: [],
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'order_review' });
await flushPromises();
expect(wrapper.find('[data-testid="review-editor-body"]').exists()).toBe(true);
expect(wrapper.get('[data-testid="shipping-order-review-view"]').attributes('data-readonly')).toBe('true');
expect(wrapper.find('[data-testid="review-header-field-input"]').attributes('disabled')).toBeDefined();
});
it('aggregates freight upload by business_no and keeps one Excel action per notice', async () => {
@@ -2907,22 +2945,46 @@ describe('ShippingOrderReviewView layout phase 1', () => {
await flushPromises();
await wrapper.get('[aria-label="WYC26082411"]').setValue(true);
await wrapper.get('[aria-label="WYC26082412"]').setValue(true);
const buttons = wrapper.get('[data-testid="review-freight-upload-batch-toolbar"]').findAll('button');
await buttons[0].trigger('click');
await wrapper.get('[data-testid="review-freight-upload-batch-toolbar"]').find('button').trigger('click');
await flushPromises();
expect(downloadFreightArchiveMock).toHaveBeenCalledWith(['WYC26082411', 'WYC26082412']);
await wrapper.get('[aria-label="WYC26082411"]').setValue(true);
await wrapper.get('[aria-label="WYC26082412"]').setValue(true);
await buttons[1].trigger('click');
await wrapper.get('[data-testid="review-freight-upload-batch-rpa"]').trigger('click');
await flushPromises();
expect(batchRpaFreightMock).toHaveBeenCalledWith(['WYC26082411', 'WYC26082412']);
await wrapper.get('[aria-label="WYC26082411"]').setValue(true);
await wrapper.get('[aria-label="WYC26082412"]').setValue(true);
await buttons[2].trigger('click');
await wrapper.get('[data-testid="review-freight-upload-batch-confirm"]').trigger('click');
await flushPromises();
expect(batchConfirmFreightMock).toHaveBeenCalledWith(['WYC26082411', 'WYC26082412']);
});
it('disables upload batch actions and hides more actions when an uploaded notice is selected', async () => {
activeCase.value = { ...activeCase.value, status: 'confirmed', confirmed_task_no: 'SN-PO-UPLOADED', confirmed_task_id: 24, has_formal_ot: true };
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-PO-UPLOADED', status: 'processing', lines: [], events: [],
ui_state: { lifecycle_stage: 'freight_upload', lifecycle_entries: [], actions: { primary: null, secondary: [] }, stage_context: { upload: {} } },
} as any);
vi.mocked(taskApi.getWorkspaceShippingFreightNoticeGroups).mockResolvedValue({
po_number: 'PO-UPLOADED', items: [
{ business_no: 'WYC-UPLOADED', po_number: 'PO-UPLOADED', upload_status: 'uploaded', lines: [] },
{ business_no: 'WYC-PENDING', po_number: 'PO-UPLOADED', upload_status: 'pending', lines: [] },
],
} as any);
const wrapper = await mountView({ lifecycle_stage: 'freight_upload' });
await flushPromises();
await wrapper.get('[aria-label="WYC-UPLOADED"]').setValue(true);
await wrapper.get('[aria-label="WYC-PENDING"]').setValue(true);
// 已上传项混入选择集时,批量写入不允许部分静默提交,必须让用户显式取消选择。
expect(wrapper.get('[data-testid="review-freight-upload-batch-rpa"]').attributes('disabled')).toBeDefined();
expect(wrapper.get('[data-testid="review-freight-upload-batch-confirm"]').attributes('disabled')).toBeDefined();
expect(wrapper.findAll('[data-testid="review-freight-upload-more"]')).toHaveLength(0);
});
it('does not place internal inventory hint fields in the primary line table', async () => {
const wrapper = await mountView();
const inputs = wrapper.findAll('[data-testid="review-line-field-input"]');