feat(in-transit-transfer): 自动调拨支持收料日期范围并收归排程通用通知
- 自动调拨任务新增收料日期范围动态参数(receipt_date_from/to):缩小匹配面便于测试与排障,非法范围由匹配层校验拒绝 - 排程动态参数表单支持占位文案 key 与空值归 null,日期筛选直达任务配置 - 执行结果通知统一走排程「启用通知」通用企微通知,任务不再自建领域通知 - 门禁契约澄清 retry_inventory_matching 语义:复用已抓库存重匹配不重抓;STP 多候选无匹配时阶段能力禁用、不隐式触发 RPA - 同步匹配/自动调拨/排程测试、四语言文案与文档
This commit is contained in:
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 时,前端只能等待实时裁决,
|
||||
// 不能因页面默认值自行开放订单复核或其他生命周期阶段。
|
||||
|
||||
@@ -817,6 +817,33 @@ const LINE_SCOPE_INVENTORY_ACTIONS = new Set([
|
||||
'override_line_inventory_source',
|
||||
]);
|
||||
|
||||
/**
|
||||
* 阶段能力按执行动作码索引(preparation.capabilities)。
|
||||
* 核心逻辑:右卡按钮的禁用态渲染必须与 submitFormalGateAction 的点击拦截消费同一份
|
||||
* 能力投影,保证「展示=执行同源」——禁止按钮渲染成可点、点击才被能力门禁弹提示。
|
||||
*/
|
||||
const stageCapabilityByActionCode = computed(() => {
|
||||
const map = new Map<string, { enabled: boolean; disabled_reason?: string | null }>();
|
||||
for (const cap of formalPreparationContext.value?.capabilities || []) {
|
||||
const code = String(cap.action_code || '').trim();
|
||||
if (code) map.set(code, cap);
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
/**
|
||||
* 给右卡动作附加阶段能力禁用原因。
|
||||
* @param action - 已统一到卡片域的动作对象(须含 code)
|
||||
* @returns 原对象浅拷贝;能力禁用时带 capabilityDisabledReason,否则该字段为 null
|
||||
*/
|
||||
function withStageCapabilityState<T extends { code: string }>(
|
||||
action: T,
|
||||
): T & { capabilityDisabledReason?: string | null } {
|
||||
const cap = stageCapabilityByActionCode.value.get(String(action.code || '').trim());
|
||||
if (!cap || cap.enabled) return { ...action, capabilityDisabledReason: null };
|
||||
return { ...action, capabilityDisabledReason: String(cap.disabled_reason || '').trim() || null };
|
||||
}
|
||||
|
||||
const currentTaskPrimaryAction = computed(() => {
|
||||
if (formalTaskProjectionPending.value) return null;
|
||||
if (hasFormalOt.value) {
|
||||
@@ -828,10 +855,10 @@ const currentTaskPrimaryAction = computed(() => {
|
||||
// 故必须统一映射到卡片域,否则按钮会因 businessActionLabel 为空而 fail-closed 消失。
|
||||
const action = currentTaskUiState.value?.primary_action ?? null;
|
||||
if (!action?.code || LINE_SCOPE_INVENTORY_ACTIONS.has(action.code)) return null;
|
||||
return {
|
||||
return withStageCapabilityState({
|
||||
code: String(action.code).trim(),
|
||||
i18nKey: `workspace.shippingNotice.processGate.actionCodes.${action.code}`,
|
||||
};
|
||||
});
|
||||
}
|
||||
const projection = shippingProcessingProjection.value;
|
||||
if (projection) {
|
||||
@@ -914,6 +941,8 @@ const currentTaskRecoveryActions = computed(() => {
|
||||
// [§2.4 单源] 任务级恢复按钮只读 A.secondary_actions;不再叠加 B.capabilities。
|
||||
// capabilities 仍可作点击执行的 stageCapabilityBypass 查找(见 handleCurrentTaskAction),
|
||||
// 但不得单独渲成右卡按钮——能力要展示须先并进 A。行级选源禁止出现在右卡。
|
||||
// [展示=执行同源] A 已渲染的按钮若命中阶段能力 disabled(capabilityDisabledReason
|
||||
// 非空),右卡必须渲染禁用态 + 原因 tooltip,禁止可点样式诱导用户点击后才被拦截。
|
||||
return (currentTaskUiState.value?.secondary_actions || [])
|
||||
.filter((action) => action.enabled
|
||||
&& String(action.code || '').trim() !== 'download_excel'
|
||||
@@ -923,7 +952,8 @@ const currentTaskRecoveryActions = computed(() => {
|
||||
// 统一右卡 domain:actionCodes.<code>(见 currentTaskPrimaryAction 注;A 的 i18nKey 可能是 chat 域)。
|
||||
i18nKey: `workspace.shippingNotice.processGate.actionCodes.${String(action.code || '').trim()}`,
|
||||
}))
|
||||
.filter((action): action is { code: string; i18nKey: string } => {
|
||||
.map((action) => withStageCapabilityState(action))
|
||||
.filter((action): action is { code: string; i18nKey: string; capabilityDisabledReason?: string | null } => {
|
||||
const code = String(action.code || '').trim();
|
||||
return Boolean(code) && !LINE_SCOPE_INVENTORY_ACTIONS.has(code);
|
||||
});
|
||||
@@ -4879,20 +4909,21 @@ watch(
|
||||
watch(
|
||||
() => [
|
||||
lifecycleCurrentStageCode.value,
|
||||
String(activeCase.value?.case_no || '').trim(),
|
||||
activeReviewDocumentId(),
|
||||
// 文件身份必须用 requestedCaseNo(与 lifecycleUiState 解析阶段同源):正式下游
|
||||
// (通知准备/货代上传/通知完成,选法 2)activeCase 刻意为 null,其 case_no/document_id
|
||||
// 在这些文件之间恒为空值,用 activeCase 做身份会让"切换文件"被误判成"同一文件的
|
||||
// 阶段推进"而弹出"已自动推进"。requestedCaseNo 在 selectCase/beginCrossRunSwitch/
|
||||
// load 里与阶段重算同一同步块内更新,切换文件时本 watcher 必然看到变化而静默;
|
||||
// 真正的自动推进只改队列投影、不触碰 requestedCaseNo,提示行为不变。
|
||||
String(requestedCaseNo.value || activeCase.value?.case_no || '').trim(),
|
||||
] as const,
|
||||
async (current, previous) => {
|
||||
const [currentStage, currentCaseNo, currentDocumentId] = current;
|
||||
const [previousStage, previousCaseNo, previousDocumentId] = previous || [];
|
||||
const [currentStage, currentFileKey] = current;
|
||||
const [previousStage, previousFileKey] = previous || [];
|
||||
if (await syncPendingReleaseAutoAdvance()) return;
|
||||
// 切换文件时生命周期阶段会随新 Case 一起变更;这不是当前文件的自动推进,
|
||||
// 切换文件时生命周期阶段会随新文件身份一起变更;这不是当前文件的自动推进,
|
||||
// 不能跳转或弹出“已自动推进”提示。
|
||||
if (
|
||||
!previous
|
||||
|| currentCaseNo !== previousCaseNo
|
||||
|| currentDocumentId !== previousDocumentId
|
||||
) return;
|
||||
if (!previous || currentFileKey !== previousFileKey) return;
|
||||
if (!currentStage || !previousStage || currentStage === previousStage) return;
|
||||
const pendingReparse = pendingReparseNavigation.value;
|
||||
if (
|
||||
|
||||
Reference in new issue
Block a user