feat(in-transit-transfer): 自动调拨支持收料日期范围并收归排程通用通知

- 自动调拨任务新增收料日期范围动态参数(receipt_date_from/to):缩小匹配面便于测试与排障,非法范围由匹配层校验拒绝
- 排程动态参数表单支持占位文案 key 与空值归 null,日期筛选直达任务配置
- 执行结果通知统一走排程「启用通知」通用企微通知,任务不再自建领域通知
- 门禁契约澄清 retry_inventory_matching 语义:复用已抓库存重匹配不重抓;STP 多候选无匹配时阶段能力禁用、不隐式触发 RPA
- 同步匹配/自动调拨/排程测试、四语言文案与文档
This commit is contained in:
hugo committed 2026-10-12 21:25:35 +08:00
1 parent 34c3bfb254
commit a8d721e793
35 files changed
+863 -138

No files matched your search

@@ -705,6 +705,9 @@ async function mountView(query: Record<string, string> = {}) {
partAvailableQty: '可用数量',
shortage: '库存不足',
pending: '库存匹配或通知文件尚未生成。',
capabilityDisabled: {
no_match_result: '暂无库存匹配结果,请先重新获取库存',
},
},
uploadComplete: {
title: '通知完成',
@@ -761,6 +764,8 @@ async function mountView(query: Record<string, string> = {}) {
actionCodes: {
confirm_customer: '确认客户',
resolve_field_conflicts: '处理字段冲突',
retry_inventory_preparation: '重新获取库存',
retry_inventory_matching: '重新匹配库存',
},
},
},
@@ -1622,6 +1627,81 @@ describe('ShippingOrderReviewView layout phase 1', () => {
);
});
it('renders capability-disabled actions as disabled buttons with reason tooltip', async () => {
// 回归(展示=执行同源):A 渲染的 retry_inventory_matching 命中阶段能力 disabled
// (no_match_result)时,右卡必须直接渲染禁用态 + 原因 tooltip;
// 禁止可点样式诱导用户点击后才被 submitFormalGateAction 弹提示拦截。
activeCase.value = {
...activeCase.value,
status: 'confirmed', has_formal_ot: true, task_missing: false,
confirmed_task_id: 906, confirmed_task_no: 'SN-RPA-CAP-DISABLED',
};
shippingProcessingProjection.value = {
workItemType: 'order_task', workItemNo: 'SN-RPA-CAP-DISABLED',
status: 'failed', userStatus: 'retryable', stage: 'inventory_fetching',
progressVersion: 5, currentGate: { status: 'blocked_retryable' },
uiState: {
status: 'retryable', stage: 'inventory_fetching', lifecycleStage: 'fulfillment_prep',
primary_action: { code: 'retry_inventory_matching' },
secondary_actions: [{ code: 'retry_inventory_preparation', enabled: true }],
},
} as any;
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-RPA-CAP-DISABLED', status: 'processing', lines: [], events: [],
ui_state: {
actions: { primary: null, secondary: [] },
process_gate: {
execution_no: 'EXEC-RPA-CAP-DISABLED',
current_blocking_gate: {
gate_code: 'inventory_preparation', evaluation_version: 2, status: 'blocked_retryable',
},
allowed_actions: ['retry_inventory_matching', 'retry_inventory_preparation'],
},
stage_context: {
preparation: {
status: 'blocked', source_locked: false,
source_options: [{ source_code: 'DSV' }],
failed_source_codes: ['DSV'],
capabilities: [
{
code: 'retry_inventory_matching', scope: 'task',
action_code: 'retry_inventory_matching', enabled: false,
disabled_reason: 'no_match_result',
},
{
code: 'retry_inventory_preparation', scope: 'task',
action_code: 'retry_inventory_preparation', enabled: true,
disabled_reason: null,
},
],
frozen_order_lines: [], lines: [],
},
},
summary: {}, steps: [],
},
} as any);
submitProcessGatePrimaryActionMock.mockClear();
messageMocks.info.mockClear();
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
// 主按钮:能力禁用 → disabled + 原因 tooltip(复用 capabilityDisabled.no_match_result 文案)。
const primary = wrapper.get('[data-testid="review-current-processing-retry"]');
expect(primary.attributes('disabled')).toBeDefined();
expect(primary.attributes('data-capability-disabled')).toBe('true');
expect(primary.attributes('title')).toContain('暂无库存匹配结果');
// 侧路按钮:能力 enabled → 保持可点,不受主按钮禁用影响。
const recovery = wrapper.get('[data-testid="review-current-task-recovery-retry_inventory_preparation"]');
expect(recovery.attributes('disabled')).toBeUndefined();
// 点击禁用按钮不得触发提交,也不得弹任何 info 提示(此前会弹未翻译 key)。
await primary.trigger('click');
await flushPromises();
expect(submitProcessGatePrimaryActionMock).not.toHaveBeenCalled();
expect(messageMocks.info).not.toHaveBeenCalled();
});
it('refreshes the processing projection after field-conflict adjudication refreshes the Case', async () => {
activeCase.value = {
...activeCase.value,
@@ -2024,6 +2104,65 @@ describe('ShippingOrderReviewView layout phase 1', () => {
}
});
it('does not auto-advance when switching formal-downstream files without an activeCase identity', async () => {
// 回归:正式下游(通知准备/货代上传/通知完成,选法 2)activeCase 刻意为 null,
// 切换前后 activeCase 身份(case_no/document_id)恒为空值;自动推进守卫若用
// activeCase 做“同一文件”判据,会把目标文件更晚的阶段误判成当前文件被推进,
// 弹出“已自动推进到货代上传”。文件身份必须用 requestedCaseNo(与阶段解析同源,
// selectCase/beginCrossRunSwitch 同步块内更新):切换必变更 → 静默;真实推进
// 不触碰 requestedCaseNo → 提示行为不变。
const originalQueue = reviewQueue.value;
try {
reviewQueue.value = {
...reviewQueue.value,
summary: { total: 2, needs_action: 2, processing: 0, completed: 0 },
items: [
{
...reviewQueue.value.items[0],
has_formal_ot: true,
lifecycle_stage: 'fulfillment_prep',
lifecycle_entries: [
{ 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' },
],
},
{
case_no: 'CASE-2', source_run_no: 'RUN-1', document_id: 2, file_name: 'po-2.pdf',
status: 'confirmed', has_formal_ot: true, issue_count: 0,
lifecycle_stage: 'freight_upload',
lifecycle_entries: [
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
},
],
};
// 选法 2 盲区:源文件无复核 Case 快照(懒加载失败/未完成时生产即如此),
// 此刻文件身份只剩 requestedCaseNo。
activeCase.value = null;
requestedCaseNo.value = 'CASE-1';
const wrapper = await mountView({ case_no: 'CASE-1', lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
messageMocks.success.mockClear();
// 模拟真实 selectCase 正式下游分支的同步块:更新 requestedCaseNo + activeCase 保持 null。
requestedCaseNo.value = 'CASE-2';
await nextTick();
await flushPromises();
expect(messageMocks.success).not.toHaveBeenCalledWith('已自动推进到货代上传');
// 守卫不得替用户改写深链:切文件是展示上下文切换,不是流程推进。
expect((wrapper.vm as any).$route.query.lifecycle_stage).toBe('fulfillment_prep');
} finally {
reviewQueue.value = originalQueue;
}
});
it('does not open a lifecycle stage before the backend authorizes lifecycle entries', async () => {
// 未收到正式 ui_state.lifecycle_entries 时,前端只能等待实时裁决,
// 不能因页面默认值自行开放订单复核或其他生命周期阶段。