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

@@ -2,14 +2,13 @@
* features/chat/shipping/useChatShippingRefresh.ts
* 用途:刷新聊天区发货通知 UI State,把后端状态机 action_buttons 同步到消息气泡。
* 依赖:shipping.api、shippingTaskId、shippingNoticeActions 常量、chat.types。
* 逻辑:由 useChatShipping 调用本文件;本文件只读取后端 /ui-state,不再从 Dify 正文解析按钮。
* 逻辑:由 useChatShipping 调用本文件;本文件只读取后端 /ui-state,不再从会话标题猜任务号或从 Dify 正文解析按钮。
*/
import { getWorkspaceShippingTaskUiState } from '@/features/chat/api/shipping.api';
import { SHIPPING_TERMINAL_CHECKPOINTS } from '@/constants/shippingNoticeActions';
import { SHIPPING_TASK_ID_RE } from '../constants/shipping';
import { findLatestShippingTaskId } from './shippingTaskId';
import { stripShippingActionListByButtons, stripShippingPlainActionMenu } from './shippingText';
import type { ChatMessage, ChatSessionItem } from '../types/chat.types';
import type { ChatMessage } from '../types/chat.types';
import type { ShippingActionButton } from '../types/shipping.types';
import type { ShippingTaskUiState } from '../types/shipping.api.types';
import type { ComputedRef, Ref } from 'vue';
@@ -19,7 +18,6 @@ export interface ShippingRefreshContext {
messages: Ref<ChatMessage[]>;
conversationId: Ref<string | null>;
isThinking: Ref<boolean>;
history: Ref<ChatSessionItem[]>;
resolvedShippingTaskId: Ref<string>;
shippingTaskIdFromQuery: ComputedRef<string>;
getActiveBatchTaskId: () => string;
@@ -29,7 +27,7 @@ export interface ShippingRefreshContext {
* 解析当前聊天页最可靠的发货任务编号。
*
* 核心逻辑:优先使用批次当前焦点任务,其次才回退到消息内嵌任务号、已解析状态和路由参数;
* 禁止再按 conversation 扫任务列表“猜”一票,避免多票会话把动作按钮挂错任务。
* 禁止再按 conversation 标题“猜”一票,避免多票会话把动作按钮挂错任务。
* @param params - 当前聊天页中可用的任务定位线索
* @returns 可信的任务编号;无法明确定位时返回空字符串
*/
@@ -38,14 +36,12 @@ export function resolvePreferredShippingTaskId(params: {
messageTaskId?: string | null;
resolvedTaskId?: string | null;
queryTaskId?: string | null;
historyTaskId?: string | null;
}) {
return String(
params.batchTaskId
|| params.messageTaskId
|| params.resolvedTaskId
|| params.queryTaskId
|| params.historyTaskId
|| '',
).trim().toUpperCase();
}
@@ -74,20 +70,11 @@ export function createShippingActionsRefresher(ctx: ShippingRefreshContext) {
if (!ctx.isShippingNoticeAgent.value) return;
const msgs = ctx.messages.value;
if (!msgs.length) return;
const cid = String(ctx.conversationId.value || '').trim();
const historyTaskId = (() => {
if (!cid) return '';
const session = ctx.history.value.find((item) => String(item.conversation_id || '') === cid);
const title = String(session?.title || '');
const match = title.match(SHIPPING_TASK_ID_RE);
return match?.[0] ? match[0].toUpperCase() : '';
})();
const taskId = resolvePreferredShippingTaskId({
batchTaskId: ctx.getActiveBatchTaskId(),
messageTaskId: findLatestShippingTaskId(msgs),
resolvedTaskId: ctx.resolvedShippingTaskId.value,
queryTaskId: ctx.shippingTaskIdFromQuery.value,
historyTaskId,
});
if (taskId) ctx.resolvedShippingTaskId.value = taskId;
let lastOpenAssistantIndex = -1;