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

@@ -15,6 +15,8 @@ import type {
ShippingProcessingPrimaryAction,
} from '@/features/chat/types/shipping.api.types';
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
import { resolveGateReasonLabel } from '@/features/shipping-progress/gateReasonLabel';
import { lookupWorkbenchAction, shouldRenderWorkbenchAction } from '@/features/shipping-progress/workbenchActionRegistry';
const props = defineProps<{
stageCode?: string | null;
@@ -41,6 +43,8 @@ const props = defineProps<{
label_key?: string | null;
parameters?: Record<string, unknown>;
}>;
/** 正式 Gate 原始状态仅用于区分未入队、运行中与外部回执等待;不参与按钮裁决。 */
gateStatus?: string | null;
taskMissing?: boolean;
confirmedTaskId?: number | null;
@@ -103,12 +107,16 @@ const statusLabel = computed(() => {
if (props.taskMissing) {
return t('chat.shippingOrderReview.currentProcessing.taskMissing');
}
if (s === 'running' && String(props.gateStatus || '').trim().toLowerCase() === 'pending') {
return t('chat.shippingOrderReview.currentProcessing.waitingStart');
}
if (!s) return t('chat.shippingOrderReview.currentProcessing.statusIdle');
return map[s] ?? t('chat.shippingOrderReview.currentProcessing.statusIdle');
});
/**
* 下一步(「下一步」section 的问题/说明文案):优先展示 blocking_reason,否则按 user_status 给系统态文案。
* 下一步(「下一步」section 的问题/说明文案):优先展示 blocking_reason 的统一 i18n 映射,
* 否则按 user_status 给系统态文案;禁止将后端内部原因码直接展示给用户。
*/
const nextStepText = computed(() => {
const safeMessage = (value: unknown): string => {
@@ -136,8 +144,27 @@ const nextStepText = computed(() => {
if (i18nKey && te(i18nKey)) {
return t(i18nKey);
}
// i18n 键缺失时回落为 code(不裸露给普通用户,最终 QA 期间应全部补齐)
return safeMessage(br.code) || t('chat.shippingOrderReview.currentTask.nextStepUnknown');
return resolveGateReasonLabel(br.code, { t, te })
|| t('chat.shippingOrderReview.currentTask.nextStepUnknown');
}
// 建单前订单冻结校验尚未提交时,明确告诉用户下一步是保存并校验。
// 保存是底栏唯一的表单提交入口,不升级为右栏 CTA;该分支也兼容历史响应
// 仍携带 validate 的情形,避免「待人工」与「无需操作」产生语义矛盾。
if (
String(props.stageCode || '').trim() === 'order_review'
&& !props.blockingReason
&& (
String(props.primaryAction?.code || '').trim() === 'validate'
|| String(props.userStatus || '').trim() === 'waiting_human'
)
) {
return t('chat.shippingOrderReview.saveOrderAndValidate');
}
if (
String(props.userStatus || '').trim() === 'running'
&& String(props.gateStatus || '').trim().toLowerCase() === 'waiting_external'
) {
return t('chat.shippingOrderReview.currentTask.nextStepWaitingExternal');
}
// 2) 无阻断时,按 user_status 给系统说明文案
const s = String(props.userStatus || '').trim() as ReviewCurrentUserStatus | '';
@@ -168,9 +195,33 @@ const showNextStep = computed(() => {
return !['completed', 'cancelled'].includes(status);
});
/**
* 判断当前工作台是否应隐藏后端下发的纯导航动作。
* 批次中心可用它打开工作台;进入工作台后必须复用注册表规则,避免当前阶段再次显示
* 「进入订单复核」或「编辑正式任务」等自跳转入口。
*/
function isHiddenWorkbenchNavigationAction(code: string): boolean {
const entry = lookupWorkbenchAction(code);
return Boolean(entry && !shouldRenderWorkbenchAction(entry, {
actionsExecutable: true,
surface: 'review',
actionCode: code,
}));
}
/**
* 当前任务卡只承载正式 Gate 的可执行业务动作。
*
* 草稿编辑/建草稿是页面能力,保存校验是底栏唯一提交;它们即使出现在历史响应中,
* 也不能升级为右栏 CTA,更不能因缺失文案泄漏内部动作码。
*/
function isNonTaskCapabilityAction(code: string): boolean {
return new Set(['edit_draft', 'create_draft', 'validate']).has(code.trim().toLowerCase());
}
/**
* 业务动作按钮:后端确认 retryable=true → 主按钮为「重试」;
* 否则若 primary_action.code 非 retry → 用 primary_action.code + i18n_key 渲染对应人工动作(进入复核/确认客户等)。
* 否则若 primary_action.code 非 retry 且不是工作台内自跳转 → 渲染对应人工动作。
*/
const showBusinessAction = computed(() => {
if (props.loading) return false;
@@ -181,6 +232,8 @@ const showBusinessAction = computed(() => {
if (props.retryable) return true;
const code = String(props.primaryAction?.code || '').trim();
if (!code) return false;
if (isNonTaskCapabilityAction(code)) return false;
if (isHiddenWorkbenchNavigationAction(code)) return false;
// retry 仅当 retryable=true 时展示(避免按钮闪烁矛盾)
if (code === 'retry') return false;
return true;
@@ -195,6 +248,7 @@ const businessActionLabel = computed(() => {
}
const pa = props.primaryAction;
if (!pa) return '';
if (isNonTaskCapabilityAction(String(pa.code || ''))) return '';
// Gate action presentation uses label_key; normalize it at the shared card boundary
// so every gate renders its business label instead of exposing the action code.
const i18nKey = String(
@@ -210,7 +264,8 @@ const businessActionLabel = computed(() => {
if (te(legacyKey)) {
return t(legacyKey);
}
return pa.code;
// 当前任务按钮没有受控文案时 fail-closed,禁止泄漏内部 action code。
return '';
});
/** 题7A:按钮 tooltip(exhausted_sources 列表与文案)。 */
@@ -231,7 +286,14 @@ const businessActionTitle = computed(() => {
const actionIsRetry = computed(() => Boolean(props.retryable) || String(props.primaryAction?.code || '') === 'retry');
const recoveryActions = computed(() => (props.recoveryActions || []).filter((action) => {
const code = String(action.code || '').trim();
return code && code !== String(props.primaryAction?.code || '').trim();
if (!code || isNonTaskCapabilityAction(code)) return false;
if (code === String(props.primaryAction?.code || '').trim()) return false;
const key = String(
action.i18nKey
|| action.label_key
|| `workspace.shippingNotice.processGate.actionCodes.${code}`,
).trim();
return Boolean(key && te(key));
}));
function recoveryActionLabel(action: (typeof recoveryActions.value)[number]): string {
@@ -240,7 +302,7 @@ function recoveryActionLabel(action: (typeof recoveryActions.value)[number]): st
|| action.label_key
|| `workspace.shippingNotice.processGate.actionCodes.${action.code}`,
).trim();
return key && te(key) ? t(key) : action.code;
return key && te(key) ? t(key) : '';
}
function handleBusinessActionClick() {