feat(schedule): 新增平台任务参数契约与动态选项支持
This commit is contained in:
1 parent
2ce1aca023
commit
8b5b0b49bf
76 files changed
+7103
-1203
No files matched your search
@@ -28,6 +28,11 @@ type ShippingApiStatusPayload = {
|
||||
code?: string;
|
||||
details?: Record<string, unknown>;
|
||||
request_id?: string;
|
||||
/** 批次重试等接口返回的已发起任务数 */
|
||||
started?: number;
|
||||
/** 批次重试等接口返回的跳过任务数 */
|
||||
skipped?: number;
|
||||
batch_no?: string;
|
||||
};
|
||||
|
||||
export type ShippingChatAgentOption = {
|
||||
|
||||
@@ -380,7 +380,7 @@ watch(() => page.currentAgentId, () => {
|
||||
@focus-task="page.switchShippingFocusTask"
|
||||
@workspace-action="page.handleShippingWorkspaceAction"
|
||||
@query-shortage="page.queryShippingShortageDetails"
|
||||
@retry-pending="page.retryCurrentShippingBatchPendingTasks"
|
||||
@retry-pending="page.openRetryFailedConfirm"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/chat/components/ChatViewOverlays.vue
|
||||
* 对话页全局弹窗与浮层:文件预览、反馈、查询预览、履历检索提示、请假 OA、删除确认、学习之窗。
|
||||
* 对话页全局弹窗与浮层:文件预览、反馈、查询预览、履历检索提示、请假 OA、删除确认、发货重试确认、学习之窗。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import FilePreviewModal from '@/shared/components/FilePreviewModal.vue';
|
||||
@@ -10,7 +10,7 @@ import ChatQueryPreviewDialog from '@/features/chat/components/ChatQueryPreviewD
|
||||
import ChatLeaveAgentDialog from '@/features/chat/components/ChatLeaveAgentDialog.vue';
|
||||
import ChatOALoginDialog from '@/features/chat/components/ChatOALoginDialog.vue';
|
||||
import ChatGuideModal from '@/features/chat/components/ChatGuideModal.vue';
|
||||
import { Loader2 } from 'lucide-vue-next';
|
||||
import { Check, Loader2, X } from 'lucide-vue-next';
|
||||
import { nextTick } from 'vue';
|
||||
import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
@@ -110,6 +110,33 @@ async function handleQueryPreviewAssetImage(assetId: string, assetName: string)
|
||||
@confirm="page.handleDeleteConfirm"
|
||||
@cancel="page.closeDeleteConfirmDialog"
|
||||
/>
|
||||
<DeleteConfirmDialog
|
||||
v-model="page.showRetryFailedConfirmDialog"
|
||||
:title="page.t('chat.shippingNoticeUi.retryFailedConfirmTitle')"
|
||||
:message="page.t('chat.shippingNoticeUi.retryFailedConfirmMessage')"
|
||||
:confirm-text="page.t('chat.shippingNoticeUi.retryFailedConfirmAction')"
|
||||
:confirm-loading="page.retryingShippingPendingTasks"
|
||||
confirm-tone="primary"
|
||||
@confirm="page.handleRetryFailedConfirm"
|
||||
@cancel="page.closeRetryFailedConfirm"
|
||||
/>
|
||||
<div
|
||||
v-if="page.shippingToastMessage"
|
||||
class="pointer-events-none fixed inset-x-0 top-20 z-[145] flex justify-center px-4"
|
||||
>
|
||||
<div class="pointer-events-auto flex max-w-[min(92vw,28rem)] items-start gap-2 rounded-full border border-emerald-200 bg-white/95 px-4 py-2 text-sm text-emerald-800 shadow-lg backdrop-blur">
|
||||
<Check class="mt-0.5 h-4 w-4 shrink-0 text-emerald-500" />
|
||||
<span class="min-w-0 flex-1 leading-5">{{ page.shippingToastMessage }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-icon-ds -mr-1 shrink-0"
|
||||
:aria-label="page.t('common.close')"
|
||||
@click="page.clearShippingToast"
|
||||
>
|
||||
<X class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<ChatGuideModal
|
||||
v-model:open="page.showGuideModal"
|
||||
v-model:active-guide-id="page.activeGuideId"
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* features/chat/components/ShippingBatchWorkspaceDrawer.vue
|
||||
* 用途:发货通知 Agent 的右侧批次工作台抽屉,承载多批次切换、任务筛选、步骤诊断与统一动作入口。
|
||||
* 依赖:shippingStepper、shippingMenu、shipping.api.types、vue-i18n、lucide-vue-next。
|
||||
* 逻辑:上游传入会话级 workspace 与当前批次任务;本组件只渲染后端 `ui_state.action_buttons` 和查看类辅助入口,执行动作仍由 useChatShipping 接管。
|
||||
* 逻辑:上游传入会话级 workspace 与当前批次任务;本组件只渲染后端 `ui_state.action_buttons` 和查看类辅助入口。
|
||||
* 「重试所有失败」仅 emit `retry-pending`,由父级打开确认弹窗后再调用 useChatShipping 执行。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { RefreshCw, Target, X } from 'lucide-vue-next';
|
||||
|
||||
@@ -190,7 +190,7 @@ export function useChatPage() {
|
||||
}, { immediate: true });
|
||||
|
||||
const dialogs = useChatPageDialogs(messages);
|
||||
const { openDeleteConfirmDialog } = dialogs;
|
||||
const { openDeleteConfirmDialog, openRetryFailedConfirm, showShippingToast } = dialogs;
|
||||
|
||||
let loadConversation: (id: string, options?: { force?: boolean }) => Promise<void>;
|
||||
let startNewChat: () => void;
|
||||
@@ -303,6 +303,29 @@ export function useChatPage() {
|
||||
});
|
||||
resetShippingConversationState = shipping.resetShippingConversationState;
|
||||
|
||||
/**
|
||||
* Drawer「重试所有失败」点击:仅打开确认弹窗,不立刻发请求。
|
||||
*/
|
||||
const openRetryFailedConfirmDialog = () => {
|
||||
if (shipping.retryingShippingPendingTasks.value) return;
|
||||
openRetryFailedConfirm(() => confirmRetryFailedTasks());
|
||||
};
|
||||
|
||||
/**
|
||||
* 确认后执行批次失败任务重试,并以非阻塞 toast 反馈结果。
|
||||
* 核心逻辑:调用 useChatShipping.retryCurrentShippingBatchPendingTasks,成功后刷新已内置;仅补 toast。
|
||||
*/
|
||||
const confirmRetryFailedTasks = async () => {
|
||||
const result = await shipping.retryCurrentShippingBatchPendingTasks();
|
||||
if (!result) return;
|
||||
showShippingToast(
|
||||
t('chat.shippingNoticeUi.retryFailedStarted', {
|
||||
started: result.started,
|
||||
skipped: result.skipped,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const conversationApi = createChatPageConversationApi({
|
||||
deps,
|
||||
route,
|
||||
@@ -570,6 +593,12 @@ export function useChatPage() {
|
||||
deleteConfirmMessage: dialogs.deleteConfirmMessage,
|
||||
closeDeleteConfirmDialog: dialogs.closeDeleteConfirmDialog,
|
||||
handleDeleteConfirm: dialogs.handleDeleteConfirm,
|
||||
showRetryFailedConfirmDialog: dialogs.showRetryFailedConfirmDialog,
|
||||
closeRetryFailedConfirm: dialogs.closeRetryFailedConfirm,
|
||||
handleRetryFailedConfirm: dialogs.handleRetryFailedConfirm,
|
||||
openRetryFailedConfirm: openRetryFailedConfirmDialog,
|
||||
shippingToastMessage: dialogs.shippingToastMessage,
|
||||
clearShippingToast: dialogs.clearShippingToast,
|
||||
showChatRating,
|
||||
isShippingNoticeAgent: shipping.isShippingNoticeAgent,
|
||||
showShippingProgressWorkspace: shipping.showShippingProgressWorkspace,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* 用途:发货通知聊天编排入口,组合 shipping/* 子模块并对 ChatView 暴露统一交互能力。
|
||||
* 依赖:shipping.api、shipping/ 下各 handler 工厂、chat.deps、chat.types、Vue refs/computed/watch。
|
||||
* 逻辑:上游由 ChatView/ChatPage 调用本 composable;本文件再把任务状态、动作刷新、文件上传、决策与发送拦截分发给 shipping 子模块。
|
||||
* 批次「重试所有失败」成功后不弹居中 msg.success,由页面级 toast 展示 started/skipped。
|
||||
*/
|
||||
|
||||
import {
|
||||
@@ -816,25 +817,35 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
return true;
|
||||
};
|
||||
|
||||
const retryCurrentShippingBatchPendingTasks = async () => {
|
||||
/**
|
||||
* 重试当前聚焦批次中可恢复的失败/排队任务。
|
||||
* 核心逻辑:调 workspace retry-pending → 刷新会话工作台/批次摘要/动作;成功反馈交给页面级非阻塞 toast,避免居中成功弹窗。
|
||||
* @returns 成功时返回 started/skipped;失败或跳过时返回 null
|
||||
*/
|
||||
const retryCurrentShippingBatchPendingTasks = async (): Promise<{
|
||||
started: number;
|
||||
skipped: number;
|
||||
} | null> => {
|
||||
const batchNo = getActiveShippingBatchNo();
|
||||
if (!batchNo || retryingShippingPendingTasks.value) return false;
|
||||
if (!batchNo || retryingShippingPendingTasks.value) return null;
|
||||
if (isShippingActionBusy.value) {
|
||||
msg.warning(t('chat.shippingNoticeUi.actionBusyHint'));
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
retryingShippingPendingTasks.value = true;
|
||||
try {
|
||||
const { retryWorkspaceShippingBatchPending } = await import('@/features/chat/api/shipping.api');
|
||||
const result = await retryWorkspaceShippingBatchPending(batchNo);
|
||||
msg.success(result.message || t('chat.shippingNoticeUi.retryPendingDone'));
|
||||
await syncShippingConversationWorkspace();
|
||||
await syncShippingBatchSummary(batchNo);
|
||||
await refreshShippingActions();
|
||||
return true;
|
||||
return {
|
||||
started: Number(result.started ?? 0),
|
||||
skipped: Number(result.skipped ?? 0),
|
||||
};
|
||||
} catch (error) {
|
||||
msg.error(error instanceof Error ? error.message : t('chat.shippingNoticeUi.retryFailed'));
|
||||
return false;
|
||||
return null;
|
||||
} finally {
|
||||
retryingShippingPendingTasks.value = false;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
/**
|
||||
* 对话页:删除确认弹窗、消息反馈弹窗状态。
|
||||
* features/chat/page/useChatPageDialogs.ts
|
||||
* 用途:对话页删除确认、发货「重试所有失败」确认、反馈弹窗与轻量 toast 状态。
|
||||
* 依赖:vue computed/ref、chat.types。
|
||||
* 逻辑:由 useChatPage 组装;ChatViewOverlays 绑定 DeleteConfirmDialog 与 toast 条。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, onBeforeUnmount, ref } from 'vue';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
const SHIPPING_TOAST_AUTO_CLOSE_MS = 3200;
|
||||
|
||||
export function useChatPageDialogs(messages: Ref<ChatMessage[]>) {
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let pendingDeleteAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
/**
|
||||
* 打开删除确认弹窗,并在确认时执行待执行动作。
|
||||
* @param message - 确认说明文案
|
||||
* @param onConfirm - 用户确认后执行的回调
|
||||
*/
|
||||
const openDeleteConfirmDialog = (
|
||||
message: string,
|
||||
onConfirm: () => Promise<void> | void,
|
||||
@@ -19,21 +29,93 @@ export function useChatPageDialogs(messages: Ref<ChatMessage[]>) {
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
/** 关闭删除确认弹窗并清空待执行动作。 */
|
||||
const closeDeleteConfirmDialog = () => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmMessage.value = '';
|
||||
pendingDeleteAction = null;
|
||||
};
|
||||
|
||||
/** 执行删除确认回调后关闭弹窗。 */
|
||||
const handleDeleteConfirm = async () => {
|
||||
if (!pendingDeleteAction) return;
|
||||
await pendingDeleteAction();
|
||||
closeDeleteConfirmDialog();
|
||||
};
|
||||
|
||||
const showRetryFailedConfirmDialog = ref(false);
|
||||
let pendingRetryFailedAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
/**
|
||||
* 打开「重试所有失败」确认弹窗。
|
||||
* 核心逻辑:仅登记确认后要执行的动作,实际请求由调用方注入。
|
||||
* @param onConfirm - 用户点「确认重试」后执行的回调
|
||||
*/
|
||||
const openRetryFailedConfirm = (onConfirm: () => Promise<void> | void) => {
|
||||
pendingRetryFailedAction = onConfirm;
|
||||
showRetryFailedConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
/** 关闭重试确认弹窗并清空待执行动作。 */
|
||||
const closeRetryFailedConfirm = () => {
|
||||
showRetryFailedConfirmDialog.value = false;
|
||||
pendingRetryFailedAction = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户确认后执行重试动作;弹窗由 DeleteConfirmDialog 自行关闭。
|
||||
* 核心逻辑:取出并清空 pending,再 await 执行,避免重复确认。
|
||||
*/
|
||||
const handleRetryFailedConfirm = async () => {
|
||||
const action = pendingRetryFailedAction;
|
||||
pendingRetryFailedAction = null;
|
||||
showRetryFailedConfirmDialog.value = false;
|
||||
if (!action) return;
|
||||
await action();
|
||||
};
|
||||
|
||||
const shippingToastMessage = ref('');
|
||||
let shippingToastTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
/** 清除 toast 自动关闭计时器。 */
|
||||
const clearShippingToastTimer = () => {
|
||||
if (!shippingToastTimer) return;
|
||||
clearTimeout(shippingToastTimer);
|
||||
shippingToastTimer = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 展示非阻塞顶部 toast(用于发货批量重试等轻量成功反馈)。
|
||||
* @param message - toast 正文;空字符串视为关闭
|
||||
*/
|
||||
const showShippingToast = (message: string) => {
|
||||
clearShippingToastTimer();
|
||||
const next = String(message || '').trim();
|
||||
shippingToastMessage.value = next;
|
||||
if (!next) return;
|
||||
shippingToastTimer = setTimeout(() => {
|
||||
shippingToastMessage.value = '';
|
||||
shippingToastTimer = null;
|
||||
}, SHIPPING_TOAST_AUTO_CLOSE_MS);
|
||||
};
|
||||
|
||||
/** 手动关闭发货 toast。 */
|
||||
const clearShippingToast = () => {
|
||||
clearShippingToastTimer();
|
||||
shippingToastMessage.value = '';
|
||||
};
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
clearShippingToastTimer();
|
||||
});
|
||||
|
||||
const showGeneralFeedbackDialog = ref(false);
|
||||
const activeFeedbackMessageIndex = ref<number | null>(null);
|
||||
|
||||
/**
|
||||
* 打开消息反馈弹窗并记录当前消息下标。
|
||||
* @param index - messages 数组下标
|
||||
*/
|
||||
const handleOpenFeedback = (index: number) => {
|
||||
activeFeedbackMessageIndex.value = index;
|
||||
showGeneralFeedbackDialog.value = true;
|
||||
@@ -61,6 +143,13 @@ export function useChatPageDialogs(messages: Ref<ChatMessage[]>) {
|
||||
openDeleteConfirmDialog,
|
||||
closeDeleteConfirmDialog,
|
||||
handleDeleteConfirm,
|
||||
showRetryFailedConfirmDialog,
|
||||
openRetryFailedConfirm,
|
||||
closeRetryFailedConfirm,
|
||||
handleRetryFailedConfirm,
|
||||
shippingToastMessage,
|
||||
showShippingToast,
|
||||
clearShippingToast,
|
||||
showGeneralFeedbackDialog,
|
||||
activeFeedbackMessageIndex,
|
||||
handleOpenFeedback,
|
||||
|
||||
@@ -111,7 +111,7 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
});
|
||||
return ok;
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeUploadFailed');
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.streamError.generic');
|
||||
ctx.msg.warning(errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!ok) ctx.msg.warning(ctx.t('chat.shippingNoticeUploadFailed'));
|
||||
if (!ok) ctx.msg.warning(ctx.t('chat.shippingInventoryUploadFailed'));
|
||||
return ok;
|
||||
};
|
||||
|
||||
@@ -108,7 +108,7 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
ctx.pendingShippingInventoryFile.value = null;
|
||||
ctx.pendingShippingUploadTaskId.value = '';
|
||||
void uploadInventoryForTask(normalizedTaskId, pendingFile).catch((e: unknown) => {
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeUploadFailed');
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingInventoryUploadFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
});
|
||||
return true;
|
||||
@@ -283,7 +283,7 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
try {
|
||||
await uploadInventoryForTask(taskId, file);
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeUploadFailed');
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingInventoryUploadFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
} finally {
|
||||
ctx.shippingInventorySelectionTaskId.value = '';
|
||||
|
||||
Reference in new issue
Block a user