chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑
This commit is contained in:
1 parent
5ef8329bd8
commit
4ec4e57005
183 files changed
+14653
-3936
No files matched your search
@@ -42,6 +42,7 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
|
||||
open_shortage_review: 'open_shortage_review',
|
||||
upload_inventory_file: 'upload_inventory_file',
|
||||
retry_inventory_preparation: 'retry',
|
||||
retry_inventory_matching: 'open_inventory_match_review',
|
||||
retry: 'retry',
|
||||
retry_parse: 'retry',
|
||||
retry_failed_documents: 'retry',
|
||||
@@ -74,10 +75,6 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
|
||||
};
|
||||
|
||||
const AUTOMATING_STATUSES = new Set(['processing', 'automating', 'queued']);
|
||||
const NEEDS_ACTION_STATUSES = new Set([
|
||||
'blocked', 'waiting_review', 'pending_review', 'waiting_human',
|
||||
'failed', 'reparse_failed', 'manual_upload_pending', 'upload_rpa_failed',
|
||||
]);
|
||||
/** 永不升为主 CTA 的动作码(仍可作次要/溢出)。 */
|
||||
const NEVER_PRIMARY_CODES = new Set(['cancel_task', 'cancel_run', 'view_details']);
|
||||
|
||||
@@ -94,18 +91,21 @@ export function mapActionCodeToIntent(code: string | null | undefined): Shipping
|
||||
|
||||
/**
|
||||
* 构建单个动作项。
|
||||
* 核心逻辑:默认 labelKey=action.{intent};chat/right 面改写订单处理 / 重试解析 / 查看进度。
|
||||
* 核心逻辑:默认 labelKey=action.{intent};chat/right 面只改写重试解析 / 查看进度。
|
||||
*/
|
||||
function toItem(
|
||||
code: string,
|
||||
intent: ShippingProcessingActionIntent,
|
||||
surface?: ActionPresentationSurface,
|
||||
targetLifecycleStage?: string | null,
|
||||
): ActionPresentationItem {
|
||||
let labelKey = `chat.shippingProcessing.action.${intent}`;
|
||||
const normalized = String(code || '').trim().toLowerCase();
|
||||
const chatOrRight = surface === 'chat' || surface === 'right';
|
||||
if (intent === 'open_order_review' && chatOrRight) {
|
||||
labelKey = 'chat.shippingProcessing.action.open_order_processing';
|
||||
// 后端明确指定接收解析 surface 时,文案必须与目标一致;不能因复用同一
|
||||
// 只读导航动作码而误显示为订单处理。该分支不改变权限或路由目标。
|
||||
if (targetLifecycleStage === 'intake_parse') {
|
||||
labelKey = 'chat.shippingProcessing.action.open_intake_parse';
|
||||
} else if (normalized === 'retry_inventory_preparation') {
|
||||
labelKey = 'workspace.shippingNotice.processGate.actionCodes.retry_inventory_preparation';
|
||||
} else if (normalized === 'retry_freight_upload_rpa' || normalized === 'retry_upload') {
|
||||
@@ -123,6 +123,12 @@ function toItem(
|
||||
intent,
|
||||
actionCode: code,
|
||||
labelKey,
|
||||
targetLifecycleStage: (
|
||||
targetLifecycleStage === 'intake_parse'
|
||||
|| targetLifecycleStage === 'order_review'
|
||||
|| targetLifecycleStage === 'fulfillment_prep'
|
||||
|| targetLifecycleStage === 'upload_complete'
|
||||
) ? targetLifecycleStage : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -192,7 +198,10 @@ export function resolveProcessingActionPresentation(
|
||||
const items: ActionPresentationItem[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
const pushCode = (raw: string | null | undefined) => {
|
||||
const pushCode = (
|
||||
raw: string | null | undefined,
|
||||
targetLifecycleStage?: string | null,
|
||||
) => {
|
||||
const code = String(raw || '').trim();
|
||||
if (!code) return;
|
||||
const key = code.toLowerCase();
|
||||
@@ -200,10 +209,8 @@ export function resolveProcessingActionPresentation(
|
||||
if (key === 'regenerate_manual_upload_todo') return;
|
||||
if (seen.has(key)) return;
|
||||
seen.add(key);
|
||||
// 识别/建单失败的 view 是进入当前 Case 处理;已完成任务才打开只读结果。
|
||||
const intent = key === 'view' && NEEDS_ACTION_STATUSES.has(status)
|
||||
? 'open_order_review'
|
||||
: mapActionCodeToIntent(code);
|
||||
// [AUTHORITY] view 仅表示查看;生命周期入口必须由后端显式下发 open_order_review。
|
||||
const intent = mapActionCodeToIntent(code);
|
||||
if (!intent || intent === 'none') {
|
||||
// [fail-closed] 未知动作不渲染原始码,仅告警。
|
||||
warnUnregisteredWorkbenchAction({
|
||||
@@ -232,7 +239,16 @@ export function resolveProcessingActionPresentation(
|
||||
return;
|
||||
}
|
||||
}
|
||||
items.push(toItem(code, intent, surface));
|
||||
items.push(toItem(
|
||||
code,
|
||||
intent,
|
||||
surface,
|
||||
targetLifecycleStage ?? (
|
||||
authoritativeUiState?.primary_action?.code === code
|
||||
? authoritativeUiState.primary_action.targetLifecycleStage
|
||||
: null
|
||||
),
|
||||
));
|
||||
};
|
||||
|
||||
// [AUTHORITY] 新版只消费同一份 ui_state;currentGate 只保留诊断,禁止产生或替换按钮。
|
||||
@@ -244,7 +260,8 @@ export function resolveProcessingActionPresentation(
|
||||
? authoritativeUiState.secondary_actions.filter((action) => action.enabled).map((action) => action.code)
|
||||
: normalizeActionCodes(projection.availableActions || []);
|
||||
for (const action of actionCodes) {
|
||||
pushCode(action);
|
||||
const secondary = authoritativeUiState?.secondary_actions.find((item) => item.code === action);
|
||||
pushCode(action, secondary?.targetLifecycleStage);
|
||||
}
|
||||
// Gate 19 RPA 失败时,人工登记作为任务级替代路径展示,避免与 RPA 重试并列。
|
||||
return partitionActionItems(items);
|
||||
@@ -268,7 +285,6 @@ export function resolveConversationTaskActionPresentation(
|
||||
const userStatus = String(task.uiState?.status ?? task.userStatus ?? '').trim().toLowerCase();
|
||||
const legacyStatus = String(task.status_label ?? '').trim().toLowerCase();
|
||||
const status = userStatus || legacyStatus;
|
||||
const isNeedsAction = task.group === 'needs_action' || NEEDS_ACTION_STATUSES.has(status);
|
||||
const isProcessing = task.group === 'processing' || AUTOMATING_STATUSES.has(status);
|
||||
if (task.group === 'history' || status === 'cancelled') {
|
||||
return empty;
|
||||
@@ -276,22 +292,27 @@ export function resolveConversationTaskActionPresentation(
|
||||
const items: ActionPresentationItem[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
const pushCode = (raw: string | null | undefined) => {
|
||||
const pushCode = (
|
||||
raw: string | null | undefined,
|
||||
targetLifecycleStage?: string | null,
|
||||
) => {
|
||||
const code = String(raw || '').trim();
|
||||
if (!code) return;
|
||||
const key = code.toLowerCase();
|
||||
if (seen.has(key)) return;
|
||||
const intent = key === 'view' && isNeedsAction
|
||||
? 'open_order_review'
|
||||
: mapActionCodeToIntent(code);
|
||||
// 任务卡同样禁止通过“待处理 + view”补造订单生命周期权限。
|
||||
const intent = mapActionCodeToIntent(code);
|
||||
if (!intent || intent === 'none') return;
|
||||
seen.add(key);
|
||||
items.push(toItem(code, intent, surface));
|
||||
items.push(toItem(code, intent, surface, targetLifecycleStage));
|
||||
};
|
||||
|
||||
pushCode(task.uiState
|
||||
? task.uiState.primary_action?.code
|
||||
: (task.primaryAction?.code || task.primary_action));
|
||||
pushCode(
|
||||
task.uiState
|
||||
? task.uiState.primary_action?.code
|
||||
: (task.primaryAction?.code || task.primary_action),
|
||||
task.uiState?.primary_action?.targetLifecycleStage,
|
||||
);
|
||||
// [ORDER-STABLE] 对 available_actions 标准化排序,确保后端顺序变化不影响按钮渲染顺序。
|
||||
const normalizedTaskActions = normalizeActionCodes(
|
||||
task.uiState?.secondary_actions?.filter((item) => item.enabled).map((item) => item.code)
|
||||
@@ -299,7 +320,8 @@ export function resolveConversationTaskActionPresentation(
|
||||
|| [],
|
||||
);
|
||||
for (const action of normalizedTaskActions) {
|
||||
pushCode(action);
|
||||
const secondary = task.uiState?.secondary_actions.find((item) => item.code === action);
|
||||
pushCode(action, secondary?.targetLifecycleStage);
|
||||
}
|
||||
|
||||
const hasPrimaryCandidate = items.some(
|
||||
|
||||
Reference in new issue
Block a user