feat(shipping-notice): 新增发货批次和任务管理功能,支持批次创建与任务处理

This commit is contained in:
hugo committed 2026-06-17 20:45:19 +08:00
1 parent 457f0f4e5e
commit 634dee4b81
81 files changed
+9088 -3625

No files matched your search

@@ -1,8 +1,8 @@
/**
* 出货聊天:助手消息动作按钮刷新(有状态 composable 工厂)。
*
* 按 taskId 拉取 getShippingChatActions,写入 messages[].shipping_actions;
* 终态 checkpoint 时清除所有按钮。
/**
* features/chat/shipping/useChatShippingRefresh.ts
* 用途:刷新聊天区发货通知动作按钮,把后端 checkpoint/action_buttons 同步到消息气泡。
* 依赖:shipping.api、shippingMenu、shippingTaskId、shippingNoticeActions 常量、chat.types。
* 逻辑:由 useChatShipping 调用本文件;本文件根据当前 taskId 拉取动作配置并回写到 messages[].shipping_actions。
*/
import {
getShippingChatActions,
@@ -27,10 +27,23 @@ export interface ShippingRefreshContext {
shippingConversationTaskIdCache: Ref<Record<string, string>>;
}
/**
* 判断某条助手消息后面是否已经出现新的用户回复。
* @param msgs - 当前消息列表
* @param index - 目标助手消息索引
* @returns `true` 表示该消息已被后续用户输入“盖住”
*/
export function assistantMessageHasLaterUserReply(msgs: Array<{ role?: string }>, index: number): boolean {
return msgs.slice(index + 1).some((item) => item.role === 'user');
}
/**
* 创建发货通知动作按钮刷新器。
*
* 核心逻辑:优先按 taskId 拉取后端 action_buttons,失败时回退到消息文本指令解析,并在终态 checkpoint 清空旧按钮。
* @param ctx - 发货通知聊天上下文
* @returns 动作刷新函数
*/
export function createShippingActionsRefresher(ctx: ShippingRefreshContext) {
let shippingActionsRequestSeq = 0;
@@ -145,6 +158,9 @@ export function createShippingActionsRefresher(ctx: ShippingRefreshContext) {
}
buttons = resolved.buttons;
}
if (chatMsg.type === 'shipping-match-result' && chatMsg.payload && typeof chatMsg.payload === 'object') {
(chatMsg.payload as { action_buttons?: ShippingActionButton[] }).action_buttons = buttons;
}
chatMsg.shipping_actions = buttons.length ? buttons : undefined;
});
};