refactor(chat/shipping): 重构发货通知模块为统一UI State驱动模式
- 重构发货通知的状态与动作获取逻辑:移除从聊天文本解析HXOPS_SHIPPING_ACTIONS注释的旧逻辑,改为统一从后端shipping_ui_state获取任务状态、动作按钮与工作流步骤 - 新增SSE实时推送shipping_ui_state事件,支持前端即时更新聊天气泡与工作台的状态与按钮 - 优化路由与登录流程:调整根路径重定向逻辑,退出登录时跳转到登录页;移除chat路由不必要的props传参;将原路由守卫中的根路径判断迁移到路由配置中 - 完善库存RPA与本地导入流程:新增本地库存文件托管接口,优化RPA回调的文件落盘与任务关联逻辑 - 新增多组单元测试覆盖焦点切换、决策处理、SSE同步等核心场景 - 修复多语言显示逻辑,使用te方法判断翻译key是否存在,避免缺失翻译时的渲染异常 - 新增reparse_inventory菜单动作,支持静默重新解析库存且不追加额外聊天消息 - 重构工作流步骤渲染函数,优先使用后端返回的步骤数据, fallback到本地推导的旧逻辑 - 清理后端旧的chat-actions API接口,将相关逻辑迁移到统一的ui_state接口中
This commit is contained in:
commit
9c036c825b
39 files changed
+3114
-456
No files matched your search
@@ -10,7 +10,7 @@ import { AlertTriangle, List, RefreshCw } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { retryWorkspaceShippingBatchPending } from '@/features/chat/api/shipping.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { buildShippingWorkflowSteps } from '@/features/chat/shipping';
|
||||
import { resolveShippingWorkflowSteps } from '@/features/chat/shipping';
|
||||
import type {
|
||||
ShippingBatchSummary,
|
||||
ShippingConversationWorkspace,
|
||||
@@ -102,7 +102,9 @@ const executionStateMeta = computed(() => {
|
||||
};
|
||||
});
|
||||
|
||||
const activeTaskSteps = computed(() => buildShippingWorkflowSteps(props.activeTaskDetail));
|
||||
const activeTaskSteps = computed(() => (
|
||||
resolveShippingWorkflowSteps(props.activeTaskDetail)
|
||||
));
|
||||
const activeStepIndex = computed(() => {
|
||||
const index = activeTaskSteps.value.findIndex((step) => step.status === 'current' || step.status === 'blocked');
|
||||
return index >= 0 ? index : Math.max(0, activeTaskSteps.value.length - 1);
|
||||
@@ -112,7 +114,7 @@ const activeStepLabel = computed(() => {
|
||||
return step ? t('chat.shippingNoticeUi.stepHeadline', {
|
||||
current: activeStepIndex.value + 1,
|
||||
total: activeTaskSteps.value.length,
|
||||
label: t(step.label),
|
||||
label: step.label.startsWith('chat.') ? t(step.label) : step.label,
|
||||
}) : '--';
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
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 { resolveShippingWorkflowSteps, type ShippingWorkflowStepItem } from '@/features/chat/shipping';
|
||||
import { hasShortageLines } from '@/features/chat/shipping/shippingShortageDetails';
|
||||
import type {
|
||||
ShippingBatchSummary,
|
||||
@@ -126,17 +126,21 @@ const resolveTaskStateMeta = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
return { text: t('chat.shippingNoticeUi.runningState'), className: 'border-sky-100 bg-sky-50 text-brand-700' };
|
||||
};
|
||||
|
||||
const taskWorkflowSteps = (task: ShippingTaskSummary | ShippingTaskDetail) => (
|
||||
resolveShippingWorkflowSteps(task)
|
||||
);
|
||||
|
||||
const taskStepNumber = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
resolveActiveStep(buildShippingWorkflowSteps(task)) + 1;
|
||||
resolveActiveStep(taskWorkflowSteps(task)) + 1;
|
||||
|
||||
const taskStepHeadline = (task: ShippingTaskSummary | ShippingTaskDetail) => {
|
||||
const steps = buildShippingWorkflowSteps(task);
|
||||
const steps = taskWorkflowSteps(task);
|
||||
const index = resolveActiveStep(steps);
|
||||
const step = steps[index];
|
||||
return step ? t('chat.shippingNoticeUi.stepHeadline', {
|
||||
current: index + 1,
|
||||
total: steps.length,
|
||||
label: t(step.label),
|
||||
label: step.label.startsWith('chat.') ? t(step.label) : step.label,
|
||||
}) : t('chat.shippingNoticeUi.stepFraction', { current: index + 1, total: steps.length });
|
||||
};
|
||||
|
||||
@@ -144,6 +148,13 @@ const currentStepProgress = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
task.step_payload?.current_step_progress || null;
|
||||
|
||||
const resolveTaskDiagnosis = (task: ShippingTaskSummary | ShippingTaskDetail) => {
|
||||
const uiSummary = task.ui_state?.summary;
|
||||
if (uiSummary?.title || uiSummary?.message || uiSummary?.error_message) {
|
||||
return {
|
||||
title: uiSummary.error_message || uiSummary.title || t('chat.shippingNoticeUi.diagnosisStepWaitingTitle', { step: taskStepNumber(task) }),
|
||||
advice: uiSummary.message || t('chat.shippingNoticeUi.diagnosisStepWaitingAdvice'),
|
||||
};
|
||||
}
|
||||
const reason = String(task.pending_human_reason || '').trim();
|
||||
const reviewStatus = String(task.review_status || '').trim();
|
||||
const processStatus = String(task.process_status || '').trim();
|
||||
@@ -226,6 +237,9 @@ const resolveTaskDiagnosis = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
};
|
||||
|
||||
const resolveSuggestedAction = (task: ShippingTaskSummary | ShippingTaskDetail) => {
|
||||
if (task.ui_state?.action_buttons?.length) {
|
||||
return task.ui_state.action_buttons.map((action) => action.label).join(' / ');
|
||||
}
|
||||
const reason = String(task.pending_human_reason || '').trim();
|
||||
const reviewStatus = String(task.review_status || '').trim();
|
||||
if (hasShortageLines(task) || reason === 'shortage' || reviewStatus === 'shortage_review') {
|
||||
@@ -246,7 +260,7 @@ const resolveSuggestedAction = (task: ShippingTaskSummary | ShippingTaskDetail)
|
||||
return t('chat.shippingNoticeUi.suggestContinue');
|
||||
};
|
||||
|
||||
const resolveActiveStep = (steps: ShippingWorkflowStepItem[]) => {
|
||||
const resolveActiveStep = (steps: Array<ShippingWorkflowStepItem | { status: string }>) => {
|
||||
const activeIndex = steps.findIndex((step) => step.status === 'current' || step.status === 'blocked');
|
||||
return activeIndex >= 0 ? activeIndex : Math.max(0, steps.length - 1);
|
||||
};
|
||||
@@ -413,7 +427,7 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
|
||||
<div class="my-3">
|
||||
<div class="scheme-stepper">
|
||||
<template v-for="(step, index) in buildShippingWorkflowSteps(task)" :key="step.id">
|
||||
<template v-for="(step, index) in taskWorkflowSteps(task)" :key="step.id">
|
||||
<div
|
||||
class="scheme-step-node"
|
||||
:class="{
|
||||
@@ -428,7 +442,7 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
<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 class="scheme-step-label">{{ step.label.startsWith('chat.') ? t(step.label) : step.label }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,8 @@ defineProps<{
|
||||
compact?: boolean;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t, te } = useI18n();
|
||||
const displayLabel = (label: string) => (te(label) ? t(label) : label);
|
||||
const stepClass = (status: ShippingWorkflowStepItem['status']) => {
|
||||
if (status === 'completed') return 'border-emerald-200 bg-emerald-50 text-emerald-700';
|
||||
if (status === 'current') return 'border-brand-300 bg-brand-50 text-brand-700';
|
||||
@@ -43,7 +44,7 @@ const dotClass = (status: ShippingWorkflowStepItem['status']) => {
|
||||
<span class="inline-flex h-5 min-w-5 items-center justify-center rounded-full text-[11px] font-semibold text-white" :class="dotClass(step.status)">
|
||||
{{ index + 1 }}
|
||||
</span>
|
||||
<span class="text-xs font-semibold">{{ t(step.label) }}</span>
|
||||
<span class="text-xs font-semibold">{{ displayLabel(step.label) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -192,26 +192,38 @@ const downloadExcel = async () => {
|
||||
<span>开始:{{ formatTime(run.started_at) }} · 完成:{{ formatTime(run.finished_at) }}</span>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-2 md:grid-cols-5">
|
||||
<div class="rounded-xl bg-white/80 px-3 py-2">
|
||||
<div class="text-xs text-slate-500">总数</div>
|
||||
<div class="text-lg font-bold text-slate-800">{{ run.total_count }}</div>
|
||||
<div class="grid grid-cols-2 gap-1.5 sm:grid-cols-4 lg:grid-cols-8">
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">总数</div>
|
||||
<div class="text-base font-bold text-slate-800">{{ run.total_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-white/80 px-3 py-2">
|
||||
<div class="text-xs text-slate-500">已处理</div>
|
||||
<div class="text-lg font-bold text-sky-700">{{ run.processed_count }}</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">已处理</div>
|
||||
<div class="text-base font-bold text-sky-700">{{ run.processed_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-white/80 px-3 py-2">
|
||||
<div class="text-xs text-slate-500">成功</div>
|
||||
<div class="text-lg font-bold text-emerald-700">{{ run.success_count }}</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">成功</div>
|
||||
<div class="text-base font-bold text-emerald-700">{{ run.success_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-white/80 px-3 py-2">
|
||||
<div class="text-xs text-slate-500">失败</div>
|
||||
<div class="text-lg font-bold text-rose-700">{{ run.failed_count }}</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">失败</div>
|
||||
<div class="text-base font-bold text-rose-700">{{ run.failed_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-white/80 px-3 py-2">
|
||||
<div class="text-xs text-slate-500">跳过</div>
|
||||
<div class="text-lg font-bold text-amber-700">{{ run.skipped_count }}</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">跳过</div>
|
||||
<div class="text-base font-bold text-amber-700">{{ run.skipped_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">合格笔数</div>
|
||||
<div class="text-base font-bold text-emerald-700">{{ run.judgement?.qualified_count ?? 0 }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">不合格笔数</div>
|
||||
<div class="text-base font-bold text-rose-700">{{ run.judgement?.unqualified_count ?? 0 }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">人工判定笔数</div>
|
||||
<div class="text-base font-bold text-amber-700">{{ run.judgement?.manual_count ?? 0 }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user