chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑

This commit is contained in:
hugo committed 2026-08-17 19:56:51 +08:00
1 parent 5ef8329bd8
commit 4ec4e57005
183 files changed
+14653 -3936

No files matched your search

@@ -17,6 +17,7 @@ import type {
ShippingCustomerOption,
ShippingInventorySourceCandidate,
ShippingTaskDetail,
ShippingUnifiedAction,
} from '@/features/chat/types/shipping.api.types';
import { BusinessError } from '@/shared/api/client';
import {
@@ -48,6 +49,8 @@ const props = withDefaults(defineProps<{
hidePrimaryActions?: boolean;
/** 订单处理工作台将 Gate 卡提升到右侧展示时隐藏此处重复卡。 */
hideGateCard?: boolean;
/** 仅作为工作台动作执行器/弹窗宿主,不渲染第二套卡片或按钮。 */
headless?: boolean;
/** 工作台权威正式 Notice 号;与 detail.task_no 不一致时禁止履约写。 */
expectedNoticeTaskNo?: string | null;
/** 工作台权威 OT 号,随履约 API 校验归属。 */
@@ -62,6 +65,7 @@ const props = withDefaults(defineProps<{
actionsExecutable: undefined,
hidePrimaryActions: false,
hideGateCard: false,
headless: false,
expectedNoticeTaskNo: null,
expectedOrderTaskNo: null,
expectedReviewCaseNo: null,
@@ -92,8 +96,26 @@ const processGateSummary = computed((): ShippingProcessGateUserSummary | null =>
|| null,
);
const unifiedActions = computed(() => props.detail.ui_state?.actions || { primary: null, secondary: [] });
const backendPrimaryAction = computed(() => unifiedActions.value.primary || null);
const backendSecondaryActions = computed(() => unifiedActions.value.secondary || []);
const rawBackendPrimaryAction = computed(() => unifiedActions.value.primary || null);
const rawBackendSecondaryActions = computed(() => unifiedActions.value.secondary || []);
/**
* 任务中心只渲染后端已给出用户文案的受控动作。
*
* action.code 是协议/执行标识,不是展示文案;缺 label 的历史或异常投影必须 fail-closed。
*/
function hasUserFacingActionLabel(
action: ShippingUnifiedAction | null | undefined,
): action is ShippingUnifiedAction & { label: string } {
return Boolean(String(action?.label || '').trim());
}
const backendPrimaryAction = computed(() => (
hasUserFacingActionLabel(rawBackendPrimaryAction.value) ? rawBackendPrimaryAction.value : null
));
const backendSecondaryActions = computed(() => (
rawBackendSecondaryActions.value.filter(hasUserFacingActionLabel)
));
/** 有 Gate 阻断时优先展示统一投影文案。 */
const displayTodoTitle = computed(() =>
processGateSummary.value?.current_blocking_gate?.label
@@ -383,7 +405,10 @@ async function runAction(action: ShippingChatAction) {
await afterSuccess();
return;
}
if (id === 'match_inventory' || id === 'rematch') {
// [AUTHORITY] Gate 投影使用 retry_inventory_matching;保留旧码仅用于过渡数据。
// 三者均必须走同一个带 execution/gate/version 的 Gate Action API,不能退回
// 旧 submitWorkspaceShippingDecision,否则会绕过当前 Gate 的乐观锁与授权校验。
if (id === 'match_inventory' || id === 'rematch' || id === 'retry_inventory_matching') {
await requestProjectedGateAction('retry_inventory_matching');
await afterSuccess();
return;
@@ -408,11 +433,13 @@ async function runAction(action: ShippingChatAction) {
}
/** 将后端统一动作适配到现有专用弹窗/提交执行器;业务判断仍完全由后端提供。 */
async function runUnifiedAction(action: NonNullable<typeof backendPrimaryAction.value>) {
async function runUnifiedAction(action: ShippingUnifiedAction) {
if (!action.enabled) return;
await runAction({
id: action.code,
label: action.label || action.code,
// 此入口也供 Footer 按 action code 委托执行;该动作不一定会渲染为卡片按钮,
// 因此展示 label 缺失时使用协议 code 作为仅供执行器的占位,而非拒绝正式 Gate 动作。
label: String(action.label || action.code),
message: action.disabled_reason || '',
variant: action.kind === 'terminate' ? 'danger' : action.kind === 'view' ? 'secondary' : 'primary',
});
@@ -426,7 +453,7 @@ async function runUnifiedAction(action: NonNullable<typeof backendPrimaryAction.
async function invokeActionByCode(actionId: string) {
const id = String(actionId || '').trim();
if (!id) return;
const projected = [backendPrimaryAction.value, ...backendSecondaryActions.value]
const projected = [rawBackendPrimaryAction.value, ...rawBackendSecondaryActions.value]
.find((item) => item && item.code === id);
if (projected) {
await runUnifiedAction(projected);
@@ -439,7 +466,7 @@ defineExpose({
});
</script>
<template>
<div class="space-y-3">
<div v-if="!headless" class="space-y-3">
<ProcessGateRecoveryCard
v-if="!hideGateCard"
:summary="processGateSummary"
@@ -486,7 +513,7 @@ defineExpose({
:disabled="!backendPrimaryAction.enabled || busyId === backendPrimaryAction.code"
@click="runUnifiedAction(backendPrimaryAction)"
>
{{ backendPrimaryAction.label || backendPrimaryAction.code }}
{{ backendPrimaryAction.label }}
</button>
<button
v-for="action in backendSecondaryActions"
@@ -496,7 +523,7 @@ defineExpose({
:disabled="!action.enabled || busyId === action.code"
@click="runUnifiedAction(action)"
>
{{ action.label || action.code }}
{{ action.label }}
</button>
</div>
<ManualUploadEvidenceDialog