refactor(frontend): 重构前端第二版
This commit is contained in:
1 parent
2631f78b00
commit
4b562cfa82
205 files changed
+15399
-12015
No files matched your search
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 出货聊天:决策 API 响应 → 助手消息 Markdown 文案(纯函数)。
|
||||
*/
|
||||
export function formatShippingDecisionAssistantMessage(
|
||||
decision: string,
|
||||
result: { message?: string; data?: Record<string, unknown>; checkpoint?: string },
|
||||
taskId: string,
|
||||
fallbackDoneMessage: string,
|
||||
): string {
|
||||
const lines: string[] = [result.message || fallbackDoneMessage];
|
||||
if (decision === 'correct_inventory_mapping') {
|
||||
const preview = (result.data?.schema_preview || {}) as Record<string, unknown>;
|
||||
const headers = Array.isArray(preview.headers) ? (preview.headers as unknown[]).filter(Boolean) : [];
|
||||
const suggested = (preview.suggested_mapping || {}) as Record<string, string>;
|
||||
if (preview.header_row_index) {
|
||||
lines.push('', `表头在第 ${preview.header_row_index} 行:${headers.join(' | ')}`);
|
||||
} else if (headers.length) {
|
||||
lines.push('', `当前表头:${headers.join(' | ')}`);
|
||||
}
|
||||
const mappingLines = [
|
||||
suggested.sku ? `- sku → ${suggested.sku}` : null,
|
||||
suggested.reservation_id ? `- reservation_id → ${suggested.reservation_id}` : null,
|
||||
suggested.available_qty ? `- available_qty → ${suggested.available_qty}` : null,
|
||||
].filter((line): line is string => Boolean(line));
|
||||
if (mappingLines.length) {
|
||||
lines.push('', '建议列映射:', ...mappingLines);
|
||||
}
|
||||
lines.push(
|
||||
'',
|
||||
'如需调整,请说明要改的列(例如:available_qty 改用 Qty Available)。',
|
||||
'也可点击「选择库存文件」重新上传。',
|
||||
);
|
||||
} else if (decision === 'confirm_inventory_mapping') {
|
||||
if (String(result.checkpoint || '').trim() === 'map_ok') {
|
||||
lines.push('', '下一步:匹配库存与发货需求(match_inventory)。');
|
||||
}
|
||||
} else if (decision === 'reparse_inventory') {
|
||||
lines.push('', '请重新上传或粘贴库存 Excel。');
|
||||
}
|
||||
lines.push('', `任务编号:${taskId}`);
|
||||
return lines.join('\n');
|
||||
}
|
||||
Reference in new issue
Block a user