feat(chat): 更新发货任务处理逻辑和界面文本
- 移除不必要的状态引用 - 更新上传处理提示文本,使用国际化支持 - 扩展发货任务摘要接口,增加错误信息和短缺信息 - 更新多语言支持的文本,改善用户体验 - 增加批次工作区的汇总信息和操作提示
This commit is contained in:
1 parent
0b083cfdbd
commit
1fc9976ca3
60 files changed
+3876
-639
No files matched your search
@@ -37,6 +37,8 @@ export interface ShippingDecisionContext {
|
||||
* @returns 人工决策与手工上传确认处理函数
|
||||
*/
|
||||
export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
const manualUploadInFlightTaskIds = new Set<string>();
|
||||
|
||||
const syncHistoryIfNeeded = async () => {
|
||||
if (!ctx.conversationId.value && ctx.history.value.length === 0) {
|
||||
await ctx.loadHistory();
|
||||
@@ -108,17 +110,21 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
};
|
||||
|
||||
const executeShippingManualUpload = async (taskId: string, displayText?: string) => {
|
||||
const normalizedTaskId = String(taskId || '').trim().toUpperCase();
|
||||
if (!normalizedTaskId || manualUploadInFlightTaskIds.has(normalizedTaskId)) return false;
|
||||
manualUploadInFlightTaskIds.add(normalizedTaskId);
|
||||
try {
|
||||
const result = await markWorkspaceShippingManualUploaded(taskId);
|
||||
const userText = (displayText || '已在货代系统手工上传完成').trim();
|
||||
const assistantContent = [
|
||||
String(result.message || '已标记为手工上传货代系统完成。').trim(),
|
||||
`任务编号:${taskId}`,
|
||||
].join('\n');
|
||||
const result = await markWorkspaceShippingManualUploaded(normalizedTaskId);
|
||||
const userText = (displayText || '我已在货代系统完成上传').trim();
|
||||
const assistantContent = String(
|
||||
result.message || `好的,任务 ${normalizedTaskId} 已确认完成,无需再处理。`,
|
||||
).trim();
|
||||
const lastUserMessage = [...ctx.messages.value].reverse().find((item) => item.role === 'user');
|
||||
const shouldAppendUser = String(lastUserMessage?.content || '').trim() !== userText;
|
||||
const userMsg: ChatMessage = {
|
||||
role: 'user',
|
||||
type: 'text',
|
||||
content: `${userText}\n任务编号:${taskId}`,
|
||||
content: userText,
|
||||
local_id: ctx.newLocalMessageId('shipping-user'),
|
||||
local_only: true,
|
||||
};
|
||||
@@ -130,14 +136,19 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
local_only: true,
|
||||
shipping_actions_used: true,
|
||||
};
|
||||
ctx.messages.value.push(userMsg, assistantMsg);
|
||||
if (shouldAppendUser) {
|
||||
ctx.messages.value.push(userMsg);
|
||||
}
|
||||
ctx.messages.value.push(assistantMsg);
|
||||
ctx.messages.value.forEach((rawMsg) => {
|
||||
const m = rawMsg as ChatMessage & { shipping_actions?: unknown };
|
||||
if (m.role === 'assistant') {
|
||||
m.shipping_actions = undefined;
|
||||
}
|
||||
});
|
||||
await ctx.saveLocalMessageToBackend(userMsg, userText);
|
||||
if (shouldAppendUser) {
|
||||
await ctx.saveLocalMessageToBackend(userMsg, userText);
|
||||
}
|
||||
await ctx.saveLocalMessageToBackend(assistantMsg, userText);
|
||||
void ctx.refreshShippingActions();
|
||||
return true;
|
||||
@@ -145,6 +156,8 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
const errorMessage = e instanceof Error ? e.message : '标记手工上传失败';
|
||||
ctx.msg.warning(errorMessage);
|
||||
return false;
|
||||
} finally {
|
||||
manualUploadInFlightTaskIds.delete(normalizedTaskId);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user