feat(chat): 更新发货任务处理逻辑和界面文本
- 移除不必要的状态引用 - 更新上传处理提示文本,使用国际化支持 - 扩展发货任务摘要接口,增加错误信息和短缺信息 - 更新多语言支持的文本,改善用户体验 - 增加批次工作区的汇总信息和操作提示
This commit is contained in:
1 parent
0b083cfdbd
commit
1fc9976ca3
60 files changed
+3876
-639
No files matched your search
@@ -40,6 +40,8 @@ const props = defineProps<{
|
||||
canSendMessage: boolean;
|
||||
isShippingNoticeAgent: boolean;
|
||||
shippingSuggestedPrompt: string;
|
||||
shippingFocusTaskNo?: string;
|
||||
shippingFocusReason?: string;
|
||||
/** 用对象包裹 Ref,避免 template 自动解包 */
|
||||
shippingPickerRefHolder: { pickerRef: Ref<HTMLInputElement | null> };
|
||||
getKbLabel: (kb: string) => string;
|
||||
@@ -53,6 +55,7 @@ const emit = defineEmits<{
|
||||
'add-remote-url': [url: string];
|
||||
'shipping-inventory-selected': [event: Event];
|
||||
'use-shipping-suggested-prompt': [];
|
||||
'clear-shipping-focus': [];
|
||||
}>();
|
||||
|
||||
const filePickerRef = ref<HTMLInputElement | null>(null);
|
||||
@@ -144,10 +147,26 @@ onBeforeUnmount(() => {
|
||||
<footer class="safe-bottom sticky bottom-0 z-20 bg-transparent p-3 md:p-6">
|
||||
<div class="relative mx-auto max-w-4xl">
|
||||
<div class="flex flex-col rounded-2xl bg-surface p-2 shadow-[0_0_15px_rgba(0,0,0,0.05)] transition-all">
|
||||
<div
|
||||
v-if="isShippingNoticeAgent && shippingFocusTaskNo"
|
||||
class="mb-2 flex items-center gap-2 rounded-xl bg-brand-500 px-3 py-2 text-xs font-medium text-white"
|
||||
>
|
||||
<span class="shrink-0">{{ $t('chat.shippingNoticeUi.currentFocus') }}</span>
|
||||
<span class="rounded-md bg-white/15 px-2 py-0.5 font-mono">{{ shippingFocusTaskNo }}</span>
|
||||
<span class="min-w-0 flex-1 truncate text-white/85">{{ shippingFocusReason || $t('chat.shippingNoticeUi.currentFocusDefaultReason') }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full p-1 text-white/80 transition hover:bg-white/15 hover:text-white"
|
||||
:title="$t('chat.shippingNoticeUi.clearFocus')"
|
||||
@click="emit('clear-shipping-focus')"
|
||||
>
|
||||
<X class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<textarea
|
||||
v-model="inputValue"
|
||||
rows="1"
|
||||
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : $t('chat.askAnything')"
|
||||
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : shippingFocusTaskNo ? $t('chat.shippingNoticeUi.focusInputPlaceholder', { taskId: shippingFocusTaskNo }) : $t('chat.askAnything')"
|
||||
class="w-full resize-none border-none bg-transparent px-3 py-2 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:border-transparent focus:outline-none focus:ring-0"
|
||||
style="min-height: 44px; max-height: 220px;"
|
||||
:disabled="isThinking || isVoiceTranscribing"
|
||||
|
||||
@@ -38,6 +38,7 @@ const {
|
||||
isMessageRunProgressLoading: (msg: ChatMessage) => boolean;
|
||||
toolRunProgress: ToolRunProgress | null;
|
||||
toolRunProgressTitle: string;
|
||||
showScrollToBottom: boolean;
|
||||
/** 供父级滚动逻辑绑定 main 元素 */
|
||||
scrollContainerHolder: { el: Ref<HTMLElement | null> };
|
||||
}>();
|
||||
@@ -49,6 +50,7 @@ const emit = defineEmits<{
|
||||
regenerate: [];
|
||||
'open-feedback': [index: number];
|
||||
'select-question': [question: string];
|
||||
'scroll-to-bottom': [];
|
||||
}>();
|
||||
|
||||
const bindScrollContainer = (node: unknown) => {
|
||||
@@ -57,52 +59,64 @@ const bindScrollContainer = (node: unknown) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main
|
||||
:ref="bindScrollContainer"
|
||||
class="flex-1 p-3 md:p-8"
|
||||
:class="messages.length === 0 ? 'overflow-hidden md:overflow-y-auto' : 'overflow-y-auto scrollbar-thin'"
|
||||
>
|
||||
<div :class="messages.length === 0 ? 'h-full' : 'flex min-h-full flex-col justify-end'">
|
||||
<ChatWelcomePanel
|
||||
v-if="messages.length === 0"
|
||||
:agent-name="agentName"
|
||||
:suggested-questions-style="suggestedQuestionsStyle"
|
||||
:styled-sections="styledSections"
|
||||
:suggested-questions="suggestedQuestions"
|
||||
@select-question="emit('select-question', $event)"
|
||||
/>
|
||||
|
||||
<template v-for="(msg, index) in messages" :key="index">
|
||||
<ChatMessageBubble
|
||||
v-if="shouldRenderMessage(msg)"
|
||||
:message="msg"
|
||||
:index="index"
|
||||
:message-count="messages.length"
|
||||
:is-thinking="isThinking"
|
||||
:show-chat-rating="showChatRating"
|
||||
:copied-index="copiedIndex"
|
||||
:is-shipping-notice-agent="isShippingNoticeAgent"
|
||||
:handlers="handlers"
|
||||
:leave-handlers="leaveHandlers"
|
||||
:shipping-handlers="shippingHandlers"
|
||||
@copy="emit('copy', { message: msg, index })"
|
||||
@edit="emit('edit', $event)"
|
||||
@resend="emit('resend', $event)"
|
||||
@regenerate="emit('regenerate')"
|
||||
@open-feedback="emit('open-feedback', index)"
|
||||
<main class="relative min-h-0 flex-1">
|
||||
<div
|
||||
:ref="bindScrollContainer"
|
||||
class="h-full p-3 md:p-8"
|
||||
:class="messages.length === 0 ? 'overflow-hidden md:overflow-y-auto' : 'overflow-y-auto scrollbar-thin'"
|
||||
>
|
||||
<div :class="messages.length === 0 ? 'h-full' : 'flex min-h-full flex-col justify-end'">
|
||||
<ChatWelcomePanel
|
||||
v-if="messages.length === 0"
|
||||
:agent-name="agentName"
|
||||
:suggested-questions-style="suggestedQuestionsStyle"
|
||||
:styled-sections="styledSections"
|
||||
:suggested-questions="suggestedQuestions"
|
||||
@select-question="emit('select-question', $event)"
|
||||
/>
|
||||
<ToolRunProgressCard
|
||||
v-if="shouldRenderMessage(msg) && shouldShowToolRunProgressAfterMessage(msg, index)"
|
||||
:run="getMessageRunProgress(msg)"
|
||||
:loading="isMessageRunProgressLoading(msg)"
|
||||
:waiting="false"
|
||||
:error="getMessageRunProgressError(msg)"
|
||||
:fallback-title="toolRunProgressTitle"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<ChatThinkingBubble v-if="showThinkingBubble" />
|
||||
<div v-if="messages.length > 0" class="h-2 md:h-3" />
|
||||
<template v-for="(msg, index) in messages" :key="index">
|
||||
<ChatMessageBubble
|
||||
v-if="shouldRenderMessage(msg)"
|
||||
:message="msg"
|
||||
:index="index"
|
||||
:message-count="messages.length"
|
||||
:is-thinking="isThinking"
|
||||
:show-chat-rating="showChatRating"
|
||||
:copied-index="copiedIndex"
|
||||
:is-shipping-notice-agent="isShippingNoticeAgent"
|
||||
:handlers="handlers"
|
||||
:leave-handlers="leaveHandlers"
|
||||
:shipping-handlers="shippingHandlers"
|
||||
@copy="emit('copy', { message: msg, index })"
|
||||
@edit="emit('edit', $event)"
|
||||
@resend="emit('resend', $event)"
|
||||
@regenerate="emit('regenerate')"
|
||||
@open-feedback="emit('open-feedback', index)"
|
||||
/>
|
||||
<ToolRunProgressCard
|
||||
v-if="shouldRenderMessage(msg) && shouldShowToolRunProgressAfterMessage(msg, index)"
|
||||
:run="getMessageRunProgress(msg)"
|
||||
:loading="isMessageRunProgressLoading(msg)"
|
||||
:waiting="false"
|
||||
:error="getMessageRunProgressError(msg)"
|
||||
:fallback-title="toolRunProgressTitle"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<ChatThinkingBubble v-if="showThinkingBubble" />
|
||||
<div v-if="messages.length > 0" class="h-2 md:h-3" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="showScrollToBottom"
|
||||
type="button"
|
||||
class="absolute bottom-4 left-1/2 z-10 flex h-10 w-10 -translate-x-1/2 items-center justify-center rounded-full border border-slate-100 bg-white text-[28px] font-light leading-none text-slate-500 shadow-[0_10px_28px_rgba(15,23,42,0.16)] transition hover:-translate-y-0.5 hover:border-slate-200 hover:text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300 dark:shadow-black/30 md:bottom-5"
|
||||
:title="$t('chat.scrollToLatest')"
|
||||
@click="emit('scroll-to-bottom')"
|
||||
>
|
||||
<span aria-hidden="true" class="-mt-1">↓</span>
|
||||
</button>
|
||||
</main>
|
||||
</template>
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* features/chat/components/ChatViewContent.vue
|
||||
* 用途:对话页主区域,组合侧栏、发货批次进度区、消息列表、输入栏与内置浏览器。
|
||||
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingBatchProgressPanel、chat.context。
|
||||
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingBatchProgressPanel、ShippingBatchWorkspaceDrawer、chat.context。
|
||||
* 逻辑:本文件只做页面结构编排;发货批次进度样式与任务续办交互下沉到独立面板组件。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
@@ -13,6 +13,7 @@ import ChatMessageList from '@/features/chat/components/ChatMessageList.vue';
|
||||
import ChatMobileHeader from '@/features/chat/components/ChatMobileHeader.vue';
|
||||
import ChatBrowserPanel from '@/features/chat/components/ChatBrowserPanel.vue';
|
||||
import ShippingBatchProgressPanel from '@/features/chat/components/ShippingBatchProgressPanel.vue';
|
||||
import ShippingBatchWorkspaceDrawer from '@/features/chat/components/ShippingBatchWorkspaceDrawer.vue';
|
||||
import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
|
||||
const page = useChatPageContext();
|
||||
@@ -85,14 +86,14 @@ const page = useChatPageContext();
|
||||
<div class="flex min-h-0 flex-1 flex-col">
|
||||
<ShippingBatchProgressPanel
|
||||
v-if="page.isShippingNoticeAgent && (page.shippingBatchSummary || page.activeShippingTaskDetail)"
|
||||
:conversation-workspace="page.shippingConversationWorkspace"
|
||||
:active-batch-no="page.activeShippingBatchNo"
|
||||
:batch-summary="page.shippingBatchSummary"
|
||||
:batch-tasks="page.shippingBatchTasks"
|
||||
:active-task-detail="page.activeShippingTaskDetail"
|
||||
:tasks-expanded="page.shippingBatchTasksExpanded"
|
||||
:inventory-selection-active="page.shippingInventorySelectionActive && page.shippingBatchTasks?.length > 1"
|
||||
@update:tasks-expanded="page.shippingBatchTasksExpanded = $event"
|
||||
@focus-task="page.switchShippingFocusTask"
|
||||
@resume-task="page.resumeShippingTask"
|
||||
:workspace-open="page.shippingWorkspaceOpen"
|
||||
@switch-batch="page.switchShippingBatch"
|
||||
@toggle-workspace="page.shippingWorkspaceOpen = !page.shippingWorkspaceOpen"
|
||||
/>
|
||||
|
||||
<ChatMessageList
|
||||
@@ -116,6 +117,7 @@ const page = useChatPageContext();
|
||||
:is-message-run-progress-loading="page.isMessageRunProgressLoading"
|
||||
:tool-run-progress="page.toolRunProgress"
|
||||
:tool-run-progress-title="page.toolRunProgressTitle"
|
||||
:show-scroll-to-bottom="page.showScrollToBottom"
|
||||
:scroll-container-holder="page.scrollContainerHolder"
|
||||
@copy="page.copyToClipboard($event.message, $event.index)"
|
||||
@edit="page.input = $event"
|
||||
@@ -123,6 +125,7 @@ const page = useChatPageContext();
|
||||
@regenerate="page.regenerate"
|
||||
@open-feedback="page.handleOpenFeedback($event)"
|
||||
@select-question="page.handleSend"
|
||||
@scroll-to-bottom="page.scrollToBottom"
|
||||
/>
|
||||
|
||||
<ChatInputBar
|
||||
@@ -139,6 +142,8 @@ const page = useChatPageContext();
|
||||
:can-send-message="page.canSendMessage"
|
||||
:is-shipping-notice-agent="page.isShippingNoticeAgent"
|
||||
:shipping-suggested-prompt="page.shippingSuggestedPrompt"
|
||||
:shipping-focus-task-no="page.focusedShippingTaskNo"
|
||||
:shipping-focus-reason="page.shippingFocusReason"
|
||||
:shipping-picker-ref-holder="page.shippingPickerRefHolder"
|
||||
:get-kb-label="page.getKbLabel"
|
||||
@send="page.handleSend()"
|
||||
@@ -148,6 +153,7 @@ const page = useChatPageContext();
|
||||
@add-remote-url="page.addRemoteUrlAttachment"
|
||||
@shipping-inventory-selected="page.handleShippingInventorySelected"
|
||||
@use-shipping-suggested-prompt="page.useShippingSuggestedPrompt"
|
||||
@clear-shipping-focus="page.clearShippingFocus"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -165,6 +171,23 @@ const page = useChatPageContext();
|
||||
@start-resize="page.browser.startResize"
|
||||
@close="page.browser.close"
|
||||
/>
|
||||
|
||||
<ShippingBatchWorkspaceDrawer
|
||||
v-if="page.isShippingNoticeAgent && (page.shippingConversationWorkspace || page.shippingBatchSummary)"
|
||||
v-model:open="page.shippingWorkspaceOpen"
|
||||
:conversation-workspace="page.shippingConversationWorkspace"
|
||||
:active-batch-no="page.activeShippingBatchNo"
|
||||
:focused-task-no="page.focusedShippingTaskNo"
|
||||
:batch-summary="page.shippingBatchSummary"
|
||||
:batch-tasks="page.shippingBatchTasks"
|
||||
:active-task-detail="page.activeShippingTaskDetail"
|
||||
:retrying-pending="page.retryingShippingPendingTasks"
|
||||
@switch-batch="page.switchShippingBatch"
|
||||
@focus-task="page.switchShippingFocusTask"
|
||||
@resume-task="page.resumeShippingTask"
|
||||
@query-shortage="page.queryShippingShortageDetails"
|
||||
@retry-pending="page.retryCurrentShippingBatchPendingTasks"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ChatShell>
|
||||
|
||||
@@ -1,43 +1,45 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/chat/components/ShippingBatchProgressPanel.vue
|
||||
* 用途:发货通知聊天顶部批次进度卡片,按原型方案 C 展示批次概览、任务切换列表、七步进度与续办弹层。
|
||||
* 依赖:shippingStepper、shipping.api.types、vue-i18n、lucide-vue-next。
|
||||
* 逻辑:上游由 ChatViewContent 传入批次/任务状态;本组件只负责展示与抛出 focus/resume 事件,不直接请求后端。
|
||||
* 用途:发货通知聊天顶部轻量批次状态条,展示当前批次进度与工作台入口。
|
||||
* 依赖:shipping.api.types、vue-i18n、批次 retry API。
|
||||
* 逻辑:生成式执行摘要由聊天消息流承载;本组件只提供固定状态 chrome 和明确范围的批次操作。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { List, PlayCircle, X } from 'lucide-vue-next';
|
||||
import { List, RefreshCw } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { buildShippingWorkflowSteps, type ShippingWorkflowStepItem } from '@/features/chat/shipping';
|
||||
import { retryWorkspaceShippingBatchPending } from '@/features/chat/api/shipping.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type {
|
||||
ShippingBatchSummary,
|
||||
ShippingConversationWorkspace,
|
||||
ShippingTaskDetail,
|
||||
ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
|
||||
const props = defineProps<{
|
||||
conversationWorkspace: ShippingConversationWorkspace | null;
|
||||
activeBatchNo: string;
|
||||
batchSummary: ShippingBatchSummary | null;
|
||||
batchTasks: ShippingTaskSummary[];
|
||||
activeTaskDetail: ShippingTaskDetail | null;
|
||||
tasksExpanded: boolean;
|
||||
inventorySelectionActive: boolean;
|
||||
workspaceOpen: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:tasksExpanded': [value: boolean];
|
||||
'focus-task': [taskNo: string];
|
||||
'resume-task': [taskNo: string];
|
||||
'switch-batch': [batchNo: string];
|
||||
'toggle-workspace': [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const showTaskDialog = ref(false);
|
||||
const retryingPending = ref(false);
|
||||
|
||||
const COMPLETED_PROCESS_STATUSES = new Set(['uploaded', 'closed']);
|
||||
const CIRCLED_NUMBERS = ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨'];
|
||||
const workspaceBatches = computed(() => props.conversationWorkspace?.batches || []);
|
||||
const activeBatchNo = computed(() =>
|
||||
String(props.activeBatchNo || props.batchSummary?.batch_no || workspaceBatches.value[0]?.batch_no || '').trim(),
|
||||
);
|
||||
|
||||
const processSummary = computed(() => {
|
||||
const summary = props.batchSummary?.process_summary || null;
|
||||
@@ -55,121 +57,36 @@ const processSummary = computed(() => {
|
||||
return { total, completed, running, pending };
|
||||
});
|
||||
|
||||
const currentTask = computed<ShippingTaskSummary | ShippingTaskDetail | null>(() => {
|
||||
const focusTaskNo = String(props.batchSummary?.current_focus_task_no || '').trim().toUpperCase();
|
||||
if (focusTaskNo) {
|
||||
return props.batchTasks.find((task) => String(task.task_no || '').trim().toUpperCase() === focusTaskNo)
|
||||
|| props.activeTaskDetail
|
||||
|| null;
|
||||
}
|
||||
return props.activeTaskDetail || props.batchTasks[0] || null;
|
||||
const abnormalCount = computed(() => {
|
||||
const batchSummary = props.batchSummary?.process_summary || {};
|
||||
return Number(batchSummary.failed || 0) + Number((batchSummary as { needs_human?: number }).needs_human || 0);
|
||||
});
|
||||
|
||||
const currentTaskNo = computed(() => String(currentTask.value?.task_no || '').trim().toUpperCase());
|
||||
const currentTaskName = computed(() =>
|
||||
String(
|
||||
currentTask.value?.source_file_name
|
||||
|| currentTask.value?.customer_name
|
||||
|| t('chat.shippingNoticeUi.currentNotice'),
|
||||
).trim(),
|
||||
const progressPercent = computed(() =>
|
||||
processSummary.value.total
|
||||
? Math.round((processSummary.value.completed / processSummary.value.total) * 100)
|
||||
: 0,
|
||||
);
|
||||
const currentTaskIndex = computed(() =>
|
||||
Number(
|
||||
currentTask.value?.batch_index
|
||||
|| props.batchSummary?.process_summary?.current_index
|
||||
|| 0,
|
||||
),
|
||||
);
|
||||
const currentTaskTotal = computed(() =>
|
||||
Number(
|
||||
currentTask.value?.batch_total
|
||||
|| props.batchSummary?.file_count
|
||||
|| processSummary.value.total
|
||||
|| 0,
|
||||
),
|
||||
);
|
||||
const currentSteps = computed(() => buildShippingWorkflowSteps(currentTask.value));
|
||||
|
||||
const resolveActiveStep = (steps: ShippingWorkflowStepItem[]) =>
|
||||
steps.findIndex((step) => step.status === 'current' || step.status === 'blocked');
|
||||
|
||||
const currentStepMeta = computed(() => {
|
||||
const steps = currentSteps.value;
|
||||
if (!steps.length) return { index: 0, label: t('chat.shippingNoticeUi.processing') };
|
||||
const activeIndex = resolveActiveStep(steps);
|
||||
const safeIndex = activeIndex >= 0 ? activeIndex : steps.length - 1;
|
||||
const executionStateMeta = computed(() => {
|
||||
if (abnormalCount.value > 0) {
|
||||
return {
|
||||
text: t('chat.shippingNoticeUi.needsIntervention'),
|
||||
className: 'border-amber-100 bg-amber-50 text-amber-700',
|
||||
};
|
||||
}
|
||||
if (processSummary.value.running > 0 || processSummary.value.pending > 0) {
|
||||
return {
|
||||
text: t('chat.shippingNoticeUi.runningState'),
|
||||
className: 'border-sky-100 bg-sky-50 text-brand-700',
|
||||
};
|
||||
}
|
||||
return {
|
||||
index: safeIndex + 1,
|
||||
label: t(steps[safeIndex]?.label || 'chat.shippingNoticeUi.processing'),
|
||||
text: t('chat.shippingNoticeUi.completedState'),
|
||||
className: 'border-emerald-100 bg-emerald-50 text-emerald-700',
|
||||
};
|
||||
});
|
||||
|
||||
const summaryLine = computed(() => t('chat.shippingNoticeUi.batchSummaryLine', {
|
||||
total: processSummary.value.total,
|
||||
completed: processSummary.value.completed,
|
||||
running: processSummary.value.running,
|
||||
pending: processSummary.value.pending,
|
||||
}));
|
||||
|
||||
/**
|
||||
* 将任务状态映射为原型中列表右侧的紧凑状态文案。
|
||||
*
|
||||
* 核心逻辑:完成态显示“已完成”,阻塞态显示“步骤 X 待确认”,运行态显示“步骤 X/Y”,
|
||||
* 其余回退到“排队中”,以匹配原型中批次队列的短标签风格。
|
||||
* @param task - 任务摘要或详情
|
||||
* @returns 原型列表使用的短文案与颜色类
|
||||
*/
|
||||
const resolveTaskStateMeta = (task: ShippingTaskSummary | ShippingTaskDetail | null) => {
|
||||
if (!task) {
|
||||
return { text: t('chat.shippingNoticeUi.queuedState'), tone: 'text-muted' };
|
||||
}
|
||||
if (COMPLETED_PROCESS_STATUSES.has(String(task.process_status || '').trim())) {
|
||||
return { text: t('chat.shippingNoticeUi.completedState'), tone: 'text-emerald-700' };
|
||||
}
|
||||
|
||||
const steps = buildShippingWorkflowSteps(task);
|
||||
const blockedIndex = steps.findIndex((step) => step.status === 'blocked');
|
||||
if (blockedIndex >= 0) {
|
||||
return {
|
||||
text: t('chat.shippingNoticeUi.stepNeedsConfirm', { step: blockedIndex + 1 }),
|
||||
tone: 'text-amber-700',
|
||||
};
|
||||
}
|
||||
|
||||
const activeIndex = resolveActiveStep(steps);
|
||||
if (activeIndex >= 0) {
|
||||
return {
|
||||
text: t('chat.shippingNoticeUi.stepFraction', { current: activeIndex + 1, total: steps.length }),
|
||||
tone: 'text-brand-600',
|
||||
};
|
||||
}
|
||||
|
||||
return { text: t('chat.shippingNoticeUi.queuedState'), tone: 'text-muted' };
|
||||
};
|
||||
|
||||
const shortTaskNo = (taskNo?: string | null) => {
|
||||
const value = String(taskNo || '').trim();
|
||||
if (value.length <= 10) return value || '--';
|
||||
return `${value.slice(0, 5)}...${value.slice(-3)}`;
|
||||
};
|
||||
|
||||
const isCurrentTask = (taskNo?: string | null) =>
|
||||
String(taskNo || '').trim().toUpperCase() === currentTaskNo.value;
|
||||
|
||||
const openTaskDialog = () => {
|
||||
if (!props.batchTasks.length) return;
|
||||
showTaskDialog.value = true;
|
||||
};
|
||||
|
||||
const handleFocusTask = (taskNo: string) => {
|
||||
emit('focus-task', taskNo);
|
||||
};
|
||||
|
||||
const handleResumeTask = (taskNo: string) => {
|
||||
showTaskDialog.value = false;
|
||||
emit('resume-task', taskNo);
|
||||
};
|
||||
|
||||
const handleRetryPending = async () => {
|
||||
const batchNo = String(props.batchSummary?.batch_no || '').trim();
|
||||
if (!batchNo || retryingPending.value) return;
|
||||
@@ -186,15 +103,37 @@ const handleRetryPending = async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="mx-auto mt-4 w-full max-w-4xl overflow-hidden rounded-2xl border border-sky-100 bg-gradient-to-br from-sky-50 via-white to-emerald-50 shadow-sm"
|
||||
>
|
||||
<div class="border-b border-sky-100/80 px-4 py-3">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<div class="text-xs text-slate-500">
|
||||
{{ summaryLine }}
|
||||
<section class="w-full px-3 pt-3 md:px-8 md:pr-10">
|
||||
<div
|
||||
class="mx-auto w-full max-w-4xl rounded-2xl border border-default bg-gradient-to-r from-sky-50 via-white to-emerald-50 px-6 py-4 shadow-sm"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex flex-wrap items-center gap-2 text-xs text-slate-500">
|
||||
<span class="font-mono font-semibold text-brand-700">{{ activeBatchNo || '--' }}</span>
|
||||
<span>
|
||||
{{ t('chat.shippingNoticeUi.batchChromeSummary', {
|
||||
total: processSummary.total,
|
||||
completed: processSummary.completed,
|
||||
running: processSummary.running,
|
||||
abnormal: abnormalCount,
|
||||
}) }}
|
||||
</span>
|
||||
<span
|
||||
class="rounded-full border px-2 py-0.5 text-[11px] font-semibold"
|
||||
:class="executionStateMeta.className"
|
||||
>
|
||||
{{ executionStateMeta.text }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 h-1.5 max-w-md overflow-hidden rounded-full bg-slate-200">
|
||||
<div
|
||||
class="h-full rounded-full bg-brand-500 transition-all"
|
||||
:style="{ width: `${progressPercent}%` }"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<button
|
||||
v-if="batchSummary?.batch_no"
|
||||
type="button"
|
||||
@@ -202,242 +141,20 @@ const handleRetryPending = async () => {
|
||||
:disabled="retryingPending"
|
||||
@click="handleRetryPending"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" :class="retryingPending ? 'animate-spin' : ''" />
|
||||
{{ retryingPending ? t('chat.shippingNoticeUi.retrying') : t('chat.shippingNoticeUi.retryPendingTasks') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-default bg-white/80 px-2.5 py-1 text-xs font-medium text-secondary transition hover:border-brand-300 hover:bg-brand-50 hover:text-brand-700"
|
||||
@click="openTaskDialog"
|
||||
@click="emit('toggle-workspace')"
|
||||
>
|
||||
<List class="h-3.5 w-3.5" />
|
||||
{{ t('chat.shippingNoticeUi.taskListResume') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="batchTasks.length > 1"
|
||||
type="button"
|
||||
class="text-xs font-medium text-brand-600 transition hover:text-brand-700"
|
||||
@click="emit('update:tasksExpanded', !tasksExpanded)"
|
||||
>
|
||||
{{ tasksExpanded ? `${t('chat.shippingNoticeUi.collapseTaskList')} ▲` : `${t('chat.shippingNoticeUi.expandTaskList')} ▼` }}
|
||||
{{ workspaceOpen ? t('chat.shippingNoticeUi.collapseTaskList') : t('chat.shippingNoticeUi.expandTaskList') }}
|
||||
<span class="text-brand-600">{{ workspaceOpen ? '▲' : '▼' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="tasksExpanded && batchTasks.length"
|
||||
class="mt-2 space-y-1 border-t border-dashed border-sky-100 pt-2"
|
||||
>
|
||||
<button
|
||||
v-for="(task, index) in batchTasks"
|
||||
:key="task.task_no"
|
||||
type="button"
|
||||
class="flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-xs transition hover:bg-white/70"
|
||||
:class="isCurrentTask(task.task_no) ? 'bg-white/80 ring-1 ring-brand-200' : ''"
|
||||
@click="handleFocusTask(task.task_no)"
|
||||
>
|
||||
<span class="text-muted">{{ CIRCLED_NUMBERS[index] || `${index + 1}` }}</span>
|
||||
<span class="flex-1 truncate" :class="isCurrentTask(task.task_no) ? 'font-medium text-secondary' : ''">
|
||||
{{ task.source_file_name || task.customer_name || t('chat.shippingNoticeUi.currentNotice') }}
|
||||
</span>
|
||||
<span class="font-mono text-brand-600">{{ shortTaskNo(task.task_no) }}</span>
|
||||
<span
|
||||
class="rounded-full px-1.5 py-0.5"
|
||||
:class="isCurrentTask(task.task_no) ? 'text-brand-600' : resolveTaskStateMeta(task).tone"
|
||||
>
|
||||
{{ resolveTaskStateMeta(task).text }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-3 px-4 py-4">
|
||||
<div class="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<div>
|
||||
<div class="font-mono text-sm font-semibold text-brand-700">
|
||||
{{ currentTaskNo || batchSummary?.batch_no || '--' }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-xs text-muted">
|
||||
当前 · 第 {{ currentTaskIndex || 0 }}/{{ currentTaskTotal || 0 }} 笔 ·
|
||||
<em class="not-italic text-secondary">{{ currentTaskName }}</em>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-xs text-muted">
|
||||
步骤 <strong class="text-secondary">{{ currentStepMeta.index }}</strong>/{{ currentSteps.length || 7 }} · {{ currentStepMeta.label }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="scheme-stepper">
|
||||
<template v-for="(step, index) in currentSteps" :key="step.id">
|
||||
<div
|
||||
class="scheme-step-node"
|
||||
:class="{
|
||||
done: step.status === 'completed',
|
||||
active: step.status === 'current' || step.status === 'blocked',
|
||||
}"
|
||||
>
|
||||
<div class="scheme-step-dot">
|
||||
{{ step.status === 'completed' ? '✓' : index + 1 }}
|
||||
</div>
|
||||
<div class="scheme-step-label">{{ t(step.label) }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="inventorySelectionActive"
|
||||
class="rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.inventoryTaskPickHint') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="showTaskDialog"
|
||||
class="fixed inset-0 z-[120] flex items-center justify-center bg-slate-900/30 px-4"
|
||||
@click.self="showTaskDialog = false"
|
||||
>
|
||||
<div class="w-full max-w-[620px] rounded-[28px] bg-white p-5 shadow-[0_24px_80px_rgba(15,23,42,0.22)]">
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<div class="text-[32px] font-semibold tracking-tight text-slate-800">
|
||||
{{ t('chat.shippingNoticeUi.taskListTitle') }}
|
||||
</div>
|
||||
<div class="mt-1 text-sm text-slate-500">
|
||||
{{ t('chat.shippingNoticeUi.taskListHint') }}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full p-2 text-slate-400 transition hover:bg-slate-100 hover:text-slate-600"
|
||||
@click="showTaskDialog = false"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 space-y-3">
|
||||
<button
|
||||
v-for="task in batchTasks"
|
||||
:key="task.task_no"
|
||||
type="button"
|
||||
class="w-full rounded-3xl border px-4 py-4 text-left transition hover:border-[#8bc8f5] hover:bg-[#f8fbff]"
|
||||
:class="isCurrentTask(task.task_no) ? 'border-[#8bc8f5] bg-[#f5fbff]' : 'border-[#e5edf5] bg-white'"
|
||||
@click="handleResumeTask(task.task_no)"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-mono text-lg font-semibold text-[#1277c8]">
|
||||
{{ task.task_no }}
|
||||
</div>
|
||||
<div class="mt-1 truncate text-[15px] text-slate-700">
|
||||
{{ task.source_file_name || task.customer_name || t('chat.shippingNoticeUi.currentNotice') }}
|
||||
</div>
|
||||
<div class="mt-1 text-sm text-slate-500">
|
||||
{{ resolveTaskStateMeta(task).text }}
|
||||
</div>
|
||||
<div
|
||||
v-if="isCurrentTask(task.task_no)"
|
||||
class="mt-2 inline-flex items-center gap-1 text-sm font-medium text-[#1277c8]"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.currentFocus') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<span
|
||||
class="rounded-full px-3 py-1 text-sm font-medium"
|
||||
:class="COMPLETED_PROCESS_STATUSES.has(String(task.process_status || '').trim())
|
||||
? 'bg-emerald-100 text-emerald-700'
|
||||
: isCurrentTask(task.task_no)
|
||||
? 'bg-sky-100 text-sky-700'
|
||||
: 'bg-amber-100 text-amber-700'"
|
||||
>
|
||||
{{ COMPLETED_PROCESS_STATUSES.has(String(task.process_status || '').trim())
|
||||
? t('chat.shippingNoticeUi.completedState')
|
||||
: isCurrentTask(task.task_no)
|
||||
? t('chat.shippingNoticeUi.runningState')
|
||||
: t('chat.shippingNoticeUi.pendingState') }}
|
||||
</span>
|
||||
<PlayCircle class="h-5 w-5 text-[#1492df]" />
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.scheme-stepper {
|
||||
display: flex;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.scheme-step-node {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-width: 52px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.scheme-step-node:not(:last-child)::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: calc(50% + 11px);
|
||||
width: calc(100% - 22px);
|
||||
height: 2px;
|
||||
background: #e2e8f0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.scheme-step-node.done:not(:last-child)::after {
|
||||
background: #0284c7;
|
||||
}
|
||||
|
||||
.scheme-step-node.active:not(:last-child)::after {
|
||||
background: linear-gradient(90deg, #0284c7 50%, #e2e8f0 50%);
|
||||
}
|
||||
|
||||
.scheme-step-dot {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin: 0 auto 0.25rem;
|
||||
border: 2px solid #e2e8f0;
|
||||
border-radius: 9999px;
|
||||
background: #fff;
|
||||
color: #64748b;
|
||||
font-size: 0.55rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.scheme-step-node.done .scheme-step-dot {
|
||||
border-color: #0284c7;
|
||||
background: #0284c7;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.scheme-step-node.active .scheme-step-dot {
|
||||
border-color: #0284c7;
|
||||
box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
|
||||
color: #0284c7;
|
||||
}
|
||||
|
||||
.scheme-step-label {
|
||||
color: #64748b;
|
||||
font-size: 0.58rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.scheme-step-node.active .scheme-step-label {
|
||||
color: #0284c7;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,509 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/chat/components/ShippingBatchWorkspaceDrawer.vue
|
||||
* 用途:发货通知 Agent 的右侧批次工作台抽屉,承载多批次切换、任务筛选、步骤诊断与恢复动作。
|
||||
* 依赖:shippingStepper、shipping.api.types、vue-i18n、lucide-vue-next。
|
||||
* 逻辑:上游传入会话级 workspace 与当前批次任务;本组件只做展示、筛选和事件抛出,执行动作仍由 useChatShipping 接管。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { RefreshCw, Target, X } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { buildShippingWorkflowSteps, type ShippingWorkflowStepItem } from '@/features/chat/shipping';
|
||||
import { hasShortageLines } from '@/features/chat/shipping/shippingShortageDetails';
|
||||
import type {
|
||||
ShippingBatchSummary,
|
||||
ShippingConversationWorkspace,
|
||||
ShippingTaskDetail,
|
||||
ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
conversationWorkspace: ShippingConversationWorkspace | null;
|
||||
activeBatchNo: string;
|
||||
focusedTaskNo: string;
|
||||
batchSummary: ShippingBatchSummary | null;
|
||||
batchTasks: ShippingTaskSummary[];
|
||||
activeTaskDetail: ShippingTaskDetail | null;
|
||||
retryingPending?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:open': [value: boolean];
|
||||
'switch-batch': [batchNo: string];
|
||||
'focus-task': [taskNo: string];
|
||||
'resume-task': [taskNo: string];
|
||||
'query-shortage': [taskNo: string];
|
||||
'retry-pending': [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const activeFilter = ref<'all' | 'abnormal' | 'completed'>('all');
|
||||
|
||||
const COMPLETED_PROCESS_STATUSES = new Set(['uploaded', 'completed', 'closed']);
|
||||
|
||||
const workspaceBatches = computed(() => props.conversationWorkspace?.batches || []);
|
||||
const activeBatchNo = computed(() =>
|
||||
String(props.activeBatchNo || props.batchSummary?.batch_no || workspaceBatches.value[0]?.batch_no || '').trim(),
|
||||
);
|
||||
|
||||
const isFailedTask = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
task.upload_status === 'failed' || String(task.process_status || '').trim() === 'upload_failed';
|
||||
|
||||
const isCompletedTask = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
COMPLETED_PROCESS_STATUSES.has(String(task.process_status || '').trim());
|
||||
|
||||
const isAbnormalTask = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
!isCompletedTask(task)
|
||||
&& (isFailedTask(task)
|
||||
|| Boolean(task.review_status || task.pending_human_reason)
|
||||
|| String(task.process_status || '').trim() === 'waiting_inventory');
|
||||
|
||||
const batchAbnormalCount = (batch: ShippingBatchSummary) => {
|
||||
const summary = batch.process_summary || {};
|
||||
return Number(summary.failed || 0) + Number((summary as { needs_human?: number }).needs_human || 0);
|
||||
};
|
||||
|
||||
const batchCompletedCount = (batch: ShippingBatchSummary) =>
|
||||
Number(batch.process_summary?.completed || 0);
|
||||
|
||||
const batchTotalCount = (batch: ShippingBatchSummary) =>
|
||||
Number(batch.process_summary?.total || batch.file_count || 0);
|
||||
|
||||
const taskCounts = computed(() => {
|
||||
const tasks = props.batchTasks || [];
|
||||
const completed = tasks.filter(isCompletedTask).length;
|
||||
const abnormal = tasks.filter(isAbnormalTask).length;
|
||||
return {
|
||||
total: tasks.length,
|
||||
abnormal,
|
||||
completed,
|
||||
};
|
||||
});
|
||||
|
||||
const filteredTasks = computed(() => {
|
||||
const tasks = props.batchTasks || [];
|
||||
if (activeFilter.value === 'abnormal') return tasks.filter(isAbnormalTask);
|
||||
if (activeFilter.value === 'completed') return tasks.filter(isCompletedTask);
|
||||
return tasks;
|
||||
});
|
||||
|
||||
const isCurrentTask = (taskNo?: string | null) =>
|
||||
String(taskNo || '').trim().toUpperCase() === String(props.focusedTaskNo || props.activeTaskDetail?.task_no || '').trim().toUpperCase();
|
||||
|
||||
const resolveTaskStateMeta = (task: ShippingTaskSummary | ShippingTaskDetail) => {
|
||||
if (isCompletedTask(task)) {
|
||||
return { text: t('chat.shippingNoticeUi.completedState'), className: 'border-emerald-100 bg-emerald-50 text-emerald-700' };
|
||||
}
|
||||
if (isFailedTask(task)) {
|
||||
return { text: t('chat.shippingNoticeUi.status.uploadFailed'), className: 'border-rose-100 bg-rose-50 text-rose-700' };
|
||||
}
|
||||
if (isAbnormalTask(task)) {
|
||||
return { text: t('chat.shippingNoticeUi.pendingState'), className: 'border-amber-100 bg-amber-50 text-amber-700' };
|
||||
}
|
||||
return { text: t('chat.shippingNoticeUi.runningState'), className: 'border-sky-100 bg-sky-50 text-brand-700' };
|
||||
};
|
||||
|
||||
const taskStepNumber = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
resolveActiveStep(buildShippingWorkflowSteps(task)) + 1;
|
||||
|
||||
const currentStepProgress = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
task.step_payload?.current_step_progress || null;
|
||||
|
||||
const resolveTaskDiagnosis = (task: ShippingTaskSummary | ShippingTaskDetail) => {
|
||||
const reason = String(task.pending_human_reason || '').trim();
|
||||
const reviewStatus = String(task.review_status || '').trim();
|
||||
const processStatus = String(task.process_status || '').trim();
|
||||
const explicitError = String(task.error_message || '').trim();
|
||||
const progress = currentStepProgress(task);
|
||||
const progressMessage = String(progress?.message || '').trim();
|
||||
const progressDetail = String(progress?.detail || '').trim();
|
||||
const step = taskStepNumber(task);
|
||||
|
||||
if (isCompletedTask(task)) {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisCompletedTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisCompletedAdvice'),
|
||||
};
|
||||
}
|
||||
if (progressMessage && reason === 'rpa_pending') {
|
||||
return {
|
||||
title: progressMessage,
|
||||
advice: progressDetail || t('chat.shippingNoticeUi.diagnosisInventoryRpaAdvice'),
|
||||
};
|
||||
}
|
||||
if (explicitError) {
|
||||
return {
|
||||
title: explicitError,
|
||||
advice: progressDetail || t('chat.shippingNoticeUi.diagnosisAdviceRetryOrFocus'),
|
||||
};
|
||||
}
|
||||
if (progressMessage && (isAbnormalTask(task) || progress?.status === 'needs_human')) {
|
||||
return {
|
||||
title: progressMessage,
|
||||
advice: progressDetail || t('chat.shippingNoticeUi.diagnosisStepWaitingAdvice'),
|
||||
};
|
||||
}
|
||||
if (isFailedTask(task) || reason === 'upload_rpa_failed') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisUploadFailedTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisUploadFailedAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'shortage' || reason === 'shortage_review' || reviewStatus === 'shortage_review') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisShortageTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisShortageAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'rpa_exhausted' || reason === 'rpa_pending' || reason === 'inv_unavail') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisInventoryRpaTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisInventoryRpaAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'align_review' || reviewStatus === 'align_review') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisAlignReviewTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisAlignReviewAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'low_confidence' || reviewStatus === 'parse_review') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisParseReviewTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisParseReviewAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'rsv_required' || reviewStatus === 'rsv_required') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisReservationRequiredTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisReservationRequiredAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'map_infer' || processStatus === 'waiting_inventory') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisInventoryWaitingTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisInventoryWaitingAdvice'),
|
||||
};
|
||||
}
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisStepWaitingTitle', { step }),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisStepWaitingAdvice'),
|
||||
};
|
||||
};
|
||||
|
||||
const resolveActiveStep = (steps: ShippingWorkflowStepItem[]) => {
|
||||
const activeIndex = steps.findIndex((step) => step.status === 'current' || step.status === 'blocked');
|
||||
return activeIndex >= 0 ? activeIndex : Math.max(0, steps.length - 1);
|
||||
};
|
||||
|
||||
const handleSwitchBatch = (batchNo: string) => {
|
||||
if (!batchNo || batchNo === activeBatchNo.value) return;
|
||||
activeFilter.value = 'all';
|
||||
emit('switch-batch', batchNo);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside
|
||||
v-if="open"
|
||||
class="hidden h-full w-[520px] shrink-0 flex-col border-l border-default bg-surface shadow-[-12px_0_40px_rgba(15,23,42,0.08)] xl:flex"
|
||||
>
|
||||
<header class="flex h-[92px] shrink-0 items-center justify-between border-b border-default px-6">
|
||||
<div>
|
||||
<div class="flex items-center gap-2 text-lg font-bold text-primary">
|
||||
<span class="grid h-5 w-5 grid-cols-2 gap-0.5 text-brand-500">
|
||||
<span class="rounded-sm bg-current"></span>
|
||||
<span class="rounded-sm border border-current"></span>
|
||||
<span class="rounded-sm border border-current"></span>
|
||||
<span class="rounded-sm bg-current"></span>
|
||||
</span>
|
||||
{{ t('chat.shippingNoticeUi.batchWorkspaceTitle') }}
|
||||
</div>
|
||||
<p class="mt-1 text-[11px] text-muted">{{ t('chat.shippingNoticeUi.batchWorkspaceSubtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex h-9 w-9 items-center justify-center rounded-full text-muted transition hover:bg-surface-soft hover:text-primary"
|
||||
@click="emit('update:open', false)"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="border-b border-default px-6 py-5">
|
||||
<div class="flex gap-3 overflow-x-auto pb-1">
|
||||
<button
|
||||
v-for="batch in workspaceBatches"
|
||||
:key="batch.batch_no"
|
||||
type="button"
|
||||
class="relative w-44 shrink-0 overflow-hidden rounded-xl border p-3 text-left transition-colors"
|
||||
:class="batch.batch_no === activeBatchNo ? 'border-brand-300 bg-surface shadow-sm ring-1 ring-brand-100' : 'border-default bg-transparent hover:bg-surface-soft'"
|
||||
@click="handleSwitchBatch(batch.batch_no)"
|
||||
>
|
||||
<div
|
||||
v-if="batch.batch_no === activeBatchNo"
|
||||
class="absolute left-0 top-0 h-1 w-full bg-brand-500"
|
||||
></div>
|
||||
<div class="mb-1 truncate font-mono text-xs font-bold text-primary">{{ batch.batch_no }}</div>
|
||||
<div class="text-[10px] font-medium text-muted">
|
||||
{{
|
||||
batchAbnormalCount(batch) > 0
|
||||
? t('chat.shippingNoticeUi.batchTabAbnormal', { completed: batchCompletedCount(batch), abnormal: batchAbnormalCount(batch) })
|
||||
: t('chat.shippingNoticeUi.batchTabNormal', { total: batchTotalCount(batch) })
|
||||
}}
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto px-6 py-6">
|
||||
<section class="rounded-2xl border border-default bg-surface p-4 shadow-sm">
|
||||
<h3 class="text-sm font-bold text-primary">{{ t('chat.shippingNoticeUi.batchActionsTitle') }}</h3>
|
||||
<div class="mt-4">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex w-full items-center justify-center gap-2 rounded-lg border border-default bg-white py-2 text-xs font-medium text-secondary transition hover:border-brand-300 hover:bg-brand-50 hover:text-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="retryingPending"
|
||||
@click="emit('retry-pending')"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" :class="retryingPending ? 'animate-spin' : ''" />
|
||||
{{ retryingPending ? t('chat.shippingNoticeUi.retrying') : t('chat.shippingNoticeUi.retryFailedTasks') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-3 rounded-lg border border-indigo-100 bg-indigo-50 p-3 text-xs leading-5 text-indigo-900/80">
|
||||
{{ t('chat.shippingNoticeUi.batchActionSafetyNotice') }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="mt-6">
|
||||
<div class="mb-3 flex items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-bold text-primary">
|
||||
{{ t('chat.shippingNoticeUi.taskDetailCount', { count: filteredTasks.length }) }}
|
||||
</h3>
|
||||
<div class="flex rounded-lg bg-slate-100 p-1 text-xs">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded px-3 py-1 transition-colors"
|
||||
:class="activeFilter === 'all' ? 'bg-white text-primary shadow-sm' : 'text-muted hover:text-secondary'"
|
||||
@click="activeFilter = 'all'"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.filterAll') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded px-3 py-1 transition-colors"
|
||||
:class="activeFilter === 'abnormal' ? 'bg-white text-primary shadow-sm' : 'text-muted hover:text-secondary'"
|
||||
@click="activeFilter = 'abnormal'"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.filterAbnormal', { count: taskCounts.abnormal }) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded px-3 py-1 transition-colors"
|
||||
:class="activeFilter === 'completed' ? 'bg-white text-primary shadow-sm' : 'text-muted hover:text-secondary'"
|
||||
@click="activeFilter = 'completed'"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.filterCompleted', { count: taskCounts.completed }) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!filteredTasks.length" class="py-10 text-center text-sm text-muted">
|
||||
{{ t('chat.shippingNoticeUi.emptyFilteredTasks') }}
|
||||
</div>
|
||||
|
||||
<div v-else class="space-y-4">
|
||||
<article
|
||||
v-for="task in filteredTasks"
|
||||
:key="task.task_no"
|
||||
class="relative overflow-hidden rounded-2xl border bg-white p-4 shadow-sm transition-colors"
|
||||
:class="[
|
||||
isFailedTask(task) ? 'border-rose-100' : isAbnormalTask(task) ? 'border-amber-100' : 'border-default',
|
||||
isCurrentTask(task.task_no) ? 'ring-1 ring-brand-200' : '',
|
||||
]"
|
||||
>
|
||||
<div
|
||||
class="absolute left-0 top-0 h-full w-1"
|
||||
:class="isFailedTask(task) ? 'bg-rose-500' : isAbnormalTask(task) ? 'bg-amber-500' : 'bg-emerald-500'"
|
||||
></div>
|
||||
<div class="mb-4 flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-mono text-sm font-bold text-primary">{{ task.task_no }}</div>
|
||||
<div class="mt-0.5 truncate text-xs text-muted">
|
||||
{{ task.source_file_name || task.customer_name || t('chat.shippingNoticeUi.currentNotice') }}
|
||||
</div>
|
||||
</div>
|
||||
<span class="rounded border px-2 py-1 text-[10px] font-bold" :class="resolveTaskStateMeta(task).className">
|
||||
{{ resolveTaskStateMeta(task).text }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 mt-4">
|
||||
<div class="scheme-stepper">
|
||||
<template v-for="(step, index) in buildShippingWorkflowSteps(task)" :key="step.id">
|
||||
<div
|
||||
class="scheme-step-node"
|
||||
:class="{
|
||||
done: step.status === 'completed',
|
||||
active: step.status === 'current',
|
||||
blocked: step.status === 'blocked',
|
||||
}"
|
||||
>
|
||||
<div class="scheme-step-dot">
|
||||
<span v-if="step.status === 'completed'">✓</span>
|
||||
<X v-else-if="step.status === 'blocked' && isFailedTask(task)" class="h-3 w-3" />
|
||||
<span v-else-if="step.status === 'blocked'">!</span>
|
||||
<span v-else>{{ index + 1 }}</span>
|
||||
</div>
|
||||
<div class="scheme-step-label">{{ t(step.label) }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="mb-3 rounded-lg border p-2.5 text-xs font-medium leading-5"
|
||||
:class="isFailedTask(task) ? 'border-rose-100 bg-rose-50 text-rose-700' : isAbnormalTask(task) ? 'border-amber-100 bg-amber-50 text-amber-700' : 'border-emerald-100 bg-emerald-50 text-emerald-700'"
|
||||
>
|
||||
<div class="font-semibold">{{ resolveTaskDiagnosis(task).title }}</div>
|
||||
<div class="mt-1 font-normal text-slate-600">{{ resolveTaskDiagnosis(task).advice }}</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
v-if="hasShortageLines(task)"
|
||||
type="button"
|
||||
class="flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-amber-100 bg-amber-50 py-1.5 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-100"
|
||||
@click="emit('query-shortage', task.task_no)"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.queryShortageDetails') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-transparent bg-surface-soft py-1.5 text-xs font-medium text-secondary transition-colors hover:border-brand-200 hover:bg-brand-50 hover:text-brand-600"
|
||||
@click="emit('focus-task', task.task_no)"
|
||||
>
|
||||
<Target class="h-3.5 w-3.5" />
|
||||
{{ t('chat.shippingNoticeUi.focusRepair') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="flex-1 rounded-lg border border-default bg-white py-1.5 text-xs font-medium text-secondary transition-colors hover:border-brand-300 hover:text-brand-700"
|
||||
@click="emit('resume-task', task.task_no)"
|
||||
>
|
||||
{{ isCompletedTask(task) ? t('chat.shippingNoticeUi.viewDetail') : t('chat.shippingNoticeUi.retrySingleTask') }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-[90] bg-slate-900/30 backdrop-blur-sm xl:hidden"
|
||||
@click="emit('update:open', false)"
|
||||
>
|
||||
<aside
|
||||
class="ml-auto flex h-full w-[min(92vw,520px)] flex-col border-l border-default bg-surface shadow-2xl"
|
||||
@click.stop
|
||||
>
|
||||
<header class="flex h-16 shrink-0 items-center justify-between border-b border-default px-4">
|
||||
<div class="font-bold text-primary">{{ t('chat.shippingNoticeUi.batchWorkspaceTitle') }}</div>
|
||||
<button type="button" class="rounded-full p-2 text-muted hover:bg-surface-soft" @click="emit('update:open', false)">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</header>
|
||||
<div class="flex-1 overflow-y-auto p-4 text-sm text-muted">
|
||||
{{ t('chat.shippingNoticeUi.mobileWorkspaceHint') }}
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.scheme-stepper {
|
||||
display: flex;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.scheme-step-node {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-width: 52px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.scheme-step-node:not(:last-child)::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: calc(50% + 11px);
|
||||
width: calc(100% - 22px);
|
||||
height: 2px;
|
||||
background: #e2e8f0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.scheme-step-node.done:not(:last-child)::after {
|
||||
background: #0284c7;
|
||||
}
|
||||
|
||||
.scheme-step-node.active:not(:last-child)::after {
|
||||
background: linear-gradient(90deg, #0284c7 50%, #e2e8f0 50%);
|
||||
}
|
||||
|
||||
.scheme-step-dot {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin: 0 auto 0.25rem;
|
||||
border: 2px solid #e2e8f0;
|
||||
border-radius: 9999px;
|
||||
background: #fff;
|
||||
color: #64748b;
|
||||
font-size: 0.55rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.scheme-step-node.done .scheme-step-dot {
|
||||
border-color: #0284c7;
|
||||
background: #0284c7;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.scheme-step-node.active .scheme-step-dot {
|
||||
border-color: #0284c7;
|
||||
box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
|
||||
color: #0284c7;
|
||||
}
|
||||
|
||||
.scheme-step-node.blocked .scheme-step-dot {
|
||||
border-color: #f59e0b;
|
||||
background: #fff;
|
||||
color: #f59e0b;
|
||||
box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
|
||||
}
|
||||
|
||||
.scheme-step-node.blocked .scheme-step-label {
|
||||
color: #d97706;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.scheme-step-label {
|
||||
color: #64748b;
|
||||
font-size: 0.58rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.scheme-step-node.active .scheme-step-label {
|
||||
color: #0284c7;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user