feat(chat): 更新发货任务处理逻辑和界面文本
- 移除不必要的状态引用 - 更新上传处理提示文本,使用国际化支持 - 扩展发货任务摘要接口,增加错误信息和短缺信息 - 更新多语言支持的文本,改善用户体验 - 增加批次工作区的汇总信息和操作提示
This commit is contained in:
1 parent
0b083cfdbd
commit
1fc9976ca3
60 files changed
+3876
-639
No files matched your search
@@ -10,7 +10,7 @@ import {
|
||||
getWorkspaceShippingBatch,
|
||||
switchWorkspaceShippingBatchFocusTask,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { SHIPPING_MENU_ACTION_SPECS } from '../constants/shipping';
|
||||
import { SHIPPING_DECISION_ACTIONS, SHIPPING_MENU_ACTION_SPECS } from '../constants/shipping';
|
||||
import { buildShippingFieldAlignmentText } from './shippingMapping';
|
||||
import { downloadWorkspaceShippingExcelFile } from './shippingDownload';
|
||||
import {
|
||||
@@ -45,6 +45,7 @@ export interface ShippingSendHandlerContext {
|
||||
attachmentPolicy: ComputedRef<{ anyEnabled: boolean }>;
|
||||
getActiveShippingTaskId: () => string;
|
||||
lastAssistantMessageContent: () => string;
|
||||
lastAssistantShippingActions: () => ChatMessage['shipping_actions'];
|
||||
sendMessage: (
|
||||
content: string,
|
||||
agentId: number,
|
||||
@@ -59,10 +60,13 @@ export interface ShippingSendHandlerContext {
|
||||
openShippingInventoryPicker: () => boolean;
|
||||
executeShippingDecision: (decision: string, displayText?: string) => Promise<boolean>;
|
||||
executeShippingManualUpload: (taskId: string, displayText?: string) => Promise<boolean>;
|
||||
handleShippingMenuAction: (action: { id?: string; message: string }) => Promise<void>;
|
||||
handleShippingAutoUploadFile: (file: File) => Promise<void>;
|
||||
handleShippingAutoUploadNoticeBatch: (files: File[]) => Promise<void>;
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
shippingSuggestedPrompt: ComputedRef<string>;
|
||||
isShippingShortageQueryIntent: (text: string) => boolean;
|
||||
queryShippingShortageDetails: (taskNo?: string, displayText?: string) => Promise<boolean>;
|
||||
msg: { warning: (text: string) => void; info: (text: string) => void };
|
||||
t: (key: string) => string;
|
||||
}
|
||||
@@ -128,6 +132,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
if (!(ctx.shippingAutoFlowRequested.value || !trimmed)) return false;
|
||||
if (!ctx.isShippingNoticeAgent.value || ctx.attachments.value.length === 0) return false;
|
||||
if (ctx.isThinking.value || ctx.isUploadingAttachments.value) return false;
|
||||
const requestedAutoFlow = ctx.shippingAutoFlowRequested.value;
|
||||
ctx.shippingAutoFlowRequested.value = false;
|
||||
const localFiles = ctx.attachments.value.filter((a) => a.kind === 'local') as Array<Extract<PendingAttachment, { kind: 'local' }>>;
|
||||
const first = localFiles[0];
|
||||
@@ -152,12 +157,10 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!trimmed) {
|
||||
if (!trimmed || requestedAutoFlow) {
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
ctx.attachments.value = [];
|
||||
try {
|
||||
const prompt = ctx.shippingSuggestedPrompt.value || '解析发货通知并创建任务';
|
||||
await ctx.pushShippingLocalUserMessage(prompt);
|
||||
await ctx.handleShippingAutoUploadNoticeBatch(localFiles.map((item) => item.file));
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '文件处理失败';
|
||||
@@ -174,12 +177,31 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
_trimmed: string,
|
||||
): Promise<boolean> => {
|
||||
if (!ctx.isShippingNoticeAgent.value) return false;
|
||||
if (ctx.isShippingShortageQueryIntent(content)) {
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
ctx.attachments.value = [];
|
||||
return ctx.queryShippingShortageDetails(undefined, content.trim());
|
||||
}
|
||||
if (await trySwitchShippingTask(content)) {
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
ctx.attachments.value = [];
|
||||
return true;
|
||||
}
|
||||
const assistantCtx = ctx.lastAssistantMessageContent();
|
||||
const numericText = content.trim();
|
||||
if (/^[1-91-9](?:[\.\、\)::]?)$/.test(numericText)) {
|
||||
const num = Number.isFinite(Number(numericText.charAt(0)))
|
||||
? Number(numericText.charAt(0))
|
||||
: '0123456789'.indexOf(numericText.charAt(0));
|
||||
const actions = ctx.lastAssistantShippingActions() || [];
|
||||
const action = num >= 1 ? actions[num - 1] : undefined;
|
||||
if (action) {
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
ctx.attachments.value = [];
|
||||
await ctx.handleShippingMenuAction(action);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const menuChoice = resolveShippingNumericChoice(content, assistantCtx);
|
||||
if (menuChoice) {
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
@@ -188,6 +210,10 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
} else if (menuChoice === 'paste') {
|
||||
ctx.msg.info(ctx.t('chat.shippingNoticePasteHint'));
|
||||
return true;
|
||||
} else if (SHIPPING_DECISION_ACTIONS.has(menuChoice)) {
|
||||
const spec = SHIPPING_MENU_ACTION_SPECS[menuChoice];
|
||||
await ctx.executeShippingDecision(menuChoice, spec?.label || spec?.message || menuChoice);
|
||||
return true;
|
||||
} else {
|
||||
await ctx.sendShippingMenuMessage(SHIPPING_MENU_ACTION_SPECS[menuChoice].message);
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user