Merge branch 'dev' into order-delivery-reply
# Conflicts: # .env.shared # backend/app/api/chat.py # backend/app/core/config/settings.py # backend/app/models/user.py # backend/app/services/admin/permission_service.py # docs/demand.md # frontend/src/app/router/routes/workspace.routes.ts # frontend/src/features/admin/modules/users/components/UserFormModal.vue # frontend/src/features/admin/modules/users/composables/useUsersAdmin.ts # frontend/src/features/admin/types/user.types.ts # frontend/src/features/auth/stores/auth.store.ts # frontend/src/features/user/views/UserProfilePage.vue # frontend/src/locales/en/admin.json # frontend/src/locales/en/errors.json # frontend/src/locales/th/admin.json # frontend/src/locales/th/errors.json # frontend/src/locales/zh-CN/admin.json # frontend/src/locales/zh-CN/errors.json # frontend/src/locales/zh-TW/admin.json # frontend/src/locales/zh-TW/errors.json # frontend/src/shared/utils/auth.ts
This commit is contained in:
commit
616034a4cd
541 files changed
+43805
-14767
No files matched your search
@@ -4,6 +4,7 @@
|
||||
* 依赖:lucide 图标、附件完整性判断工具。
|
||||
* 逻辑:附件卡片位于文本框上方;订单审核结果随对应聊天消息展示,输入区只保留附件处理状态。
|
||||
* 同时支持采购合同双文件输入控件:底部左区放附件/合同等工具,右区语音与发送并排;采购合同审查用专用上传按钮,不展示通用回形针附件入口。
|
||||
* 货代订单抽取提交中(isOrderExtractionSubmitting)时发送钮展示 Loader,免责声明区提示提交中。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
@@ -58,6 +59,8 @@ const props = defineProps<{
|
||||
isVoiceRecording: boolean;
|
||||
isVoiceTranscribing: boolean;
|
||||
isUploadingAttachments: boolean;
|
||||
/** 货代订单抽取统一提交进行中;为 true 时发送钮 Loader 且禁用。 */
|
||||
isOrderExtractionSubmitting?: boolean;
|
||||
canSendMessage: boolean;
|
||||
isShippingNoticeAgent: boolean;
|
||||
isProcurementContractAgent?: boolean;
|
||||
@@ -843,7 +846,7 @@ watch(
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="isThinking && !isUploadingAttachments"
|
||||
v-if="isThinking && !isUploadingAttachments && !isOrderExtractionSubmitting"
|
||||
type="button"
|
||||
class="flex h-10 w-10 items-center justify-center rounded-full border border-rose-300 bg-rose-50 text-rose-600 shadow-sm transition-all duration-200 hover:scale-105 hover:bg-rose-100 active:scale-95"
|
||||
:title="$t('chat.stopGenerating')"
|
||||
@@ -862,14 +865,15 @@ watch(
|
||||
: 'border-brand-500 bg-brand-500 text-white shadow-[0_0_0_4px_rgba(59,130,246,0.18)] hover:scale-105 hover:bg-brand-600 hover:shadow-[0_0_0_6px_rgba(59,130,246,0.24)] active:scale-95'"
|
||||
@click="emit('send')"
|
||||
>
|
||||
<Loader2 v-if="isUploadingAttachments" class="h-4 w-4 animate-spin" />
|
||||
<Loader2 v-if="isUploadingAttachments || isOrderExtractionSubmitting" class="h-4 w-4 animate-spin" />
|
||||
<Send v-else class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 text-center text-[11px] text-muted">
|
||||
<span v-if="isThinking">{{ $t('chat.thinking') }}</span>
|
||||
<span v-if="isOrderExtractionSubmitting">{{ $t('chat.shippingNoticeSubmitting') }}</span>
|
||||
<span v-else-if="isThinking">{{ $t('chat.thinking') }}</span>
|
||||
<span v-else>{{ $t('chat.disclaimer') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -54,7 +54,6 @@ const {
|
||||
pinMessagesToBottom?: boolean;
|
||||
/** 供父级滚动逻辑绑定 main 元素 */
|
||||
scrollContainerHolder: { el: Ref<HTMLElement | null> };
|
||||
compactShippingProgress?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -68,7 +67,6 @@ const emit = defineEmits<{
|
||||
'maintenance-edit-record': [record: MaintenanceRecord];
|
||||
'maintenance-view-record-history': [device: MaintenanceDevice];
|
||||
'maintenance-create-record-for-device': [device: MaintenanceDevice];
|
||||
'open-batch-workbench': [];
|
||||
/** 在途仓自动调拨:业务流激活时向上冒泡,父级据此隐藏聊天输入框。 */
|
||||
'transfer-flow-active': [active: boolean];
|
||||
}>();
|
||||
@@ -207,7 +205,6 @@ const hasFollowingShippingProgressCard = (items: ChatMessage[], index: number):
|
||||
:leave-handlers="leaveHandlers"
|
||||
:shipping-handlers="shippingHandlers"
|
||||
:training-handlers="trainingHandlers"
|
||||
:compact-shipping-progress="compactShippingProgress"
|
||||
:attachment-summary-only="hasFollowingShippingProgressCard(messages, index)"
|
||||
@copy="emit('copy', { message: msg, index })"
|
||||
@edit="emit('edit', $event)"
|
||||
@@ -217,7 +214,6 @@ const hasFollowingShippingProgressCard = (items: ChatMessage[], index: number):
|
||||
@maintenance-edit-record="emit('maintenance-edit-record', $event)"
|
||||
@maintenance-view-record-history="emit('maintenance-view-record-history', $event)"
|
||||
@maintenance-create-record-for-device="emit('maintenance-create-record-for-device', $event)"
|
||||
@open-batch-workbench="emit('open-batch-workbench')"
|
||||
/>
|
||||
<ToolRunProgressCard
|
||||
v-if="shouldRenderMessage(msg) && shouldShowToolRunProgressAfterMessage(msg, index)"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/chat/components/ChatMobileHeader.vue
|
||||
* 移动端顶栏:Agent 名称、学习之窗与 Agent 切换弹层。
|
||||
* 移动端顶栏:Agent 名称、学习之窗与 Agent 切换弹层。作业面 Agent 可隐藏历史入口。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
@@ -15,6 +15,7 @@ defineProps<{
|
||||
activeAgentId: number;
|
||||
hasAgentGuides: boolean;
|
||||
userAgents: ChatMobileHeaderAgent[];
|
||||
hideHistory?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -85,6 +86,7 @@ onBeforeUnmount(() => {
|
||||
<LayoutGrid class="h-5 w-5" />
|
||||
</button>
|
||||
<button
|
||||
v-if="!hideHistory"
|
||||
type="button"
|
||||
class="flex h-9 w-9 items-center justify-center rounded-full text-muted transition-colors hover-surface-soft"
|
||||
:title="$t('chat.history')"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 依赖:lucide-vue-next、LocaleToggleButton、ExternalSystemLinks、AgentCategoryList、chat.types。
|
||||
* 逻辑:由聊天页面传入当前 Agent、历史记录与用户可用 Agent;通过事件把新会话、切换 Agent、反馈、进入管理控制台等操作回传给页面。
|
||||
* 管理员通过底部右侧工具图标进入管理控制台;用户下拉菜单仅保留退出登录。
|
||||
* 关联服务入口与主题/语言等底栏图标统一为同尺寸 inline icon 按钮,避免错位。
|
||||
* 合同付款预警、立账凭证第一期不走对话,hideSessionUi 时隐藏新会话与历史列表。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
@@ -48,6 +48,7 @@ const props = defineProps<{
|
||||
userAgents: ChatSidebarAgent[];
|
||||
currentUser: Record<string, unknown> | null;
|
||||
appliedTheme: string;
|
||||
hideSessionUi?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -198,13 +199,16 @@ const orderExtractionAttentionClass = (item: DisplayHistoryItem) => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="px-4 pb-4">
|
||||
<div v-if="!hideSessionUi" class="px-4 pb-4">
|
||||
<button type="button" class="chat-sidebar-btn" @click="onNewChat">
|
||||
<Plus class="h-4 w-4" /> {{ $t('chat.createNewChat') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-else class="px-4 pb-3 text-xs leading-5 text-muted">
|
||||
{{ $t('chat.taskAgent.sessionHint') }}
|
||||
</p>
|
||||
|
||||
<div class="flex items-center justify-between px-4 py-2">
|
||||
<div v-if="!hideSessionUi" class="flex items-center justify-between px-4 py-2">
|
||||
<span class="text-xs font-semibold text-muted">{{ $t('chat.history') }}</span>
|
||||
<button
|
||||
v-if="displayHistory.length > 0"
|
||||
@@ -216,7 +220,7 @@ const orderExtractionAttentionClass = (item: DisplayHistoryItem) => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="scrollbar-thin flex-1 overflow-y-auto px-2">
|
||||
<div v-if="!hideSessionUi" class="scrollbar-thin flex-1 overflow-y-auto px-2">
|
||||
<div v-if="displayHistory.length === 0" class="py-8 text-center text-sm italic text-muted">
|
||||
{{ $t('chat.noHistory') }}
|
||||
</div>
|
||||
|
||||
@@ -4,17 +4,18 @@
|
||||
|
||||
* 用途:对话页主区域,组合侧栏、消息列表、输入栏、货代会话 Workflow 时间线与内置浏览器。
|
||||
|
||||
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingWorkflowTimeline、chat.context。
|
||||
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingWorkflowTimeline、ContractPaymentChatPanel、VoucherCheckChatPanel、chunkLoadRecovery、chat.context。
|
||||
|
||||
* 逻辑:本文件只做页面结构编排;货代 Chat 仅上传/进度通知,履约写操作不在本页;
|
||||
* 右侧「本次处理」由 conversationId 驱动 Workflow projection,extractionRunNo 仅作进度装饰;
|
||||
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js。
|
||||
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js;合同付款预警、立账凭证 Agent 用 Tab 作业面替换消息列表与输入框;
|
||||
* 货代会话主区域:有会话即全屏批次进度中心(常驻),无会话为欢迎页+输入框,会话标题取自侧栏历史并传给中心。
|
||||
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import { computed, defineAsyncComponent, provide, ref, watch } from 'vue';
|
||||
import { computed, provide, ref, watch } from 'vue';
|
||||
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
@@ -34,6 +35,8 @@ import ChatBrowserPanel from '@/features/chat/components/ChatBrowserPanel.vue';
|
||||
|
||||
import ShippingWorkflowTimeline from '@/features/chat/components/shipping/ShippingWorkflowTimeline.vue';
|
||||
|
||||
import { shouldShowShippingWorkbench } from '@/features/chat/shipping/shippingWorkbenchLayout';
|
||||
|
||||
import TrainingWorkspacePanel from '@/features/chat/components/TrainingWorkspacePanel.vue';
|
||||
|
||||
import LedgerConfigPanel from '@/features/maintenance/components/LedgerConfigPanel.vue';
|
||||
@@ -44,7 +47,7 @@ import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
|
||||
import { matchesTrainingAgent } from '@/features/chat/training/trainingWorkspace.utils';
|
||||
|
||||
import { agentHasIntentUiProfile, resolveAgentCode, AGENT_CODE_IN_TRANSIT_TRANSFER } from '@/shared/utils/agent-registry.utils';
|
||||
import { agentHasIntentUiProfile, resolveAgentCode, AGENT_CODE_IN_TRANSIT_TRANSFER, isContractPaymentAgent, isVoucherCheckAgent } from '@/shared/utils/agent-registry.utils';
|
||||
|
||||
import {
|
||||
SHIPPING_WORKFLOW_KEY,
|
||||
@@ -65,11 +68,21 @@ import {
|
||||
|
||||
} from '@/features/maintenance/utils/maintenance-panel-layout.utils';
|
||||
|
||||
import { defineRecoverableAsyncComponent } from '@/shared/utils/chunkLoadRecovery';
|
||||
|
||||
/** 复核工作台按需分包:仅 order-review 模式加载,避免 Chat 首屏带上 PDF.js。 */
|
||||
const ShippingOrderReviewView = defineAsyncComponent(
|
||||
const ShippingOrderReviewView = defineRecoverableAsyncComponent(
|
||||
() => import('@/features/chat/views/ShippingOrderReviewView.vue'),
|
||||
);
|
||||
|
||||
const ContractPaymentChatPanel = defineRecoverableAsyncComponent(
|
||||
() => import('@/features/contract-payment/components/ContractPaymentChatPanel.vue'),
|
||||
);
|
||||
|
||||
const VoucherCheckChatPanel = defineRecoverableAsyncComponent(
|
||||
() => import('@/features/voucher-check/components/VoucherCheckChatPanel.vue'),
|
||||
);
|
||||
|
||||
type MaintenanceRecordPanelCommand = {
|
||||
|
||||
mode: 'list' | 'create';
|
||||
@@ -114,42 +127,32 @@ const isMaintenanceAgentPage = computed(() => agentHasIntentUiProfile(page.curre
|
||||
/** 在途仓自动调拨 Agent:无消息时展示专属首页入口区(决策:补 Chat 首页入口 A 方案)。 */
|
||||
const isInTransitTransferAgent = computed(() => resolveAgentCode(page.currentAgent) === AGENT_CODE_IN_TRANSIT_TRANSFER);
|
||||
|
||||
/** 合同付款预警 Agent:主区嵌台账 Tab,隐藏对话输入与历史。 */
|
||||
const isContractPaymentAgentPage = computed(() => isContractPaymentAgent(page.currentAgent));
|
||||
|
||||
/** 立账凭证 Agent:主区嵌检核任务 / 企微发送记录 Tab,隐藏对话输入与历史。 */
|
||||
const isVoucherCheckAgentPage = computed(() => isVoucherCheckAgent(page.currentAgent));
|
||||
|
||||
/** builtin 作业面 Agent 共用:隐藏新会话、历史列表与输入框。 */
|
||||
const hideTaskChatSessionUi = computed(() => isContractPaymentAgentPage.value || isVoucherCheckAgentPage.value);
|
||||
|
||||
/** 在途仓自动调拨业务流激活(来源选择/待处理等子视图)时隐藏聊天输入框,模拟业务页。 */
|
||||
const transferFlowActive = ref(false);
|
||||
watch(isInTransitTransferAgent, (isTransfer) => { if (!isTransfer) transferFlowActive.value = false; });
|
||||
|
||||
/** 批次进度工作台按需打开;关闭时不占用对话区右侧布局。 */
|
||||
const batchWorkbenchOpen = ref(false);
|
||||
|
||||
|
||||
|
||||
const showShippingWorkflowTimeline = computed(() => (
|
||||
page.isShippingNoticeAgent
|
||||
&& batchWorkbenchOpen.value
|
||||
&& Boolean(activeShippingConversationId.value)
|
||||
));
|
||||
|
||||
const compactShippingProgress = computed(() => batchWorkbenchOpen.value);
|
||||
|
||||
function openBatchWorkbench() {
|
||||
batchWorkbenchOpen.value = true;
|
||||
}
|
||||
|
||||
function closeBatchWorkbench() {
|
||||
batchWorkbenchOpen.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批次中心只服务于用户主动打开时所在的会话。切换历史会话或 Agent 后必须关闭,
|
||||
* 否则旧会话的右侧投影会短暂占用新会话的对话区并造成“本次处理”串批错觉。
|
||||
* 货代发货会话主区域规则(方案 A):
|
||||
* 有会话 ID → 全屏批次进度中心(常驻不可关闭);无会话 → 欢迎页 + 输入框(唯一提交入口)。
|
||||
*/
|
||||
watch(
|
||||
() => [activeShippingConversationId.value, Number(page.currentAgentId || 0)] as const,
|
||||
(next, previous) => {
|
||||
if (!previous || next[0] === previous[0] && next[1] === previous[1]) return;
|
||||
batchWorkbenchOpen.value = false;
|
||||
},
|
||||
);
|
||||
const showShippingWorkflowTimeline = computed(() => shouldShowShippingWorkbench({
|
||||
isShippingNoticeAgent: page.isShippingNoticeAgent,
|
||||
conversationId: activeShippingConversationId.value,
|
||||
}));
|
||||
|
||||
/** 侧栏历史项中的会话标题;批次中心头部直接复用,保持侧栏与中心一致。 */
|
||||
const activeShippingConversationTitle = computed(() => (
|
||||
page.displayHistory.find((item) => item.conversation_id === activeShippingConversationId.value)?.title || ''
|
||||
));
|
||||
|
||||
const embeddedIframeSrc = computed(() => {
|
||||
|
||||
@@ -391,6 +394,8 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
:applied-theme="page.appliedTheme"
|
||||
|
||||
:hide-session-ui="hideTaskChatSessionUi"
|
||||
|
||||
@new-chat="page.handleSidebarNewChat"
|
||||
|
||||
@open-guide="page.openGuideModal"
|
||||
@@ -432,6 +437,8 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
:user-agents="page.userAgents"
|
||||
|
||||
:hide-history="hideTaskChatSessionUi"
|
||||
|
||||
@open-guide="page.openGuideModal"
|
||||
|
||||
@go-history="page.goToWorkspace('history')"
|
||||
@@ -474,9 +481,14 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
<ShippingOrderReviewView v-if="isOrderReviewMode" />
|
||||
|
||||
<div v-else class="flex min-h-0 min-w-0 flex-1" :class="showShippingWorkflowTimeline ? 'shipping-workbench-layout' : ''">
|
||||
<ContractPaymentChatPanel v-else-if="isContractPaymentAgentPage" />
|
||||
|
||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col" :class="showShippingWorkflowTimeline ? 'shipping-chat-column' : ''">
|
||||
<VoucherCheckChatPanel v-else-if="isVoucherCheckAgentPage" />
|
||||
|
||||
<div v-else class="flex min-h-0 min-w-0 flex-1">
|
||||
|
||||
<!-- 中心展示时对话列整体隐藏(含输入框),新文件提交走新建对话(spec 方案 A 硬性决策)。 -->
|
||||
<div v-show="!showShippingWorkflowTimeline" class="flex min-h-0 min-w-0 flex-1 flex-col">
|
||||
|
||||
<TrainingWorkspacePanel
|
||||
|
||||
@@ -556,8 +568,6 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
:scroll-container-holder="page.scrollContainerHolder"
|
||||
|
||||
:compact-shipping-progress="compactShippingProgress"
|
||||
|
||||
@copy="page.copyToClipboard($event.message, $event.index)"
|
||||
|
||||
@edit="page.input = $event"
|
||||
@@ -578,8 +588,6 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
@maintenance-create-record-for-device="openMaintenanceRecordCreate"
|
||||
|
||||
@open-batch-workbench="openBatchWorkbench"
|
||||
|
||||
@transfer-flow-active="transferFlowActive = $event"
|
||||
|
||||
/>
|
||||
@@ -608,6 +616,8 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
:is-uploading-attachments="page.isUploadingAttachments"
|
||||
|
||||
:is-order-extraction-submitting="page.isOrderExtractionSubmitting"
|
||||
|
||||
:can-send-message="page.canSendMessage"
|
||||
|
||||
:is-shipping-notice-agent="page.isShippingNoticeAgent"
|
||||
@@ -666,10 +676,9 @@ watch(() => page.currentAgentId, () => {
|
||||
<ShippingWorkflowTimeline
|
||||
v-if="showShippingWorkflowTimeline"
|
||||
:conversation-id="activeShippingConversationId"
|
||||
:conversation-title="activeShippingConversationTitle"
|
||||
:refresh-trigger="page.workflowRefreshTrigger"
|
||||
:controller="shippingProcessing"
|
||||
|
||||
@close="closeBatchWorkbench"
|
||||
/>
|
||||
|
||||
|
||||
@@ -820,16 +829,3 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/** 打开批次工作台后,左侧对话保留为压缩入口,右侧取得主工作区宽度。 */
|
||||
@media (min-width: 1024px) {
|
||||
.shipping-workbench-layout {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.shipping-chat-column {
|
||||
flex: 0 0 clamp(360px, 32vw, 520px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -500,6 +500,17 @@ const stopNonSafetyVideoTimer = () => {
|
||||
workspace.stopMaterialTimer();
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理普通培训主视频播放结束事件。
|
||||
* AI 触发时机:学员完整播放当前主视频到结尾时调用;仅出国规章培训将视频播放结束作为一次学习完成,其他培训类型保持现有阶段推进入口。
|
||||
*/
|
||||
const handleNonSafetyVideoEnded = () => {
|
||||
stopNonSafetyVideoTimer();
|
||||
if (workspace.isOverseasRegulationsTraining) {
|
||||
workspace.markVideoCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
watch([() => workspace.learnerTab, nonSafetyVideoMaterials], () => {
|
||||
if (!nonSafetyVideoMaterials.value.some((material) => material.id === activeNonSafetyVideoId.value)) {
|
||||
activeNonSafetyVideoId.value = nonSafetyVideoMaterials.value[0]?.id ?? null;
|
||||
@@ -589,8 +600,8 @@ const leanStatusMeta: Record<LeanTrainingTaskStatus, { badgeClass: string; label
|
||||
/** 看板总结弹框上下文:员工姓名 + 完整总结文案;为 null 时弹框关闭。 */
|
||||
const summaryModal = ref<{ name: string; text: string } | null>(null);
|
||||
|
||||
/** 总结列预览截断:最多显示 15 个字,超出部分以省略号收尾,点击可弹框查看全文。 */
|
||||
const truncateSummary = (text: string) => (text.length > 15 ? `${text.slice(0, 15)}…` : text);
|
||||
/** 总结列预览截断:最多显示 4 个字,超出部分以省略号收尾,点击可弹框查看全文。 */
|
||||
const truncateSummary = (text: string) => (text.length > 4 ? `${text.slice(0, 4)}…` : text);
|
||||
|
||||
/** 打开总结详情弹框:仅当该行有总结文案时可点击(无总结的行显示 "--" 不可点)。 */
|
||||
const openSummaryModal = (name: string, text: string) => {
|
||||
@@ -992,7 +1003,7 @@ const currentSafetyStageText = computed(() => {
|
||||
:src="activeNonSafetyVideo.resource?.fileUrl"
|
||||
@play="startNonSafetyVideoTimer"
|
||||
@pause="stopNonSafetyVideoTimer"
|
||||
@ended="stopNonSafetyVideoTimer"
|
||||
@ended="handleNonSafetyVideoEnded"
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="mt-3 rounded-2xl border border-dashed border-default bg-surface-soft px-4 py-10 text-center text-sm text-muted">
|
||||
@@ -1831,6 +1842,10 @@ const currentSafetyStageText = computed(() => {
|
||||
>
|
||||
<option v-for="period in workspace.leanDashboard.periods" :key="period.id" :value="period.id">{{ $t('chat.training.lean.dashboard.periodLabel', { index: period.index }) }}({{ period.weekKey }})</option>
|
||||
</select>
|
||||
<button type="button" class="inline-flex items-center gap-1.5 rounded-lg bg-emerald-600 px-2.5 py-1.5 text-xs font-medium text-white transition hover:bg-emerald-700 disabled:cursor-not-allowed disabled:opacity-60" :disabled="workspace.leanExportLoading" @click="workspace.exportLeanDashboard">
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ workspace.leanExportLoading ? $t('chat.training.lean.dashboard.exporting') : $t('chat.training.lean.dashboard.export') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-full bg-white px-3 py-1 text-xs font-medium text-emerald-700">{{ $t('chat.training.lean.dueAt', { time: workspace.leanDashboard.task.dueAt.slice(0, 16).replace('T', ' ') }) }}</div>
|
||||
@@ -1862,7 +1877,7 @@ const currentSafetyStageText = computed(() => {
|
||||
<td class="border-b border-default px-3 py-2.5 text-secondary"><div v-for="video in row.videos" :key="`${video.name}-${video.watchedAt}`" class="whitespace-nowrap">{{ video.watchedAt ? video.watchedAt.slice(0, 16).replace('T', ' ') : '--' }}</div><span v-if="!row.videos.length">--</span></td>
|
||||
<!-- 状态徽章三态:已完成(绿)/已延期(红)/进行中(蓝),文案统一中文(含其余三语言),禁止回显原始键。 -->
|
||||
<td class="border-b border-default px-3 py-2.5"><span class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold" :class="row.status === 'completed' ? 'bg-emerald-50 text-emerald-700' : row.status === 'overdue' ? 'bg-red-50 text-red-700' : 'bg-blue-50 text-blue-700'">{{ $t(`chat.training.lean.status.${row.status}`) }}</span></td>
|
||||
<!-- [RULE] 总结列最多显示 15 个字:超出截断并显示省略号,点击弹框查看全部文案;无总结显示 "--"。
|
||||
<!-- [RULE] 总结列最多显示 4 个字:超出截断并显示省略号,点击弹框查看全部文案;无总结显示 "--"。
|
||||
常显虚线下划线提示可点击(用户复测反馈点击无效,实为部署版本差异,此处强化可点性视觉)。 -->
|
||||
<td class="border-b border-default px-3 py-2.5 text-secondary">
|
||||
<button v-if="row.summaryText" type="button" class="max-w-56 cursor-pointer text-left whitespace-pre-wrap break-words underline decoration-dotted decoration-secondary/60 underline-offset-2 transition hover:decoration-solid hover:text-primary" :title="$t('chat.training.lean.summaryModal.viewHint')" @click="openSummaryModal(row.name, row.summaryText)">{{ truncateSummary(row.summaryText) }}</button>
|
||||
|
||||
@@ -75,7 +75,6 @@ const {
|
||||
leaveHandlers: LeaveMessageHandlers;
|
||||
shippingHandlers: ShippingMessageHandlers;
|
||||
trainingHandlers: TrainingHandlers;
|
||||
compactShippingProgress?: boolean;
|
||||
/** 下方已有货代进度卡时,用户气泡附件只显示摘要。 */
|
||||
attachmentSummaryOnly?: boolean;
|
||||
}>();
|
||||
@@ -89,7 +88,6 @@ const emit = defineEmits<{
|
||||
'maintenance-edit-record': [record: MaintenanceRecord];
|
||||
'maintenance-view-record-history': [device: MaintenanceDevice];
|
||||
'maintenance-create-record-for-device': [device: MaintenanceDevice];
|
||||
'open-batch-workbench': [];
|
||||
}>();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
@@ -747,11 +745,9 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
:retrying="retryingOrderExtraction"
|
||||
:refreshing="refreshingOrderExtraction"
|
||||
:cancelling="cancellingOrderExtraction"
|
||||
:compact-progress="compactShippingProgress"
|
||||
@retry="retryShippingOrderExtraction"
|
||||
@refresh="refreshShippingOrderExtraction"
|
||||
@cancel="cancelShippingOrderExtraction"
|
||||
@open-batch-workbench="emit('open-batch-workbench')"
|
||||
/>
|
||||
<LeaveMessageBlock
|
||||
v-if="isLeaveMessage"
|
||||
|
||||
+54
@@ -22,6 +22,7 @@ const i18n = createI18n({
|
||||
actionCodes: {
|
||||
reload_inventory_result: '重新读取库存结果',
|
||||
retry_inventory_preparation: '重新获取库存',
|
||||
confirm_customer: '确认客户',
|
||||
},
|
||||
inventoryActions: {
|
||||
reloadInventoryResult: '重新读取库存结果',
|
||||
@@ -337,4 +338,57 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
// 关键断言:无 statusDetail 时说明行完全不渲染,不留空壳。
|
||||
expect(wrapper.find('[data-testid="review-current-task-status-detail"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders the suggested next action instead of the reason text when next_action is present', () => {
|
||||
// v4 语义分离:「下一步」给建议动作(确认客户),原因文案(客户尚未确认)
|
||||
// 属于阻塞原因位,不得再挤进下一步槽位。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: {
|
||||
code: 'customer_unresolved',
|
||||
message: '客户尚未确认',
|
||||
nextAction: 'confirm_customer',
|
||||
} as any,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text()).toBe('确认客户');
|
||||
});
|
||||
|
||||
it('hides the generic run-level status detail when a specific blocking reason is shown', () => {
|
||||
// v4 去重:具体阻断原因已由「下一步」承载时,泛化的「当前步骤需要人工处理」属纯重复。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: {
|
||||
code: 'customer_unresolved',
|
||||
message: '客户尚未确认',
|
||||
nextAction: 'confirm_customer',
|
||||
} as any,
|
||||
statusDetail: { text: '当前步骤需要人工处理' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="review-current-task-status-detail"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps the run-level status detail when the blocking reason is generic', () => {
|
||||
// 无具体原因(未知码、无契约文案)时,Run 级等待说明仍是唯一信息,必须保留。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: { code: 'internal_gate_reason' } as any,
|
||||
statusDetail: { text: '当前步骤需要人工处理' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-status-detail"]').text()).toBe('当前步骤需要人工处理');
|
||||
});
|
||||
});
|
||||
+27
-6
@@ -10,7 +10,9 @@
|
||||
禁止把读取占位误述为「系统处理中」,也不做骨架→真值的二次刷新;
|
||||
loading 仅在挂载期抑制可执行动作,等权威投影到达后再放行(fail-closed);
|
||||
由 ShippingOrderReviewView 在 mountCurrentProcessingCard 时挂载;
|
||||
v2 新增 statusDetail:状态块内嵌动态说明(隐藏裁决在视图侧,见 spec §5.2)。
|
||||
v2 新增 statusDetail:状态块内嵌动态说明(隐藏裁决在视图侧,见 spec §5.2);
|
||||
v4 语义分离:下一步优先消费 blocking_reason.next_action 的建议动作文案,
|
||||
且具体阻断原因在场时隐藏泛化 statusDetail(防同卡三行「待人工」空话)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
@@ -20,7 +22,10 @@ import type {
|
||||
ShippingProcessingBlockingReason,
|
||||
ShippingProcessingPrimaryAction,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import {
|
||||
isGenericBlockingReason,
|
||||
resolveShippingProcessingStageLabel,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveGateReasonLabel } from '@/features/shipping-progress/gateReasonLabel';
|
||||
import { lookupWorkbenchAction, shouldRenderWorkbenchAction } from '@/features/shipping-progress/workbenchActionRegistry';
|
||||
import { inventoryActionLabelKey, isInternalInventoryAction } from '@/features/shipping-progress/actionPresentation';
|
||||
@@ -147,9 +152,15 @@ const nextStepText = computed(() => {
|
||||
// 其余按 user_status/blocking_reason 照常渲染,空态自然落在「状态待确认」,不做骨架二次刷新。
|
||||
const automationMessage = props.loading ? safeMessage(props.automation?.message) : '';
|
||||
if (automationMessage) return automationMessage;
|
||||
// 1) blocking_reason → 用后端给的 i18n_key 渲染具体阻断
|
||||
// 1) blocking_reason → 先给契约注册的「建议动作」(下一步=做什么),
|
||||
// 再回退原因文案(i18n_key / Gate 命名空间);禁止裸露内部原因码。
|
||||
const br = props.blockingReason;
|
||||
if (br) {
|
||||
const nextAction = String(br.nextAction || br.next_action || '').trim();
|
||||
const actionKey = nextAction
|
||||
? `workspace.shippingNotice.processGate.actionCodes.${nextAction}`
|
||||
: '';
|
||||
if (actionKey && te(actionKey)) return t(actionKey);
|
||||
const i18nKey = String(br.i18nKey || '').trim();
|
||||
if (i18nKey && te(i18nKey)) {
|
||||
return t(i18nKey);
|
||||
@@ -205,6 +216,15 @@ const showNextStep = computed(() => {
|
||||
return !['completed', 'cancelled'].includes(status);
|
||||
});
|
||||
|
||||
/**
|
||||
* 状态块内嵌动态说明的显隐:具体阻断原因已由「下一步」承载时,
|
||||
* Run 级泛化等待说明(如「当前步骤需要人工处理」)属纯重复,隐藏。
|
||||
*/
|
||||
const showStatusDetail = computed(() => {
|
||||
if (!props.statusDetail?.text) return false;
|
||||
return isGenericBlockingReason(props.blockingReason, te);
|
||||
});
|
||||
|
||||
/**
|
||||
* 判断当前工作台是否应隐藏后端下发的纯导航动作。
|
||||
* 批次中心可用它打开工作台;进入工作台后必须复用注册表规则,避免当前阶段再次显示
|
||||
@@ -382,13 +402,14 @@ type ReviewCurrentUserStatus =
|
||||
/>
|
||||
{{ statusLabel }}
|
||||
</dd>
|
||||
<!-- v2:状态块内嵌动态说明(弱文本一行,不加标题/图标/区块;显隐裁决在视图侧)。 -->
|
||||
<!-- v2:状态块内嵌动态说明(弱文本一行,不加标题/图标/区块;
|
||||
v4:blocking_reason 已含具体原因时隐藏,避免与「下一步」重复)。 -->
|
||||
<p
|
||||
v-if="statusDetail?.text"
|
||||
v-if="showStatusDetail"
|
||||
class="w-full text-[11px] leading-4 text-muted"
|
||||
data-testid="review-current-task-status-detail"
|
||||
aria-live="polite"
|
||||
>{{ statusDetail.text }}</p>
|
||||
>{{ statusDetail?.text }}</p>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
|
||||
+61
@@ -173,3 +173,64 @@ describe('ReviewDocumentNavigation', () => {
|
||||
narrow.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ReviewDocumentNavigation queue row status icons', () => {
|
||||
/**
|
||||
* 以指定字段挂载单行侧栏队列,返回该行按钮包装器。
|
||||
*/
|
||||
function mountRow(item: Partial<ReviewDocumentNavItem>) {
|
||||
return mount(ReviewDocumentNavigation, {
|
||||
props: {
|
||||
items: [{ case_no: 'C-1', file_name: 'f1.pdf', status: 'draft', ...item }],
|
||||
activeCaseNo: 'C-1',
|
||||
navAriaLabel: 'nav',
|
||||
forceMode: 'sidebar',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
}).get('[data-testid="review-doc-nav-C-1"]');
|
||||
}
|
||||
|
||||
it('renders confirmed cases as in-progress spinner instead of done check', () => {
|
||||
const row = mountRow({ status: 'confirmed' });
|
||||
// 关键断言:已创建任务是系统在办中间态,必须转圈而非绿勾。
|
||||
expect(row.find('svg.animate-spin').exists()).toBe(true);
|
||||
expect(row.find('svg.text-emerald-500').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders ready-to-confirm cases as amber attention icon', () => {
|
||||
const row = mountRow({ status: 'ready' });
|
||||
// 关键断言:可确认是等人操作,属于待办而非完成。
|
||||
expect(row.find('svg.text-amber-500').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('renders backend gate-blocked cases as amber attention icon', () => {
|
||||
const row = mountRow({ status: 'confirmed', needs_attention: true });
|
||||
// 关键断言:needs_attention 是后端门禁裁决,优先于中间态转圈。
|
||||
expect(row.find('svg.text-amber-500').exists()).toBe(true);
|
||||
expect(row.find('svg.animate-spin').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('reserves the green check for terminal upload_complete', () => {
|
||||
const row = mountRow({ status: 'confirmed', lifecycle_stage: 'upload_complete' });
|
||||
expect(row.find('svg.text-emerald-500').exists()).toBe(true);
|
||||
expect(row.find('svg.animate-spin').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders failed and neutral states as before', () => {
|
||||
expect(mountRow({ status: 'failed' }).find('svg.text-rose-500').exists()).toBe(true);
|
||||
const idle = mountRow({ status: 'non_order' });
|
||||
expect(idle.find('svg.text-muted').exists()).toBe(true);
|
||||
expect(idle.find('svg.animate-spin').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps the truthful state icon on the selected row', () => {
|
||||
const row = mountRow({ status: 'draft' });
|
||||
// 关键断言:选中态由行高亮表达,图标不再被 active 覆盖成灰圈。
|
||||
expect(row.find('svg.text-amber-500').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('treats missing needs_attention as false for old queue payloads', () => {
|
||||
const row = mountRow({ status: 'confirmed', needs_attention: undefined });
|
||||
expect(row.find('svg.animate-spin').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
+25
-10
@@ -11,6 +11,7 @@ import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
Circle,
|
||||
LoaderCircle,
|
||||
Search,
|
||||
TriangleAlert,
|
||||
X,
|
||||
@@ -23,10 +24,12 @@ export type ReviewDocumentNavItem = {
|
||||
file_name?: string | null;
|
||||
status: string;
|
||||
issue_count?: number;
|
||||
/** 队列接口按当前门禁裁决的"需人工"标志(blocked_manual/blocked_retryable/failed_terminal);前端禁止自行推断阻塞。 */
|
||||
needs_attention?: boolean | null;
|
||||
po_number?: string | null;
|
||||
customer_name?: string | null;
|
||||
stage_label?: string | null;
|
||||
/** 队列接口下发的生命周期码;仅用于本地化展示,不参与阶段裁决。 */
|
||||
/** 队列接口下发的生命周期码;用于阶段文字展示与终态(upload_complete)绿勾判定,不参与阶段裁决。 */
|
||||
lifecycle_stage?: ReviewLifecycleStageCode | null;
|
||||
};
|
||||
|
||||
@@ -118,17 +121,20 @@ function lifecycleStageLabel(item: ReviewDocumentNavItem): string | null {
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航状态图标语义。
|
||||
* 队列状态图标语义,按优先级命中即停:
|
||||
* 失败 → 需人工(草稿问题数 / needs_attention 门禁阻塞)→ 终态绿勾
|
||||
* → 等人状态 ⚠ → 系统在办转圈 → 中性灰圈 → 兜底转圈。
|
||||
* 绿勾只属于终态(upload_complete / closed / completed);选中态由行高亮表达,
|
||||
* 本函数不感知选中,图标永远如实反映状态。
|
||||
*/
|
||||
function navIconKind(item: ReviewDocumentNavItem): 'active' | 'alert' | 'processing' | 'done' | 'failed' | 'idle' {
|
||||
if (props.activeCaseNo === item.case_no) return 'active';
|
||||
function navIconKind(item: ReviewDocumentNavItem): 'alert' | 'done' | 'failed' | 'processing' | 'idle' {
|
||||
const status = String(item.status || '').toLowerCase();
|
||||
if (item.issue_count && item.issue_count > 0) return 'alert';
|
||||
if (status === 'failed' || status === 'error') return 'failed';
|
||||
if (status === 'confirmed' || status === 'completed' || status === 'ready' || status === 'closed') return 'done';
|
||||
if (status === 'processing' || status === 'reparse_pending' || status === 'queued') return 'processing';
|
||||
if (status === 'non_order' || status === 'cancelled' || status === 'superseded') return 'idle';
|
||||
if (status === 'draft' || status === 'pending_review' || status === 'waiting_review') return 'alert';
|
||||
if ((item.issue_count && item.issue_count > 0) || item.needs_attention === true) return 'alert';
|
||||
if (item.lifecycle_stage === 'upload_complete' || status === 'completed' || status === 'closed') return 'done';
|
||||
if (['draft', 'ready', 'unreviewed', 'quality_issue', 'pending_review', 'waiting_review'].includes(status)) return 'alert';
|
||||
if (['confirmed', 'confirming', 'processing', 'reparse_pending', 'queued'].includes(status)) return 'processing';
|
||||
if (['non_order', 'cancelled', 'superseded'].includes(status)) return 'idle';
|
||||
return 'processing';
|
||||
}
|
||||
|
||||
@@ -139,7 +145,7 @@ function matchesStatusFilter(item: ReviewDocumentNavItem): boolean {
|
||||
if (statusFilter.value === 'all') return true;
|
||||
const kind = navIconKind(item);
|
||||
if (statusFilter.value === 'needs_action') return kind === 'alert';
|
||||
if (statusFilter.value === 'processing') return kind === 'processing' || kind === 'active';
|
||||
if (statusFilter.value === 'processing') return kind === 'processing';
|
||||
if (statusFilter.value === 'done') return kind === 'done';
|
||||
if (statusFilter.value === 'failed') return kind === 'failed';
|
||||
return true;
|
||||
@@ -218,6 +224,11 @@ function onSelect(caseNo: string) {
|
||||
class="h-3.5 w-3.5 shrink-0 text-rose-500"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<LoaderCircle
|
||||
v-else-if="navIconKind(item) === 'processing'"
|
||||
class="h-3.5 w-3.5 shrink-0 animate-spin text-brand-600"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<Circle
|
||||
v-else
|
||||
class="h-3 w-3 shrink-0 text-muted"
|
||||
@@ -329,6 +340,10 @@ function onSelect(caseNo: string) {
|
||||
v-else-if="navIconKind(item) === 'failed'"
|
||||
class="mt-0.5 h-3.5 w-3.5 shrink-0 text-rose-500"
|
||||
/>
|
||||
<LoaderCircle
|
||||
v-else-if="navIconKind(item) === 'processing'"
|
||||
class="mt-0.5 h-3.5 w-3.5 shrink-0 animate-spin text-brand-600"
|
||||
/>
|
||||
<Circle
|
||||
v-else
|
||||
class="mt-0.5 h-3 w-3 shrink-0 text-muted"
|
||||
|
||||
@@ -9,33 +9,13 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { loadPdfJs } from '@/shared/utils/pdfjs';
|
||||
import type { ShippingOrderReviewEvidence } from '../../types/shipping.api.types';
|
||||
import { normalizedTopLeftBBoxToViewportRect } from './pdfHighlightCoords';
|
||||
|
||||
/** 有合法 bbox 时四种质量都绘制;颜色只提示可信度,不隐藏取值位置。 */
|
||||
const DRAWABLE_QUALITIES = new Set(['verified', 'candidate', 'unavailable', 'invalid']);
|
||||
|
||||
type PdfJsModule = typeof import('pdfjs-dist');
|
||||
|
||||
let pdfjsLoader: Promise<PdfJsModule> | null = null;
|
||||
|
||||
/**
|
||||
* 动态加载 pdfjs 与 worker;同页复用单例 Promise。
|
||||
*/
|
||||
async function loadPdfJs(): Promise<PdfJsModule> {
|
||||
if (!pdfjsLoader) {
|
||||
pdfjsLoader = (async () => {
|
||||
const [pdfjs, workerMod] = await Promise.all([
|
||||
import('pdfjs-dist'),
|
||||
import('pdfjs-dist/build/pdf.worker.min.mjs?url'),
|
||||
]);
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = workerMod.default;
|
||||
return pdfjs;
|
||||
})();
|
||||
}
|
||||
return pdfjsLoader;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
src: string;
|
||||
evidence?: ShippingOrderReviewEvidence | null;
|
||||
|
||||
+82
@@ -1184,4 +1184,86 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
const row = wrapper.find('[data-testid="shipping-processing-file-DOC-10"]');
|
||||
expect(row.findAll('button')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('shows a specific blocking reason once per waiting-human card without header duplication', async () => {
|
||||
// v4 去重:具体原因由文件行页脚独家承载;任务卡头不再重复同一句。
|
||||
// ui_state 挂在任务条目上(与后端 EML 聚合下发形态一致:任务级为代表子项原因)。
|
||||
const projection = buildProjection();
|
||||
setStatusGroup(projection, 'waiting_human', [{
|
||||
user_task_no: 'OT-REASON-ONCE', group: 'waiting_human', status_label: 'pending_review',
|
||||
file_count: 1, run_no: 'RUN-REASON-ONCE', can_append: false,
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: { code: 'customer_unresolved', message: '客户尚未确认' },
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
objects: [{
|
||||
kind: 'document', object_key: 'DOC-REASON', label: 'reason.pdf', filename: 'reason.pdf',
|
||||
document_id: 91, root_document_id: 91, status_label: 'pending_review',
|
||||
}],
|
||||
}]);
|
||||
const workItem = buildWorkItem('OT-REASON-ONCE', {
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'reason.pdf', documentId: 91,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-REASON',
|
||||
},
|
||||
status: 'waiting_human',
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: { code: 'customer_unresolved', message: '客户尚未确认' },
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// 关键断言:具体原因全文只出现一次,且带「阻塞原因:」前缀落在文件行页脚。
|
||||
const matches = wrapper.text().match(/客户尚未确认/g) || [];
|
||||
expect(matches.length).toBe(1);
|
||||
expect(wrapper.text()).toContain('阻塞原因:客户尚未确认');
|
||||
});
|
||||
|
||||
it('hides the blocker line when the backend only provides a generic fallback reason', async () => {
|
||||
// v4:未知原因码不得渲染成「当前步骤需要人工处理」空话;状态芯片已表达待人工。
|
||||
const projection = buildProjection();
|
||||
setStatusGroup(projection, 'waiting_human', [{
|
||||
user_task_no: 'OT-REASON-GENERIC', group: 'waiting_human', status_label: 'pending_review',
|
||||
file_count: 1, run_no: 'RUN-REASON-GENERIC', can_append: false,
|
||||
objects: [{
|
||||
kind: 'document', object_key: 'DOC-GENERIC', label: 'generic.pdf', filename: 'generic.pdf',
|
||||
document_id: 92, root_document_id: 92, status_label: 'pending_review',
|
||||
}],
|
||||
}]);
|
||||
const workItem = buildWorkItem('OT-REASON-GENERIC', {
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'generic.pdf', documentId: 92,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-GENERIC',
|
||||
},
|
||||
status: 'waiting_human',
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: { code: 'mystery_internal_code' },
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.text()).not.toContain('阻塞原因');
|
||||
expect(wrapper.text()).not.toContain('当前步骤需要人工处理');
|
||||
});
|
||||
});
|
||||
+16
-7
@@ -30,8 +30,8 @@ import {
|
||||
toggleTaskDetails,
|
||||
} from '@/features/chat/shipping/conversationProcessingState';
|
||||
import {
|
||||
resolveBlockingReasonText,
|
||||
resolveShippingProcessingMessage,
|
||||
resolveShippingProcessingReasonLabel,
|
||||
resolveShippingProcessingStageLabel,
|
||||
resolveShippingProcessingStatusLabel,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
@@ -593,7 +593,8 @@ function workbenchFileReason(file: WorkbenchFileRow, task: ConversationProcessin
|
||||
const reason = file.projection.uiState
|
||||
? file.projection.uiState.blocking_reason
|
||||
: file.projection.blockingReason;
|
||||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||||
// v4:具体原因才展示(Gate 命名空间/契约 message 可解析),通用兜底返回空串隐藏。
|
||||
return resolveBlockingReasonText(reason, te, t);
|
||||
}
|
||||
return taskReasonLabel(task);
|
||||
}
|
||||
@@ -686,12 +687,20 @@ function stageLabel(task: ConversationProcessingUserTask): string {
|
||||
return intakeStageLabel(projection);
|
||||
}
|
||||
|
||||
/** 展示后端 ui_state 已裁决的阻断原因;i18n 仅负责翻译,不映射或猜测业务原因。 */
|
||||
/** 展示后端 ui_state 已裁决的阻断原因;v4:具体原因才展示,通用兜底返回空串。 */
|
||||
function taskReasonLabel(task: ConversationProcessingUserTask): string {
|
||||
const reason = task.uiState
|
||||
? task.uiState.blocking_reason
|
||||
: task.blockingReason;
|
||||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||||
return resolveBlockingReasonText(reason, te, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务卡头原因行显隐:workbench 模式下文件行页脚已逐文件承载原因,
|
||||
* 卡头不再重复同一句;非 workbench(折叠聚合卡)仍由卡头独家展示。
|
||||
*/
|
||||
function taskHeaderReasonVisible(task: ConversationProcessingUserTask): boolean {
|
||||
return !props.workbenchMode || visibleWorkbenchFileRows(task).length === 0;
|
||||
}
|
||||
|
||||
/** 同一 EML 聚合卡状态计数;仅用后端下发的 aggregateSummary,不从 UI 状态推导。 */
|
||||
@@ -960,7 +969,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
<div v-if="taskHeaderReasonVisible(task) && taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
{{ taskReasonLabel(task) }}
|
||||
</div>
|
||||
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">
|
||||
@@ -1056,7 +1065,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
<div v-if="!workbenchMode" class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||||
</div>
|
||||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">{{ taskReasonLabel(task) }}</div>
|
||||
<div v-if="taskHeaderReasonVisible(task) && taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">{{ taskReasonLabel(task) }}</div>
|
||||
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">{{ aggregateStatusLabel(task) }}</div>
|
||||
</button>
|
||||
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-amber-200/70 pt-2">
|
||||
@@ -1323,7 +1332,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
<div v-if="taskHeaderReasonVisible(task) && taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
{{ taskReasonLabel(task) }}
|
||||
</div>
|
||||
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-emerald-200/70 pt-2">
|
||||
|
||||
+12
-16
@@ -74,7 +74,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('does not present historical handling items or CTA as current work when the live projection exists', () => {
|
||||
@@ -115,16 +116,6 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('collapses file-level progress when the batch workbench is open', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-COMPACT', compactProgress: true },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([]) } } },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-status-groups"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('uses unified EML aggregation and keeps candidate creation out of completed', async () => {
|
||||
const aggregate = {
|
||||
workItemType: 'order_task', workItemNo: 'INTAKE:SNI-1', sourceType: 'eml', rootOrderTaskNo: 'OT-1',
|
||||
@@ -643,7 +634,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).toContain('3 个文件');
|
||||
expect(wrapper.text()).toContain('系统处理中');
|
||||
expect(wrapper.text()).toContain('处理时间偏长');
|
||||
expect(wrapper.text()).toContain('打开批次进度中心');
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.text()).not.toContain('打开批次进度中心');
|
||||
expect(wrapper.text()).not.toContain('刷新状态');
|
||||
expect(wrapper.text()).not.toContain('取消本次识别');
|
||||
expect(wrapper.text()).not.toContain('PO-450003.pdf');
|
||||
@@ -731,7 +723,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
});
|
||||
expect(wrapper.text()).toContain('订单候选已生成');
|
||||
expect(wrapper.text()).toContain('候选待人工确认 · 2 项');
|
||||
expect(wrapper.text()).toContain('打开批次进度中心');
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.text()).not.toContain('打开批次进度中心');
|
||||
expect(wrapper.text()).not.toContain('部分附件需人工处理');
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
|
||||
});
|
||||
@@ -826,7 +819,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
});
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-view-details"]').exists()).toBe(false);
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('does not render multi-OT ChatProgressSummary list', () => {
|
||||
@@ -914,7 +908,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('does not render the removed view details link', () => {
|
||||
@@ -956,7 +951,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).toContain('共 1 个文件');
|
||||
});
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingOrderExtractionCard.vue
|
||||
* 用途:聊天主区「本次订单文件处理」摘要卡——标题、文件数+状态、一行 handling 摘要、唯一主 CTA、查看详情。
|
||||
* 用途:聊天主区「本次订单文件处理」摘要卡——标题、文件数+状态、一行 handling 摘要、无对话流 CTA(批次中心常驻,方案 A)。
|
||||
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、vue-router、vue-i18n。
|
||||
* 逻辑:对话区默认展示状态-EML 聚合;批次工作台打开后切换为紧凑摘要,长进度/Gate/刷新取消由工作台承接。
|
||||
* 逻辑:对话区默认展示状态-EML 聚合;无对话流 CTA(批次中心常驻,方案 A),长进度/Gate/刷新取消由工作台承接。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { AlertCircle, ArrowRight, CheckCircle2, ChevronDown, CircleX, FileText, LoaderCircle, Mail, RefreshCw, TriangleAlert } from 'lucide-vue-next';
|
||||
import { AlertCircle, CheckCircle2, ChevronDown, CircleX, FileText, LoaderCircle, Mail, RefreshCw, TriangleAlert } from 'lucide-vue-next';
|
||||
import type {
|
||||
ShippingOrderExtractionHandlingItemState,
|
||||
ShippingOrderExtractionFileState,
|
||||
@@ -44,15 +44,12 @@ const props = defineProps<{
|
||||
readonlyReason?: string | null;
|
||||
/** 可选统一投影;摘要卡不再渲染进度,仅保留 prop 兼容宿主。 */
|
||||
processingProjection?: ShippingProcessingProjection | null;
|
||||
/** 批次工作台打开时,左侧只保留摘要,避免与工作台重复展示文件明细。 */
|
||||
compactProgress?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
retry: [];
|
||||
refresh: [];
|
||||
cancel: [reason?: string];
|
||||
'open-batch-workbench': [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -425,7 +422,6 @@ const hasAnyStatusGroupTask = computed(() => (
|
||||
*/
|
||||
const recognizingPlaceholderVisible = computed(() => (
|
||||
hasConversationStatusGroups.value
|
||||
&& !props.compactProgress
|
||||
&& !hasAnyStatusGroupTask.value
|
||||
&& (submittedFileCount.value ?? 0) > 0
|
||||
));
|
||||
@@ -850,7 +846,7 @@ async function onPrimaryChatAction() {
|
||||
<div v-if="handlingSummaryLine && !hasConversationStatusGroups" class="mt-1 text-sm text-secondary">{{ handlingSummaryLine }}</div>
|
||||
</div>
|
||||
|
||||
<div v-if="hasConversationStatusGroups && !compactProgress" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-status-groups">
|
||||
<div v-if="hasConversationStatusGroups" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-status-groups">
|
||||
<div v-if="recognizingPlaceholderVisible" class="flex items-center gap-2 rounded-lg border border-default bg-surface p-3 text-sm text-muted">
|
||||
<LoaderCircle class="h-4 w-4 animate-spin text-brand-500" />
|
||||
<span data-testid="shipping-order-extraction-recognizing-placeholder">{{ t('chat.shippingProcessing.recognizingAttachments') }}</span>
|
||||
@@ -899,7 +895,7 @@ async function onPrimaryChatAction() {
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else-if="!compactProgress && emlAggregate" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-eml-aggregate">
|
||||
<div v-else-if="emlAggregate" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-eml-aggregate">
|
||||
<article class="overflow-hidden rounded-lg border border-default bg-surface shadow-sm">
|
||||
<div class="flex items-start gap-3 border-b border-default bg-surface-soft p-3 dark:bg-slate-950/30">
|
||||
<Mail class="mt-0.5 h-5 w-5 text-brand-500" />
|
||||
@@ -926,7 +922,7 @@ async function onPrimaryChatAction() {
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<div v-else-if="!compactProgress" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30">
|
||||
<div v-else class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30">
|
||||
<div v-for="row in activeEmailRows" :key="row.unitId" class="overflow-hidden rounded-lg border border-default bg-surface shadow-sm">
|
||||
<div class="flex items-start gap-3 border-b border-default bg-surface-soft p-3 dark:bg-slate-950/30"><Mail class="mt-0.5 h-5 w-5 text-brand-500" /><div class="min-w-0 flex-1"><div class="flex items-center justify-between gap-3"><span class="font-medium">{{ t('chat.shippingProcessing.emailPrefix') }}{{ row.fileName }}</span><span class="rounded border px-2 py-0.5 text-xs" :class="isFailedParseRow(row) || emailHasFailedChild(row) ? 'border-rose-200 bg-rose-100/70 text-rose-600' : emailIsCompleted(row) ? 'border-emerald-200 bg-emerald-100/70 text-emerald-600' : 'border-brand-200 bg-brand-100/70 text-brand-600'">{{ isFailedParseRow(row) || emailHasFailedChild(row) ? t('chat.shippingProcessing.batchException') : emailIsCompleted(row) ? t('chat.shippingProcessing.batchExtracted') : t('chat.shippingProcessing.parsingAttachments') }}</span></div><span class="mt-1 block font-mono text-xs text-muted">{{ t('chat.shippingProcessing.emailMeta') }}</span></div></div>
|
||||
<div class="mx-4 my-2 flex flex-col gap-2 border-l-2 border-default bg-surface-soft p-3 pl-4 dark:border-slate-700 dark:bg-slate-950/30"><div v-for="child in childRows(row)" :key="`child-${child.unitId}`" class="flex items-center justify-between gap-3 text-sm"><span class="flex min-w-0 items-center gap-2"><CheckCircle2 v-if="child.status === 'candidate_ready'" class="h-4 w-4 text-emerald-500" /><LoaderCircle v-else-if="!isFailedParseRow(child)" class="h-4 w-4 animate-spin text-brand-500" /><AlertCircle v-else class="h-4 w-4 text-rose-500" /><span class="truncate">{{ child.fileName }}</span></span><span :class="rowStatusClass(child)">{{ rowStatusLabel(child) }}</span></div></div>
|
||||
@@ -936,20 +932,6 @@ async function onPrimaryChatAction() {
|
||||
<div v-for="row in failedRows" :key="`failed-${row.unitId}`" class="rounded-lg border border-rose-200 bg-rose-50 p-3 dark:border-rose-800 dark:bg-rose-950/30"><div class="flex items-center justify-between text-rose-600"><span class="flex items-center gap-2 font-medium"><AlertCircle class="h-5 w-5" />{{ row.fileName }}</span><span class="rounded bg-rose-100 px-2 py-0.5 text-xs">{{ t('chat.shippingProcessing.batchException') }}</span></div><p class="mt-2 pl-7 text-sm">{{ row.explainability?.message || t('chat.shippingProcessing.batchManualVerify') }}</p></div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end border-t border-default bg-brand-50/60 p-3 dark:bg-brand-950/20">
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
v-if="!compactProgress && (hasConversationStatusGroups || String(props.runNo || '').trim())"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2 rounded-lg bg-brand-600 px-5 py-2.5 text-sm font-medium text-white shadow-sm hover:bg-brand-700"
|
||||
data-testid="shipping-order-extraction-open-batch-workbench"
|
||||
@click="emit('open-batch-workbench')"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.openBatchWorkbench') }}
|
||||
<ArrowRight class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="false" class="flex items-start gap-3">
|
||||
<CircleX class="mt-0.5 h-4 w-4 shrink-0" />
|
||||
<div class="min-w-0 flex-1">
|
||||
|
||||
@@ -104,10 +104,11 @@ function buildController(
|
||||
function mountTimeline(
|
||||
processing = processingProjection(),
|
||||
workItems: ShippingProcessingProjection[] = [],
|
||||
extraProps: Record<string, unknown> = {},
|
||||
) {
|
||||
return mount(ShippingWorkflowTimeline, {
|
||||
attachTo: document.body,
|
||||
props: { conversationId: 'conv-1', controller: buildController(processing, workItems) },
|
||||
props: { conversationId: 'conv-1', controller: buildController(processing, workItems), ...extraProps },
|
||||
global: { plugins: [i18n], stubs: { teleport: true } },
|
||||
});
|
||||
}
|
||||
@@ -124,6 +125,24 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
gateRecovery.submitPrimaryAction.mockClear();
|
||||
});
|
||||
|
||||
it('has no close button and reuses the conversation title in the header', () => {
|
||||
const wrapper = mountTimeline(processingProjection(), [], { conversationTitle: 'PO#6075309 09-15' });
|
||||
|
||||
// 中心常驻不可关闭(方案 A):关闭按钮必须消失。
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-close"]').exists()).toBe(false);
|
||||
|
||||
// 会话标题直接复用侧栏命名,保持两处一致。
|
||||
const titleNode = wrapper.find('[data-testid="shipping-workflow-conversation-title"]');
|
||||
expect(titleNode.exists()).toBe(true);
|
||||
expect(titleNode.text()).toContain('PO#6075309 09-15');
|
||||
});
|
||||
|
||||
it('omits the title node when no conversation title is provided', () => {
|
||||
const wrapper = mountTimeline(processingProjection(), []);
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-conversation-title"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('prefers backend five-stage lifecycle nodes and shows the authorized download toolbar in freight upload', async () => {
|
||||
const processing = processingProjection({
|
||||
lifecycle_nodes: [
|
||||
@@ -205,25 +224,6 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-DOC-9"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('labels a manually actionable batch as action needed instead of processing', async () => {
|
||||
const task = { ...processingProjection().processing[0], group: 'needs_action' };
|
||||
const processing = processingProjection({
|
||||
summary: { total_files: 1, processing_files: 0, completed_files: 0, waiting_human_files: 1, failed_files: 0 },
|
||||
needs_action: [task], processing: [],
|
||||
status_groups: { failed: [], waiting_human: [task], processing: [], completed: [], cancelled: [], archived: [] },
|
||||
} as Partial<ConversationProcessingProjection>);
|
||||
const wrapper = mountTimeline(processing, [fileProjection({
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'order_review', lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [], blocking_reason: null, primary_action: null, secondary_actions: [],
|
||||
},
|
||||
})]);
|
||||
await flushPromises();
|
||||
|
||||
// 关键断言:锁定表示仍有待办,不得与「处理中 0」形成视觉矛盾。
|
||||
expect(wrapper.get('[data-testid="shipping-workflow-panel-pinned"]').text()).toBe('待处理');
|
||||
});
|
||||
|
||||
it('navigates only through the backend lifecycle entry', async () => {
|
||||
const file = fileProjection({
|
||||
uiState: {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 用途:聊天页右侧「批次进度中心」——后端批次投影、五阶段进度和文件行操作。
|
||||
* 依赖:vue-i18n、useMessage、useShippingNoticeWorkflow、ShippingConversationProcessingCard、
|
||||
* ReasonDialog、ProcessGateRecoveryCard。
|
||||
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;标题栏仅保留批次名称、加载与截断提示,
|
||||
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;标题栏保留批次名称、会话标题、加载与截断提示;中心常驻不可关闭(方案 A),
|
||||
* 文件总览和进度仅消费后端批次 summary;
|
||||
* 文件清单消费后端 conversation_processing.status_groups;work_items 仅用于定位同一
|
||||
* 展示 DTO 的操作对象;整批操作走 Run API,单文件取消走 Unit API;
|
||||
@@ -14,7 +14,7 @@
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { ChevronDown, ChevronRight, Lock, RefreshCw } from 'lucide-vue-next';
|
||||
import { RefreshCw } from 'lucide-vue-next';
|
||||
import {
|
||||
downloadWorkspaceShippingExcelFile,
|
||||
downloadWorkspaceShippingExportArchive,
|
||||
@@ -59,10 +59,8 @@ const props = defineProps<{
|
||||
refreshTrigger?: number;
|
||||
/** 测试或父级注入时可直接传入控制器,跳过自建轮询。 */
|
||||
controller?: UseShippingNoticeWorkflowReturn | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
/** 当前会话标题;父级从侧栏历史匹配传入,中心头部直接复用(无新增接口)。 */
|
||||
conversationTitle?: string | null;
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -91,11 +89,6 @@ const ctl = computed((): UseShippingNoticeWorkflowReturn => (
|
||||
props.controller || injected || localController
|
||||
));
|
||||
|
||||
/**
|
||||
* 侧栏折叠态:默认展开。
|
||||
* 有处理中/待处理/未查看完成任务时强制展开,仅允许收起文件详情。
|
||||
*/
|
||||
const collapsed = ref(false);
|
||||
/** 复核返回对话时展示的聚焦提示(由 focus_notice 触发一次)。 */
|
||||
const focusTaskBanner = ref<string | null>(null);
|
||||
const actionBusyItemNo = ref<string | null>(null);
|
||||
@@ -249,34 +242,6 @@ const initialLoading = computed(() => Boolean(ctl.value.initialLoading?.value));
|
||||
const manualRefreshing = computed(() => Boolean(ctl.value.manualRefreshing?.value));
|
||||
const isRefreshing = computed(() => Boolean(ctl.value.isRefreshing?.value));
|
||||
const error = computed(() => ctl.value.error.value);
|
||||
/**
|
||||
* 右侧仍有用户必须持续可见的任务时,禁止收起整个处理面板。
|
||||
* 核心逻辑:处理中 / 待处理 / 未查看完成均属活跃可见任务;无此类任务才允许收起侧栏。
|
||||
*/
|
||||
const hasPinnedProcessingTasks = computed(() => {
|
||||
const projection = displayProcessing.value;
|
||||
if (!projection) return false;
|
||||
return statusGroupTasks('failed', 'waiting_human', 'processing', 'completed').length > 0;
|
||||
});
|
||||
|
||||
/**
|
||||
* 切换侧栏折叠:活跃任务存在时强制保持展开。
|
||||
*/
|
||||
function togglePanelCollapsed() {
|
||||
if (hasPinnedProcessingTasks.value) {
|
||||
collapsed.value = false;
|
||||
return;
|
||||
}
|
||||
collapsed.value = !collapsed.value;
|
||||
}
|
||||
|
||||
watch(
|
||||
hasPinnedProcessingTasks,
|
||||
(pinned) => {
|
||||
if (pinned) collapsed.value = false;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/**
|
||||
* 移除右侧常驻「批次与文件列表」长列表抽屉(UI-REFACTOR 方案 7)。
|
||||
@@ -839,7 +804,6 @@ watch(
|
||||
return;
|
||||
}
|
||||
if (!focusedTaskExists.value) return;
|
||||
collapsed.value = false;
|
||||
focusTaskBanner.value = normalized;
|
||||
// [UI-01/UI-02] 真正选中进度卡,禁止只显示提示条。
|
||||
await onProcessingFocus(normalized);
|
||||
@@ -856,31 +820,12 @@ watch(
|
||||
|
||||
<template>
|
||||
<aside
|
||||
class="flex min-w-0 flex-1 shrink-0 flex-col border-l border-default bg-surface shadow-[-16px_0_40px_rgba(15,23,42,0.10)] transition-[width] duration-200"
|
||||
:class="collapsed ? '!w-14' : ''"
|
||||
class="flex min-w-0 flex-1 shrink-0 flex-col bg-surface"
|
||||
data-testid="shipping-workflow-timeline"
|
||||
>
|
||||
<div class="flex w-full items-center gap-1 border-b border-default px-2 py-2">
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-md p-1.5 text-muted hover:bg-surface-muted hover:text-primary"
|
||||
data-testid="shipping-workflow-close"
|
||||
:title="t('chat.shippingProcessing.closeWorkbench')"
|
||||
@click="emit('close')"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
<component
|
||||
:is="hasPinnedProcessingTasks ? 'div' : 'button'"
|
||||
:type="hasPinnedProcessingTasks ? undefined : 'button'"
|
||||
class="flex min-w-0 flex-1 items-center justify-between gap-2 rounded-md px-1 py-1 text-left"
|
||||
:class="hasPinnedProcessingTasks
|
||||
? 'cursor-default'
|
||||
: 'hover:bg-surface-muted/60'"
|
||||
data-testid="shipping-workflow-panel-toggle"
|
||||
@click="togglePanelCollapsed"
|
||||
>
|
||||
<div v-if="!collapsed" class="min-w-0">
|
||||
<div class="flex min-w-0 flex-1 items-center justify-between gap-2 rounded-md px-1 py-1 text-left">
|
||||
<div class="min-w-0">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ te('chat.shippingProcessing.panelTitle')
|
||||
@@ -888,14 +833,11 @@ watch(
|
||||
: t('chat.shippingProcessing.title') }}
|
||||
</div>
|
||||
<span
|
||||
v-if="hasPinnedProcessingTasks"
|
||||
class="inline-flex items-center gap-0.5 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-secondary"
|
||||
data-testid="shipping-workflow-panel-pinned"
|
||||
:title="t('chat.shippingProcessing.panelPinnedHint')"
|
||||
>
|
||||
<Lock class="h-3 w-3 shrink-0" aria-hidden="true" />
|
||||
{{ t('chat.shippingProcessing.panelPinnedLabel') }}
|
||||
</span>
|
||||
v-if="conversationTitle"
|
||||
class="min-w-0 truncate rounded bg-surface-muted px-1.5 py-0.5 text-xs text-secondary"
|
||||
data-testid="shipping-workflow-conversation-title"
|
||||
:title="conversationTitle"
|
||||
>{{ conversationTitle }}</span>
|
||||
</div>
|
||||
<div class="mt-0.5 space-y-0.5 text-xs text-secondary" data-testid="shipping-workflow-panel-summary">
|
||||
<template v-if="initialLoading && !displayProcessing">
|
||||
@@ -918,12 +860,7 @@ watch(
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<ChevronDown
|
||||
v-if="!collapsed && !hasPinnedProcessingTasks"
|
||||
class="h-4 w-4 shrink-0 text-muted"
|
||||
/>
|
||||
<ChevronRight v-else-if="collapsed" class="h-4 w-4 shrink-0 text-muted" />
|
||||
</component>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-md p-1.5 text-muted hover:bg-surface-muted hover:text-primary disabled:opacity-50"
|
||||
@@ -939,7 +876,7 @@ watch(
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!collapsed" class="min-h-0 flex-1 overflow-y-auto p-5">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto p-5">
|
||||
<div
|
||||
v-if="initialLoading && !displayProcessing"
|
||||
class="mb-4 space-y-3"
|
||||
|
||||
Reference in new issue
Block a user