feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口
完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
This commit is contained in:
1 parent
8e0bbf7a81
commit
c94d173f92
181 files changed
+12947
-1724
No files matched your search
+26
-10
@@ -2,7 +2,7 @@
|
||||
* features/workspace/shipping-task-center/TaskTodoPanel.actionsExecutable.spec.ts
|
||||
* 用途:验收 A2——Gate 只读时 Footer 委托 invokeActionByCode 仍可写。
|
||||
* 依赖:Vitest、Vue Test Utils、TaskTodoPanel、shipping.api mock。
|
||||
* 逻辑:gateCanHandle=false + actionsExecutable=true 时匹配库存 API 被调用;
|
||||
* 逻辑:gateCanHandle=false + actionsExecutable=true 时正式 Gate Action 被调用;
|
||||
* actionsExecutable=false 时直接返回;hidePrimaryActions 时不渲染 action_buttons。
|
||||
*/
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
@@ -11,20 +11,22 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import TaskTodoPanel from './TaskTodoPanel.vue';
|
||||
import type { ShippingTaskDetail } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const matchInventory = vi.fn().mockResolvedValue({});
|
||||
const postGateAction = vi.fn().mockResolvedValue({});
|
||||
const refreshBadge = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
confirmWorkspaceShippingCustomer: vi.fn(),
|
||||
confirmWorkspaceShippingInventorySource: vi.fn(),
|
||||
freezeWorkspaceShippingOrder: vi.fn(),
|
||||
generateWorkspaceShippingExcel: vi.fn(),
|
||||
listWorkspaceShippingCustomerOptions: vi.fn().mockResolvedValue([]),
|
||||
matchWorkspaceShippingInventory: (...args: unknown[]) => matchInventory(...args),
|
||||
retryWorkspaceShippingUpload: vi.fn(),
|
||||
submitWorkspaceShippingDecision: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/shipping-process-gates/api/process-gates.api', () => ({
|
||||
postWorkspaceProcessGateAction: (...args: unknown[]) => postGateAction(...args),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
|
||||
downloadWorkspaceShippingExcelFile: vi.fn(),
|
||||
}));
|
||||
@@ -77,18 +79,24 @@ function detail(): ShippingTaskDetail {
|
||||
summary: { title: 't', message: 'm' },
|
||||
action_buttons: [],
|
||||
checkpoint_kind: 'inventory',
|
||||
process_gate: null,
|
||||
process_gate: {
|
||||
execution_no: 'SPE-1',
|
||||
current_blocking_gate: {
|
||||
gate_code: 'inventory_matching',
|
||||
evaluation_version: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
} as unknown as ShippingTaskDetail;
|
||||
}
|
||||
|
||||
describe('TaskTodoPanel actionsExecutable', () => {
|
||||
beforeEach(() => {
|
||||
matchInventory.mockClear();
|
||||
postGateAction.mockClear();
|
||||
refreshBadge.mockClear();
|
||||
});
|
||||
|
||||
it('invokes match API when gateCanHandle=false but actionsExecutable=true', async () => {
|
||||
it('invokes formal Gate Action when gateCanHandle=false but actionsExecutable=true', async () => {
|
||||
const wrapper = mount(TaskTodoPanel, {
|
||||
props: {
|
||||
detail: detail(),
|
||||
@@ -101,7 +109,15 @@ describe('TaskTodoPanel actionsExecutable', () => {
|
||||
expect(wrapper.get('[data-testid="gate-stub"]').attributes('data-can-handle')).toBe('false');
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await flushPromises();
|
||||
expect(matchInventory).toHaveBeenCalledWith('SN-1', undefined);
|
||||
expect(postGateAction).toHaveBeenCalledWith(
|
||||
'SPE-1',
|
||||
'inventory_matching',
|
||||
expect.objectContaining({
|
||||
action_code: 'retry_inventory_matching',
|
||||
expected_gate_version: 3,
|
||||
idempotency_key: expect.any(String),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('blocks fulfillment invoke when expectedNoticeTaskNo mismatches', async () => {
|
||||
@@ -117,7 +133,7 @@ describe('TaskTodoPanel actionsExecutable', () => {
|
||||
});
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await flushPromises();
|
||||
expect(matchInventory).not.toHaveBeenCalled();
|
||||
expect(postGateAction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('no-ops invokeActionByCode when actionsExecutable=false', async () => {
|
||||
@@ -132,6 +148,6 @@ describe('TaskTodoPanel actionsExecutable', () => {
|
||||
});
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await flushPromises();
|
||||
expect(matchInventory).not.toHaveBeenCalled();
|
||||
expect(postGateAction).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -23,9 +23,7 @@ import {
|
||||
confirmWorkspaceShippingCustomer,
|
||||
confirmWorkspaceShippingInventorySource,
|
||||
freezeWorkspaceShippingOrder,
|
||||
generateWorkspaceShippingExcel,
|
||||
listWorkspaceShippingCustomerOptions,
|
||||
matchWorkspaceShippingInventory,
|
||||
retryWorkspaceShippingUpload,
|
||||
submitWorkspaceShippingDecision,
|
||||
type ShippingFulfillmentOwnershipContext,
|
||||
@@ -35,6 +33,7 @@ import { refreshShippingTodoBadge } from '@/features/workspace/composables/useSh
|
||||
import InventorySourceSelectDialog from './InventorySourceSelectDialog.vue';
|
||||
import ManualUploadEvidenceDialog from './ManualUploadEvidenceDialog.vue';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import { postWorkspaceProcessGateAction } from '@/features/shipping-process-gates/api/process-gates.api';
|
||||
import type { ShippingProcessGateUserSummary } from '@/features/chat/types/shipping.api.types';
|
||||
import { gateSummaryIndicatesManualUpload } from '@/features/chat/shipping/shippingProcessingFulfillment';
|
||||
|
||||
@@ -48,6 +47,8 @@ const props = withDefaults(defineProps<{
|
||||
actionsExecutable?: boolean;
|
||||
/** 为 true 时隐藏全部 action_buttons(订单处理工作台写入口仅 Footer)。 */
|
||||
hidePrimaryActions?: boolean;
|
||||
/** 订单处理工作台将 Gate 卡提升到右侧展示时隐藏此处重复卡。 */
|
||||
hideGateCard?: boolean;
|
||||
/** 工作台权威正式 Notice 号;与 detail.task_no 不一致时禁止履约写。 */
|
||||
expectedNoticeTaskNo?: string | null;
|
||||
/** 工作台权威 OT 号,随履约 API 校验归属。 */
|
||||
@@ -61,6 +62,7 @@ const props = withDefaults(defineProps<{
|
||||
gateCanHandle: undefined,
|
||||
actionsExecutable: undefined,
|
||||
hidePrimaryActions: false,
|
||||
hideGateCard: false,
|
||||
expectedNoticeTaskNo: null,
|
||||
expectedOrderTaskNo: null,
|
||||
expectedReviewCaseNo: null,
|
||||
@@ -223,6 +225,7 @@ const visibleActions = computed(() => {
|
||||
if (hasBlockingGate.value) return [];
|
||||
return actionButtons.value.filter((action) => {
|
||||
const id = String(action.id || '');
|
||||
if (id === 'regenerate_manual_upload_todo') return false;
|
||||
if (UNIFIED_OWNED_ACTION_IDS.has(id)) {
|
||||
return false;
|
||||
}
|
||||
@@ -419,6 +422,24 @@ async function assertFulfillmentOwnership(): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 将兼容按钮收口为服务端正式 Gate Action;缺少 Projection 身份时只刷新。 */
|
||||
async function requestProjectedGateAction(actionCode: string): Promise<boolean> {
|
||||
const executionNo = String(processGateSummary.value?.execution_no || '').trim();
|
||||
const gate = processGateSummary.value?.current_blocking_gate;
|
||||
const gateCode = String(gate?.gate_code || '').trim();
|
||||
const version = Number(gate?.evaluation_version);
|
||||
if (!executionNo || !gateCode || !Number.isInteger(version)) {
|
||||
emit('refreshed');
|
||||
return false;
|
||||
}
|
||||
await postWorkspaceProcessGateAction(executionNo, gateCode, {
|
||||
action_code: actionCode,
|
||||
expected_gate_version: version,
|
||||
idempotency_key: `task-todo:${executionNo}:${gateCode}:${version}:${actionCode}:${crypto.randomUUID()}`,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行后端允许的动作;人工上传/客户/库存源/冻结走对话框,其余走对应工作台 API。
|
||||
*/
|
||||
@@ -458,12 +479,12 @@ async function runAction(action: ShippingChatAction) {
|
||||
return;
|
||||
}
|
||||
if (id === 'generate_excel') {
|
||||
await generateWorkspaceShippingExcel(props.detail.task_no, ownership);
|
||||
await requestProjectedGateAction('regenerate_excel_artifact');
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'match_inventory' || id === 'rematch') {
|
||||
await matchWorkspaceShippingInventory(props.detail.task_no, ownership);
|
||||
await requestProjectedGateAction('retry_inventory_matching');
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
@@ -511,6 +532,7 @@ defineExpose({
|
||||
<template>
|
||||
<div class="space-y-3">
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="!hideGateCard"
|
||||
:summary="processGateSummary"
|
||||
:can-handle="resolvedGateCanHandle"
|
||||
:navigation-context="{
|
||||
@@ -520,6 +542,7 @@ defineExpose({
|
||||
@refreshed="afterSuccess"
|
||||
@refresh-needed="afterSuccess"
|
||||
@confirm-customer="() => void openCustomerDialog()"
|
||||
@manual-upload="() => void invokeActionByCode('mark_manual_uploaded')"
|
||||
/>
|
||||
<section
|
||||
v-if="!hasBlockingGate && !isSystemAutoWait"
|
||||
|
||||
Reference in new issue
Block a user