feat(shipping_notice): 完成货代发货通知全流程功能迭代与重构
主要变更: 1. 移除废弃的发货通知字段抽取独立Workflow Agent相关代码 2. 重构Dify服务调用,新增inputs参数支持注入环境变量配置的工具API地址与密钥 3. 新增auto_progress工具API与checkpoint catalog接口,支持流程自动推进 4. 统一字段命名,将column_mapping_json改为map_json并兼容旧有调用 5. 重构库存匹配、解析结果的展示格式,改为标准化多语言Markdown表格 6. 新增ODM ID库存字段支持,优化库存解析与映射逻辑 7. 新增LibreOffice转换隔离Profile配置,避免多实例运行冲突 8. 新增完整环境变量配置、数据库迁移脚本与测试用例 9. 适配前端代码,更新字段命名与聊天跳转逻辑 10. 更新OpenAPI规范适配Dify工具调用,删除已归档的旧部署文档
This commit is contained in:
1 parent
2ce5256483
commit
c18c0394d0
50 files changed
+6088
-2407
No files matched your search
@@ -101,7 +101,7 @@ export async function applyWorkspaceShippingInventoryMapping(taskNo: string, col
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ column_mapping_json: columnMappingJson }),
|
||||
body: JSON.stringify({ map_json: columnMappingJson }),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingInventoryUploadResponse & { error?: string };
|
||||
@@ -210,6 +210,39 @@ export async function matchWorkspaceShippingInventory(taskNo: string) {
|
||||
return body;
|
||||
}
|
||||
|
||||
/** Hxops 聊天兜底:等同 Dify auto_progress Tool */
|
||||
export async function autoProgressWorkspaceShippingTask(taskNo: string, lang?: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/auto-progress`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(lang ? { lang } : {}),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
export async function markWorkspaceShippingManualUploaded(taskNo: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/mark-manual-uploaded`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
export async function generateWorkspaceShippingExcel(taskNo: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/generate-excel`,
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Action button ids for shipping-notice chat.
|
||||
* Keep in sync with backend `state_machine.py` → ACTION_SPECS keys.
|
||||
* CI: backend/tests/test_shipping_notice_state_machine.py::test_frontend_action_ids_match_backend
|
||||
*/
|
||||
export const SHIPPING_ACTION_IDS = [
|
||||
'confirm',
|
||||
'reject',
|
||||
'reparse',
|
||||
'confirm_inventory_mapping',
|
||||
'correct_inventory_mapping',
|
||||
'reparse_inventory',
|
||||
'rematch',
|
||||
'retry_rpa',
|
||||
'upload_inventory_file',
|
||||
'retry_upload',
|
||||
'download_excel',
|
||||
'generate_excel',
|
||||
'mark_manual_uploaded',
|
||||
'paste_inventory_json',
|
||||
'edit_inventory_mapping',
|
||||
'match_inventory',
|
||||
'refresh',
|
||||
] as const;
|
||||
|
||||
export type ShippingActionId = (typeof SHIPPING_ACTION_IDS)[number];
|
||||
|
||||
export const SHIPPING_KNOWN_ACTION_ID_SET = new Set<string>(SHIPPING_ACTION_IDS);
|
||||
|
||||
/** Backend state-machine codes — must never appear in user-visible chat text. */
|
||||
export const SHIPPING_TERMINAL_CHECKPOINTS = new Set(['uploaded', 'completed', 'rejected']);
|
||||
|
||||
export const SHIPPING_INTERNAL_STATUS_TOKENS = [
|
||||
'rpa_pending',
|
||||
'upload_rpa_pending',
|
||||
'rpa_exhausted',
|
||||
'inv_unavail',
|
||||
'align_review',
|
||||
'map_infer',
|
||||
'parse_review',
|
||||
'shortage_review',
|
||||
'low_confidence',
|
||||
'waiting_inventory',
|
||||
'inventory_ready',
|
||||
'pending_review',
|
||||
'waiting_upload',
|
||||
'upload_failed',
|
||||
'ready_to_match',
|
||||
'ready_to_export',
|
||||
'export_ready',
|
||||
'upload_req',
|
||||
'inventory_pending',
|
||||
'map_ok',
|
||||
'parse_ok',
|
||||
'needs_human',
|
||||
'fulfillable',
|
||||
'unfulfillable',
|
||||
] as const;
|
||||
+70
-2
@@ -444,6 +444,9 @@ const messages = {
|
||||
download: 'Download Excel',
|
||||
lines: 'Shipment lines',
|
||||
qty: 'Qty',
|
||||
columns: {
|
||||
sku: 'SKU'
|
||||
},
|
||||
events: 'Event log',
|
||||
filters: {
|
||||
status: 'Status'
|
||||
@@ -1278,13 +1281,31 @@ const messages = {
|
||||
disclaimer: 'AI can make mistakes. Please verify important information.',
|
||||
createNewChat: 'New Chat',
|
||||
shippingNoticeContinue: 'Please continue shipping task {taskId}. Call get_task_status first and tell me the next step.',
|
||||
shippingNoticeActionsHint: 'Choose an action (no need to type):',
|
||||
shippingNoticeActionsHint: 'Choose an action:',
|
||||
shippingNoticeMissingTaskId: 'Task ID not found. Complete shipping notice parsing first.',
|
||||
shippingNoticeUploadDone: 'Inventory file uploaded: {fileName}.',
|
||||
shippingNoticeUploadOk: 'Upload succeeded.',
|
||||
shippingNoticeUploadFailed: 'Inventory upload failed.',
|
||||
shippingNoticePasteHint: 'Paste inventory rows in the input box, then send.',
|
||||
shippingNoticeDecisionDone: 'Action completed.',
|
||||
shippingNoticeMapping: {
|
||||
inventoryHeaders: 'Inventory headers',
|
||||
headerRow: 'Header row: {row}',
|
||||
sample: 'Sample',
|
||||
orderDetails: 'Order details',
|
||||
orderRowCount: 'Order rows: {count}',
|
||||
orderSkuPreview: 'SKUs (first {count}): {skus}',
|
||||
skuColumnRequired: 'SKU column (required)',
|
||||
availableQtyColumnRequired: 'Available qty column (required)',
|
||||
reservationIdColumnOptional: 'Reservation ID column (optional)',
|
||||
selectHeader: 'Select a header',
|
||||
reservationIdNotUsed: '(Do not use Reservation ID)',
|
||||
reupload: 'Re-upload',
|
||||
applying: 'Applying...',
|
||||
applyAndParse: 'Apply mapping and parse',
|
||||
empty: '(empty)',
|
||||
unrecognized: '(unrecognized)'
|
||||
},
|
||||
clearAll: 'Clear All',
|
||||
clearOneRecord: 'Clear This Record',
|
||||
agents: 'Agents',
|
||||
@@ -1984,6 +2005,9 @@ const messages = {
|
||||
download: '下载 Excel',
|
||||
lines: '发货明细',
|
||||
qty: '数量',
|
||||
columns: {
|
||||
sku: 'SKU'
|
||||
},
|
||||
events: '事件记录',
|
||||
filters: {
|
||||
status: '状态'
|
||||
@@ -2798,13 +2822,31 @@ const messages = {
|
||||
disclaimer: 'AI 可能会犯错,请核实重要信息。',
|
||||
createNewChat: '创建新对话',
|
||||
shippingNoticeContinue: '请继续处理发货任务 {taskId},请先调用 get_task_status 查询当前状态并告知我下一步。',
|
||||
shippingNoticeActionsHint: '请选择操作(无需输入文字):',
|
||||
shippingNoticeActionsHint: '请选择操作:',
|
||||
shippingNoticeMissingTaskId: '未找到任务编号,请先完成发货通知解析。',
|
||||
shippingNoticeUploadDone: '库存文件已上传:{fileName}。',
|
||||
shippingNoticeUploadOk: '上传成功。',
|
||||
shippingNoticeUploadFailed: '库存文件上传失败。',
|
||||
shippingNoticePasteHint: '请在输入框粘贴库存小表内容后发送。',
|
||||
shippingNoticeDecisionDone: '操作已完成。',
|
||||
shippingNoticeMapping: {
|
||||
inventoryHeaders: '库存表头',
|
||||
headerRow: '表头行:{row}',
|
||||
sample: '样例',
|
||||
orderDetails: '订单明细',
|
||||
orderRowCount: '订单行数:{count}',
|
||||
orderSkuPreview: 'SKU(前{count}):{skus}',
|
||||
skuColumnRequired: 'SKU 列(必填)',
|
||||
availableQtyColumnRequired: '可用数量列(必填)',
|
||||
reservationIdColumnOptional: 'Reservation ID 列(可选)',
|
||||
selectHeader: '请选择表头列名',
|
||||
reservationIdNotUsed: '(不使用 Reservation ID)',
|
||||
reupload: '重新上传',
|
||||
applying: '应用中...',
|
||||
applyAndParse: '应用映射并解析',
|
||||
empty: '(空)',
|
||||
unrecognized: '(未识别)'
|
||||
},
|
||||
clearAll: '清空全部',
|
||||
clearOneRecord: '清除该记录',
|
||||
agents: '智能体',
|
||||
@@ -5392,6 +5434,32 @@ const messages = {
|
||||
thinking: 'กำลังสร้างคำตอบ...',
|
||||
disclaimer: 'AI อาจทำผิดพลาดได้ โปรดตรวจสอบข้อมูลสำคัญ',
|
||||
createNewChat: 'แชทใหม่',
|
||||
shippingNoticeContinue: 'กรุณาดำเนินการงานจัดส่งต่อ {taskId} โปรดเรียก get_task_status ก่อนและบอกขั้นตอนถัดไป',
|
||||
shippingNoticeActionsHint: 'เลือกการทำงาน:',
|
||||
shippingNoticeMissingTaskId: 'ไม่พบรหัสงาน โปรดแยกใบแจ้งส่งสินค้าก่อน',
|
||||
shippingNoticeUploadDone: 'อัปโหลดไฟล์สต็อกแล้ว: {fileName}',
|
||||
shippingNoticeUploadOk: 'อัปโหลดสำเร็จ',
|
||||
shippingNoticeUploadFailed: 'อัปโหลดไฟล์สต็อกล้มเหลว',
|
||||
shippingNoticePasteHint: 'วางข้อมูลสต็อกในช่องข้อความแล้วส่ง',
|
||||
shippingNoticeDecisionDone: 'ดำเนินการเสร็จแล้ว',
|
||||
shippingNoticeMapping: {
|
||||
inventoryHeaders: 'หัวคอลัมน์สต็อก',
|
||||
headerRow: 'แถวหัวตาราง: {row}',
|
||||
sample: 'ตัวอย่าง',
|
||||
orderDetails: 'รายละเอียดคำสั่งซื้อ',
|
||||
orderRowCount: 'จำนวนแถวคำสั่งซื้อ: {count}',
|
||||
orderSkuPreview: 'SKU (แรก {count}): {skus}',
|
||||
skuColumnRequired: 'คอลัมน์ SKU (จำเป็น)',
|
||||
availableQtyColumnRequired: 'คอลัมน์จำนวนคงเหลือ (จำเป็น)',
|
||||
reservationIdColumnOptional: 'คอลัมน์ Reservation ID (ไม่บังคับ)',
|
||||
selectHeader: 'เลือกชื่อหัวคอลัมน์',
|
||||
reservationIdNotUsed: '(ไม่ใช้ Reservation ID)',
|
||||
reupload: 'อัปโหลดใหม่',
|
||||
applying: 'กำลังนำไปใช้...',
|
||||
applyAndParse: 'นำการจับคู่ไปใช้และแยกข้อมูล',
|
||||
empty: '(ว่าง)',
|
||||
unrecognized: '(ไม่รู้จัก)'
|
||||
},
|
||||
clearAll: 'ล้างทั้งหมด',
|
||||
clearOneRecord: 'ลบรายการนี้',
|
||||
agents: 'ตัวแทน',
|
||||
|
||||
+297
-224
@@ -54,13 +54,16 @@ import {
|
||||
getWorkspaceShippingTask,
|
||||
applyWorkspaceShippingInventoryMapping,
|
||||
getShippingChatActions,
|
||||
autoProgressWorkspaceShippingTask,
|
||||
generateWorkspaceShippingExcel,
|
||||
markWorkspaceShippingManualUploaded,
|
||||
matchWorkspaceShippingInventory,
|
||||
SHIPPING_NOTICE_AGENT_NAME,
|
||||
submitWorkspaceShippingDecision,
|
||||
uploadWorkspaceShippingInventory,
|
||||
workspaceShippingExportUrl,
|
||||
} from '../api/shippingNotice';
|
||||
import { SHIPPING_INTERNAL_STATUS_TOKENS, SHIPPING_KNOWN_ACTION_ID_SET, SHIPPING_TERMINAL_CHECKPOINTS } from '../constants/shippingNoticeActions';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { appliedTheme, toggleLightDark } = useTheme();
|
||||
@@ -176,14 +179,72 @@ const stripReasoningPrelude = (text: string) => {
|
||||
|
||||
const sanitizeShippingConversationText = (text: string) => {
|
||||
if (!isShippingNoticeAgent.value) return text;
|
||||
return String(text || '')
|
||||
let result = String(text || '')
|
||||
.replace(/\btask_id\s*[::]/gi, '任务编号:')
|
||||
.replace(/\btask_id\b/gi, '任务编号');
|
||||
|
||||
// Agent 有时会复述「(显示 "rpa_pending")」类后台标记
|
||||
result = result.replace(/[((]\s*显示\s*[「"'`][^"'`]+[」"'`]\s*[))]/g, '');
|
||||
result = result.replace(
|
||||
/\b(process_status|pending_human_reason|review_status|checkpoint|match_status|human_options)\s*[::=]\s*[「"'`]?[\w.-]+[「"'`]?/gi,
|
||||
'',
|
||||
);
|
||||
|
||||
for (const token of SHIPPING_INTERNAL_STATUS_TOKENS) {
|
||||
const quoted = new RegExp(`[「"'“”‘’]\\s*${token}\\s*[」"'“”‘’]`, 'gi');
|
||||
result = result.replace(quoted, '');
|
||||
result = result.replace(new RegExp(`\`${token}\``, 'gi'), '');
|
||||
}
|
||||
|
||||
return result.replace(/\n{3,}/g, '\n\n').trim();
|
||||
};
|
||||
|
||||
type ShippingActionVariant = 'primary' | 'secondary' | 'danger';
|
||||
|
||||
const extractShippingActionsDirective = (rawText: string): {
|
||||
cleanedText: string;
|
||||
buttons: Array<{ id: string; label: string; message: string; variant?: ShippingActionVariant }>;
|
||||
} => {
|
||||
const text = String(rawText || '');
|
||||
const re = /<!--\s*HXOPS_SHIPPING_ACTIONS\s*:\s*([\s\S]*?)\s*-->/gi;
|
||||
let cleaned = text;
|
||||
const buttons: Array<{ id: string; label: string; message: string; variant?: ShippingActionVariant }> = [];
|
||||
for (;;) {
|
||||
const m = re.exec(text);
|
||||
if (!m) break;
|
||||
const body = String(m[1] || '').trim();
|
||||
if (!body) continue;
|
||||
try {
|
||||
const parsed = JSON.parse(body);
|
||||
if (Array.isArray(parsed)) {
|
||||
for (const item of parsed) {
|
||||
if (!item || typeof item !== 'object') continue;
|
||||
const id = String((item as any).id || '').trim();
|
||||
const label = String((item as any).label || '').trim();
|
||||
const message = String((item as any).message || '').trim();
|
||||
const variantRaw = String((item as any).variant || '').trim();
|
||||
const variant: ShippingActionVariant | undefined = (variantRaw === 'primary' || variantRaw === 'secondary' || variantRaw === 'danger')
|
||||
? (variantRaw as ShippingActionVariant)
|
||||
: undefined;
|
||||
if (!id || !label || !message) continue;
|
||||
if (!SHIPPING_KNOWN_ACTION_ID_SET.has(id)) {
|
||||
console.warn(`[shipping] unknown action id in HXOPS_SHIPPING_ACTIONS: ${id}`);
|
||||
}
|
||||
buttons.push({ id, label, message, variant });
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
cleaned = cleaned.replace(re, '').trim();
|
||||
return { cleanedText: cleaned, buttons };
|
||||
};
|
||||
|
||||
const renderMarkdown = (text: string) => {
|
||||
if (!text) return '';
|
||||
const displayText = sanitizeShippingConversationText(stripReasoningPrelude(text));
|
||||
const stripped = isShippingNoticeAgent.value ? extractShippingActionsDirective(text).cleanedText : text;
|
||||
const displayText = sanitizeShippingConversationText(stripReasoningPrelude(stripped));
|
||||
try {
|
||||
// 把 # 标题、代码块、[链接](url) 等 Markdown 解析成 HTML
|
||||
return marked.parse(displayText);
|
||||
@@ -2128,6 +2189,7 @@ const displayHistory = computed<DisplayHistoryItem[]>(() => {
|
||||
const serverIds = new Set(server.map((h) => h.conversation_id));
|
||||
const pending: DisplayHistoryItem[] = (runs.value || [])
|
||||
.filter((r) => r.agentId === currentAgentId.value)
|
||||
.filter((r) => r.status === 'running')
|
||||
.filter((r) => r.runId !== activeRunId.value)
|
||||
.map((r) => ({
|
||||
id: 0,
|
||||
@@ -2362,12 +2424,15 @@ const normalizeMenuDigit = (ch: string) => {
|
||||
};
|
||||
|
||||
const classifyShippingMenuLine = (desc: string): ShippingMenuAction | null => {
|
||||
if (/上传|excel|xlsx|xls|csv|库存文件|\.xlsx/i.test(desc)) return 'upload';
|
||||
const normalized = String(desc || '').trim();
|
||||
if (!normalized) return null;
|
||||
if (/已确认/.test(normalized)) return null;
|
||||
if (/(?:选择|上传).*(?:库存|excel|xlsx|xls|csv)/i.test(normalized)) return 'upload';
|
||||
if (/粘贴|文本|小量|直接发/i.test(desc)) return 'paste';
|
||||
if (/重试|rpa|拉取/i.test(desc)) return 'retry_rpa';
|
||||
if (/(?:重试|重新)\s*RPA|重试.*(?:导出|获取|拉取)|RPA.*(?:导出|获取|拉取).*重试/i.test(desc)) return 'retry_rpa';
|
||||
if (/重新解析|重解析|reparse/i.test(desc)) return 'reparse';
|
||||
if (/驳回|取消|reject/i.test(desc)) return 'reject';
|
||||
if (/确认|confirm/i.test(desc)) return 'confirm';
|
||||
if (/^(?:确认|confirm)\b/i.test(normalized)) return 'confirm';
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -2387,20 +2452,6 @@ const parseShippingMenuFromContext = (
|
||||
return map;
|
||||
};
|
||||
|
||||
const buildShippingMenuButtons = (ctx: string) => {
|
||||
const menu = parseShippingMenuFromContext(ctx);
|
||||
if (!menu.size) return null;
|
||||
return [...menu.entries()]
|
||||
.sort(([a], [b]) => a - b)
|
||||
.map(([num, item]) => {
|
||||
const spec = SHIPPING_MENU_ACTION_SPECS[item.action];
|
||||
return {
|
||||
...spec,
|
||||
label: `${num}. ${item.desc || spec.label}`,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const resolveShippingNumericChoice = (text: string): ShippingMenuAction | null => {
|
||||
const normalized = text.trim();
|
||||
if (!/^[1-91-9](?:[\.\、\)::]?)$/.test(normalized)) return null;
|
||||
@@ -2408,142 +2459,26 @@ const resolveShippingNumericChoice = (text: string): ShippingMenuAction | null =
|
||||
return parseShippingMenuFromContext(lastAssistantMessageContent()).get(num)?.action || null;
|
||||
};
|
||||
|
||||
const isShippingFieldAlignmentPrompt = (text: string) => {
|
||||
if (/无需确认|确认失败|已驳回|rejected|unfulfillable|重新创建|建议方案|不需要确认/.test(text)) {
|
||||
return false;
|
||||
}
|
||||
const hasAlignmentTable = (
|
||||
text.includes('|系统字段|库存列|')
|
||||
|| text.includes('字段对齐表:')
|
||||
|| text.includes('字段对齐表:')
|
||||
);
|
||||
if (!hasAlignmentTable) return false;
|
||||
const hasConfirm = (
|
||||
text.includes('请确认')
|
||||
|| text.includes('确认后才能匹配')
|
||||
);
|
||||
if (!hasConfirm) return false;
|
||||
const hasInventoryContext = (
|
||||
text.includes('库存列')
|
||||
|| text.includes('field_alignment')
|
||||
|| text.includes('inventory_columns')
|
||||
|| text.includes('available_qty')
|
||||
|| text.includes('reservation_id')
|
||||
);
|
||||
return hasInventoryContext;
|
||||
};
|
||||
|
||||
const inferShippingActionsFromContent = (content: string) => {
|
||||
const text = String(content || '');
|
||||
if (text.includes('已生成发货 Excel') || text.includes('download_excel') || text.includes('waiting_upload')) {
|
||||
return [
|
||||
{ id: 'download_excel', label: '下载 Excel', message: '下载发货 Excel', variant: 'secondary' as const },
|
||||
];
|
||||
}
|
||||
if (text.includes('生成 Excel') || text.includes('generate_shipment_excel') || text.includes('generate_excel')) {
|
||||
return [
|
||||
{ id: 'generate_excel', label: '生成发货 Excel', message: '生成发货 Excel', variant: 'primary' as const },
|
||||
];
|
||||
}
|
||||
if (
|
||||
text.includes('match_inventory')
|
||||
|| (text.includes('匹配库存') && text.includes('任务编号'))
|
||||
) {
|
||||
return [
|
||||
{ id: 'match_inventory', label: '匹配库存', message: '匹配库存', variant: 'primary' as const },
|
||||
];
|
||||
}
|
||||
if (
|
||||
text.includes('reservation_id_required')
|
||||
|| text.includes('Reservation ID 必填')
|
||||
|| text.includes('缺少 Reservation ID')
|
||||
) {
|
||||
return [
|
||||
{ id: 'reparse', label: '重新解析', message: '重新解析', variant: 'secondary' as const },
|
||||
{ id: 'edit_inventory_mapping', label: '修改映射', message: '修改库存列映射', variant: 'primary' as const },
|
||||
{ id: 'upload_inventory_file', label: '选择库存文件', message: '我要上传库存 Excel', variant: 'secondary' as const },
|
||||
{ id: 'reject', label: '驳回', message: '驳回', variant: 'danger' as const },
|
||||
];
|
||||
}
|
||||
if (isShippingFieldAlignmentPrompt(text)) {
|
||||
return [
|
||||
{ id: 'confirm_inventory_mapping', label: '确认', message: '确认', variant: 'primary' as const },
|
||||
{ id: 'correct_inventory_mapping', label: '更正映射', message: '更正映射', variant: 'secondary' as const },
|
||||
{ id: 'reparse_inventory', label: '重新上传', message: '重新上传库存', variant: 'secondary' as const },
|
||||
{ id: 'reject', label: '取消', message: '驳回', variant: 'danger' as const },
|
||||
];
|
||||
}
|
||||
if (
|
||||
text.includes('请确认以上信息')
|
||||
|| text.includes('请确认以上')
|
||||
|| text.includes('请确认以下')
|
||||
|| text.includes('请核对')
|
||||
|| text.includes('确认后继续')
|
||||
|| text.includes('回复「确认」')
|
||||
|| text.includes('回复"确认"')
|
||||
|| /回复\s*[\[【「"'((]?\s*确认/.test(text)
|
||||
) {
|
||||
return [
|
||||
{ id: 'confirm', label: '确认', message: '确认', variant: 'primary' as const },
|
||||
{ id: 'reparse', label: '重新解析', message: '重新解析', variant: 'secondary' as const },
|
||||
{ id: 'reject', label: '驳回', message: '驳回', variant: 'danger' as const },
|
||||
];
|
||||
}
|
||||
if (text.includes('库存数量不足') || text.includes('缺口明细')) {
|
||||
return [
|
||||
{ id: 'confirm', label: '确认部分发货', message: '确认', variant: 'primary' as const },
|
||||
{ id: 'rematch', label: '重新匹配', message: '重新匹配', variant: 'secondary' as const },
|
||||
{ id: 'reject', label: '驳回', message: '驳回', variant: 'danger' as const },
|
||||
];
|
||||
}
|
||||
if (
|
||||
text.includes('waiting_inventory')
|
||||
|| text.includes('inventory_rpa_pending')
|
||||
|| text.includes('重试 RPA')
|
||||
|| text.includes('上传库存')
|
||||
|| text.includes('upload_inventory_file')
|
||||
|| /[1-3][\.\、\)]/.test(text)
|
||||
) {
|
||||
const menuButtons = buildShippingMenuButtons(text);
|
||||
if (menuButtons?.length) return menuButtons;
|
||||
return [
|
||||
{ id: 'upload_inventory_file', label: '选择库存文件', message: '我要上传库存 Excel', variant: 'primary' as const },
|
||||
{ id: 'paste_inventory_json', label: '粘贴库存', message: '我粘贴库存小表', variant: 'secondary' as const },
|
||||
{ id: 'retry_rpa', label: '重试 RPA', message: '重试 RPA 导出库存', variant: 'secondary' as const },
|
||||
];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
const shouldPreferInferredShippingActions = (
|
||||
const resolveShippingActionButtons = (
|
||||
content: string,
|
||||
inferred: Array<{ id: string }>,
|
||||
api: Array<{ id: string }>,
|
||||
apiButtons: Array<{ id: string; label: string; message: string; variant?: string }> | null,
|
||||
options?: { apiResolved?: boolean },
|
||||
) => {
|
||||
if (!inferred.length || !api.length) return false;
|
||||
const text = String(content || '');
|
||||
const hasConfirmPrompt = (
|
||||
text.includes('请确认')
|
||||
|| text.includes('回复「确认」')
|
||||
|| text.includes('回复"确认"')
|
||||
|| /回复\s*[\[【「"'((]?\s*确认/.test(text)
|
||||
|| text.includes('请核对')
|
||||
|| text.includes('确认后继续')
|
||||
);
|
||||
if (!hasConfirmPrompt) return false;
|
||||
const inferredHasDecision = inferred.some((b) => ['confirm', 'reparse', 'reject'].includes(b.id));
|
||||
if (!inferredHasDecision) return false;
|
||||
const apiLooksLikeInventoryMenu = api.some((b) => [
|
||||
'upload_inventory_file',
|
||||
'retry_rpa',
|
||||
'paste_inventory_json',
|
||||
'confirm_inventory_mapping',
|
||||
'correct_inventory_mapping',
|
||||
'reparse_inventory',
|
||||
'edit_inventory_mapping',
|
||||
].includes(b.id));
|
||||
if (!apiLooksLikeInventoryMenu) return false;
|
||||
return true;
|
||||
const directive = extractShippingActionsDirective(String(content || ''));
|
||||
if (options?.apiResolved) {
|
||||
return {
|
||||
buttons: apiButtons || [],
|
||||
cleanedText: directive.cleanedText,
|
||||
fromDirective: false,
|
||||
};
|
||||
}
|
||||
if (directive.buttons.length) {
|
||||
return { buttons: directive.buttons, cleanedText: directive.cleanedText, fromDirective: true };
|
||||
}
|
||||
if (apiButtons?.length) {
|
||||
return { buttons: apiButtons, cleanedText: directive.cleanedText, fromDirective: false };
|
||||
}
|
||||
return { buttons: [], cleanedText: directive.cleanedText, fromDirective: false };
|
||||
};
|
||||
|
||||
const SHIPPING_DECISION_ACTIONS = new Set([
|
||||
@@ -2586,7 +2521,17 @@ const executeShippingDecision = async (decision: string, displayText?: string) =
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const result = await submitWorkspaceShippingDecision(taskId, decision);
|
||||
const result =
|
||||
decision === 'confirm_inventory_mapping'
|
||||
? await autoProgressWorkspaceShippingTask(taskId)
|
||||
: await submitWorkspaceShippingDecision(taskId, decision);
|
||||
if (decision === 'correct_inventory_mapping') {
|
||||
const preview = result?.data?.schema_preview;
|
||||
const key = String(taskId || '').trim().toUpperCase();
|
||||
if (key && preview && typeof preview === 'object') {
|
||||
shippingInventorySchemaPreviewCache.value = { ...shippingInventorySchemaPreviewCache.value, [key]: preview };
|
||||
}
|
||||
}
|
||||
const userText = (displayText || decision).trim();
|
||||
const assistantContent = formatShippingDecisionAssistantMessage(decision, result, taskId);
|
||||
const userMsg = {
|
||||
@@ -2616,6 +2561,9 @@ const executeShippingDecision = async (decision: string, displayText?: string) =
|
||||
if (!exists) await loadHistory();
|
||||
}
|
||||
void refreshShippingActions();
|
||||
if (decision === 'correct_inventory_mapping') {
|
||||
await openShippingInventoryMappingFormForTask(taskId);
|
||||
}
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
msg.warning(e?.message || t('chat.shippingNoticeUploadFailed'));
|
||||
@@ -2653,7 +2601,9 @@ const formatShippingDecisionAssistantMessage = (
|
||||
'也可点击「选择库存文件」重新上传。',
|
||||
);
|
||||
} else if (decision === 'confirm_inventory_mapping') {
|
||||
lines.push('', '下一步:匹配库存与发货需求(match_inventory)。');
|
||||
if (String(result.checkpoint || '').trim() === 'map_ok') {
|
||||
lines.push('', '下一步:匹配库存与发货需求(match_inventory)。');
|
||||
}
|
||||
} else if (decision === 'reparse_inventory') {
|
||||
lines.push('', '请重新上传或粘贴库存 Excel。');
|
||||
}
|
||||
@@ -2696,6 +2646,43 @@ const pushShippingLocalAssistantMessage = async (text: string) => {
|
||||
await saveLocalMessageToBackend(assistantMsg);
|
||||
};
|
||||
|
||||
const buildShippingInventoryUploadPrompt = (
|
||||
result: Record<string, any> | null | undefined,
|
||||
fileName?: string,
|
||||
) => {
|
||||
const checkpoint = String(result?.checkpoint || '').trim();
|
||||
const hasAlignment = Boolean(result?.data?.field_alignment && typeof result?.data?.field_alignment === 'object');
|
||||
const suggestOk = Boolean(result?.data?.suggest_ok);
|
||||
const prefix = fileName ? `我已上传库存文件《${fileName}》` : '我已上传库存文件';
|
||||
|
||||
if (checkpoint === 'map_infer') {
|
||||
if (suggestOk) {
|
||||
return `${prefix}。请继续处理库存列映射;如果系统已识别出完整映射,请直接应用映射,并展示字段对齐结果给我确认。`;
|
||||
}
|
||||
return `${prefix}。请继续解析库存列映射,并在拿到可用映射后展示字段对齐结果给我确认。`;
|
||||
}
|
||||
|
||||
if (checkpoint === 'align_review' || hasAlignment) {
|
||||
return `${prefix}。请展示库存字段对齐结果,并引导我确认或更正映射。`;
|
||||
}
|
||||
|
||||
return `${prefix}。请继续处理库存导入,并告诉我下一步。`;
|
||||
};
|
||||
|
||||
const continueShippingInventoryUploadWithDify = async (
|
||||
taskId: string,
|
||||
result: Record<string, any> | null | undefined,
|
||||
fileName?: string,
|
||||
) => {
|
||||
const key = String(taskId || '').trim().toUpperCase();
|
||||
const schemaPreview = result?.data?.schema_preview;
|
||||
if (key && schemaPreview && typeof schemaPreview === 'object') {
|
||||
shippingInventorySchemaPreviewCache.value = { ...shippingInventorySchemaPreviewCache.value, [key]: schemaPreview };
|
||||
}
|
||||
resolvedShippingTaskId.value = taskId;
|
||||
await sendShippingMenuMessage(buildShippingInventoryUploadPrompt(result, fileName));
|
||||
};
|
||||
|
||||
const normalizeShippingHeaderForDisplay = (raw: any): string => {
|
||||
const text = String(raw ?? '').replace(/\s+/g, ' ').trim();
|
||||
return text.replace(/ /g, '\u00A0');
|
||||
@@ -2781,21 +2768,7 @@ const handleShippingAutoUploadFile = async (file: File) => {
|
||||
}
|
||||
resolvedShippingTaskId.value = taskId;
|
||||
const result = await uploadWorkspaceShippingInventory(taskId, file);
|
||||
const checkpoint = String((result as any)?.checkpoint || '').trim();
|
||||
const schemaPreview = (result as any)?.data?.schema_preview;
|
||||
if (checkpoint === 'inventory_mapping_inference' && schemaPreview && typeof schemaPreview === 'object') {
|
||||
shippingInventorySchemaPreviewCache.value = { ...shippingInventorySchemaPreviewCache.value, [taskId]: schemaPreview };
|
||||
}
|
||||
const alignmentText = buildShippingFieldAlignmentText(result);
|
||||
const hint = alignmentText || String(result.message || t('chat.shippingNoticeUploadOk')).trim();
|
||||
await pushShippingLocalAssistantMessage(
|
||||
[
|
||||
`库存已上传:${file.name}`,
|
||||
`任务编号:${taskId}`,
|
||||
hint,
|
||||
].filter(Boolean).join('\n'),
|
||||
);
|
||||
void refreshShippingActions();
|
||||
await continueShippingInventoryUploadWithDify(taskId, result as Record<string, any>, file.name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2859,6 +2832,58 @@ const isShippingInventoryUploadIntent = (text: string) => {
|
||||
].some((pattern) => pattern.test(normalized));
|
||||
};
|
||||
|
||||
const isShippingManualUploadIntent = (text: string) => {
|
||||
const normalized = text.trim();
|
||||
if (!normalized) return false;
|
||||
return [
|
||||
/已在货代系统手工上传/,
|
||||
/已手工上传/,
|
||||
/手工上传完成/,
|
||||
/手动上传完成/,
|
||||
/货代.*上传完成/,
|
||||
].some((pattern) => pattern.test(normalized));
|
||||
};
|
||||
|
||||
const executeShippingManualUpload = async (taskId: string, displayText?: string) => {
|
||||
try {
|
||||
const result = await markWorkspaceShippingManualUploaded(taskId);
|
||||
const userText = (displayText || '已在货代系统手工上传完成').trim();
|
||||
const assistantContent = [
|
||||
String(result.message || '已标记为手工上传货代系统完成。').trim(),
|
||||
`任务编号:${taskId}`,
|
||||
].join('\n');
|
||||
const userMsg = {
|
||||
role: 'user' as const,
|
||||
type: 'text' as const,
|
||||
content: `${userText}\n任务编号:${taskId}`,
|
||||
local_id: newLocalMessageId('shipping-user'),
|
||||
local_only: true,
|
||||
};
|
||||
const assistantMsg = {
|
||||
role: 'assistant' as const,
|
||||
type: 'text' as const,
|
||||
content: assistantContent,
|
||||
local_id: newLocalMessageId('shipping-assistant'),
|
||||
local_only: true,
|
||||
shipping_actions_used: true,
|
||||
};
|
||||
messages.value.push(userMsg, assistantMsg);
|
||||
messages.value.forEach((rawMsg) => {
|
||||
const m = rawMsg as any;
|
||||
if (m.role === 'assistant') {
|
||||
m.shipping_actions = undefined;
|
||||
}
|
||||
});
|
||||
await saveLocalMessageToBackend(userMsg, userText);
|
||||
await saveLocalMessageToBackend(assistantMsg, userText);
|
||||
void refreshShippingActions();
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
msg.warning(e?.message || '标记手工上传失败');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const isShippingGenerateExcelIntent = (text: string) => {
|
||||
const normalized = text.trim();
|
||||
if (!normalized) return false;
|
||||
@@ -2919,6 +2944,11 @@ const sendShippingMenuMessage = async (message: string) => {
|
||||
const handleShippingMenuAction = async (action: { id?: string; message: string }, msg?: any) => {
|
||||
if (isThinking.value) return;
|
||||
|
||||
if (action.id === 'refresh') {
|
||||
await sendShippingMenuMessage(action.message || '刷新');
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.id === 'download_excel') {
|
||||
const taskId = getActiveShippingTaskId();
|
||||
if (!taskId) {
|
||||
@@ -3022,6 +3052,18 @@ const handleShippingMenuAction = async (action: { id?: string; message: string }
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.id === 'mark_manual_uploaded') {
|
||||
if (msg?.shipping_actions_used) return;
|
||||
if (msg) msg.shipping_actions_used = true;
|
||||
const taskId = getActiveShippingTaskId();
|
||||
if (!taskId) {
|
||||
msg.warning(t('chat.shippingNoticeMissingTaskId'));
|
||||
return;
|
||||
}
|
||||
await executeShippingManualUpload(taskId, action.message || '已在货代系统手工上传完成');
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.id === 'paste_inventory_json') {
|
||||
msg.info(t('chat.shippingNoticePasteHint'));
|
||||
return;
|
||||
@@ -3082,6 +3124,7 @@ const refreshShippingActions = async () => {
|
||||
}
|
||||
if (taskId) resolvedShippingTaskId.value = taskId;
|
||||
let apiButtons: Array<{ id: string; label: string; message: string; variant?: string }> | null = null;
|
||||
let apiCheckpoint: string | null = null;
|
||||
let apiResolved = false;
|
||||
|
||||
if (taskId && !isThinking.value) {
|
||||
@@ -3090,6 +3133,7 @@ const refreshShippingActions = async () => {
|
||||
const data = await getShippingChatActions(taskId);
|
||||
if (seq === shippingActionsRequestSeq) {
|
||||
apiResolved = true;
|
||||
apiCheckpoint = data.checkpoint ? String(data.checkpoint) : null;
|
||||
apiButtons = data.action_buttons?.length ? data.action_buttons : null;
|
||||
}
|
||||
} catch {
|
||||
@@ -3097,6 +3141,16 @@ const refreshShippingActions = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (apiResolved && apiCheckpoint && SHIPPING_TERMINAL_CHECKPOINTS.has(apiCheckpoint)) {
|
||||
msgs.forEach((rawMsg) => {
|
||||
const m = rawMsg as any;
|
||||
if (m.role === 'assistant') {
|
||||
m.shipping_actions = undefined;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let lastOpenAssistantIndex = -1;
|
||||
for (let i = msgs.length - 1; i >= 0; i -= 1) {
|
||||
const item = msgs[i];
|
||||
@@ -3132,15 +3186,22 @@ const refreshShippingActions = async () => {
|
||||
}
|
||||
|
||||
let buttons: Array<{ id: string; label: string; message: string; variant?: string }> = [];
|
||||
if (apiResolved && index === targetAssistantIndex) {
|
||||
const inferred = inferShippingActionsFromContent(String(msg.content || ''));
|
||||
if (apiButtons && apiButtons.length && shouldPreferInferredShippingActions(String(msg.content || ''), inferred, apiButtons)) {
|
||||
buttons = inferred;
|
||||
} else {
|
||||
buttons = apiButtons || inferred;
|
||||
if (index === targetAssistantIndex) {
|
||||
const resolved = resolveShippingActionButtons(
|
||||
String(msg.content || ''),
|
||||
apiResolved ? (apiButtons ?? []) : null,
|
||||
{ apiResolved },
|
||||
);
|
||||
if (resolved.fromDirective) {
|
||||
msg.content = resolved.cleanedText;
|
||||
}
|
||||
buttons = resolved.buttons;
|
||||
} else if (!apiResolved) {
|
||||
buttons = inferShippingActionsFromContent(String(msg.content || ''));
|
||||
const resolved = resolveShippingActionButtons(String(msg.content || ''), null);
|
||||
if (resolved.fromDirective) {
|
||||
msg.content = resolved.cleanedText;
|
||||
}
|
||||
buttons = resolved.buttons;
|
||||
}
|
||||
msg.shipping_actions = buttons.length ? buttons : undefined;
|
||||
});
|
||||
@@ -3175,38 +3236,7 @@ const handleShippingInventorySelected = async (event: Event) => {
|
||||
|
||||
try {
|
||||
const result = await uploadWorkspaceShippingInventory(taskId, file);
|
||||
const checkpoint = String((result as any)?.checkpoint || '').trim();
|
||||
const schemaPreview = (result as any)?.data?.schema_preview;
|
||||
if (checkpoint === 'inventory_mapping_inference' && schemaPreview && typeof schemaPreview === 'object') {
|
||||
const key = String(taskId || '').trim().toUpperCase();
|
||||
if (key) {
|
||||
shippingInventorySchemaPreviewCache.value = { ...shippingInventorySchemaPreviewCache.value, [key]: schemaPreview };
|
||||
}
|
||||
const hint = [
|
||||
String((result as any)?.message || '').trim(),
|
||||
'请点击下方“修改映射”,用下拉框选择 SKU / 可用数量 / Reservation ID 列。',
|
||||
].filter(Boolean).join('\n');
|
||||
await pushShippingLocalAssistantMessage(
|
||||
[
|
||||
`库存已上传:${file.name}`,
|
||||
`任务编号:${taskId}`,
|
||||
hint,
|
||||
].filter(Boolean).join('\n'),
|
||||
);
|
||||
resolvedShippingTaskId.value = taskId;
|
||||
void refreshShippingActions();
|
||||
return;
|
||||
}
|
||||
const alignmentText = buildShippingFieldAlignmentText(result);
|
||||
const hint = alignmentText || String(result.message || t('chat.shippingNoticeUploadOk')).trim();
|
||||
await pushShippingLocalAssistantMessage(
|
||||
[
|
||||
`库存已上传:${file.name}`,
|
||||
`任务编号:${taskId}`,
|
||||
hint,
|
||||
].filter(Boolean).join('\n'),
|
||||
);
|
||||
void refreshShippingActions();
|
||||
await continueShippingInventoryUploadWithDify(taskId, result as Record<string, any>, file.name);
|
||||
} catch (e: any) {
|
||||
msg.warning(e?.message || t('chat.shippingNoticeUploadFailed'));
|
||||
}
|
||||
@@ -3384,6 +3414,19 @@ const handleSend = async (textOrEvent?: string | Event) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (isShippingManualUploadIntent(content)) {
|
||||
const taskId = getActiveShippingTaskId();
|
||||
if (!taskId) {
|
||||
msg.warning('未找到任务编号,请先完成前面的步骤');
|
||||
return;
|
||||
}
|
||||
resolvedShippingTaskId.value = taskId;
|
||||
if (typeof textOrEvent !== 'string') input.value = '';
|
||||
attachments.value = [];
|
||||
await executeShippingManualUpload(taskId, content.trim());
|
||||
return;
|
||||
}
|
||||
|
||||
if (isShippingInventoryUploadIntent(content)) {
|
||||
if (typeof textOrEvent !== 'string') input.value = '';
|
||||
if (openShippingInventoryPicker()) return;
|
||||
@@ -3706,6 +3749,7 @@ const deleteHistoryItem = async (id: string, event: Event) => {
|
||||
try {
|
||||
await deleteChatSession(id, currentAgentId.value);
|
||||
history.value = history.value.filter(h => h.conversation_id !== id);
|
||||
runs.value = runs.value.filter((r) => !(r.agentId === currentAgentId.value && r.conversationId === id));
|
||||
if (conversationId.value === id) {
|
||||
startNewChat();
|
||||
}
|
||||
@@ -4520,63 +4564,63 @@ const showChatRating = ref(false);
|
||||
<div class="text-sm font-medium text-secondary whitespace-pre-wrap">{{ msg.content }}</div>
|
||||
<div class="rounded-2xl border border-default bg-surface-soft/90 p-4 space-y-4">
|
||||
<div class="space-y-2">
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">库存表头</div>
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ $t('chat.shippingNoticeMapping.inventoryHeaders') }}</div>
|
||||
<div class="text-xs text-muted">
|
||||
表头行:{{ getShippingInventoryMappingPayload(msg)!.schema_preview.header_row_index || 1 }}
|
||||
{{ $t('chat.shippingNoticeMapping.headerRow', { row: getShippingInventoryMappingPayload(msg)!.schema_preview.header_row_index || 1 }) }}
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="h in (getShippingInventoryMappingPayload(msg)!.schema_preview.headers || [])"
|
||||
:key="`inv-h-${h}`"
|
||||
class="rounded-full border border-default bg-surface px-3 py-1 text-xs text-secondary"
|
||||
>{{ normalizeShippingHeaderForDisplay(h) || '(空)' }}</span>
|
||||
>{{ normalizeShippingHeaderForDisplay(h) || $t('chat.shippingNoticeMapping.empty') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="Array.isArray(getShippingInventoryMappingPayload(msg)!.schema_preview.sample_rows) && getShippingInventoryMappingPayload(msg)!.schema_preview.sample_rows.length"
|
||||
class="text-xs text-muted whitespace-pre-wrap"
|
||||
>
|
||||
样例:{{ (getShippingInventoryMappingPayload(msg)!.schema_preview.sample_rows[0] || []).join(' | ') }}
|
||||
{{ $t('chat.shippingNoticeMapping.sample') }}:{{ (getShippingInventoryMappingPayload(msg)!.schema_preview.sample_rows[0] || []).join(' | ') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">订单明细</div>
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ $t('chat.shippingNoticeMapping.orderDetails') }}</div>
|
||||
<div class="text-xs text-muted">
|
||||
订单行数:{{ getShippingInventoryMappingPayload(msg)!.order.line_count }};SKU(前{{ getShippingInventoryMappingPayload(msg)!.order.skus.length }}):{{ getShippingInventoryMappingPayload(msg)!.order.skus.join(',') || '(未识别)' }}
|
||||
{{ $t('chat.shippingNoticeMapping.orderRowCount', { count: getShippingInventoryMappingPayload(msg)!.order.line_count }) }};{{ $t('chat.shippingNoticeMapping.orderSkuPreview', { count: getShippingInventoryMappingPayload(msg)!.order.skus.length, skus: getShippingInventoryMappingPayload(msg)!.order.skus.join(',') || $t('chat.shippingNoticeMapping.unrecognized') }) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">SKU 列(必填)</span>
|
||||
<span class="text-xs font-semibold text-muted">{{ $t('chat.shippingNoticeMapping.skuColumnRequired') }}</span>
|
||||
<select
|
||||
v-model="getShippingInventoryMappingPayload(msg)!.form.sku"
|
||||
class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400"
|
||||
:disabled="getShippingInventoryMappingPayload(msg)!.applying"
|
||||
>
|
||||
<option value="" disabled>请选择表头列名</option>
|
||||
<option value="" disabled>{{ $t('chat.shippingNoticeMapping.selectHeader') }}</option>
|
||||
<option v-for="h in (getShippingInventoryMappingPayload(msg)!.schema_preview.headers || [])" :key="`sku-${h}`" :value="h">{{ normalizeShippingHeaderForDisplay(h) }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">可用数量列(必填)</span>
|
||||
<span class="text-xs font-semibold text-muted">{{ $t('chat.shippingNoticeMapping.availableQtyColumnRequired') }}</span>
|
||||
<select
|
||||
v-model="getShippingInventoryMappingPayload(msg)!.form.available_qty"
|
||||
class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400"
|
||||
:disabled="getShippingInventoryMappingPayload(msg)!.applying"
|
||||
>
|
||||
<option value="" disabled>请选择表头列名</option>
|
||||
<option value="" disabled>{{ $t('chat.shippingNoticeMapping.selectHeader') }}</option>
|
||||
<option v-for="h in (getShippingInventoryMappingPayload(msg)!.schema_preview.headers || [])" :key="`qty-${h}`" :value="h">{{ normalizeShippingHeaderForDisplay(h) }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5 md:col-span-2">
|
||||
<span class="text-xs font-semibold text-muted">Reservation ID 列(可选)</span>
|
||||
<span class="text-xs font-semibold text-muted">{{ $t('chat.shippingNoticeMapping.reservationIdColumnOptional') }}</span>
|
||||
<select
|
||||
v-model="getShippingInventoryMappingPayload(msg)!.form.reservation_id"
|
||||
class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400"
|
||||
:disabled="getShippingInventoryMappingPayload(msg)!.applying"
|
||||
>
|
||||
<option value="">(不使用 Reservation ID)</option>
|
||||
<option value="">{{ $t('chat.shippingNoticeMapping.reservationIdNotUsed') }}</option>
|
||||
<option v-for="h in (getShippingInventoryMappingPayload(msg)!.schema_preview.headers || [])" :key="`rid-${h}`" :value="h">{{ normalizeShippingHeaderForDisplay(h) }}</option>
|
||||
</select>
|
||||
</label>
|
||||
@@ -4589,7 +4633,7 @@ const showChatRating = ref(false);
|
||||
:disabled="getShippingInventoryMappingPayload(msg)!.applying"
|
||||
@click="reuploadShippingInventoryFromMappingForm(msg)"
|
||||
>
|
||||
重新上传
|
||||
{{ $t('chat.shippingNoticeMapping.reupload') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@@ -4597,14 +4641,14 @@ const showChatRating = ref(false);
|
||||
:disabled="getShippingInventoryMappingPayload(msg)!.applying"
|
||||
@click="applyShippingInventoryMappingForm(msg)"
|
||||
>
|
||||
{{ getShippingInventoryMappingPayload(msg)!.applying ? '应用中...' : '应用映射并解析' }}
|
||||
{{ getShippingInventoryMappingPayload(msg)!.applying ? $t('chat.shippingNoticeMapping.applying') : $t('chat.shippingNoticeMapping.applyAndParse') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="chat-markdown prose prose-sm max-w-none leading-7 text-primary prose-a:text-blue-600 prose-p:my-1 prose-li:my-0.5 prose-ol:my-2 prose-ul:my-2 prose-headings:my-2 prose-hr:my-3 prose-code:rounded prose-code:bg-slate-100 prose-code:px-1 prose-code:text-blue-700 prose-pre:my-3 prose-pre:border prose-pre:border-slate-700 prose-pre:bg-slate-900 prose-pre:text-slate-100"
|
||||
class="chat-markdown prose prose-sm max-w-none leading-7 text-primary prose-a:text-blue-600 prose-p:my-1 prose-li:my-0.5 prose-ol:my-2 prose-ul:my-2 prose-headings:my-2 prose-hr:my-3 prose-code:rounded prose-code:bg-slate-100 prose-code:px-1 prose-code:text-blue-700 prose-pre:my-3 prose-pre:border prose-pre:border-slate-700 prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-table:w-full prose-table:border-collapse prose-th:border prose-th:border-slate-200 prose-th:bg-slate-50 prose-th:px-3 prose-th:py-2 prose-th:text-left prose-td:border prose-td:border-slate-200 prose-td:px-3 prose-td:py-2"
|
||||
@click="handleChatMarkdownClick"
|
||||
v-html="renderMarkdown(msg.content)"
|
||||
></div>
|
||||
@@ -5263,6 +5307,35 @@ const showChatRating = ref(false);
|
||||
|
||||
</template>
|
||||
<style scoped>
|
||||
:deep(.chat-markdown table) {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 0.75rem 0;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown th),
|
||||
:deep(.chat-markdown td) {
|
||||
border: 1px solid rgb(226 232 240);
|
||||
padding: 0.5rem 0.75rem;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown th) {
|
||||
background: rgb(248 250 252);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:deep(.dark .chat-markdown th),
|
||||
:deep(.dark .chat-markdown td) {
|
||||
border-color: rgb(51 65 85);
|
||||
}
|
||||
|
||||
:deep(.dark .chat-markdown th) {
|
||||
background: rgb(30 41 59);
|
||||
}
|
||||
|
||||
:deep(.chat-markdown details) {
|
||||
margin-top: 1rem;
|
||||
border: 1px solid rgb(226 232 240);
|
||||
|
||||
@@ -89,9 +89,12 @@ const resolveChatAgent = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const openInChat = (taskNo: string) => {
|
||||
const openInChat = (taskNo: string, conversationId?: string | null) => {
|
||||
if (!chatAgentId.value) return;
|
||||
router.push({ path: `/chat/${chatAgentId.value}`, query: { task_id: taskNo } });
|
||||
const query: Record<string, string> = { task_id: taskNo };
|
||||
const cid = String(conversationId || '').trim();
|
||||
if (cid) query.conversation_id = cid;
|
||||
router.push({ path: `/chat/${chatAgentId.value}`, query });
|
||||
};
|
||||
|
||||
const downloadExport = async (taskNo: string) => {
|
||||
@@ -207,7 +210,7 @@ onMounted(async () => {
|
||||
v-if="chatAgentId"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-brand-300 bg-brand-50 px-3 py-1.5 text-sm font-medium text-brand-700 hover:bg-brand-100"
|
||||
@click="openInChat(detail.task_no)"
|
||||
@click="openInChat(detail.task_no, detail.conversation_id)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.openChat') }}
|
||||
@@ -241,7 +244,7 @@ onMounted(async () => {
|
||||
<table class="min-w-full text-sm">
|
||||
<thead class="bg-surface-soft text-left text-xs text-muted">
|
||||
<tr>
|
||||
<th class="px-3 py-2">SKU</th>
|
||||
<th class="px-3 py-2">{{ $t('workspace.shippingNotice.columns.sku') }}</th>
|
||||
<th class="px-3 py-2">{{ $t('workspace.shippingNotice.qty') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Reference in new issue
Block a user