feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码

This commit is contained in:
hugo committed 2026-08-23 00:27:18 +08:00
1 parent 935bf26fa6
commit 7cfd5d167e
230 files changed
+9337 -10989

No files matched your search

@@ -62,7 +62,6 @@ const props = defineProps<{
}>();
const emit = defineEmits<{
retry: [];
locate: [lineKey?: string | null, fieldId?: string | null];
action: [code: string, parameters?: Record<string, unknown>];
}>();
@@ -219,8 +218,7 @@ function isNonTaskCapabilityAction(code: string): boolean {
}
/**
* 业务动作按钮:后端确认 retryable=true → 主按钮为「重试」;
* 否则若 primary_action.code 非 retry 且不是工作台内自跳转 → 渲染对应人工动作。
* 业务动作按钮只消费 primary_action;retryable 是状态,不是授权。
*/
const showBusinessAction = computed(() => {
if (props.loading) return false;
@@ -228,13 +226,12 @@ const showBusinessAction = computed(() => {
// [STEP] 自动处理期间没有人工业务动作;只保留外层的刷新进度入口。
// 防止正式任务编辑等历史 primary_action 穿透到库存获取运行态。
if (props.userStatus === 'running') return false;
if (props.retryable) return true;
const code = String(props.primaryAction?.code || '').trim();
if (isInternalInventoryAction(code)) return false;
if (!code) return false;
if (isNonTaskCapabilityAction(code)) return false;
if (isHiddenWorkbenchNavigationAction(code)) return false;
// retry 仅当 retryable=true 时展示(避免按钮闪烁矛盾)
// 无对象边界的泛化 retry 永不展示。
if (code === 'retry') return false;
return true;
});
@@ -243,7 +240,6 @@ const businessActionLabel = computed(() => {
const code = String(props.primaryAction?.code || '').trim();
const inventoryKey = inventoryActionLabelKey(code);
if (inventoryKey && te(inventoryKey)) return t(inventoryKey);
if (props.retryable) return t('chat.shippingOrderReview.currentTask.actionRetry');
const pa = props.primaryAction;
if (!pa) return '';
if (isNonTaskCapabilityAction(String(pa.code || ''))) return '';
@@ -257,11 +253,6 @@ const businessActionLabel = computed(() => {
if (i18nKey && te(i18nKey)) {
return t(i18nKey);
}
// fallback 到 legacy chat.shippingProcessing.action
const legacyKey = `chat.shippingProcessing.action.${pa.code}`;
if (te(legacyKey)) {
return t(legacyKey);
}
// 当前任务按钮没有受控文案时 fail-closed,禁止泄漏内部 action code。
return '';
});
@@ -274,7 +265,7 @@ const businessActionTitle = computed(() => {
return '';
});
const actionIsRetry = computed(() => Boolean(props.retryable) || String(props.primaryAction?.code || '') === 'retry');
const actionIsRetry = computed(() => String(props.primaryAction?.code || '').trim().startsWith('retry_'));
const actionIsInventoryRpa = computed(() => String(props.primaryAction?.code || '').trim() === 'retry_inventory_preparation');
const recoveryActions = computed(() => (props.recoveryActions || []).filter((action) => {
const code = String(action.code || '').trim();
@@ -301,14 +292,7 @@ function recoveryActionLabel(action: (typeof recoveryActions.value)[number]): st
function handleBusinessActionClick() {
const primaryActionCode = String(props.primaryAction?.code || '').trim();
if (props.retryable && primaryActionCode && primaryActionCode !== 'retry') {
emit('action', primaryActionCode, props.primaryAction?.parameters ?? {});
return;
}
if (actionIsRetry.value) {
emit('retry');
return;
}
if (!primaryActionCode || primaryActionCode === 'retry') return;
emit('action', primaryActionCode, props.primaryAction?.parameters ?? {});
}