feat(shipping-notice): 新增临时库存管理功能,支持创建会话、获取分析结果及字段映射建议
This commit is contained in:
1 parent
46eb63f5bb
commit
e9bdd81f1a
320 files changed
+28361
-10487
No files matched your search
@@ -24,24 +24,19 @@ import {
|
||||
createShippingActionsRefresher,
|
||||
createShippingConversationHelpers,
|
||||
createShippingDecisionHandlers,
|
||||
createShippingMappingFormHandlers,
|
||||
createShippingMenuHandlers,
|
||||
createShippingParseReviewHandlers,
|
||||
createShippingSendHandlers,
|
||||
createShippingUploadHandlers,
|
||||
onNoticeBatchConversationChanging,
|
||||
findLatestShippingTaskId,
|
||||
getShippingInventoryMappingPayload,
|
||||
getShippingMatchResultPayload,
|
||||
getShippingParseReviewPayload,
|
||||
getShippingInventorySampleRowText,
|
||||
hasShippingInventorySampleRows,
|
||||
normalizeShippingHeaderForDisplay,
|
||||
sanitizeShippingConversationText,
|
||||
shippingActionButtonClass,
|
||||
} from '../shipping';
|
||||
import { reportShippingDebugEvent } from '../shipping/shippingDebugReporter';
|
||||
import { classifyShippingUploadFile } from '../shipping/shippingUploadPrompt';
|
||||
import { isShippingSpreadsheetFile } from '../shipping/shippingUploadPrompt';
|
||||
import { extractExt } from '../constants/shipping';
|
||||
import {
|
||||
getWorkspaceShippingConversationBatches,
|
||||
@@ -83,7 +78,6 @@ export interface UseChatShippingOptions {
|
||||
history: Ref<ChatSessionItem[]>;
|
||||
loadHistory: () => Promise<void>;
|
||||
input: Ref<string>;
|
||||
chatScrollContainer: Ref<HTMLElement | null>;
|
||||
attachments: Ref<PendingAttachment[]>;
|
||||
selectedKb: Ref<string>;
|
||||
isUploadingAttachments: Ref<boolean>;
|
||||
@@ -97,7 +91,7 @@ export interface UseChatShippingOptions {
|
||||
agentId: number,
|
||||
kb: string,
|
||||
files: ChatUploadFileSpec[],
|
||||
context?: { task_id?: string; batch_no?: string; shipping_intake_nos?: string[]; display_query?: string },
|
||||
context?: { task_id?: string; batch_no?: string; shipping_intake_nos?: string[]; shipping_temporary_inventory_asset_no?: string; shipping_temporary_inventory_session_no?: string; display_query?: string },
|
||||
hooks?: SendMessageLifecycleHooks,
|
||||
) => Promise<ChatMessageSendResult>;
|
||||
startChatTurn: (options: import('../types/chat-turn.types').StartChatTurnOptions) => Promise<boolean>;
|
||||
@@ -235,7 +229,7 @@ export const resolveLatestShippingMessageRecoveryPayload = (
|
||||
/**
|
||||
* 组装发货通知聊天所需的状态、动作处理器与发送拦截逻辑。
|
||||
*
|
||||
* 核心逻辑:统一管理当前任务/批次上下文,组合上传、映射、决策、动作刷新等子模块,并对 ChatView 暴露稳定 API。
|
||||
* 核心逻辑:统一管理当前任务/批次上下文,组合上传、解析复核、匹配结果、决策与动作刷新等子模块,并对 ChatView 暴露稳定 API。
|
||||
* @param options - 聊天页依赖与响应式状态集合
|
||||
* @returns 发货通知聊天场景所需的状态、事件处理器和工具函数
|
||||
*/
|
||||
@@ -253,7 +247,6 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
history,
|
||||
loadHistory,
|
||||
input,
|
||||
chatScrollContainer,
|
||||
attachments,
|
||||
selectedKb,
|
||||
isUploadingAttachments,
|
||||
@@ -316,7 +309,6 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
const retryingShippingPendingTasks = ref(false);
|
||||
const activeShippingTaskDetail = ref<ShippingTaskDetail | null>(null);
|
||||
const shippingFocusReason = ref('');
|
||||
const shippingInventorySchemaPreviewCache = ref<Record<string, unknown>>({});
|
||||
const autoResumedShippingTasks = ref<Record<string, boolean>>({});
|
||||
const lastConversationSyncKey = ref('');
|
||||
let shippingStatusPollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
@@ -628,7 +620,6 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
shippingWorkspaceOpen.value = false;
|
||||
retryingShippingPendingTasks.value = false;
|
||||
activeShippingTaskDetail.value = null;
|
||||
shippingInventorySchemaPreviewCache.value = {};
|
||||
lastConversationSyncKey.value = '';
|
||||
};
|
||||
|
||||
@@ -753,25 +744,6 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
getActiveBatchTaskId,
|
||||
});
|
||||
|
||||
const {
|
||||
openShippingInventoryMappingFormForTask,
|
||||
applyShippingInventoryMappingForm,
|
||||
reuploadShippingInventoryFromMappingForm,
|
||||
} = createShippingMappingFormHandlers({
|
||||
messages,
|
||||
chatScrollContainer,
|
||||
shippingInventorySchemaPreviewCache,
|
||||
shippingInventoryPickerRef,
|
||||
pendingShippingUploadTaskId,
|
||||
resolvedShippingTaskId,
|
||||
newLocalMessageId,
|
||||
saveLocalMessageToBackend,
|
||||
startChatTurn,
|
||||
currentAgentId,
|
||||
refreshShippingActions,
|
||||
msg,
|
||||
});
|
||||
|
||||
/**
|
||||
* Dify SSE 完成后立即净化最后一条回复,并同步后端动作按钮。
|
||||
*
|
||||
@@ -860,11 +832,9 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
history,
|
||||
isShippingNoticeAgent,
|
||||
currentAgentId,
|
||||
shippingInventorySchemaPreviewCache,
|
||||
getActiveShippingTaskId,
|
||||
getActiveShippingBatchNo: () => resolvedShippingBatchNo.value || shippingBatchNoFromQuery.value || '',
|
||||
loadHistory,
|
||||
openShippingInventoryMappingFormForTask,
|
||||
refreshShippingActions,
|
||||
startChatTurn,
|
||||
msg,
|
||||
@@ -1074,13 +1044,22 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
shippingBatchTasks,
|
||||
shippingInventorySelectionActive,
|
||||
shippingInventorySelectionTaskId,
|
||||
shippingInventorySchemaPreviewCache,
|
||||
getActiveShippingTaskId,
|
||||
startChatTurn,
|
||||
refreshShippingActions,
|
||||
getParsedIntakeNos: shippingIntakes.getParsedIntakeNos,
|
||||
getSelectedCandidateNos: shippingIntakes.getSelectedCandidateNos,
|
||||
clearConsumedNoticeAttachments: shippingIntakes.clearConsumedAttachments,
|
||||
sendTemporaryInventoryMessage: async (assetNo, fileName) => sendMessage(
|
||||
`我已上传库存文件:${fileName},请先检查文件结构并说明下一步。`,
|
||||
currentAgentId.value,
|
||||
selectedKb.value,
|
||||
[],
|
||||
{
|
||||
shipping_temporary_inventory_asset_no: assetNo,
|
||||
display_query: `上传库存文件:${fileName}`,
|
||||
},
|
||||
),
|
||||
msg,
|
||||
t,
|
||||
});
|
||||
@@ -1092,7 +1071,6 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
getActiveShippingBatchNo: () => resolvedShippingBatchNo.value || shippingBatchNoFromQuery.value || '',
|
||||
messages,
|
||||
sendShippingMenuMessage,
|
||||
openShippingInventoryMappingFormForTask,
|
||||
openShippingInventoryPicker,
|
||||
openShippingNoticePicker,
|
||||
openShippingCustomerDialog,
|
||||
@@ -1272,21 +1250,20 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
const inputEl = event.target as HTMLInputElement | null;
|
||||
const files = inputEl?.files ? Array.from(inputEl.files) : [];
|
||||
if (!files.length) return false;
|
||||
const noticeFiles = files.filter((file) => classifyShippingUploadFile(file, extractExt) === 'notice');
|
||||
const otherFiles = files.filter((file) => classifyShippingUploadFile(file, extractExt) !== 'notice');
|
||||
const noticeFiles = files.filter((file) => !isShippingSpreadsheetFile(file, extractExt));
|
||||
const spreadsheetFiles = files.filter((file) => isShippingSpreadsheetFile(file, extractExt));
|
||||
if (noticeFiles.length) {
|
||||
void shippingIntakes.enqueueNoticeFiles(noticeFiles);
|
||||
}
|
||||
// 同一次选择中的库存/其他文件直接落入本地附件,避免清空 input 后通用 handler 丢失 FileList
|
||||
for (const file of otherFiles) {
|
||||
const kind = classifyShippingUploadFile(file, extractExt);
|
||||
// 表格附件先留在本地等待用户声明;不能因扩展名直接送订单或库存解析。
|
||||
for (const file of spreadsheetFiles) {
|
||||
attachments.value = [
|
||||
...attachments.value,
|
||||
{
|
||||
id: `${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
||||
kind: 'local',
|
||||
file,
|
||||
type: kind === 'inventory' ? 'document' : 'document',
|
||||
type: 'document',
|
||||
uploadStatus: 'waiting',
|
||||
uploadProgress: 0,
|
||||
},
|
||||
@@ -1455,14 +1432,8 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
queryShippingShortageDetails,
|
||||
resetShippingConversationState,
|
||||
resumeShippingTaskFromQuery,
|
||||
normalizeShippingHeaderForDisplay,
|
||||
getShippingInventoryMappingPayload,
|
||||
getShippingMatchResultPayload,
|
||||
getShippingParseReviewPayload,
|
||||
hasShippingInventorySampleRows,
|
||||
getShippingInventorySampleRowText,
|
||||
applyShippingInventoryMappingForm,
|
||||
reuploadShippingInventoryFromMappingForm,
|
||||
updateShippingParseReviewHeader,
|
||||
updateShippingParseReviewLine,
|
||||
addShippingParseReviewLine,
|
||||
|
||||
Reference in new issue
Block a user