Files
syops/frontend/src/features/chat/constants/shipping.ts
T
hugo 1fc9976ca3 feat(chat): 更新发货任务处理逻辑和界面文本
- 移除不必要的状态引用
- 更新上传处理提示文本,使用国际化支持
- 扩展发货任务摘要接口,增加错误信息和短缺信息
- 更新多语言支持的文本,改善用户体验
- 增加批次工作区的汇总信息和操作提示
2026-06-29 14:43:27 +08:00

43 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* features/chat/constants/shipping.ts
* 用途:发货通知功能常量 — 任务编号正则、菜单动作规格与决策动作集合。
* 依赖:types/shipping.types(ShippingMenuAction)。
* 逻辑:shipping/* handler 与 useChatShipping 引用本模块,避免动作 id 硬编码分散。
*/
import type { ShippingMenuAction } from '../types/shipping.types';
/** 工作区发货任务编号格式(如 SN-20250610-ABCDEF12) */
export const SHIPPING_TASK_ID_RE = /SN-\d{8}-[A-F0-9]{8}/i;
export const SHIPPING_MENU_ACTION_SPECS: Record<
ShippingMenuAction,
{ id: string; label: string; message: string; variant: 'primary' | 'secondary' | 'danger' }
> = {
upload: { id: 'upload_inventory_file', label: '选择库存文件', message: '我要上传库存 Excel', variant: 'primary' },
paste: { id: 'paste_inventory_json', label: '粘贴库存', message: '我粘贴库存小表', variant: 'secondary' },
retry_rpa: { id: 'retry_rpa', label: '重试 RPA', message: '重试 RPA 导出库存', variant: 'secondary' },
confirm: { id: 'confirm', label: '确认', message: '确认', variant: 'primary' },
reparse: { id: 'reparse', label: '重新解析', message: '重新解析', variant: 'secondary' },
reject: { id: 'reject', label: '驳回', message: '驳回', variant: 'danger' },
};
export const SHIPPING_DECISION_ACTIONS = new Set([
'confirm',
'confirm_inventory_mapping',
'correct_inventory_mapping',
'reparse_inventory',
'retry_rpa',
'reject',
'reparse',
'rematch',
]);
/** 从文件名或 URL 提取扩展名(小写,不含点) */
export const extractExt = (value: string) => {
const text = (value || '').trim().toLowerCase();
const withoutQuery = (text.split('?')[0] || '').split('#')[0] || '';
const idx = withoutQuery.lastIndexOf('.');
if (idx < 0) return '';
return withoutQuery.slice(idx + 1).trim();
};