feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingProcessingLabels.ts
|
||||
* 用途:将统一 ShippingProcessing 状态/阶段码映射到四语言 i18n 键。
|
||||
* 依赖:vue-i18n Composer(由调用方传入 t / te)。
|
||||
* 逻辑:统一读 chat.shippingProcessing.*(含原 shippingWorkflow 合并键,如 taskStatus)。
|
||||
*/
|
||||
|
||||
/** 会话 processing 旧 status_label → 统一 ShippingProcessingStatus。 */
|
||||
const LEGACY_STATUS_TO_PROCESSING: Record<string, string> = {
|
||||
queued: 'processing',
|
||||
processing: 'processing',
|
||||
pending_review: 'waiting_review',
|
||||
waiting_review: 'waiting_review',
|
||||
failed: 'failed',
|
||||
completed: 'completed',
|
||||
cancelled: 'cancelled',
|
||||
cancelling: 'processing',
|
||||
blocked: 'blocked',
|
||||
automating: 'automating',
|
||||
};
|
||||
|
||||
/**
|
||||
* 解析统一处理状态的展示文案键。
|
||||
* 核心逻辑:优先 `chat.shippingProcessing.status.<code>`。
|
||||
* @param status - ShippingProcessingStatus 码
|
||||
* @returns i18n key
|
||||
*/
|
||||
export function shippingProcessingStatusKey(status: string): string {
|
||||
const code = String(status || '').trim();
|
||||
const mapped = LEGACY_STATUS_TO_PROCESSING[code] || code;
|
||||
return mapped
|
||||
? `chat.shippingProcessing.status.${mapped}`
|
||||
: 'chat.shippingProcessing.status.processing';
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析任务状态展示文案。
|
||||
*
|
||||
* @param code - 后端 status / status_label
|
||||
* @param te - i18n te
|
||||
* @param t - i18n t
|
||||
* @returns 本地化文案;皆无则回退原码
|
||||
*/
|
||||
export function resolveShippingProcessingStatusLabel(
|
||||
code: string,
|
||||
te: (key: string) => boolean,
|
||||
t: (key: string) => string,
|
||||
): string {
|
||||
const raw = String(code || '').trim();
|
||||
if (!raw) return '—';
|
||||
const processingKey = shippingProcessingStatusKey(raw);
|
||||
if (te(processingKey)) return t(processingKey);
|
||||
const taskStatusKey = `chat.shippingProcessing.taskStatus.${raw}`;
|
||||
if (te(taskStatusKey)) return t(taskStatusKey);
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析统一处理文案。
|
||||
*
|
||||
* @param leaf - 文案叶子键(如 groupNeedsAction)
|
||||
* @param te - i18n te
|
||||
* @param t - i18n t
|
||||
* @param params - 插值参数
|
||||
* @returns 本地化文案
|
||||
*/
|
||||
export function resolveShippingProcessingMessage(
|
||||
leaf: string,
|
||||
te: (key: string) => boolean,
|
||||
t: (key: string, params?: Record<string, unknown>) => string,
|
||||
params?: Record<string, unknown>,
|
||||
): string {
|
||||
const code = String(leaf || '').trim();
|
||||
if (!code) return '';
|
||||
const primary = `chat.shippingProcessing.${code}`;
|
||||
if (te(primary)) return t(primary, params);
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析统一处理阶段的展示文案键。
|
||||
* @param stage - ShippingProcessingStage 码
|
||||
* @returns i18n key
|
||||
*/
|
||||
export function shippingProcessingStageKey(stage: string): string {
|
||||
const code = String(stage || '').trim();
|
||||
return code
|
||||
? `chat.shippingProcessing.stage.${code}`
|
||||
: 'chat.shippingProcessing.stage.upload_received';
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析工作项类型文案键。
|
||||
* @param workItemType - order_intake | order_task
|
||||
* @returns i18n key
|
||||
*/
|
||||
export function shippingProcessingWorkItemTypeKey(workItemType: string): string {
|
||||
const code = String(workItemType || '').trim();
|
||||
return code
|
||||
? `chat.shippingProcessing.workItemType.${code}`
|
||||
: 'chat.shippingProcessing.workItemType.order_task';
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析来源类型文案键(eml / direct_pdf)。
|
||||
* @param sourceType - OrderIntakeSourceType
|
||||
* @returns i18n key
|
||||
*/
|
||||
export function shippingProcessingSourceTypeKey(sourceType: string): string {
|
||||
const code = String(sourceType || '').trim();
|
||||
return code
|
||||
? `chat.shippingProcessing.sourceType.${code}`
|
||||
: 'chat.shippingProcessing.sourceType.eml';
|
||||
}
|
||||
Reference in new issue
Block a user