feat(shipping-notice): 新增货代客户管理功能,支持客户导入、识别证据管理与客户确认

This commit is contained in:
hugo committed 2026-07-16 08:16:19 +08:00
1 parent b595e157e9
commit 4fbaed2b4c
176 files changed
+14011 -994

No files matched your search

@@ -22,6 +22,8 @@ import {
import { resolveShippingDecisionFromText, resolveShippingNumericChoice } from './shippingMenu';
import { classifyShippingUploadFile } from './shippingUploadPrompt';
import { extractExt } from '../constants/shipping';
import { createChatMessageAttachmentSnapshots } from '../utils/attachmentCard.utils';
import type { SendMessageLifecycleHooks } from '../composables/useChat';
import type { StartChatTurnOptions } from '../types/chat-turn.types';
import type { ChatMessage, ChatSessionItem } from '../types/chat.types';
import type { ChatUploadFileSpec, PendingAttachment, ShippingActionButton } from '../types/shipping.types';
@@ -51,8 +53,8 @@ export interface ShippingSendHandlerContext {
kb: string,
files: ChatUploadFileSpec[],
context?: { task_id?: string; batch_no?: string; shipping_intake_nos?: string[]; display_query?: string },
hooks?: { onAssistantMessageFinished?: (message: ChatMessage, runMessages: ChatMessage[]) => void | Promise<void> },
) => Promise<void>;
hooks?: SendMessageLifecycleHooks,
) => Promise<boolean | void>;
buildFileSpecsForSend: () => Promise<ChatUploadFileSpec[]>;
loadHistory: () => Promise<void>;
sendShippingMenuMessage: (message: string) => Promise<void>;
@@ -71,8 +73,13 @@ export interface ShippingSendHandlerContext {
hasSelectedNoticeCandidates?: () => boolean;
openShippingDuplicateDialog?: (attachmentId?: string) => void;
getParsedIntakeNos?: () => string[];
markOrderExtractionStarted?: (intakeNos: string[]) => void;
rollbackOrderExtractionStarted?: (intakeNos: string[]) => void;
refreshNoticeIntakeStatuses?: () => Promise<void>;
clearConsumedNoticeAttachments?: () => void;
applyShippingMessageRecovery?: (message: ChatMessage) => Promise<boolean>;
applyShippingBatchSnapshot?: (message: ChatMessage) => boolean;
syncShippingConversationWorkspace: (options?: { preferLatest?: boolean }) => Promise<boolean>;
refreshShippingActions: () => Promise<void>;
shippingSuggestedPrompt: ComputedRef<string>;
isShippingShortageQueryIntent: (text: string) => boolean;
@@ -211,11 +218,13 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
}
const intakeNos = ctx.getParsedIntakeNos?.() || [];
if (intakeNos.length) {
const userAttachments = createChatMessageAttachmentSnapshots(noticeItems);
const query = trimmed || ctx.t('chat.shippingOrderExtractionDefaultPrompt');
ctx.shippingAutoFlowRequested.value = false;
if (typeof textOrEvent !== 'string') ctx.input.value = '';
ctx.markOrderExtractionStarted?.(intakeNos);
try {
await ctx.sendMessage(
const sent = await ctx.sendMessage(
query,
ctx.currentAgentId.value,
ctx.selectedKb.value,
@@ -225,15 +234,30 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
display_query: query,
},
{
onAssistantMessageFinished: async () => {
userAttachments,
onAssistantMessageFinished: async (assistantMessage) => {
if (ctx.applyShippingMessageRecovery) {
await ctx.applyShippingMessageRecovery(assistantMessage);
} else {
ctx.applyShippingBatchSnapshot?.(assistantMessage);
}
await ctx.refreshNoticeIntakeStatuses?.();
if (!(await ctx.syncShippingConversationWorkspace({ preferLatest: true }))) {
await new Promise((resolve) => setTimeout(resolve, 300));
await ctx.syncShippingConversationWorkspace({ preferLatest: true });
}
ctx.clearConsumedNoticeAttachments?.();
await ctx.refreshShippingActions();
},
},
);
if (sent === false) {
ctx.rollbackOrderExtractionStarted?.(intakeNos);
return true;
}
await ctx.loadHistory();
} catch (e: unknown) {
ctx.rollbackOrderExtractionStarted?.(intakeNos);
const errorMessage = e instanceof Error ? e.message : '文件处理失败';
ctx.msg.warning(errorMessage);
}