feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程

清理废弃的shipping xfa ocr automark相关代码和job配置
新增收料报表管理的前端页面、路由和侧边栏入口
新增后端收料报表配置接口、数据库模型和RPA脚本
优化发货通知流程的重试策略,将shipping相关job默认不自动重试
移除废弃的库存源确认相关逻辑,更新流程门禁规则
重构订单模板的值适配器模块,新增坐标OCR值适配器
清理前端shipping菜单和action的废弃选项
更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
hugo committed 2026-08-20 20:23:10 +08:00
1 parent 260465b72d
commit 1b6483a4ea
466 files changed
+32115 -33796

No files matched your search

@@ -17,16 +17,24 @@ import {
auditWorkspaceShippingOrderReviewEligibilityDetails,
auditWorkspaceShippingOrderReviewVersionHistory,
getWorkspaceShippingTask,
decideWorkspaceShippingOrderReviewLineFulfillment,
retryWorkspaceShippingOrderStpAutoCreate,
retryWorkspaceShippingTask,
retryWorkspaceShippingTaskLine,
} from '@/features/chat/api/shipping.api';
const { downloadWorkspaceShippingInventoryFileMock } = vi.hoisted(() => ({
downloadWorkspaceShippingInventoryFileMock: vi.fn().mockResolvedValue(undefined),
const { downloadWorkspaceShippingLineInventoryFileMock } = vi.hoisted(() => ({
downloadWorkspaceShippingLineInventoryFileMock: vi.fn().mockResolvedValue(undefined),
}));
const { downloadWorkspaceShippingExcelFileMock } = vi.hoisted(() => ({
downloadWorkspaceShippingExcelFileMock: vi.fn().mockResolvedValue(undefined),
}));
vi.mock('@/features/chat/shipping/shippingDownload', () => ({
downloadWorkspaceShippingInventoryFile: downloadWorkspaceShippingInventoryFileMock,
downloadWorkspaceShippingLineInventoryFile: downloadWorkspaceShippingLineInventoryFileMock,
}));
vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
downloadWorkspaceShippingExcelFile: downloadWorkspaceShippingExcelFileMock,
}));
const focusSuggestionField = vi.fn();
@@ -38,6 +46,12 @@ const confirmMock = vi.fn();
const reloadLatestDraftMock = vi.fn().mockResolvedValue(undefined);
const refreshShippingProcessingMock = vi.fn().mockResolvedValue(undefined);
const patchLineMock = vi.fn().mockResolvedValue(undefined);
const { submitProcessGatePrimaryActionMock } = vi.hoisted(() => ({
submitProcessGatePrimaryActionMock: vi.fn().mockResolvedValue({ outcome: 'submitted' }),
}));
const { postFormalGateActionMock } = vi.hoisted(() => ({
postFormalGateActionMock: vi.fn().mockResolvedValue({}),
}));
const messageMocks = vi.hoisted(() => ({
info: vi.fn(),
@@ -94,9 +108,13 @@ const workItem = ref<Record<string, any> | null>(null);
const reviewProgressContext = ref<Record<string, any> | null>(null);
/** 与 activeCase 同源共享,供断言 Progress 优先阶段源。 */
const shippingProcessingProjection = ref<Record<string, any> | null>(null);
/** 正式任务投影的请求中状态;用于覆盖 Case 先到、Projection 后到的过渡窗口。 */
const shippingProcessingLoading = ref(false);
const intakeParseContext = ref<Record<string, any> | null>(null);
const activeCase = ref({
/** 每个用例必须从独立的 Case 图快照开始,避免嵌套 schema/draft 被浅拷贝污染。 */
function createActiveCaseFixture() {
return {
case_no: 'CASE-1',
document_id: 1,
status: 'draft',
@@ -140,7 +158,10 @@ const activeCase = ref({
process_gate: null,
profile_match: { available: false, visibility: 'admin_only', candidates: [] },
automation: { status: 'idle', can_auto_create: false, can_build: true },
});
};
}
const activeCase = ref<Record<string, any>>(createActiveCaseFixture());
vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
const actual = await importOriginal<typeof import('@/features/chat/api/shipping.api')>();
@@ -149,6 +170,8 @@ vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
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',
job_id: 901,
@@ -254,7 +277,6 @@ function createReviewComposableMock() {
markNonOrder: vi.fn(),
markQualityIssue: vi.fn(),
reparseDocument: vi.fn(),
uploadReplacement: vi.fn(),
focusSuggestionField,
setEvidenceDrawerFocus: vi.fn(),
clearEvidenceDrawerFocus: vi.fn(),
@@ -268,19 +290,9 @@ function createReviewComposableMock() {
showWorkflowProgress: computed(() => false),
workflowProgressPolling: computed(() => false),
shippingProcessingProjection,
shippingProcessingLoading: ref(false),
shippingProcessingLoading,
shippingProcessingError: ref(null),
refreshShippingProcessing: refreshShippingProcessingMock,
reparseProgressActive: computed(() => false),
reparseProgressPolling: computed(() => false),
reparseProgressRefreshFailed: computed(() => false),
reparseProgressStage: computed(() => 'submitted'),
reparseLastStableStage: computed(() => 'submitted'),
reparseRunStatus: computed(() => 'queued'),
reparseLastActivityAt: computed(() => null),
reparseLastRefreshedAt: computed(() => null),
reparseStalePolls: computed(() => 0),
refreshReparseProgress: vi.fn(),
};
}
@@ -290,6 +302,17 @@ vi.mock('@/shared/composables/useMessage', () => ({
useMessage: () => messageMocks,
}));
vi.mock('@/features/shipping-process-gates/composables/useShippingProcessGateRecovery', () => ({
useShippingProcessGateRecovery: () => ({
busy: ref(false),
submitPrimaryAction: submitProcessGatePrimaryActionMock,
}),
}));
vi.mock('@/features/shipping-process-gates/api/process-gates.api', () => ({
postWorkspaceProcessGateAction: (...args: unknown[]) => postFormalGateActionMock(...args),
}));
vi.mock('../components/shipping-review/ReviewDocumentPreview.vue', () => ({
default: {
name: 'ReviewDocumentPreview',
@@ -422,7 +445,6 @@ async function mountView(query: Record<string, string> = {}) {
markNonOrder: '非订单',
markQualityIssue: '质量异常',
reparse: '重新识别',
uploadReplacement: '替换 PDF',
saveNow: '保存并校验',
saveOrderAndValidate: '保存订单并校验',
confirmCreate: '确认并建单',
@@ -491,25 +513,6 @@ async function mountView(query: Record<string, string> = {}) {
saveFailed: '失败',
versionConflict: { badge: '冲突' },
statusBanner: { unknown: '未知' },
reparseFailedVersion: {
notice: 'V{failedVersion} 重新识别失败,失败阶段:{stage}。当前展示并可继续复核:V{displayedVersion}。',
unknownStage: '未知阶段',
stages: { layout_parsing: '解析 PDF 页面与表格' },
},
reparseProgress: {
title: '重识别',
subtitle: '',
polling: '',
refreshFailed: '',
failed: '',
retry: '',
stages: {
submitted: '1',
layout_parsing: '2',
extracting: '3',
draft_ready: '4',
},
},
autoProgress: {
status: { unknown: '', needs_retry: '待重试', needs_human: '需要人工处理' },
result: '{status}',
@@ -592,6 +595,9 @@ async function mountView(query: Record<string, string> = {}) {
frozenOrder: '冻结订单',
inventorySource: '库存源',
downloadInventory: '下载库存文件',
retryInventory: '重新获取库存',
releaseShortage: '库存缺口放行',
shortage: '库存不足',
pending: '库存匹配或通知文件尚未生成。',
},
},
@@ -658,26 +664,10 @@ async function mountView(query: Record<string, string> = {}) {
/** 将共享 Case fixture 恢复为可编辑草稿,避免跨用例污染确认恢复态。 */
function resetActiveCaseFixture() {
activeCase.value = {
...activeCase.value,
case_no: 'CASE-1',
document_id: 1,
status: 'draft',
confirmed_task_no: null,
confirmed_task_id: null,
has_formal_ot: false,
task_missing: false,
recovery_available: null,
post_confirm_auto_progress: null,
process_gate: null,
current_stage: null,
technical_progress: null,
automation: { status: 'idle', can_auto_create: false, can_build: true },
available_actions: ['validate', 'confirm', 'mark_non_order', 'reparse'],
profile_match: { available: false, visibility: 'admin_only', candidates: [] },
};
shippingProcessingProjection.value = null;
intakeParseContext.value = null;
activeCase.value = createActiveCaseFixture();
shippingProcessingProjection.value = null;
shippingProcessingLoading.value = false;
intakeParseContext.value = null;
}
describe('ShippingOrderReviewView layout phase 1', () => {
@@ -712,6 +702,21 @@ describe('ShippingOrderReviewView layout phase 1', () => {
},
automation: { status: 'manual_fallback', can_auto_create: false, can_build: true },
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-GATE-1', status: 'processing', lines: [], events: [],
ui_state: {
actions: {
primary: {
code: 'confirm_customer', kind: 'current_gate', enabled: true,
dispatch: 'navigation', ui_handler: 'customer_resolution',
requires_confirmation: false,
},
secondary: [],
},
process_gate: { execution_no: 'EXEC-GATE-1' }, summary: {}, steps: [],
},
} as any);
const wrapper = await mountView();
await flushPromises();
@@ -721,6 +726,114 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.find('[data-testid="mock-process-gate"]').exists()).toBe(false);
});
it('submits a server-authorized Gate action from the current-task card without an action-code alias', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', has_formal_ot: true, task_missing: false,
confirmed_task_id: 98, confirmed_task_no: 'SN-EXCEL-1',
};
shippingProcessingProjection.value = {
workItemType: 'order_task', workItemNo: 'SN-EXCEL-1', sourceType: 'direct_pdf',
rootOrderTaskNo: 'SN-EXCEL-1', shippingNoticeNo: 'SN-EXCEL-1', conversationId: 'conv-1',
submissionNo: 'SUB-EXCEL-1', intakeNo: 'SNI-EXCEL-1', status: 'blocked', stage: 'excel_generating',
progressVersion: 1, lastActivityAt: '2026-08-18T12:13:30Z', currentGate: {
gateCode: 'artifact_generation', status: 'blocked_retryable', nextActionCode: 'regenerate_excel_artifact',
},
processGate: {
execution_no: 'EXEC-EXCEL-1', status: 'blocked_retryable', current_gate_code: 'artifact_generation',
next_action_code: 'regenerate_excel_artifact', allowed_actions: ['regenerate_excel_artifact'],
current_blocking_gate: { gate_code: 'artifact_generation', status: 'blocked_retryable', evaluation_version: 8 },
},
availableActions: ['regenerate_excel_artifact'],
sourceSummary: { emailSubject: null, filename: 'po.xlsx', documentCount: 1, parsedDocumentCount: 1, candidateCount: 1, customerName: null, poNumber: null },
childOrderTasks: [],
uiState: {
status: 'retryable', stage: 'excel_generating', blocking_reason: null,
primary_action: { code: 'regenerate_excel_artifact', i18nKey: 'chat.shippingProcessing.action.regenerate_excel' },
secondary_actions: [],
},
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-EXCEL-1', status: 'processing', lines: [], events: [],
ui_state: {
actions: {
primary: {
code: 'regenerate_excel_artifact', kind: 'recovery', enabled: true,
dispatch: 'mutation',
target_surface: 'fulfillment_prep', target_anchor: 'excel_artifact',
requires_confirmation: false,
},
secondary: [],
},
process_gate: {
execution_no: 'EXEC-EXCEL-1',
current_blocking_gate: {
gate_code: 'artifact_generation', evaluation_version: 8,
},
},
summary: {}, steps: [],
},
} as any);
const wrapper = await mountView();
await flushPromises();
await wrapper.get('[data-testid="review-current-task-primary-action"]').trigger('click');
await flushPromises();
// 关键断言:旧 Projection 的 regenerate_excel 不可执行;正式任务的原始动作码
// 只委托统一 Gate 执行器,由其按后端版本与授权再次校验。
expect(submitProcessGatePrimaryActionMock).toHaveBeenCalledWith(
expect.objectContaining({
execution_no: 'EXEC-EXCEL-1',
current_blocking_gate: expect.objectContaining({ gate_code: 'artifact_generation' }),
}),
{ actionCode: 'regenerate_excel_artifact' },
);
expect(postFormalGateActionMock).not.toHaveBeenCalled();
});
it('does not submit an action merely because its code has a Gate-like prefix', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', has_formal_ot: true, task_missing: false,
confirmed_task_id: 99, confirmed_task_no: 'SN-UNAUTHORIZED-1',
// 旧 Case 投影仍可能带上 Gate;不能让它以动作码前缀绕过实时 Projection。
process_gate: {
execution_no: 'EXEC-STALE-CASE-1', status: 'blocked_retryable', owner_type: 'human', technical_auto_only: false,
current_blocking_gate: { gate_code: 'artifact_generation', status: 'blocked_retryable' },
},
};
shippingProcessingProjection.value = {
workItemType: 'order_task', workItemNo: 'SN-UNAUTHORIZED-1', sourceType: 'direct_pdf',
rootOrderTaskNo: 'SN-UNAUTHORIZED-1', shippingNoticeNo: 'SN-UNAUTHORIZED-1', conversationId: 'conv-1',
submissionNo: 'SUB-UNAUTHORIZED-1', intakeNo: 'SNI-UNAUTHORIZED-1', status: 'blocked', stage: 'excel_generating',
progressVersion: 1, lastActivityAt: '2026-08-18T12:13:30Z', currentGate: {
gateCode: 'artifact_generation', status: 'blocked_retryable', nextActionCode: 'confirm_customer',
},
processGate: {
execution_no: 'EXEC-UNAUTHORIZED-1', status: 'blocked_retryable', current_gate_code: 'artifact_generation',
next_action_code: 'confirm_customer', allowed_actions: ['confirm_customer'],
current_blocking_gate: { gate_code: 'artifact_generation', status: 'blocked_retryable', evaluation_version: 9 },
},
availableActions: ['confirm_customer'],
sourceSummary: { emailSubject: null, filename: 'po.xlsx', documentCount: 1, parsedDocumentCount: 1, candidateCount: 1, customerName: null, poNumber: null },
childOrderTasks: [],
uiState: {
status: 'retryable', stage: 'excel_generating', blocking_reason: null,
primary_action: { code: 'regenerate_excel_artifact', i18nKey: 'chat.shippingProcessing.action.regenerate_excel' },
secondary_actions: [],
},
};
const wrapper = await mountView();
await flushPromises();
// 旧 Projection 的 action 不可替代正式任务动作;详情无同码授权时右侧不展示写按钮。
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
expect(submitProcessGatePrimaryActionMock).not.toHaveBeenCalled();
});
it('routes the right-rail field-conflict action through the registered focus executor', async () => {
activeCase.value = {
...activeCase.value,
@@ -816,7 +929,33 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
});
it('shows restored version as current and latest version only as failed attempt', async () => {
it('keeps a formal task action loading until its authoritative processing projection arrives', async () => {
// Case 快照先返回时可能携带历史/降级 Gate;正式 OT 的动作必须等待统一 Projection 裁决。
activeCase.value = {
...activeCase.value,
status: 'confirmed',
has_formal_ot: true,
confirmed_task_id: 90,
confirmed_task_no: 'SN-PROJECTION-PENDING',
process_gate: {
execution_no: 'EXEC-PROJECTION-PENDING', status: 'blocked_retryable', owner_type: 'human', technical_auto_only: false,
current_blocking_gate: { gate_code: 'inventory_preparation', status: 'blocked_retryable' },
primary_action: { code: 'retry', label_key: 'chat.shippingOrderReview.currentTask.actionRetry' },
},
automation: { status: 'failed', retryable: true, can_auto_create: false, can_build: true },
};
shippingProcessingProjection.value = null;
shippingProcessingLoading.value = true;
const wrapper = await mountView();
await flushPromises();
// 关键断言:不得先显示 Case 的通用“重试”,避免 Projection 到达后按钮语义跳变。
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
});
it('does not render legacy reparse failure stage as a separate progress source', async () => {
reviewProgressContext.value = {
item_no: 'WFI-1',
current_version_no: 4,
@@ -832,21 +971,20 @@ describe('ShippingOrderReviewView layout phase 1', () => {
};
const wrapper = await mountView();
const notice = wrapper.find('[data-testid="review-reparse-failed-version-notice"]');
expect(notice.text()).toContain('V4 重新识别失败');
expect(notice.text()).toContain('解析 PDF 页面与表格');
expect(notice.text()).toContain('V3');
// 关键断言:顶栏当前版本跟随旧成功结果 V3,禁止把旧字段标成失败尝试 V4。
expect(wrapper.find('[data-testid="review-reparse-failed-version-notice"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-reparse-progress"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-reparse-progress-rail"]').exists()).toBe(false);
// 关键断言:页面只消费统一生命周期/处理投影,禁止用旧失败阶段重建另一条进度轨道。
expect(wrapper.find('[data-testid="review-workbench-execution-summary"]').exists()).toBe(false);
expect(wrapper.text()).toContain('V3');
});
it('does not show reparse-failure version notice for normal review', async () => {
it('does not render a legacy reparse progress rail for normal review', async () => {
reviewProgressContext.value = {
item_no: 'WFI-1', current_version_no: 3, lifecycle_status: 'pending_review',
};
const wrapper = await mountView();
expect(wrapper.find('[data-testid="review-reparse-failed-version-notice"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-reparse-progress"]').exists()).toBe(false);
});
it('renders main editor + summary rail without chat context toggle', async () => {
@@ -1210,7 +1348,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
intakeParseContext.value = {
case_no: 'CASE-1',
attachment: { document_id: 1, filename: 'current.pdf', mime_type: 'application/pdf', preview_kind: 'pdf' },
email: { document_id: 2, filename: 'source.eml', text: 'current CASE-1 EML body' },
email: { document_id: 2, filename: 'source.eml', render_kind: 'text', text: 'current CASE-1 EML body' },
};
const intakeWrapper = await mountView({ lifecycle_stage: 'intake_parse' });
@@ -1218,6 +1356,11 @@ describe('ShippingOrderReviewView layout phase 1', () => {
// 关键断言:接收解析面板只显示当前 Case context 的邮件正文和附件。
expect(intakeWrapper.get('[data-testid="intake-parse-email-body"]').text()).toContain('current CASE-1 EML body');
expect(intakeWrapper.get('[data-testid="intake-parse-attachment-preview"] iframe').attributes('src')).toBe('blob:mock-pdf');
const intakeFooter = intakeWrapper.get('[data-testid="review-footer-actions"]');
// 关键断言:接收解析处置复用订单复核的固定底栏,滚动邮件/附件时仍可操作。
expect(intakeFooter.classes()).toEqual(expect.arrayContaining(['sticky', 'bottom-0']));
expect(intakeFooter.text()).toContain('非订单');
expect(intakeWrapper.find('[data-testid="intake-parse-disposition-actions"]').exists()).toBe(false);
const orderWrapper = await mountView({ lifecycle_stage: 'order_review' });
// 关键断言:订单复核底栏保留 validate,但不再承载四个接收解析处置入口。
@@ -1449,11 +1592,24 @@ describe('ShippingOrderReviewView layout phase 1', () => {
.toBeLessThan(wrapper.html().indexOf('review-fulfillment-prep-workspace'));
});
it('keeps frozen order lines visible when the inventory file and match result are not ready', async () => {
it('renders one row-level inventory workspace with each line source and authorized retry', async () => {
const taskApi = await import('@/features/chat/api/shipping.api');
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_id: 903, confirmed_task_no: 'SN-FROZEN', has_formal_ot: true,
line_fulfillment: {
lines: [{
line_key: 'line-frozen',
inventory_source: { code: 'DBS', label: 'DBS', status: 'resolved' },
inventory_allowed_actions: ['retry_inventory_preparation', 'retry_inventory_matching'],
line_allowed_actions: ['release_inventory_shortage'],
release_template_fields: [
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'inventory_snapshot', requires_manual: false },
{ field_id: '102', display_name: '库位', value: null, value_source: 'manual_required', requires_manual: true },
],
release_required_fields: [{ field_id: '102', display_name: '库位' }],
}],
},
};
shippingProcessingProjection.value = {
uiState: {
@@ -1469,11 +1625,15 @@ describe('ShippingOrderReviewView layout phase 1', () => {
lifecycle_stage: 'fulfillment_prep', lifecycle_entries: [{ code: 'fulfillment_prep', state: 'current' }],
stage_context: {
preparation: {
status: 'blocked', has_match_result: false,
status: 'blocked', has_match_result: true,
frozen_order_lines: [{
line_key: 'line-frozen', reservation_id: 'RSV-FROZEN', part_number: 'PN-FROZEN', required_qty: '6',
}],
lines: [], inventory_sources: [{ source_code: 'CRANE', status: 'waiting', inventory_file_id: null }],
lines: [{
line_key: 'line-frozen', reservation_id: 'RSV-FROZEN', part_number: 'PN-FROZEN',
required_qty: '6', available_qty: null, shortage_qty: null, source_code: 'DBS',
inventory_file_no: 'SIF-LINE-DBS', status: 'shortage',
}],
artifact: { file_name: null, status: 'not_generated' },
},
},
@@ -1483,78 +1643,63 @@ describe('ShippingOrderReviewView layout phase 1', () => {
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
// 关键断言:无库存文件时仍展示冻结订单;库存匹配空态不能吞掉订单明细。
expect(wrapper.get('[data-testid="review-fulfillment-frozen-order"]').text()).toContain('RSV-FROZEN');
expect(wrapper.get('[data-testid="review-fulfillment-frozen-order"]').text()).toContain('PN-FROZEN');
expect(wrapper.get('[data-testid="review-fulfillment-prep-pending"]').exists()).toBe(true);
// 关键断言:订单基线列和库存事实合为唯一行级工作表,库存源不得退化为任务级 CRANE。
const workspace = wrapper.get('[data-testid="review-fulfillment-prep-workspace"]');
expect(workspace.text()).toContain('RSV-FROZEN');
expect(workspace.text()).toContain('PN-FROZEN');
expect(workspace.text()).toContain('DBS');
expect(wrapper.find('[data-testid="review-fulfillment-frozen-order"]').exists()).toBe(false);
expect(wrapper.get('[data-testid="review-fulfillment-line-download-line-frozen"]').attributes('title'))
.toBeTruthy();
expect(wrapper.get('[data-testid="review-fulfillment-line-retry-preparation-line-frozen"]').attributes('title'))
.toBeTruthy();
expect(wrapper.get('[data-testid="review-fulfillment-line-retry-matching-line-frozen"]').exists()).toBe(true);
expect(wrapper.get('[data-testid="review-fulfillment-line-release-line-frozen"]').exists()).toBe(true);
expect(workspace.text()).toContain('库存不足');
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');
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');
const dialog = wrapper.get('[data-testid="review-release-inventory-dialog"]');
await dialog.find('textarea').setValue('客户确认分批发货');
await dialog.find('input').setValue('A-01');
await dialog.get('button.bg-amber-600').trigger('click');
expect(vi.mocked(decideWorkspaceShippingOrderReviewLineFulfillment)).toHaveBeenCalledWith('CASE-1', expect.objectContaining({
line_key: 'line-frozen',
reason: '客户确认分批发货',
release_field_values: { '102': 'A-01' },
}));
});
it('only exposes inventory download for the current task when the backend confirms its active file', async () => {
const taskApi = await import('@/features/chat/api/shipping.api');
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_id: 905, confirmed_task_no: 'SN-INVENTORY-FILE', has_formal_ot: true,
};
shippingProcessingProjection.value = {
uiState: {
lifecycleStage: 'fulfillment_prep',
lifecycleEntries: [{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' }],
primary_action: null,
secondary_actions: [],
},
};
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-INVENTORY-FILE', status: 'processing', lines: [], events: [],
ui_state: {
lifecycle_stage: 'fulfillment_prep', lifecycle_entries: [{ code: 'fulfillment_prep', state: 'current' }],
stage_context: {
preparation: {
frozen_order_lines: [], lines: [], has_match_result: false,
inventory_file: { available: true, file_name: 'confirmed-inventory.xlsx' },
},
},
},
} as any);
it('keeps intake parse on the standard workbench and removes the inventory return row', 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,
}],
};
const intakeWrapper = await mountView({ lifecycle_stage: 'intake_parse' });
await flushPromises();
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
// 关键断言:只有服务端声明当前任务 active link 文件可用时才出现入口,避免跨订单猜测下载。
const download = wrapper.get('[data-testid="review-fulfillment-inventory-download"]');
expect(download.text()).toContain('下载库存文件');
await download.trigger('click');
expect(downloadWorkspaceShippingInventoryFileMock).toHaveBeenCalledWith('SN-INVENTORY-FILE');
// 关键断言:接收解析不是库存工作面,避免用户看不到重解析入口。
expect(intakeWrapper.find('[data-testid="shipping-order-review-view"]').attributes('data-workbench-mode'))
.toBe('standard');
expect(intakeWrapper.find('[data-testid="review-enter-inventory-mode"]').exists()).toBe(false);
expect(intakeWrapper.find('[data-testid="review-return-standard-mode"]').exists()).toBe(false);
} finally {
reviewQueue.value = originalQueue;
}
});
it('does not expose inventory download when the current task has no active inventory file', async () => {
const taskApi = await import('@/features/chat/api/shipping.api');
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_id: 906, confirmed_task_no: 'SN-NO-INVENTORY-FILE', has_formal_ot: true,
};
shippingProcessingProjection.value = {
uiState: {
lifecycleStage: 'fulfillment_prep',
lifecycleEntries: [{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' }],
primary_action: null,
secondary_actions: [],
},
};
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-NO-INVENTORY-FILE', status: 'processing', lines: [], events: [],
ui_state: {
lifecycle_stage: 'fulfillment_prep', lifecycle_entries: [{ code: 'fulfillment_prep', state: 'current' }],
stage_context: { preparation: { frozen_order_lines: [], lines: [], has_match_result: false, inventory_file: { available: false } } },
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
expect(wrapper.find('[data-testid="review-fulfillment-inventory-download"]').exists()).toBe(false);
});
it('prefers the formal Gate over a stale processing projection in the current-task card', async () => {
it('uses the current processing projection instead of a stale formal-task Gate in the current-task card', async () => {
const taskApi = await import('@/features/chat/api/shipping.api');
activeCase.value = {
...activeCase.value,
@@ -1582,9 +1727,9 @@ describe('ShippingOrderReviewView layout phase 1', () => {
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
// 关键断言:正式 Gate 阻断时,右栏不得继续写成“系统正在处理”。
// 关键断言:正式任务详情是附件/明细快照;当前 Gate 必须由实时 Projection 裁决。
expect(wrapper.get('[data-testid="review-build-gate-rail"] [data-testid="review-current-processing-card"]')
.attributes('data-user-status')).toBe('retryable');
.attributes('data-user-status')).toBe('running');
});
it('ignores a late formal-task response after switching to another PDF', async () => {
@@ -1657,7 +1802,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.get('[data-testid="review-footer-actions"]').text()).toContain('保存订单并校验');
});
it('keeps manual upload registration out of the upload main area because the current-task card owns it', async () => {
it('keeps backend-authorized manual upload registration out of the upload main area', async () => {
const originalQueue = reviewQueue.value;
try {
activeCase.value = {
@@ -1691,6 +1836,8 @@ describe('ShippingOrderReviewView layout phase 1', () => {
actions: {
primary: {
code: 'mark_manual_uploaded', kind: 'forward', enabled: true,
target_surface: 'upload_complete',
target_anchor: 'manual_upload',
requires_confirmation: false,
},
secondary: [],
@@ -1700,14 +1847,205 @@ describe('ShippingOrderReviewView layout phase 1', () => {
} as any);
const withAuthorization = await mountView({ lifecycle_stage: 'upload_complete' });
await flushPromises();
// Gate 写操作只在右侧“当前任务”显示;主区只保留上传事实与审计摘要。
expect(withAuthorization.find('[data-testid="review-lifecycle-upload-manual"]').exists()).toBe(false);
// 无界面 TaskTodoPanel 仍须挂载执行器,供右栏 Gate 动作统一调度。
expect((withAuthorization.vm as { formalTodoPanelRef?: unknown }).formalTodoPanelRef).toBeTruthy();
// 正式动作直接提交当前 Gate,不允许无界面 TaskTodoPanel 作为隐藏执行器。
expect((withAuthorization.vm as { formalTodoPanelRef?: unknown }).formalTodoPanelRef).toBeUndefined();
} finally {
reviewQueue.value = originalQueue;
}
});
it('opens the page-level evidence dialog when the authorized 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,
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-UPLOAD-DIALOG', status: 'processing', lines: [], events: [],
ui_state: {
actions: {
primary: {
code: 'mark_manual_uploaded', kind: 'forward', enabled: true,
dispatch: 'dialog', ui_handler: 'manual_upload_evidence',
target_surface: 'upload_complete', target_anchor: 'manual_upload',
requires_confirmation: false,
},
secondary: [],
},
summary: {}, steps: [],
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'upload_complete' });
await flushPromises();
await wrapper.get('[data-testid="review-current-task-primary-action"]').trigger('click');
await flushPromises();
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 () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-DOWNLOAD-DISPATCH', confirmed_task_id: 20, has_formal_ot: true,
schema: {
...activeCase.value.schema,
fields: [
...activeCase.value.schema.fields,
{ field_id: 'fld-line-no', field_code: 'line_no', display_name: '项次', scope: 'line', value_type: 'string', required: true, options: [] },
{ field_id: 'fld-part-number', field_code: 'part_number', display_name: '料号', scope: 'line', value_type: 'string', required: true, options: [] },
{ field_id: 'fld-quantity', field_code: 'quantity', display_name: '数量', scope: 'line', value_type: 'number', required: true, options: [] },
],
},
draft: {
...activeCase.value.draft,
lines: [
{ line_key: 'LINE-1', values: { 'fld-line-no': { value: '10' }, 'fld-part-number': { value: 'PN-ONE' }, 'fld-quantity': { value: '4' } }, machine_fields: [] },
{ line_key: 'LINE-2', values: { 'fld-line-no': { value: '20' }, 'fld-part-number': { value: 'PN-TWO' }, 'fld-quantity': { value: '7' } }, machine_fields: [] },
],
},
line_fulfillment: {
lines: [
{ line_key: 'LINE-1', reservation_id: 'RSV-1', line_status: 'fulfilled' },
{ line_key: 'LINE-2', reservation_id: 'RSV-2', line_status: 'fulfilled' },
],
},
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-DOWNLOAD-DISPATCH', status: 'completed', lines: [], events: [],
ui_state: {
actions: {
primary: {
code: 'mark_manual_uploaded', kind: 'forward', enabled: true,
dispatch: 'dialog', ui_handler: 'manual_upload_evidence',
requires_confirmation: false,
},
secondary: [{
code: 'download_excel', label: '下载 Excel', kind: 'view', enabled: true,
dispatch: 'view', ui_handler: 'excel_download',
target_surface: 'upload_complete', target_anchor: 'excel_artifact',
requires_confirmation: false,
}],
},
lifecycle_stage: 'upload_complete',
lifecycle_entries: [{ code: 'upload_complete', state: 'current' }],
process_gate: { execution_no: 'EXEC-DOWNLOAD-DISPATCH' }, summary: {}, steps: [],
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'upload_complete' });
await flushPromises();
const rows = wrapper.findAll('[data-testid="review-upload-complete-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 flushPromises();
// 下载是 Artifact 只读操作;订单行不按 PO 聚合,且不得伪装成 Gate mutation。
expect(downloadWorkspaceShippingExcelFileMock).toHaveBeenCalledWith('SN-DOWNLOAD-DISPATCH');
expect(messageMocks.success).not.toHaveBeenCalled();
expect(submitProcessGatePrimaryActionMock).not.toHaveBeenCalled();
});
it('keeps backend-authorized Excel regeneration out of fulfillment preparation main area', async () => {
const originalQueue = reviewQueue.value;
try {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-EXCEL-RETRY', confirmed_task_id: 12, has_formal_ot: true,
};
reviewQueue.value = {
...reviewQueue.value,
items: [{
...reviewQueue.value.items[0], lifecycle_stage: 'fulfillment_prep',
lifecycle_entries: [
{ 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: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
}],
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-EXCEL-RETRY', status: 'processing', lines: [], events: [],
ui_state: {
actions: {
primary: {
code: 'regenerate_excel_artifact', kind: 'recovery', enabled: true,
dispatch: 'mutation',
target_surface: 'fulfillment_prep',
target_anchor: 'excel_artifact',
requires_confirmation: false,
},
secondary: [],
},
stage_context: { preparation: { status: 'blocked', has_match_result: false, lines: [] } },
summary: {}, steps: [],
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
// Gate 18 的写入口只属于右侧“当前任务”;准备区仅展示库存与产物事实。
expect(wrapper.find('[data-testid="review-lifecycle-preparation-regenerate_excel_artifact"]').exists()).toBe(false);
} finally {
reviewQueue.value = originalQueue;
}
});
it('does not place a backend action in a lifecycle area when its anchor differs', async () => {
const originalQueue = reviewQueue.value;
try {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-ANCHOR-1', confirmed_task_id: 13, has_formal_ot: true,
};
reviewQueue.value = {
...reviewQueue.value,
items: [{
...reviewQueue.value.items[0], lifecycle_stage: 'fulfillment_prep',
lifecycle_entries: [
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
],
}],
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-ANCHOR-1', status: 'processing', lines: [], events: [],
ui_state: {
actions: {
primary: {
code: 'regenerate_excel_artifact', kind: 'recovery', enabled: true,
dispatch: 'mutation',
target_surface: 'fulfillment_prep', target_anchor: 'inventory_matching',
requires_confirmation: false,
},
secondary: [],
},
stage_context: { preparation: { status: 'blocked', has_match_result: false, lines: [] } },
summary: {}, steps: [],
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
// 位置必须同时由后端 surface 与 anchor 授权;前端不能仅凭动作码或阶段补放。
expect(wrapper.find('[data-testid="review-lifecycle-preparation-regenerate_excel_artifact"]').exists()).toBe(false);
} finally {
reviewQueue.value = originalQueue;
}
}, 15000);
it('renders a persistent result panel for a completed formal task', async () => {
activeCase.value = {
...activeCase.value,
@@ -1914,7 +2252,7 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
expect(messageMocks.warning).toHaveBeenCalledWith('审计记录失败,敏感面板未打开,请重试');
});
it('restores object-level retry from post_confirm_auto_progress after reload', async () => {
it('waits for the authoritative Gate projection instead of restoring Case retry after reload', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed',
@@ -1938,15 +2276,15 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
};
const wrapper = await mountView();
await flushPromises();
// 关键断言:琥珀色确认条已移除;刷新后对象级重试挂在当前处理卡。
// 关键断言:正式 OT 的旧 Case 快照不是写授权;实时 Gate 未返回时只能等待。
expect(wrapper.find('[data-testid="review-confirm-outcome"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="retry-auto-progress-after-confirm"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-processing-ot"]').text()).toContain('SN-RECOVER-1');
}, 15000);
it('retries formal OT via unified /retry from main card after refresh without confirmSuccess (UI-01)', async () => {
// 关键断言:刷新后无 confirmSuccess 时,主卡仍用 confirmed_task_no 调统一 /retry(禁止 auto-progress)。
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();
activeCase.value = {
...activeCase.value,
@@ -1972,10 +2310,8 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
const wrapper = await mountView();
await flushPromises();
const retryBtn = wrapper.find('[data-testid="review-current-processing-retry"]');
expect(retryBtn.exists()).toBe(true);
await retryBtn.trigger('click');
await flushPromises();
expect(retryWorkspaceShippingTask).toHaveBeenCalledWith('SN-OT-FAIL-1');
expect(retryBtn.exists()).toBe(false);
expect(retryWorkspaceShippingTask).not.toHaveBeenCalled();
}, 15000);
it('disables the formal Gate retry while inventory preparation is waiting for RPA callback', async () => {
@@ -2005,6 +2341,25 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
secondary_actions: [],
},
};
vi.mocked(getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-OT-WAITING-INVENTORY', status: 'processing', lines: [], events: [],
ui_state: {
actions: {
primary: {
code: 'retry_inventory_preparation', kind: 'recovery', enabled: true,
dispatch: 'mutation', requires_confirmation: false,
},
secondary: [],
},
process_gate: {
execution_no: 'EXEC-INVENTORY-WAITING',
current_blocking_gate: {
gate_code: 'inventory_preparation', evaluation_version: 1,
},
},
summary: {}, steps: [],
},
} as any);
const wrapper = await mountView();
await flushPromises();
@@ -2147,8 +2502,8 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
expect(wrapper.find('[data-testid="review-profile-match-panel"]').exists()).toBe(true);
}, 15000);
it('hydrates progress-failed retry state from Case projection without confirm UI', async () => {
// 关键断言:无确认建单按钮时,仍可从 post_confirm_auto_progress 恢复对象级重试入口。
it('does not hydrate a write retry from Case projection without formal Gate data', async () => {
// 关键断言:无确认建单按钮时,Case 的失败状态只能作为历史摘要,不能恢复写入口。
activeCase.value = {
...activeCase.value,
status: 'confirmed',
@@ -2173,7 +2528,7 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
const wrapper = await mountView();
await flushPromises();
expect(wrapper.find('[data-testid="review-confirm-create"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-processing-ot"]').text()).toContain('SN-CONFIRM-PROGRESS-FAIL');
}, 15000);
});