feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
@@ -1,15 +1,13 @@
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingSendHandler.ts
|
||||
* 用途:在聊天发送前拦截发货通知专属意图,如订单抽取、切票、决策文本和附件自动流程。
|
||||
* 依赖:shipping.api、shippingIntents、shippingMenu、shippingDownload、chat.types。
|
||||
* 逻辑:已预处理 Intake 创建独立订单抽取 Run;其他业务动作经 Chat Turn / handleShippingMenuAction。
|
||||
* 依赖:shipping.api(任务详情)、shippingIntents、shippingMenu、shippingDownload、chat.types。
|
||||
* 逻辑:已预处理 Intake 创建独立订单抽取 Run;co8 后切票不再调用 shipping_batches API,改提示用户使用 processing 工作台。
|
||||
*/
|
||||
import {
|
||||
getWorkspaceShippingBatch,
|
||||
getWorkspaceShippingTask,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { SHIPPING_DECISION_ACTIONS, SHIPPING_MENU_ACTION_SPECS } from '../constants/shipping';
|
||||
import { buildShippingSwitchFocusTurn } from './shippingTurnActions';
|
||||
import { downloadWorkspaceShippingExcelFile } from './shippingDownload';
|
||||
import {
|
||||
isShippingDownloadExcelIntent,
|
||||
@@ -146,58 +144,17 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 拦截切票/切任务意图(co8 已下线批次 API)。
|
||||
*
|
||||
* 核心逻辑:识别切换意图后提示用户使用右侧 processing 工作台,消费发送且不发起网络请求。
|
||||
* @param content - 用户输入
|
||||
* @returns 识别到切换意图时恒为 true
|
||||
*/
|
||||
const trySwitchShippingTask = async (content: string): Promise<boolean> => {
|
||||
const intent = parseShippingTaskSwitchIntent(content);
|
||||
if (!intent) return false;
|
||||
const batchNo = ctx.getActiveShippingBatchNo();
|
||||
if (!batchNo) {
|
||||
ctx.msg.warning('当前没有可切换的批次');
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const detail = await getWorkspaceShippingBatch(batchNo);
|
||||
const tasks = Array.isArray(detail.tasks) ? detail.tasks : [];
|
||||
if (tasks.length <= 1) {
|
||||
ctx.msg.info('当前批次只有 1 票,无需切换');
|
||||
return true;
|
||||
}
|
||||
const focusTaskNo = String(detail.focus_task?.task_no || detail.current_focus_task_no || '').trim().toUpperCase();
|
||||
const currentIndex = Math.max(tasks.findIndex((item) => String(item.task_no || '').trim().toUpperCase() === focusTaskNo), 0);
|
||||
let targetTaskNo = '';
|
||||
if (intent.mode === 'task') {
|
||||
targetTaskNo = String(intent.taskNo || '').trim().toUpperCase();
|
||||
} else if (intent.mode === 'next') {
|
||||
targetTaskNo = String(tasks[Math.min(currentIndex + 1, tasks.length - 1)]?.task_no || '').trim().toUpperCase();
|
||||
} else {
|
||||
targetTaskNo = String(tasks[Math.max(currentIndex - 1, 0)]?.task_no || '').trim().toUpperCase();
|
||||
}
|
||||
if (!targetTaskNo) {
|
||||
ctx.msg.warning('未找到要切换的任务');
|
||||
return true;
|
||||
}
|
||||
if (targetTaskNo === focusTaskNo) {
|
||||
ctx.msg.info(intent.mode === 'next' ? '已经是最后一票' : intent.mode === 'prev' ? '已经是第一票' : '已在当前任务');
|
||||
return true;
|
||||
}
|
||||
ctx.resolvedShippingTaskId.value = targetTaskNo;
|
||||
const turn = buildShippingSwitchFocusTurn(batchNo, targetTaskNo, content.trim());
|
||||
await ctx.startChatTurn({
|
||||
agentId: ctx.currentAgentId.value,
|
||||
inputType: 'action',
|
||||
displayText: turn.displayText,
|
||||
actionType: turn.actionType,
|
||||
payload: turn.payload,
|
||||
refs: turn.refs,
|
||||
hooks: {
|
||||
onAssistantMessageFinished: async () => {
|
||||
void ctx.refreshShippingActions();
|
||||
},
|
||||
},
|
||||
});
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '切换任务失败';
|
||||
ctx.msg.warning(errorMessage);
|
||||
}
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeUi.batchSwitchRemoved'));
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -293,10 +250,11 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
}
|
||||
if (!(ctx.shippingAutoFlowRequested.value || !trimmed)) return false;
|
||||
if (!trimmed || requestedAutoFlow) {
|
||||
// co8:本地文件改走 Intake 入队,不再清空后打 create_batch Chat Turn。
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
ctx.attachments.value = [];
|
||||
try {
|
||||
await ctx.handleShippingAutoUploadNoticeBatch(localFiles.map((item) => item.file));
|
||||
ctx.attachments.value = ctx.attachments.value.filter((item) => item.kind !== 'local');
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '文件处理失败';
|
||||
ctx.msg.warning(errorMessage);
|
||||
|
||||
Reference in new issue
Block a user