Merge branch 'hugo-shipping-notice' into dev
This commit is contained in:
commit
3985b34dda
606 files changed
+52167
-36839
No files matched your search
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* features/chat/components/ChatInputBar.spec.ts
|
||||
* 用途:验证采购合同双文件在聊天输入栏中的统一卡片展示与删除交互。
|
||||
* 依赖:Vue Test Utils、Vue I18n、ChatInputBar。
|
||||
* 逻辑:我方原合同和卖方回传合同均以附件卡片展示;删除我方原合同必须通知上层清除对应资产状态。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { ref } from 'vue';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import ChatInputBar from './ChatInputBar.vue';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: { 'zh-CN': {} },
|
||||
});
|
||||
|
||||
/** 创建采购合同双文件输入栏所需的最小属性。 */
|
||||
function mountProcurementInputBar() {
|
||||
return mount(ChatInputBar, {
|
||||
props: {
|
||||
modelValue: '',
|
||||
procurementReviewMode: 'compare',
|
||||
attachments: [{
|
||||
id: 'seller-contract',
|
||||
kind: 'local',
|
||||
file: new File(['seller'], '卖方回传合同.md', { type: 'text/markdown' }),
|
||||
type: 'document',
|
||||
uploadStatus: 'waiting',
|
||||
uploadProgress: 0,
|
||||
}],
|
||||
attachmentPolicy: { anyEnabled: true, canLocal: true, canRemote: false, accept: '.md' },
|
||||
isThinking: false,
|
||||
isVoiceRecording: false,
|
||||
isVoiceTranscribing: false,
|
||||
isUploadingAttachments: false,
|
||||
canSendMessage: true,
|
||||
isShippingNoticeAgent: false,
|
||||
isProcurementContractAgent: true,
|
||||
procurementOriginalContractName: '我方原合同.md',
|
||||
isMaintenanceAgent: false,
|
||||
canManageMaintenance: false,
|
||||
canForceCreateShippingDuplicate: false,
|
||||
shippingSuggestedPrompt: '',
|
||||
shippingPickerRefHolder: { pickerRef: ref(null) },
|
||||
shippingNoticePickerRefHolder: { pickerRef: ref(null) },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
/** 创建仅选择我方原合同、尚未选择卖方回传合同的输入栏。 */
|
||||
function mountOriginalContractOnlyInputBar() {
|
||||
return mount(ChatInputBar, {
|
||||
props: {
|
||||
modelValue: '',
|
||||
procurementReviewMode: 'compare',
|
||||
attachments: [],
|
||||
attachmentPolicy: { anyEnabled: true, canLocal: true, canRemote: false, accept: '.md' },
|
||||
isThinking: false,
|
||||
isVoiceRecording: false,
|
||||
isVoiceTranscribing: false,
|
||||
isUploadingAttachments: true,
|
||||
canSendMessage: false,
|
||||
isShippingNoticeAgent: false,
|
||||
isProcurementContractAgent: true,
|
||||
procurementOriginalContractName: '我方原合同.md',
|
||||
isMaintenanceAgent: false,
|
||||
canManageMaintenance: false,
|
||||
canForceCreateShippingDuplicate: false,
|
||||
shippingSuggestedPrompt: '',
|
||||
shippingPickerRefHolder: { pickerRef: ref(null) },
|
||||
shippingNoticePickerRefHolder: { pickerRef: ref(null) },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('ChatInputBar procurement contract attachments', () => {
|
||||
it('shows the original contract immediately even before a seller contract is selected', () => {
|
||||
const wrapper = mountOriginalContractOnlyInputBar();
|
||||
|
||||
// 原合同上传中时卖方附件数组为空,仍必须显示原合同卡片提供明确反馈。
|
||||
expect(wrapper.get('[data-testid="chat-attachment-list"]')).toBeTruthy();
|
||||
expect(wrapper.get('[data-testid="procurement-original-contract-card"]')).toBeTruthy();
|
||||
expect(wrapper.findAll('[data-testid="chat-attachment-card"]')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('renders the original contract as a standard attachment card and clears it on delete', async () => {
|
||||
const wrapper = mountProcurementInputBar();
|
||||
|
||||
// 断言两份合同使用同一附件卡片结构,防止我方原合同退化回独立小标签。
|
||||
expect(wrapper.get('[data-testid="procurement-original-contract-card"]')).toBeTruthy();
|
||||
expect(wrapper.findAll('[data-testid="chat-attachment-card"], [data-testid="procurement-original-contract-card"]')).toHaveLength(2);
|
||||
|
||||
await wrapper.get('[data-testid="remove-procurement-original-contract"]').trigger('click');
|
||||
|
||||
// 删除操作必须交由父级清空 originalContractAssetNo 与名称,避免残留无形基准文件。
|
||||
expect(wrapper.emitted('clear-procurement-original-contract')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('keeps original-contract delete pointer events out of the attachment drag surface', async () => {
|
||||
const wrapper = mountProcurementInputBar();
|
||||
let dragSurfaceReceivedPointerDown = false;
|
||||
wrapper.get('[data-testid="chat-attachment-list"]').element.addEventListener('pointerdown', () => {
|
||||
dragSurfaceReceivedPointerDown = true;
|
||||
});
|
||||
|
||||
// 删除按钮不能触发横向拖拽容器,否则指针捕获会干扰实际 click 事件。
|
||||
await wrapper.get('[data-testid="remove-procurement-original-contract"]').trigger('pointerdown');
|
||||
|
||||
expect(dragSurfaceReceivedPointerDown).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -159,6 +159,12 @@ const hasProcurementContractAttachment = computed(() =>
|
||||
&& props.attachments.some((item) => item.kind === 'local'),
|
||||
);
|
||||
|
||||
/** 显示我方原合同卡片的文件扩展名;没有扩展名时使用通用文档标识。 */
|
||||
function getProcurementOriginalContractExtension(name: string): string {
|
||||
const extension = name.split('.').pop()?.trim();
|
||||
return extension ? extension.toUpperCase().slice(0, 4) : 'DOC';
|
||||
}
|
||||
|
||||
const procurementQuickActions = computed(() => {
|
||||
const actions = [
|
||||
{
|
||||
@@ -457,7 +463,7 @@ watch(
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="attachments.length > 0"
|
||||
v-if="attachments.length > 0 || (isProcurementContractAgent && procurementReviewMode === 'compare' && procurementOriginalContractName)"
|
||||
data-testid="chat-attachment-list"
|
||||
class="relative flex items-center gap-1 px-2.5 pb-2 pt-1"
|
||||
>
|
||||
@@ -473,9 +479,44 @@ watch(
|
||||
@pointercancel="stopAttachmentDrag"
|
||||
@pointerleave="stopAttachmentDrag"
|
||||
>
|
||||
<article
|
||||
v-if="isProcurementContractAgent && procurementReviewMode === 'compare' && procurementOriginalContractName"
|
||||
data-testid="procurement-original-contract-card"
|
||||
class="group relative flex h-[68px] w-[250px] shrink-0 items-center gap-3 rounded-xl border border-[#9cc7f2] bg-[#eef6ff] px-3 py-2.5 transition-colors"
|
||||
:title="procurementOriginalContractName"
|
||||
>
|
||||
<div
|
||||
class="flex h-11 w-10 shrink-0 flex-col items-center justify-center rounded-lg bg-brand-50 text-brand-700 dark:bg-brand-900/30 dark:text-brand-300"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<FileText class="h-4.5 w-4.5" />
|
||||
<span class="mt-0.5 max-w-9 truncate text-[9px] font-bold leading-none">{{ getProcurementOriginalContractExtension(procurementOriginalContractName) }}</span>
|
||||
</div>
|
||||
<div class="min-w-0 flex-1 pr-5">
|
||||
<p class="truncate text-sm font-medium text-primary">
|
||||
<span class="mr-1 text-[#2f80d1]">{{ $t('chat.procurementContract.originalContractChip', { name: '' }) }}</span>
|
||||
{{ procurementOriginalContractName }}
|
||||
</p>
|
||||
<div class="mt-1 flex min-w-0 items-center gap-1.5 text-[11px] leading-none text-muted">
|
||||
<span>{{ $t('chat.attachment.pending') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="remove-procurement-original-contract"
|
||||
class="absolute right-1.5 top-1.5 flex h-6 w-6 items-center justify-center rounded-full text-muted opacity-80 transition hover:bg-surface hover:text-red-500 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-400"
|
||||
:title="t('chat.attachment.remove')"
|
||||
:aria-label="t('chat.attachment.removeNamed', { name: procurementOriginalContractName })"
|
||||
@pointerdown.stop
|
||||
@click.stop="emit('clear-procurement-original-contract')"
|
||||
>
|
||||
<X class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</article>
|
||||
<article
|
||||
v-for="a in attachments"
|
||||
:key="a.id"
|
||||
data-testid="chat-attachment-card"
|
||||
class="group relative flex h-[68px] w-[250px] shrink-0 items-center gap-3 rounded-xl px-3 py-2.5 transition-colors"
|
||||
:class="isProcurementContractAgent && a.kind === 'local'
|
||||
? 'border border-[#9cc7f2] bg-[#eef6ff]'
|
||||
@@ -572,7 +613,8 @@ watch(
|
||||
:disabled="isAttachmentRemoveDisabled(a)"
|
||||
:title="t('chat.attachment.remove')"
|
||||
:aria-label="t('chat.attachment.removeNamed', { name: getAttachmentName(a) })"
|
||||
@click="emit('remove-attachment', a.id)"
|
||||
@pointerdown.stop
|
||||
@click.stop="emit('remove-attachment', a.id)"
|
||||
>
|
||||
<X class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
@@ -606,19 +648,6 @@ watch(
|
||||
@change="emit('procurement-original-contract-selected', $event)"
|
||||
/>
|
||||
|
||||
<div
|
||||
v-if="isProcurementContractAgent && procurementReviewMode === 'compare' && procurementOriginalContractName"
|
||||
class="flex flex-wrap gap-2 px-3 pb-1"
|
||||
>
|
||||
<div class="flex items-center gap-2 rounded-lg border border-dashed border-[#8db8e6] bg-[#eef6ff] px-2 py-1 text-xs font-semibold text-[#1f5f99]">
|
||||
<FileText class="h-3.5 w-3.5" />
|
||||
<span class="max-w-[260px] truncate">{{ $t('chat.procurementContract.originalContractChip', { name: procurementOriginalContractName }) }}</span>
|
||||
<button type="button" class="text-[#1f5f99] hover:opacity-80" @click="emit('clear-procurement-original-contract')">
|
||||
<X class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="hasProcurementContractAttachment"
|
||||
class="flex flex-wrap items-center gap-2 px-3 pb-1"
|
||||
|
||||
@@ -48,6 +48,7 @@ const {
|
||||
pinMessagesToBottom?: boolean;
|
||||
/** 供父级滚动逻辑绑定 main 元素 */
|
||||
scrollContainerHolder: { el: Ref<HTMLElement | null> };
|
||||
compactShippingProgress?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -61,6 +62,7 @@ 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 bindScrollContainer = (node: unknown) => {
|
||||
@@ -77,32 +79,45 @@ const getMessageKey = (msg: ChatMessage, index: number) => (
|
||||
|| `${msg.role}:${msg.run_id || 'none'}:${String(msg.content || '').slice(0, 40)}:${index}`
|
||||
);
|
||||
|
||||
/** 同一 Run 只展示最后一张状态卡,避免历史恢复/SSE 补帧造成重复窗口。 */
|
||||
/** 同一 Run 或同一次上传批次只展示最后一张状态卡,避免历史恢复/SSE 补帧造成重复窗口。 */
|
||||
const isDuplicateShippingExtractionMessage = (items: ChatMessage[], index: number): boolean => {
|
||||
const current = items[index];
|
||||
if (!current?.shipping_order_extraction_state) return false;
|
||||
const payload = current.payload && typeof current.payload === 'object'
|
||||
? current.payload as Record<string, unknown>
|
||||
: {};
|
||||
const identity = String(
|
||||
const runIdentity = String(
|
||||
payload.order_extraction_run_no
|
||||
|| payload.formId
|
||||
|| current.shipping_order_extraction_state.runNo
|
||||
|| '',
|
||||
).trim();
|
||||
if (!identity) return false;
|
||||
const batchIdentity = String(
|
||||
payload.shipping_order_extraction_upload_batch_id
|
||||
|| current.shipping_order_extraction_state.uploadBatchId
|
||||
|| '',
|
||||
).trim();
|
||||
if (!runIdentity && !batchIdentity) return false;
|
||||
return items.slice(index + 1).some((candidate) => {
|
||||
if (!candidate?.shipping_order_extraction_state) return false;
|
||||
const candidatePayload = candidate.payload && typeof candidate.payload === 'object'
|
||||
? candidate.payload as Record<string, unknown>
|
||||
: {};
|
||||
const candidateIdentity = String(
|
||||
const candidateRunIdentity = String(
|
||||
candidatePayload.order_extraction_run_no
|
||||
|| candidatePayload.formId
|
||||
|| candidate.shipping_order_extraction_state.runNo
|
||||
|| '',
|
||||
).trim();
|
||||
return candidateIdentity === identity;
|
||||
const candidateBatchIdentity = String(
|
||||
candidatePayload.shipping_order_extraction_upload_batch_id
|
||||
|| candidate.shipping_order_extraction_state.uploadBatchId
|
||||
|| '',
|
||||
).trim();
|
||||
return Boolean(
|
||||
(batchIdentity && candidateBatchIdentity === batchIdentity)
|
||||
|| (runIdentity && candidateRunIdentity === runIdentity),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -153,6 +168,7 @@ const isLatestAssistantMessage = (items: ChatMessage[], index: number) => {
|
||||
:leave-handlers="leaveHandlers"
|
||||
:shipping-handlers="shippingHandlers"
|
||||
:training-handlers="trainingHandlers"
|
||||
:compact-shipping-progress="compactShippingProgress"
|
||||
@copy="emit('copy', { message: msg, index })"
|
||||
@edit="emit('edit', $event)"
|
||||
@resend="emit('resend', $event)"
|
||||
@@ -161,6 +177,7 @@ const isLatestAssistantMessage = (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)"
|
||||
|
||||
@@ -88,7 +88,8 @@ const route = useRoute();
|
||||
|
||||
const shippingProcessing = useShippingNoticeWorkflow({
|
||||
// 历史会话首屏直接使用路由 ID,与聊天消息并行拉取统一进度。
|
||||
conversationId: () => page.conversationId || String(route.query.conversation_id || ''),
|
||||
// 路由切换先于 page 历史消息回填;必须先切换 Projection,禁止短暂复用旧会话卡片。
|
||||
conversationId: () => String(route.query.conversation_id || page.conversationId || ''),
|
||||
refreshTrigger: () => page.workflowRefreshTrigger,
|
||||
});
|
||||
provide(SHIPPING_WORKFLOW_KEY, shippingProcessing);
|
||||
@@ -151,13 +152,39 @@ const activeExtractionRunNo = computed(() => {
|
||||
|
||||
});
|
||||
|
||||
/** 批次进度工作台按需打开;关闭时不占用对话区右侧布局。 */
|
||||
const batchWorkbenchOpen = ref(false);
|
||||
|
||||
|
||||
|
||||
const showShippingWorkflowTimeline = computed(() => (
|
||||
page.isShippingNoticeAgent
|
||||
&& batchWorkbenchOpen.value
|
||||
&& Boolean(page.conversationId || activeExtractionRunNo.value)
|
||||
));
|
||||
|
||||
const compactShippingProgress = computed(() => batchWorkbenchOpen.value);
|
||||
|
||||
function openBatchWorkbench() {
|
||||
batchWorkbenchOpen.value = true;
|
||||
}
|
||||
|
||||
function closeBatchWorkbench() {
|
||||
batchWorkbenchOpen.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批次中心只服务于用户主动打开时所在的会话。切换历史会话或 Agent 后必须关闭,
|
||||
* 否则旧会话的右侧投影会短暂占用新会话的对话区并造成“本次处理”串批错觉。
|
||||
*/
|
||||
watch(
|
||||
() => [String(page.conversationId || ''), Number(page.currentAgentId || 0)] as const,
|
||||
(next, previous) => {
|
||||
if (!previous || next[0] === previous[0] && next[1] === previous[1]) return;
|
||||
batchWorkbenchOpen.value = false;
|
||||
},
|
||||
);
|
||||
|
||||
const embeddedIframeSrc = computed(() => {
|
||||
|
||||
const agent = page.currentAgent;
|
||||
@@ -480,9 +507,9 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
<ShippingOrderReviewView v-if="isOrderReviewMode" />
|
||||
|
||||
<div v-else class="flex min-h-0 min-w-0 flex-1">
|
||||
<div v-else class="flex min-h-0 min-w-0 flex-1" :class="showShippingWorkflowTimeline ? 'shipping-workbench-layout' : ''">
|
||||
|
||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col">
|
||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col" :class="showShippingWorkflowTimeline ? 'shipping-chat-column' : ''">
|
||||
|
||||
<TrainingWorkspacePanel
|
||||
|
||||
@@ -560,6 +587,8 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
:scroll-container-holder="page.scrollContainerHolder"
|
||||
|
||||
:compact-shipping-progress="compactShippingProgress"
|
||||
|
||||
@copy="page.copyToClipboard($event.message, $event.index)"
|
||||
|
||||
@edit="page.input = $event"
|
||||
@@ -580,6 +609,8 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
@maintenance-create-record-for-device="openMaintenanceRecordCreate"
|
||||
|
||||
@open-batch-workbench="openBatchWorkbench"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
@@ -666,6 +697,8 @@ watch(() => page.currentAgentId, () => {
|
||||
:conversation-id="page.conversationId"
|
||||
:refresh-trigger="page.workflowRefreshTrigger"
|
||||
:controller="shippingProcessing"
|
||||
|
||||
@close="closeBatchWorkbench"
|
||||
/>
|
||||
|
||||
|
||||
@@ -816,3 +849,16 @@ 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>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/chat/components/ShippingWorkflowStepper.vue
|
||||
* 用途:货代发货七步流程 Stepper 展示组件。
|
||||
* 用途:货代发货四阶段 Stepper 展示组件。
|
||||
* 依赖:shipping/shippingStepper、vue-i18n。
|
||||
* 逻辑:Chat 与工作台传入 steps 数组;本组件只负责步骤高亮与标签渲染。
|
||||
*/
|
||||
@@ -33,7 +33,7 @@ const dotClass = (status: ShippingWorkflowStepItem['status']) => {
|
||||
<template>
|
||||
<div class="space-y-2">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.18em] text-muted">{{ t('chat.shippingNoticeUi.stepperTitle') }}</div>
|
||||
<div class="grid gap-2" :class="compact ? 'sm:grid-cols-4 xl:grid-cols-7' : 'md:grid-cols-4 xl:grid-cols-7'">
|
||||
<div class="grid gap-2" :class="compact ? 'sm:grid-cols-4' : 'md:grid-cols-4'">
|
||||
<div
|
||||
v-for="(step, index) in steps"
|
||||
:key="step.id"
|
||||
|
||||
@@ -72,6 +72,7 @@ const {
|
||||
leaveHandlers: LeaveMessageHandlers;
|
||||
shippingHandlers: ShippingMessageHandlers;
|
||||
trainingHandlers: TrainingHandlers;
|
||||
compactShippingProgress?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -83,6 +84,7 @@ 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();
|
||||
@@ -712,7 +714,9 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
? 'rounded-2xl rounded-tr-sm bg-brand-600 px-5 py-2.5 text-white shadow-sm shadow-brand-500/15'
|
||||
: isContractReviewMessage
|
||||
? 'w-full'
|
||||
: 'chat-msg-assistant'"
|
||||
: shippingOrderExtractionState
|
||||
? 'w-full'
|
||||
: 'chat-msg-assistant'"
|
||||
>
|
||||
<template v-if="message.role === 'user'">
|
||||
<ChatMessageAttachmentList
|
||||
@@ -731,9 +735,11 @@ 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"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewActionConfirmDialog.vue
|
||||
用途:复核页破坏性/不可逆操作的二次确认弹窗(确认建单、重识别、非订单、质量异常、替代 PDF)。
|
||||
用途:复核页破坏性/不可逆操作的二次确认弹窗(确认建单、重识别、非订单、质量异常)。
|
||||
依赖:vue-i18n、dialog-overlay / dialog-panel 设计系统样式。
|
||||
逻辑:ShippingOrderReviewView 以 v-model 控制显隐;质量异常须选原因码,other 时备注必填;
|
||||
非订单/重识别将说明写入 comment,并附带稳定 reasonCode。
|
||||
@@ -9,7 +9,7 @@
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
export type ReviewConfirmAction = 'confirm' | 'reparse' | 'non_order' | 'replace' | 'quality_issue';
|
||||
export type ReviewConfirmAction = 'confirm' | 'reparse' | 'non_order' | 'quality_issue';
|
||||
|
||||
/** 确认弹窗提交载荷:稳定原因码 + 自由说明,供后端审计复盘。 */
|
||||
export type ReviewConfirmPayload = {
|
||||
|
||||
+45
@@ -18,6 +18,8 @@ const i18n = createI18n({
|
||||
line: '第 {index} 行',
|
||||
buildEligibility: {
|
||||
overallResult: '整单结果', canBuildYes: '可建单', canBuildNo: '待处理',
|
||||
manualBuildLabel: '人工建单', autoBuildLabel: '自动建单',
|
||||
autoBuildYes: '可自动建单', autoBuildNo: '暂不可自动建单',
|
||||
manualConfirmOnly: '需人工确认', blockReasons: { unknown: '未知阻断' },
|
||||
routingStatus: { unknown: '未知' },
|
||||
},
|
||||
@@ -40,6 +42,49 @@ const eligibility = {
|
||||
};
|
||||
|
||||
describe('ReviewBuildEligibilityDetailsDrawer', () => {
|
||||
it('separates manual buildability from automatic creation eligibility', () => {
|
||||
const wrapper = mount(ReviewBuildEligibilityDetailsDrawer, {
|
||||
props: {
|
||||
open: true,
|
||||
eligibility: {
|
||||
can_build: true,
|
||||
can_auto_create: false,
|
||||
status: 'ready',
|
||||
failed_gates: ['field_conflicts_resolved'],
|
||||
issues: [],
|
||||
line_projections: [],
|
||||
},
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 关键断言:抽屉不能只写“可建单”而让自动门禁失败看似矛盾。
|
||||
expect(wrapper.find('[data-testid="review-eligibility-manual-status"]').text()).toContain('可建单');
|
||||
expect(wrapper.find('[data-testid="review-eligibility-auto-status"]').text()).toContain('暂不可自动建单');
|
||||
});
|
||||
|
||||
it('does not render an empty diagnostic section when there are no diagnostic facts', () => {
|
||||
const wrapper = mount(ReviewBuildEligibilityDetailsDrawer, {
|
||||
props: {
|
||||
open: true,
|
||||
eligibility: {
|
||||
can_build: true,
|
||||
can_auto_create: false,
|
||||
status: 'ready',
|
||||
issues: [],
|
||||
failed_gates: [],
|
||||
assessment: { missing_required_fields: [] },
|
||||
line_projections: [{ line_key: 'L1', line_index: 0, can_build: true }],
|
||||
},
|
||||
fieldConflicts: [],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 关键断言:没有问题明细时不能留下无内容的边框占位区。
|
||||
expect(wrapper.findAll('section')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('lists the exact conflicting field, line, sources and values', () => {
|
||||
const wrapper = mount(ReviewBuildEligibilityDetailsDrawer, {
|
||||
props: {
|
||||
|
||||
+31
-4
@@ -134,6 +134,15 @@ const unexplainedBlocked = computed(() => Boolean(
|
||||
&& !props.eligibility.assessment?.missing_required_fields?.length
|
||||
&& !(props.eligibility.line_projections || []).some((line) => line.can_build === false),
|
||||
));
|
||||
|
||||
/** 有可解释的诊断事实时才渲染中段,避免通过订单留下空白占位框。 */
|
||||
const hasDiagnosticDetails = computed(() => Boolean(
|
||||
props.eligibility?.assessment?.missing_required_fields?.length
|
||||
|| nonConflictIssues.value.length
|
||||
|| unexplainedBlocked.value
|
||||
|| props.fieldConflicts?.length
|
||||
|| hasFieldConflictIssue.value
|
||||
));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -163,12 +172,27 @@ const unexplainedBlocked = computed(() => Boolean(
|
||||
: 'border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100'"
|
||||
data-testid="review-eligibility-details-overall"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="font-semibold">{{ t('chat.shippingOrderReview.buildEligibility.overallResult') }}</span>
|
||||
<span class="text-slate-600 dark:text-slate-300">{{ t('chat.shippingOrderReview.buildEligibility.manualBuildLabel') }}</span>
|
||||
<span class="rounded-full px-2 py-0.5 font-medium" :class="eligibility.can_build ? 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/60 dark:text-emerald-100' : 'bg-amber-100 text-amber-900 dark:bg-amber-900/60 dark:text-amber-100'">
|
||||
{{ eligibility.can_build
|
||||
<span data-testid="review-eligibility-manual-status">{{ eligibility.can_build
|
||||
? t('chat.shippingOrderReview.buildEligibility.canBuildYes')
|
||||
: t('chat.shippingOrderReview.buildEligibility.canBuildNo') }}
|
||||
: t('chat.shippingOrderReview.buildEligibility.canBuildNo') }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-slate-600 dark:text-slate-300">{{ t('chat.shippingOrderReview.buildEligibility.autoBuildLabel') }}</span>
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-medium"
|
||||
:class="eligibility.can_auto_create
|
||||
? 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/60 dark:text-emerald-100'
|
||||
: 'bg-amber-100 text-amber-900 dark:bg-amber-900/60 dark:text-amber-100'"
|
||||
data-testid="review-eligibility-auto-status"
|
||||
>
|
||||
{{ eligibility.can_auto_create
|
||||
? t('chat.shippingOrderReview.buildEligibility.autoBuildYes')
|
||||
: t('chat.shippingOrderReview.buildEligibility.autoBuildNo') }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="eligibility.can_build && eligibility.can_auto_create === false" class="mt-1">
|
||||
@@ -183,7 +207,10 @@ const unexplainedBlocked = computed(() => Boolean(
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<section class="rounded-lg border border-slate-200 bg-slate-50 p-3 text-xs dark:border-slate-700 dark:bg-slate-950/40">
|
||||
<section
|
||||
v-if="hasDiagnosticDetails"
|
||||
class="rounded-lg border border-slate-200 bg-slate-50 p-3 text-xs dark:border-slate-700 dark:bg-slate-950/40"
|
||||
>
|
||||
<div v-if="eligibility.assessment?.missing_required_fields?.length" class="mt-2">
|
||||
<div class="font-medium">{{ t('chat.shippingOrderReview.workbench.requiredFields') }}</div>
|
||||
<div class="mt-1 text-rose-700 dark:text-rose-300">
|
||||
|
||||
+12
-9
@@ -165,8 +165,8 @@ describe('ReviewBuildEligibilitySummary', () => {
|
||||
expect(wrapper.text()).not.toContain('can_auto_create');
|
||||
});
|
||||
|
||||
it('hides primary-block under focusBuildability for inventory combo (UI-03)', () => {
|
||||
// 关键断言:库存阻断由 Gate 卡表达时,资格摘要不得再输出首要阻断标题。
|
||||
it('keeps primary-block under focusBuildability for inventory combo (UI-03)', () => {
|
||||
// 关键断言:当前任务卡只承载动作,资格摘要仍保留库存门禁的具体解释。
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
@@ -218,13 +218,14 @@ describe('ReviewBuildEligibilitySummary', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-build-eligibility-summary"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-eligibility-gate-checklist"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-eligibility-gate-checklist"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-exception-nav"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('hides primary-block under focusBuildability for field completeness combo (UI-03)', () => {
|
||||
// 关键断言:字段阻断组合态下资格卡只保留摘要与异常导航,不输出第二份首要阻断。
|
||||
it('keeps concrete missing-field diagnostics visible under focusBuildability (UI-03)', () => {
|
||||
// 关键断言:当前任务卡只承载动作;建单资格卡仍必须给出缺失字段和首要阻断,
|
||||
// 否则用户无法从泛化 Gate 文案定位订单明细问题。
|
||||
const wrapper = mount(ReviewBuildEligibilitySummary, {
|
||||
props: {
|
||||
eligibility: {
|
||||
@@ -280,11 +281,13 @@ describe('ReviewBuildEligibilitySummary', () => {
|
||||
})],
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-eligibility-gate-checklist"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('缺失必填:PO');
|
||||
});
|
||||
|
||||
it('hides primary-block when technical_auto_only leaves business gate inactive (UI-03)', () => {
|
||||
// 关键断言:仅技术 Gate pending 时 focusBuildability=false,资格卡可展示阻断;本测验证开启 focus 时仍唯一。
|
||||
it('keeps passing eligibility concise when focusBuildability is enabled (UI-03)', () => {
|
||||
// 关键断言:无阻断时不额外渲染首要阻断;focusBuildability 不影响资格事实展示。
|
||||
const wrapper = mount(ReviewBuildEligibilitySummary, {
|
||||
props: {
|
||||
eligibility: {
|
||||
|
||||
+5
-5
@@ -21,8 +21,8 @@ const props = defineProps<{
|
||||
/** 当前定位异常序号;未定位时为 0。 */
|
||||
exceptionOrdinal?: number;
|
||||
/**
|
||||
* 为 true 时只展示能否建单/自动建单与异常导航,隐藏门禁清单与首要阻断文案,
|
||||
* 避免与 ProcessGateRecoveryCard 重复表达同一业务阻断。
|
||||
* 兼容旧调用方的展示偏好。当前任务卡只承载动作,建单门禁仍须完整展示,
|
||||
* 因此该参数不再隐藏字段级诊断,避免用户只能看到泛化阻断原因。
|
||||
*/
|
||||
focusBuildability?: boolean;
|
||||
}>();
|
||||
@@ -233,7 +233,7 @@ const gateChecklist = computed(() => {
|
||||
{{ t('chat.shippingOrderReview.buildEligibility.manualConfirmOnly') }}
|
||||
</p>
|
||||
<ul
|
||||
v-if="!focusBuildability && gateChecklist.length"
|
||||
v-if="gateChecklist.length"
|
||||
class="mt-2 space-y-1 text-xs"
|
||||
data-testid="review-eligibility-gate-checklist"
|
||||
>
|
||||
@@ -285,7 +285,7 @@ const gateChecklist = computed(() => {
|
||||
<p v-if="conflictFields.length"><span class="font-semibold">{{ t('chat.shippingOrderReview.workbench.conflictFields') }}:</span>{{ [...new Set(conflictFields)].join('、') }}</p>
|
||||
</div>
|
||||
<div
|
||||
v-if="!focusBuildability && lowConfidenceFields.length"
|
||||
v-if="lowConfidenceFields.length"
|
||||
class="mt-2 rounded-lg border border-amber-200 bg-amber-50 px-2.5 py-2 text-xs text-amber-950 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100"
|
||||
data-testid="review-low-confidence-fields"
|
||||
>
|
||||
@@ -298,7 +298,7 @@ const gateChecklist = computed(() => {
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="!focusBuildability && !eligibility.can_build && primaryBlockMessage"
|
||||
v-if="!eligibility.can_build && primaryBlockMessage"
|
||||
class="mt-2 rounded-lg border border-amber-200 bg-amber-50 px-2.5 py-2 text-xs text-amber-950 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100"
|
||||
data-testid="review-eligibility-primary-block"
|
||||
>
|
||||
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewConversationRetryDrawer.vue
|
||||
用途:按需展示本次对话级自动推进重试的逐项结果,不占用订单复核主内容。
|
||||
依赖:vue-i18n、对话级重试 API 返回的摘要和对象结果。
|
||||
逻辑:仅用户主动从顶栏打开;按结果分类展示,关闭不改变任务真实状态。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { RefreshCw } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
type RetryItem = {
|
||||
object_type: string;
|
||||
object_ref: string;
|
||||
action?: string | null;
|
||||
outcome: string;
|
||||
reason_code?: string | null;
|
||||
};
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
result: {
|
||||
summary: { total: number; retried: number; skipped: number; failed: number; blocked?: number };
|
||||
items: RetryItem[];
|
||||
} | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ close: [] }>();
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const items = computed(() => props.result?.items || []);
|
||||
|
||||
function itemLabel(item: RetryItem): string {
|
||||
const code = String(item.reason_code || '').trim();
|
||||
const key = `chat.shippingOrderReview.conversationRetry.reason.${code}`;
|
||||
return code && te(key) ? t(key) : outcomeLabel(item.outcome);
|
||||
}
|
||||
|
||||
function outcomeLabel(outcome: string): string {
|
||||
const key = `chat.shippingOrderReview.conversationRetry.outcome.${String(outcome || '').trim()}`;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.conversationRetry.outcome.unknown');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open && result"
|
||||
class="fixed inset-0 z-40 flex justify-end bg-slate-900/10"
|
||||
data-testid="review-conversation-retry-drawer"
|
||||
@click.self="emit('close')"
|
||||
>
|
||||
<aside class="flex h-full w-full max-w-[360px] flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-slate-800 dark:bg-slate-900">
|
||||
<header class="flex items-center justify-between gap-3 border-b border-slate-200 px-3 py-2.5 dark:border-slate-800">
|
||||
<div class="flex min-w-0 items-center gap-2">
|
||||
<span class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/60 dark:text-amber-200">
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
</span>
|
||||
<div class="min-w-0">
|
||||
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.conversationRetry.title') }}</h2>
|
||||
<p class="truncate text-[11px] text-muted">{{ t('chat.shippingOrderReview.conversationRetry.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="rounded border border-slate-300 px-2 py-1 text-xs hover:bg-slate-50 dark:border-slate-600 dark:hover:bg-slate-800" data-testid="review-conversation-retry-drawer-close" @click="emit('close')">
|
||||
{{ t('chat.shippingOrderReview.workbench.close') }}
|
||||
</button>
|
||||
</header>
|
||||
<div class="flex flex-wrap gap-1.5 border-b border-slate-200 px-3 py-2 dark:border-slate-800">
|
||||
<p class="rounded-full bg-emerald-50 px-2 py-1 text-[11px] text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300" data-testid="review-conversation-retry-retried">{{ t('chat.shippingOrderReview.conversationRetry.retried') }} <strong>{{ result.summary.retried }}</strong></p>
|
||||
<p class="rounded-full bg-slate-100 px-2 py-1 text-[11px] text-slate-600 dark:bg-slate-800 dark:text-slate-300" data-testid="review-conversation-retry-skipped">{{ t('chat.shippingOrderReview.conversationRetry.skipped') }} <strong>{{ result.summary.skipped }}</strong></p>
|
||||
<p class="rounded-full bg-rose-50 px-2 py-1 text-[11px] text-rose-700 dark:bg-rose-950/40 dark:text-rose-300" data-testid="review-conversation-retry-failed">{{ t('chat.shippingOrderReview.conversationRetry.failed') }} <strong>{{ result.summary.failed }}</strong></p>
|
||||
<p class="rounded-full bg-violet-50 px-2 py-1 text-[11px] text-violet-700 dark:bg-violet-950/40 dark:text-violet-300" data-testid="review-conversation-retry-blocked">{{ t('chat.shippingOrderReview.conversationRetry.blocked') }} <strong>{{ result.summary.blocked || 0 }}</strong></p>
|
||||
</div>
|
||||
<ul class="min-h-0 flex-1 divide-y divide-slate-100 overflow-y-auto dark:divide-slate-800" data-testid="review-conversation-retry-item-list">
|
||||
<li v-for="item in items" :key="`${item.object_type}:${item.object_ref}`" class="px-3 py-2.5 text-xs">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<p class="min-w-0 truncate font-medium text-slate-800 dark:text-slate-100">{{ item.object_ref }}</p>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-1.5 py-0.5 text-[10px]"
|
||||
:class="item.outcome === 'queued' ? 'bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300' : item.outcome === 'needs_human' ? 'bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300' : 'bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-300'"
|
||||
>{{ outcomeLabel(item.outcome) }}</span>
|
||||
</div>
|
||||
<p class="mt-0.5 text-[11px] text-muted">{{ itemLabel(item) }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
</template>
|
||||
+146
-4
@@ -15,6 +15,39 @@ const i18n = createI18n({
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
'chat.shippingOrderReview.processGate.actionCodes.retry_inventory_matching': '重新库存匹配',
|
||||
workspace: {
|
||||
shippingNotice: {
|
||||
processGate: {
|
||||
actionCodes: {
|
||||
retry_inventory_preparation: '重新获取库存',
|
||||
},
|
||||
inventoryActions: {
|
||||
retryInventoryMatching: '重新库存匹配',
|
||||
retryInventoryPreparation: '重新获取库存',
|
||||
},
|
||||
reasons: {
|
||||
inventory_shortage_review_required: '存在库存缺口,需要人工处理',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
saveOrderAndValidate: '保存订单并校验',
|
||||
currentProcessing: {
|
||||
waitingStart: '等待系统启动',
|
||||
},
|
||||
currentTask: {
|
||||
statusRunning: '系统处理中',
|
||||
nextStepWaitingExternal: '等待外部系统回执,暂不需要人工操作',
|
||||
},
|
||||
},
|
||||
shippingProcessing: {
|
||||
gateReasons: {
|
||||
generic: '当前步骤需要人工处理',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -44,6 +77,20 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('hides the order-review entry when the user is already in the lifecycle workbench', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
primaryAction: { code: 'open_order_review', i18nKey: 'chat.shippingProcessing.action.open_order_review' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 批次中心可以用它进入工作台;工作台当前阶段不能再显示同一个自跳转入口。
|
||||
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders Gate label_key for every primary action presentation', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
@@ -60,18 +107,113 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').text()).toBe('重新库存匹配');
|
||||
});
|
||||
|
||||
it('renders server-provided recovery actions without duplicating the primary action', async () => {
|
||||
it('does not render save and validate as a current-task action', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 保存订单并校验是底栏唯一动作;未提交校验必须给出明确交接提示,不能显示系统处理中。
|
||||
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
|
||||
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text()).toBe('保存订单并校验');
|
||||
});
|
||||
|
||||
it('labels an unqueued automatic Gate as waiting for system start', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'fulfillment_prep',
|
||||
userStatus: 'running',
|
||||
gateStatus: 'pending',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).toContain('等待系统启动');
|
||||
});
|
||||
|
||||
it('explains external wait without calling it generic system processing', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'upload_complete',
|
||||
userStatus: 'running',
|
||||
gateStatus: 'waiting_external',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text())
|
||||
.toBe('等待外部系统回执,暂不需要人工操作');
|
||||
});
|
||||
|
||||
it('never exposes an internal action code when its presentation is absent', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
primaryAction: { code: 'edit_draft' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 回退显示 edit_draft 会泄漏内部能力码;必须 fail-closed 隐藏。
|
||||
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).not.toContain('edit_draft');
|
||||
});
|
||||
|
||||
it('renders a localized reason instead of an internal blocking code in the next step', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'inventory_matching',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: { code: 'inventory_shortage_review_required' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
const nextStep = wrapper.get('[data-testid="review-current-task-next-step-text"]').text();
|
||||
expect(nextStep).toBe('存在库存缺口,需要人工处理');
|
||||
expect(nextStep).not.toContain('inventory_shortage_review_required');
|
||||
});
|
||||
|
||||
it('hides internal inventory recovery targets while retaining the stable primary action', async () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'inventory_matching',
|
||||
userStatus: 'waiting_human',
|
||||
primaryAction: { code: 'retry_inventory_matching', i18nKey: 'retry_inventory_matching' },
|
||||
recoveryActions: [{ code: 'retry_inventory_from_preparation' }],
|
||||
recoveryActions: [{
|
||||
code: 'retry_inventory_from_preparation',
|
||||
i18nKey: 'chat.shippingOrderReview.processGate.actionCodes.retry_inventory_matching',
|
||||
}],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="review-current-task-recovery-retry_inventory_from_preparation"]').exists()).toBe(true);
|
||||
expect(wrapper.findAll('button').length).toBe(2);
|
||||
expect(wrapper.find('[data-testid="review-current-task-recovery-retry_inventory_from_preparation"]').exists()).toBe(false);
|
||||
expect(wrapper.findAll('button').length).toBe(1);
|
||||
});
|
||||
|
||||
it('emits rematch and RPA refresh as distinct actions for a shortage with an active inventory file', async () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'fulfillment_prep',
|
||||
userStatus: 'waiting_human',
|
||||
primaryAction: { code: 'retry_inventory_matching' },
|
||||
recoveryActions: [{ code: 'retry_inventory_preparation' }],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
await wrapper.get('[data-testid="review-current-task-primary-action"]').trigger('click');
|
||||
await wrapper.get('[data-testid="review-current-task-recovery-retry_inventory_preparation"]').trigger('click');
|
||||
|
||||
// 两个稳定 action 码分别进入 Gate API:重匹配不可误触 RPA,重新获取库存才会触发 RPA。
|
||||
expect(wrapper.emitted('action')).toEqual([
|
||||
['retry_inventory_matching', {}],
|
||||
['retry_inventory_preparation', {}],
|
||||
]);
|
||||
});
|
||||
});
|
||||
+81
-24
@@ -8,13 +8,16 @@
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { RefreshCw, Crosshair } from 'lucide-vue-next';
|
||||
import { Bot, RefreshCw, Crosshair } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type {
|
||||
ShippingProcessingBlockingReason,
|
||||
ShippingProcessingPrimaryAction,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { 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';
|
||||
|
||||
const props = defineProps<{
|
||||
stageCode?: string | null;
|
||||
@@ -41,14 +44,14 @@ const props = defineProps<{
|
||||
label_key?: string | null;
|
||||
parameters?: Record<string, unknown>;
|
||||
}>;
|
||||
/** 正式 Gate 原始状态仅用于区分未入队、运行中与外部回执等待;不参与按钮裁决。 */
|
||||
gateStatus?: string | null;
|
||||
|
||||
taskMissing?: boolean;
|
||||
confirmedTaskId?: number | null;
|
||||
showAdminDiagnosis?: boolean;
|
||||
retrying?: boolean;
|
||||
locating?: boolean;
|
||||
/** 题7A:自动次数已耗尽但允许人工继续的源;不为空时按钮语义提示「人工继续」+ tooltip 列名。 */
|
||||
retryExhaustedSources?: string[] | null;
|
||||
/** 仅 UI 展示的 running 文案(如 inventory_preparation 正在跑时主卡按钮 loading 附加信息)。 */
|
||||
automation?: {
|
||||
status?: string | null;
|
||||
@@ -103,12 +106,16 @@ const statusLabel = computed(() => {
|
||||
if (props.taskMissing) {
|
||||
return t('chat.shippingOrderReview.currentProcessing.taskMissing');
|
||||
}
|
||||
if (s === 'running' && String(props.gateStatus || '').trim().toLowerCase() === 'pending') {
|
||||
return t('chat.shippingOrderReview.currentProcessing.waitingStart');
|
||||
}
|
||||
if (!s) return t('chat.shippingOrderReview.currentProcessing.statusIdle');
|
||||
return map[s] ?? t('chat.shippingOrderReview.currentProcessing.statusIdle');
|
||||
});
|
||||
|
||||
/**
|
||||
* 下一步(「下一步」section 的问题/说明文案):优先展示 blocking_reason,否则按 user_status 给系统态文案。
|
||||
* 下一步(「下一步」section 的问题/说明文案):优先展示 blocking_reason 的统一 i18n 映射,
|
||||
* 否则按 user_status 给系统态文案;禁止将后端内部原因码直接展示给用户。
|
||||
*/
|
||||
const nextStepText = computed(() => {
|
||||
const safeMessage = (value: unknown): string => {
|
||||
@@ -136,8 +143,27 @@ const nextStepText = computed(() => {
|
||||
if (i18nKey && te(i18nKey)) {
|
||||
return t(i18nKey);
|
||||
}
|
||||
// i18n 键缺失时回落为 code(不裸露给普通用户,最终 QA 期间应全部补齐)
|
||||
return safeMessage(br.code) || t('chat.shippingOrderReview.currentTask.nextStepUnknown');
|
||||
return resolveGateReasonLabel(br.code, { t, te })
|
||||
|| t('chat.shippingOrderReview.currentTask.nextStepUnknown');
|
||||
}
|
||||
// 建单前订单冻结校验尚未提交时,明确告诉用户下一步是保存并校验。
|
||||
// 保存是底栏唯一的表单提交入口,不升级为右栏 CTA;该分支也兼容历史响应
|
||||
// 仍携带 validate 的情形,避免「待人工」与「无需操作」产生语义矛盾。
|
||||
if (
|
||||
String(props.stageCode || '').trim() === 'order_review'
|
||||
&& !props.blockingReason
|
||||
&& (
|
||||
String(props.primaryAction?.code || '').trim() === 'validate'
|
||||
|| String(props.userStatus || '').trim() === 'waiting_human'
|
||||
)
|
||||
) {
|
||||
return t('chat.shippingOrderReview.saveOrderAndValidate');
|
||||
}
|
||||
if (
|
||||
String(props.userStatus || '').trim() === 'running'
|
||||
&& String(props.gateStatus || '').trim().toLowerCase() === 'waiting_external'
|
||||
) {
|
||||
return t('chat.shippingOrderReview.currentTask.nextStepWaitingExternal');
|
||||
}
|
||||
// 2) 无阻断时,按 user_status 给系统说明文案
|
||||
const s = String(props.userStatus || '').trim() as ReviewCurrentUserStatus | '';
|
||||
@@ -168,9 +194,33 @@ const showNextStep = computed(() => {
|
||||
return !['completed', 'cancelled'].includes(status);
|
||||
});
|
||||
|
||||
/**
|
||||
* 判断当前工作台是否应隐藏后端下发的纯导航动作。
|
||||
* 批次中心可用它打开工作台;进入工作台后必须复用注册表规则,避免当前阶段再次显示
|
||||
* 「进入订单复核」或「编辑正式任务」等自跳转入口。
|
||||
*/
|
||||
function isHiddenWorkbenchNavigationAction(code: string): boolean {
|
||||
const entry = lookupWorkbenchAction(code);
|
||||
return Boolean(entry && !shouldRenderWorkbenchAction(entry, {
|
||||
actionsExecutable: true,
|
||||
surface: 'review',
|
||||
actionCode: code,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前任务卡只承载正式 Gate 的可执行业务动作。
|
||||
*
|
||||
* 草稿编辑/建草稿是页面能力,保存校验是底栏唯一提交;它们即使出现在历史响应中,
|
||||
* 也不能升级为右栏 CTA,更不能因缺失文案泄漏内部动作码。
|
||||
*/
|
||||
function isNonTaskCapabilityAction(code: string): boolean {
|
||||
return new Set(['edit_draft', 'create_draft', 'validate']).has(code.trim().toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务动作按钮:后端确认 retryable=true → 主按钮为「重试」;
|
||||
* 否则若 primary_action.code 非 retry → 用 primary_action.code + i18n_key 渲染对应人工动作(进入复核/确认客户等)。
|
||||
* 否则若 primary_action.code 非 retry 且不是工作台内自跳转 → 渲染对应人工动作。
|
||||
*/
|
||||
const showBusinessAction = computed(() => {
|
||||
if (props.loading) return false;
|
||||
@@ -180,21 +230,23 @@ const showBusinessAction = computed(() => {
|
||||
if (props.userStatus === 'running') return false;
|
||||
if (props.retryable) return true;
|
||||
const code = String(props.primaryAction?.code || '').trim();
|
||||
if (isInternalInventoryAction(code)) return false;
|
||||
if (!code) return false;
|
||||
if (isNonTaskCapabilityAction(code)) return false;
|
||||
if (isHiddenWorkbenchNavigationAction(code)) return false;
|
||||
// retry 仅当 retryable=true 时展示(避免按钮闪烁矛盾)
|
||||
if (code === 'retry') return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
const businessActionLabel = computed(() => {
|
||||
if (props.retryable) {
|
||||
if ((props.retryExhaustedSources || []).length > 0) {
|
||||
return t('chat.shippingOrderReview.currentTask.actionRetryWithExhausted');
|
||||
}
|
||||
return t('chat.shippingOrderReview.currentTask.actionRetry');
|
||||
}
|
||||
const code = String(props.primaryAction?.code || '').trim();
|
||||
const inventoryKey = inventoryActionLabelKey(code);
|
||||
if (inventoryKey && te(inventoryKey)) return t(inventoryKey);
|
||||
if (props.retryable) return t('chat.shippingOrderReview.currentTask.actionRetry');
|
||||
const pa = props.primaryAction;
|
||||
if (!pa) return '';
|
||||
if (isNonTaskCapabilityAction(String(pa.code || ''))) return '';
|
||||
// Gate action presentation uses label_key; normalize it at the shared card boundary
|
||||
// so every gate renders its business label instead of exposing the action code.
|
||||
const i18nKey = String(
|
||||
@@ -210,17 +262,11 @@ const businessActionLabel = computed(() => {
|
||||
if (te(legacyKey)) {
|
||||
return t(legacyKey);
|
||||
}
|
||||
return pa.code;
|
||||
// 当前任务按钮没有受控文案时 fail-closed,禁止泄漏内部 action code。
|
||||
return '';
|
||||
});
|
||||
|
||||
/** 题7A:按钮 tooltip(exhausted_sources 列表与文案)。 */
|
||||
const businessActionTitle = computed(() => {
|
||||
const exhausted = Array.isArray(props.retryExhaustedSources) ? props.retryExhaustedSources.filter(Boolean) : [];
|
||||
if (exhausted.length > 0) {
|
||||
return t('chat.shippingOrderReview.currentTask.actionRetryExhaustedTooltip', {
|
||||
sources: exhausted.join(', '),
|
||||
});
|
||||
}
|
||||
const retryingFlag = Boolean(props.retrying);
|
||||
if (retryingFlag) {
|
||||
return t('chat.shippingOrderReview.currentTask.actionRetryRunningTooltip');
|
||||
@@ -229,18 +275,28 @@ const businessActionTitle = computed(() => {
|
||||
});
|
||||
|
||||
const actionIsRetry = computed(() => Boolean(props.retryable) || String(props.primaryAction?.code || '') === 'retry');
|
||||
const actionIsInventoryRpa = computed(() => String(props.primaryAction?.code || '').trim() === 'retry_inventory_preparation');
|
||||
const recoveryActions = computed(() => (props.recoveryActions || []).filter((action) => {
|
||||
const code = String(action.code || '').trim();
|
||||
return code && code !== String(props.primaryAction?.code || '').trim();
|
||||
if (!code || isNonTaskCapabilityAction(code) || isInternalInventoryAction(code)) return false;
|
||||
if (code === String(props.primaryAction?.code || '').trim()) return false;
|
||||
const key = String(
|
||||
action.i18nKey
|
||||
|| action.label_key
|
||||
|| `workspace.shippingNotice.processGate.actionCodes.${code}`,
|
||||
).trim();
|
||||
return Boolean(key && te(key));
|
||||
}));
|
||||
|
||||
function recoveryActionLabel(action: (typeof recoveryActions.value)[number]): string {
|
||||
const inventoryKey = inventoryActionLabelKey(action.code);
|
||||
if (inventoryKey && te(inventoryKey)) return t(inventoryKey);
|
||||
const key = String(
|
||||
action.i18nKey
|
||||
|| action.label_key
|
||||
|| `workspace.shippingNotice.processGate.actionCodes.${action.code}`,
|
||||
).trim();
|
||||
return key && te(key) ? t(key) : action.code;
|
||||
return key && te(key) ? t(key) : '';
|
||||
}
|
||||
|
||||
function handleBusinessActionClick() {
|
||||
@@ -383,8 +439,9 @@ type ReviewCurrentUserStatus =
|
||||
:title="businessActionTitle"
|
||||
@click="handleBusinessActionClick"
|
||||
>
|
||||
<Bot v-if="actionIsInventoryRpa" class="h-3.5 w-3.5" />
|
||||
<RefreshCw
|
||||
v-if="actionIsRetry"
|
||||
v-else-if="actionIsRetry"
|
||||
class="h-3.5 w-3.5"
|
||||
:class="{ 'animate-spin': Boolean(retrying) }"
|
||||
/>
|
||||
|
||||
+15
@@ -246,6 +246,21 @@ describe('ReviewDocumentEvidenceDrawer', () => {
|
||||
expect(wrapper.find('[data-testid="review-evidence-no-bbox"]').text()).toContain('10 EA');
|
||||
});
|
||||
|
||||
it('renders email evidence through the safe HTML preview URL', () => {
|
||||
const wrapper = mountDrawer({
|
||||
emailPreview: {
|
||||
document_id: 9,
|
||||
filename: 'source.eml',
|
||||
text: 'fallback text',
|
||||
render_kind: 'safe_html',
|
||||
preview_url: '/email-preview?token=one-shot',
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-email-evidence-html"]').attributes('src'))
|
||||
.toBe('/email-preview?token=one-shot');
|
||||
expect(wrapper.find('[data-testid="review-email-evidence-preview"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('does not render when closed', () => {
|
||||
const wrapper = mountDrawer({ open: false });
|
||||
expect(wrapper.find('[data-testid="review-document-evidence-drawer"]').exists()).toBe(false);
|
||||
|
||||
+14
-1
@@ -44,6 +44,7 @@ const props = defineProps<{
|
||||
docked: boolean;
|
||||
floatSide: 'right' | 'left';
|
||||
src: string;
|
||||
emailPreview?: { document_id: number; filename: string; text: string; render_kind: 'safe_html' | 'text'; preview_url?: string } | null;
|
||||
evidence: ShippingOrderReviewEvidence | null;
|
||||
evidenceList: ShippingOrderReviewEvidence[];
|
||||
fieldLabel?: string;
|
||||
@@ -729,8 +730,20 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
|
||||
<div class="grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)_auto]">
|
||||
<iframe
|
||||
v-if="emailPreview?.render_kind === 'safe_html' && emailPreview.preview_url"
|
||||
:src="emailPreview.preview_url"
|
||||
sandbox=""
|
||||
referrerpolicy="no-referrer"
|
||||
:title="fieldLabel || t('chat.shippingOrderReview.evidenceDrawer.title')"
|
||||
class="min-h-0 h-full w-full border-0 bg-white"
|
||||
data-testid="review-email-evidence-html"
|
||||
/>
|
||||
<div v-else-if="emailPreview" class="min-h-0 overflow-auto whitespace-pre-wrap p-4 font-mono text-xs leading-6 text-slate-700 dark:text-slate-200" data-testid="review-email-evidence-preview">
|
||||
{{ emailPreview.text }}
|
||||
</div>
|
||||
<ReviewDocumentPreview
|
||||
v-if="src"
|
||||
v-else-if="src"
|
||||
class="min-h-0"
|
||||
:src="src"
|
||||
:evidence="evidence"
|
||||
|
||||
+80
-2
@@ -20,6 +20,13 @@ const i18n = createI18n({
|
||||
unnamedDocument: '未命名 PDF',
|
||||
documentNavigation: '导航',
|
||||
caseStatuses: { draft: '草稿', unknown: '未知' },
|
||||
lifecycle: {
|
||||
stages: {
|
||||
order_review: '订单复核',
|
||||
fulfillment_prep: '通知准备',
|
||||
upload_complete: '通知完成',
|
||||
},
|
||||
},
|
||||
otNav: {
|
||||
listTitle: '订单列表 · {count}',
|
||||
searchPlaceholder: '搜索',
|
||||
@@ -71,16 +78,66 @@ describe('ReviewDocumentNavigation', () => {
|
||||
expect(wrapper.find('[data-testid="review-document-navigation"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('uses top tabs for 2–4 OTs', () => {
|
||||
const wrapper = mountNav(3, 'tabs');
|
||||
it('uses compact top tabs for 2–4 OTs', () => {
|
||||
const wrapper = mountNav(3);
|
||||
expect(wrapper.find('[data-testid="review-doc-nav-tabs"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-doc-nav-list"]').exists()).toBe(false);
|
||||
expect(wrapper.attributes('data-nav-mode')).toBe('tabs');
|
||||
});
|
||||
|
||||
it('uses sidebar list for 5–20 OTs', () => {
|
||||
const wrapper = mountNav(8, 'sidebar');
|
||||
expect(wrapper.find('[data-testid="review-doc-nav-list"]').exists()).toBe(true);
|
||||
expect(wrapper.attributes('data-nav-mode')).toBe('sidebar');
|
||||
expect(wrapper.classes()).toContain('sticky');
|
||||
});
|
||||
|
||||
it('keeps the sidebar collapse rail and the explicitly forced sidebar mode', async () => {
|
||||
const wrapper = mount(ReviewDocumentNavigation, {
|
||||
props: {
|
||||
items: items(8),
|
||||
activeCaseNo: 'C-1',
|
||||
navAriaLabel: 'nav',
|
||||
forceMode: 'sidebar',
|
||||
initiallyCollapsed: true,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 关键断言:收起后仍保留文件身份摘要,不能退化成无法识别的纯编号轨。
|
||||
expect(wrapper.attributes('data-nav-mode')).toBe('sidebar');
|
||||
expect(wrapper.get('[data-testid="review-doc-nav-C-2"]').text()).toContain('f2');
|
||||
await wrapper.get('[data-testid="review-doc-nav-collapse"]').trigger('click');
|
||||
expect(wrapper.get('[data-testid="review-doc-nav-C-2"]').text()).toContain('f2.pdf');
|
||||
expect(wrapper.get('[data-testid="review-doc-nav-list"]').attributes('data-collapsed')).toBe('false');
|
||||
});
|
||||
|
||||
it('keeps the file name as the queue row title while projecting PO, lifecycle stage and status', () => {
|
||||
const rows = items(5);
|
||||
rows[1] = {
|
||||
...rows[1],
|
||||
file_name: 'purchase-order-2.pdf',
|
||||
po_number: 'PO-002',
|
||||
lifecycle_stage: 'fulfillment_prep',
|
||||
status: 'processing',
|
||||
};
|
||||
const wrapper = mount(ReviewDocumentNavigation, {
|
||||
props: {
|
||||
items: rows,
|
||||
activeCaseNo: 'C-1',
|
||||
navAriaLabel: 'nav',
|
||||
forceMode: 'sidebar',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 文件导航先展示可识别的文件名;PO/阶段/状态仍都来自后端队列 DTO。
|
||||
const queueRow = wrapper.get('[data-testid="review-doc-nav-C-2"]');
|
||||
expect(queueRow.find('.font-medium').text()).toBe('purchase-order-2.pdf');
|
||||
expect(queueRow.text()).toContain('PO-002');
|
||||
expect(queueRow.text()).toContain('通知准备');
|
||||
// 关键断言:队列行内容必须是实际 DOM 子节点,不能被原生 template 隐藏成空白框。
|
||||
expect(queueRow.find('template').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('shows search for 20+ OTs', () => {
|
||||
@@ -94,4 +151,25 @@ describe('ReviewDocumentNavigation', () => {
|
||||
await wrapper.get('[data-testid="review-doc-nav-C-2"]').trigger('click');
|
||||
expect(wrapper.emitted('select')?.[0]).toEqual(['C-2']);
|
||||
});
|
||||
|
||||
it('keeps backend lifecycle stage visible in tabs and narrow queue', async () => {
|
||||
const rows = items(2);
|
||||
rows[1] = { ...rows[1], lifecycle_stage: 'fulfillment_prep', status: 'processing' };
|
||||
const tabs = mount(ReviewDocumentNavigation, {
|
||||
props: { items: rows, activeCaseNo: 'C-1', navAriaLabel: 'nav', forceMode: 'tabs' },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const narrow = mount(ReviewDocumentNavigation, {
|
||||
props: { items: rows, activeCaseNo: 'C-1', navAriaLabel: 'nav', forceMode: 'narrow' },
|
||||
global: { plugins: [i18n] },
|
||||
attachTo: document.body,
|
||||
});
|
||||
|
||||
// 关键断言:文件队列在任何响应式形态都只投影后端已裁决阶段。
|
||||
expect(tabs.get('[data-testid="review-doc-nav-C-2"]').text()).toContain('通知准备');
|
||||
await narrow.get('[data-testid="review-doc-nav-narrow-trigger"]').trigger('click');
|
||||
// 窄屏抽屉通过 Teleport 挂到 body,断言真实可见容器而非组件根节点。
|
||||
expect(document.body.querySelector('[data-testid="review-doc-nav-C-2"]')?.textContent).toContain('通知准备');
|
||||
narrow.unmount();
|
||||
});
|
||||
});
|
||||
+42
-11
@@ -1,8 +1,8 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewDocumentNavigation.vue
|
||||
用途:订单处理工作台 OT/PDF 导航(按数量响应式:隐藏 / 顶栏标签 / 左侧列表 / 窄屏抽屉)。
|
||||
用途:订单处理工作台 OT/PDF 导航(按数量响应式:隐藏 / 紧凑标签 / 左侧列表 / 窄屏抽屉)。
|
||||
依赖:vue-i18n、lucide-vue-next。
|
||||
逻辑:1 份隐藏;2–4 顶栏;≥5 左侧列表(可收起);20+ 搜索过滤;窄屏「订单 i/n」抽屉。
|
||||
逻辑:1 份隐藏;桌面端 2–4 紧凑标签、5–20 左侧列表(可收起);20+ 搜索过滤;窄屏「订单 i/n」抽屉。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
@@ -26,8 +26,12 @@ export type ReviewDocumentNavItem = {
|
||||
po_number?: string | null;
|
||||
customer_name?: string | null;
|
||||
stage_label?: string | null;
|
||||
/** 队列接口下发的生命周期码;仅用于本地化展示,不参与阶段裁决。 */
|
||||
lifecycle_stage?: ReviewLifecycleStageCode | null;
|
||||
};
|
||||
|
||||
type ReviewLifecycleStageCode = 'intake_parse' | 'order_review' | 'fulfillment_prep' | 'upload_complete';
|
||||
|
||||
export type ReviewDocumentNavMode = 'hidden' | 'tabs' | 'sidebar' | 'sidebar_search' | 'narrow';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -44,6 +48,7 @@ const props = defineProps<{
|
||||
const emit = defineEmits<{
|
||||
select: [caseNo: string];
|
||||
'mode-change': [mode: ReviewDocumentNavMode];
|
||||
'collapse-change': [collapsed: boolean];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -82,12 +87,14 @@ const mode = computed<ReviewDocumentNavMode>(() => {
|
||||
const count = props.items.length;
|
||||
if (count <= 1) return 'hidden';
|
||||
if (isNarrow.value) return 'narrow';
|
||||
// 多文件先选文件、后查看阶段;2–4 用紧凑标签,5+ 才占用左侧工作列。
|
||||
if (count <= 4) return 'tabs';
|
||||
if (count <= 20) return 'sidebar';
|
||||
return 'sidebar_search';
|
||||
});
|
||||
|
||||
watch(mode, (value) => emit('mode-change', value), { immediate: true });
|
||||
watch(collapsed, (value) => emit('collapse-change', value), { immediate: true });
|
||||
|
||||
const activeIndex = computed(() => {
|
||||
const idx = props.items.findIndex((item) => item.case_no === props.activeCaseNo);
|
||||
@@ -102,6 +109,14 @@ function caseStatusLabel(status: string): string {
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.caseStatuses.unknown');
|
||||
}
|
||||
|
||||
/** 后端阶段码只做 i18n 投影;缺失时保留空白,禁止按 Case 状态补造阶段。 */
|
||||
function lifecycleStageLabel(item: ReviewDocumentNavItem): string | null {
|
||||
const code = String(item.lifecycle_stage || '').trim() as ReviewLifecycleStageCode;
|
||||
if (!['intake_parse', 'order_review', 'fulfillment_prep', 'upload_complete'].includes(code)) return null;
|
||||
const key = `chat.shippingOrderReview.lifecycle.stages.${code}`;
|
||||
return te(key) ? t(key) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航状态图标语义。
|
||||
*/
|
||||
@@ -168,7 +183,7 @@ function onSelect(caseNo: string) {
|
||||
? 'rounded-xl border border-slate-200 bg-white p-2 shadow-sm dark:border-slate-800 dark:bg-slate-900'
|
||||
: mode === 'narrow'
|
||||
? ''
|
||||
: 'sticky top-3 flex max-h-[calc(100vh-6rem)] w-full shrink-0 flex-col rounded-xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900 lg:w-64'"
|
||||
: ['sticky top-3 flex max-h-[calc(100vh-6rem)] w-full shrink-0 flex-col rounded-xl border border-slate-200 bg-white shadow-sm transition-[width] duration-200 dark:border-slate-800 dark:bg-slate-900', collapsed ? 'lg:w-20' : 'lg:w-64']"
|
||||
>
|
||||
<!-- 2–4:顶部标签 -->
|
||||
<div
|
||||
@@ -208,11 +223,15 @@ function onSelect(caseNo: string) {
|
||||
class="h-3 w-3 shrink-0 text-slate-400"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span class="truncate">{{ item.po_number || item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}</span>
|
||||
<span class="truncate">{{ item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}</span>
|
||||
</span>
|
||||
<span class="truncate text-[10px] text-slate-500 dark:text-slate-400">
|
||||
{{ item.customer_name || caseStatusLabel(item.status) }}
|
||||
<template v-if="item.stage_label"> · {{ item.stage_label }}</template>
|
||||
{{ [
|
||||
item.po_number,
|
||||
lifecycleStageLabel(item),
|
||||
item.stage_label,
|
||||
item.customer_name || caseStatusLabel(item.status),
|
||||
].filter(Boolean).join(' · ') }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -227,6 +246,7 @@ function onSelect(caseNo: string) {
|
||||
type="button"
|
||||
class="rounded p-1 text-muted hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
data-testid="review-doc-nav-collapse"
|
||||
:aria-label="collapsed ? t('chat.shippingOrderReview.documentNavigation') : t('chat.shippingOrderReview.documentNavigation')"
|
||||
@click="collapsed = !collapsed"
|
||||
>
|
||||
<ChevronLeft
|
||||
@@ -270,6 +290,7 @@ function onSelect(caseNo: string) {
|
||||
<div
|
||||
class="min-h-0 flex-1 overflow-y-auto p-1.5"
|
||||
data-testid="review-doc-nav-list"
|
||||
:data-collapsed="collapsed"
|
||||
>
|
||||
<button
|
||||
v-for="(item, index) in (collapsed ? items : filteredItems)"
|
||||
@@ -287,9 +308,13 @@ function onSelect(caseNo: string) {
|
||||
>
|
||||
<span
|
||||
v-if="collapsed"
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-slate-100 text-[10px] font-semibold dark:bg-slate-800"
|
||||
class="flex h-12 w-full min-w-0 flex-col items-center justify-center rounded-md bg-slate-100 px-1 text-[10px] dark:bg-slate-800"
|
||||
:title="`${index + 1}. ${item.file_name || item.case_no}`"
|
||||
>
|
||||
{{ index + 1 }}
|
||||
<span class="font-semibold">{{ index + 1 }}</span>
|
||||
<span class="mt-0.5 w-full truncate text-center text-[9px] font-medium text-slate-600 dark:text-slate-300">
|
||||
{{ (item.file_name || item.case_no).replace(/\.[^.]+$/, '').slice(0, 7) }}
|
||||
</span>
|
||||
</span>
|
||||
<template v-else>
|
||||
<TriangleAlert
|
||||
@@ -310,10 +335,14 @@ function onSelect(caseNo: string) {
|
||||
/>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block truncate font-medium text-primary">
|
||||
{{ item.po_number || item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}
|
||||
{{ item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}
|
||||
</span>
|
||||
<span class="block truncate text-[10px] text-muted">
|
||||
{{ item.customer_name || caseStatusLabel(item.status) }}
|
||||
{{ [
|
||||
item.po_number,
|
||||
lifecycleStageLabel(item),
|
||||
item.customer_name || caseStatusLabel(item.status),
|
||||
].filter(Boolean).join(' · ') }}
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
@@ -367,7 +396,9 @@ function onSelect(caseNo: string) {
|
||||
@click="onSelect(item.case_no)"
|
||||
>
|
||||
<span class="font-medium">{{ item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}</span>
|
||||
<span class="text-[10px] text-muted">{{ caseStatusLabel(item.status) }}</span>
|
||||
<span class="text-[10px] text-muted">
|
||||
{{ [lifecycleStageLabel(item), caseStatusLabel(item.status)].filter(Boolean).join(' · ') }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
@@ -172,7 +172,7 @@ defineExpose({
|
||||
{{ t('chat.shippingNoticeDuplicateMatchTask', { taskNo: primaryMatch.task_no }) }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-muted">
|
||||
{{ t('chat.shippingNoticeDuplicateMatchStatus', { status: primaryMatch.process_status }) }}
|
||||
{{ t('chat.shippingNoticeDuplicateMatchStatus', { status: primaryMatch.lifecycle || 'active' }) }}
|
||||
</div>
|
||||
<div v-if="primaryMatch.matched_fields?.length" class="mt-0.5 text-muted">
|
||||
{{ t('chat.shippingNoticeDuplicateMatchFields', { fields: primaryMatch.matched_fields.join(', ') }) }}
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewFieldConflictPanel.spec.ts
|
||||
* 用途:验证过期字段冲突卡在服务端返回 404 后会刷新,而不会保留为可再次提交的错误入口。
|
||||
* 依赖:Vitest、Vue Test Utils、Vue I18n、ReviewFieldConflictPanel。
|
||||
* 逻辑:模拟并发刷新已消耗冲突,组件必须通知父工作台重取 Case 最新投影。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import ReviewFieldConflictPanel from './ReviewFieldConflictPanel.vue';
|
||||
|
||||
const { resolveFieldConflict } = vi.hoisted(() => ({
|
||||
resolveFieldConflict: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
resolveWorkspaceShippingOrderReviewFieldConflict: resolveFieldConflict,
|
||||
}));
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: { shippingOrderReview: {
|
||||
fieldConflict: {
|
||||
title: '字段冲突 {count} 项', subtitle: '请选择值', focusEvidence: '定位证据',
|
||||
evidenceIssueTitle: '证据待确认({count})', evidenceIssueSubtitle: '请核对证据',
|
||||
scope: { header: '订单头', line: '订单明细' },
|
||||
customValue: '手工值', customPlaceholder: '请输入', submitCustom: '确认手工值',
|
||||
resolveReason: '人工裁决', resolveFailed: '提交失败', resolveSuccess: '已处理',
|
||||
fields: { part_number: '料号' }, reasons: { field_conflict: '字段冲突' },
|
||||
evidenceRole: {}, optionLabel: '候选 {index}', adoptOption: '采用候选值',
|
||||
},
|
||||
resume: { autoCreated: '已自动建单', waitingManualConfirm: '待人工确认' },
|
||||
} },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
describe('ReviewFieldConflictPanel', () => {
|
||||
it('separates evidence gaps from value conflicts and does not offer a duplicate value decision', () => {
|
||||
const wrapper = mount(ReviewFieldConflictPanel, {
|
||||
props: {
|
||||
caseNo: 'SORC-1', draftVersion: 1, editable: true,
|
||||
conflicts: [],
|
||||
evidenceIssues: [{
|
||||
conflict_key: '-1:reservation_id', field_code: 'reservation_id', line_index: null, scope: 'header',
|
||||
reason: 'evidence_missing', options: [],
|
||||
}],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-evidence-issue-panel"]').text()).toContain('订单头 · reservation_id');
|
||||
expect(wrapper.find('[data-testid="review-field-conflict-custom-toggle"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('refreshes the case when confirming a stale manual value returns conflict-not-found', async () => {
|
||||
resolveFieldConflict.mockRejectedValueOnce(new BusinessError({
|
||||
message: 'Field conflict not found',
|
||||
code: 'SHIPPING.REVIEW_FIELD_CONFLICT_NOT_FOUND',
|
||||
status: 404,
|
||||
}));
|
||||
const wrapper = mount(ReviewFieldConflictPanel, {
|
||||
props: {
|
||||
caseNo: 'SORC-1', draftVersion: 1, editable: true,
|
||||
conflicts: [{
|
||||
conflict_key: '-1:part_number', field_code: 'part_number', line_index: -1,
|
||||
reason: 'field_conflict', options: [],
|
||||
}],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
await wrapper.get('[data-testid="review-field-conflict-custom-toggle"]').trigger('click');
|
||||
await wrapper.get('[data-testid="review-field-conflict-custom-input"]').setValue('PN-001');
|
||||
await wrapper.get('[data-testid="review-field-conflict-custom-submit"]').trigger('click');
|
||||
await vi.waitFor(() => expect(wrapper.emitted('refreshed')).toHaveLength(1));
|
||||
|
||||
// 关键断言:404 代表页面投影过期,父工作台会加载最新 Case 并移除这张卡。
|
||||
expect(resolveFieldConflict).toHaveBeenCalledWith('SORC-1', '-1:part_number', expect.objectContaining({
|
||||
resolution: 'custom', custom_value: 'PN-001', expected_draft_version: 1,
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -18,6 +18,7 @@ const props = defineProps<{
|
||||
caseNo: string;
|
||||
draftVersion: number | null | undefined;
|
||||
conflicts: ShippingOrderReviewFieldConflict[] | null | undefined;
|
||||
evidenceIssues?: ShippingOrderReviewFieldConflict[] | null | undefined;
|
||||
editable: boolean;
|
||||
}>();
|
||||
|
||||
@@ -33,6 +34,7 @@ const customOpenKey = ref<string | null>(null);
|
||||
const customValue = ref('');
|
||||
|
||||
const openConflicts = computed(() => props.conflicts || []);
|
||||
const openEvidenceIssues = computed(() => props.evidenceIssues || []);
|
||||
|
||||
/**
|
||||
* 字段编码本地化标签(无文案时回退 field_code)。
|
||||
@@ -50,6 +52,17 @@ function reasonLabel(reason: string): string {
|
||||
return te(key) ? t(key) : reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* 区分订单头与明细字段;同名字段不能被误读成同一份业务值。
|
||||
*/
|
||||
function scopeLabel(scope: string | null | undefined): string {
|
||||
const code = ['header', 'line', 'line_unassigned', 'unscoped'].includes(String(scope || ''))
|
||||
? String(scope)
|
||||
: 'unscoped';
|
||||
const key = `chat.shippingOrderReview.fieldConflict.scope.${code}`;
|
||||
return t(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 证据角色本地化(主 PDF / 辅助 / 邮件正文)。
|
||||
*/
|
||||
@@ -105,6 +118,12 @@ async function adoptOption(conflict: ShippingOrderReviewFieldConflict, optionInd
|
||||
showReviewResumeOutcome(result.resume_outcome, msg, t, t('chat.shippingOrderReview.fieldConflict.resolveSuccess'));
|
||||
emit('refreshed');
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof BusinessError && error.code === 'SHIPPING.REVIEW_FIELD_CONFLICT_NOT_FOUND') {
|
||||
// 冲突已被其他刷新/裁决消耗:以服务端最新 Case 为准,撤掉当前过期卡片。
|
||||
msg.info(resolveLocalizedErrorMessage(error.code, error.message));
|
||||
emit('refreshed');
|
||||
return;
|
||||
}
|
||||
const message = error instanceof BusinessError
|
||||
? resolveLocalizedErrorMessage(error.code, error.message)
|
||||
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.fieldConflict.resolveFailed'));
|
||||
@@ -146,6 +165,12 @@ async function submitCustom(conflict: ShippingOrderReviewFieldConflict) {
|
||||
showReviewResumeOutcome(result.resume_outcome, msg, t, t('chat.shippingOrderReview.fieldConflict.resolveSuccess'));
|
||||
emit('refreshed');
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof BusinessError && error.code === 'SHIPPING.REVIEW_FIELD_CONFLICT_NOT_FOUND') {
|
||||
// 与采用候选值保持同一 stale-data 恢复路径,禁止把已解决冲突留在页面上。
|
||||
msg.info(resolveLocalizedErrorMessage(error.code, error.message));
|
||||
emit('refreshed');
|
||||
return;
|
||||
}
|
||||
const message = error instanceof BusinessError
|
||||
? resolveLocalizedErrorMessage(error.code, error.message)
|
||||
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.fieldConflict.resolveFailed'));
|
||||
@@ -158,11 +183,11 @@ async function submitCustom(conflict: ShippingOrderReviewFieldConflict) {
|
||||
|
||||
<template>
|
||||
<section
|
||||
v-if="openConflicts.length"
|
||||
v-if="openConflicts.length || openEvidenceIssues.length"
|
||||
class="rounded-xl border border-rose-200 bg-rose-50/70 p-3 shadow-sm dark:border-rose-900 dark:bg-rose-950/40"
|
||||
data-testid="review-field-conflict-panel"
|
||||
>
|
||||
<header class="flex flex-wrap items-start justify-between gap-2">
|
||||
<header v-if="openConflicts.length" class="flex flex-wrap items-start justify-between gap-2">
|
||||
<div>
|
||||
<h2 class="text-sm font-semibold text-rose-950 dark:text-rose-50">
|
||||
{{ t('chat.shippingOrderReview.fieldConflict.title', { count: openConflicts.length }) }}
|
||||
@@ -264,5 +289,38 @@ async function submitCustom(conflict: ShippingOrderReviewFieldConflict) {
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div
|
||||
v-if="openEvidenceIssues.length"
|
||||
class="mt-3 rounded-lg border border-amber-200 bg-amber-50/80 p-2.5 dark:border-amber-900 dark:bg-amber-950/30"
|
||||
data-testid="review-evidence-issue-panel"
|
||||
>
|
||||
<h2 class="text-sm font-semibold text-amber-950 dark:text-amber-50">
|
||||
{{ t('chat.shippingOrderReview.fieldConflict.evidenceIssueTitle', { count: openEvidenceIssues.length }) }}
|
||||
</h2>
|
||||
<p class="mt-0.5 text-xs text-amber-800 dark:text-amber-200">
|
||||
{{ t('chat.shippingOrderReview.fieldConflict.evidenceIssueSubtitle') }}
|
||||
</p>
|
||||
<ul class="mt-2 space-y-1.5">
|
||||
<li
|
||||
v-for="issue in openEvidenceIssues"
|
||||
:key="`${issue.conflict_key}-${issue.reason}`"
|
||||
class="flex flex-wrap items-center justify-between gap-2 rounded border border-amber-200 bg-white/95 px-2.5 py-2 text-xs dark:border-amber-900 dark:bg-slate-900"
|
||||
>
|
||||
<span class="text-amber-950 dark:text-amber-50">
|
||||
<span class="text-muted">{{ scopeLabel(issue.scope) }} · </span>
|
||||
<span class="font-mono">{{ fieldLabel(issue.field_code) }}</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="text-[11px] text-primary underline-offset-2 hover:underline"
|
||||
data-testid="review-evidence-issue-focus"
|
||||
@click="onFocus(issue)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.fieldConflict.focusEvidence') }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewIntakeParsePanel.spec.ts
|
||||
* 用途:锁定接收解析工作面只展示当前 Case 已授权的邮件正文与附件预览。
|
||||
* 依赖:Vitest、Vue Test Utils、vue-i18n、ReviewIntakeParsePanel。
|
||||
* 逻辑:PDF 才允许嵌入预览;非 PDF 明确降级;所有处置仅向父级发出意图。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import ReviewIntakeParsePanel from './ReviewIntakeParsePanel.vue';
|
||||
import type { ShippingOrderReviewIntakeParseContext } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
lifecycle: {
|
||||
intakeParse: {
|
||||
title: '接收解析',
|
||||
email: '邮件正文',
|
||||
noEmail: '无邮件上下文',
|
||||
attachment: '当前附件',
|
||||
fileName: '文件名',
|
||||
fileType: '文件类型',
|
||||
preview: '附件预览',
|
||||
loadPreview: '加载附件预览',
|
||||
previewUnsupported: '当前附件不支持预览',
|
||||
loadFailed: '接收解析上下文加载失败',
|
||||
retry: '重试',
|
||||
loading: '正在加载接收解析上下文',
|
||||
},
|
||||
},
|
||||
markNonOrder: '标记为非订单',
|
||||
markQualityIssue: '文件质量异常',
|
||||
reparse: '重新识别此 PDF',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const emailPdfContext: ShippingOrderReviewIntakeParseContext = {
|
||||
case_no: 'CASE-1',
|
||||
attachment: {
|
||||
document_id: 11,
|
||||
filename: 'current.pdf',
|
||||
mime_type: 'application/pdf',
|
||||
preview_kind: 'pdf',
|
||||
},
|
||||
email: {
|
||||
document_id: 7,
|
||||
filename: 'source.eml',
|
||||
render_kind: 'text',
|
||||
text: 'approved body text',
|
||||
},
|
||||
};
|
||||
|
||||
const unsupportedContext: ShippingOrderReviewIntakeParseContext = {
|
||||
...emailPdfContext,
|
||||
attachment: {
|
||||
document_id: 12,
|
||||
filename: 'source.xlsx',
|
||||
mime_type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
preview_kind: 'unsupported',
|
||||
},
|
||||
email: null,
|
||||
};
|
||||
|
||||
function mountPanel(props: Record<string, unknown>) {
|
||||
return mount(ReviewIntakeParsePanel, {
|
||||
props: {
|
||||
loading: false,
|
||||
loadFailed: false,
|
||||
previewUrl: null,
|
||||
previewLoading: false,
|
||||
...props,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('ReviewIntakeParsePanel', () => {
|
||||
it('renders EML text and only the selected attachment preview', () => {
|
||||
const wrapper = mountPanel({ context: emailPdfContext, previewUrl: 'blob:pdf' });
|
||||
|
||||
// 关键断言:邮件正文与当前附件来自同一个受控 Case context,PDF 才嵌入预览。
|
||||
expect(wrapper.get('[data-testid="intake-parse-email-body"]').text()).toContain('approved body text');
|
||||
expect(wrapper.get('[data-testid="intake-parse-attachment-preview"] iframe').attributes('src')).toBe('blob:pdf');
|
||||
});
|
||||
|
||||
it('uses a compact attachment heading without duplicate metadata', () => {
|
||||
const wrapper = mountPanel({ context: emailPdfContext, previewUrl: 'blob:pdf' });
|
||||
|
||||
// 关键断言:文件名与当前附件合并展示,MIME 类型不再占用预览空间。
|
||||
expect(wrapper.get('[data-testid="intake-parse-attachment-heading"]').text()).toContain('当前附件');
|
||||
expect(wrapper.get('[data-testid="intake-parse-attachment-heading"]').text()).toContain('current.pdf');
|
||||
expect(wrapper.text()).not.toContain('文件类型');
|
||||
});
|
||||
|
||||
it('loads isolated EML HTML from the backend preview URL inside a sandboxed iframe', () => {
|
||||
const wrapper = mountPanel({
|
||||
context: {
|
||||
...emailPdfContext,
|
||||
email: {
|
||||
...emailPdfContext.email!,
|
||||
render_kind: 'safe_html',
|
||||
preview_url: '/api/workspace/shipping-notice/order-review-cases/CASE-1/email-preview?preview_token=single-use',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// 关键断言:HTML 不得通过 srcdoc 注入工作台 DOM,必须由受控 URL 在无脚本 iframe 中读取。
|
||||
const frame = wrapper.get('[data-testid="intake-parse-email-html"]');
|
||||
expect(frame.attributes('sandbox')).toBeDefined();
|
||||
expect(frame.attributes('src')).toContain('preview_token=single-use');
|
||||
expect(frame.attributes('srcdoc')).toBeUndefined();
|
||||
expect(wrapper.find('[data-testid="intake-parse-email-body"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('does not render a PDF frame for an unsupported attachment', () => {
|
||||
const wrapper = mountPanel({ context: unsupportedContext });
|
||||
|
||||
// 关键断言:非 PDF 不得退化为 iframe,必须明确告知不可预览。
|
||||
expect(wrapper.find('[data-testid="intake-parse-attachment-preview"]').exists()).toBe(false);
|
||||
expect(wrapper.get('[data-testid="intake-parse-preview-unsupported"]').exists()).toBe(true);
|
||||
expect(wrapper.get('[data-testid="intake-parse-no-email"]').text()).toContain('无邮件上下文');
|
||||
});
|
||||
|
||||
it('does not render parse disposition controls inside the scrolling intake panel', () => {
|
||||
const wrapper = mountPanel({
|
||||
context: emailPdfContext,
|
||||
});
|
||||
|
||||
// 关键断言:按钮由父级固定底栏统一承载,面板滚动时不得随内容离开视口。
|
||||
expect(wrapper.find('[data-testid="intake-parse-disposition-actions"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="intake-parse-mark-non-order"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('does not render deprecated parse disposition controls inside the scrolling panel', () => {
|
||||
const wrapper = mountPanel({
|
||||
context: emailPdfContext,
|
||||
});
|
||||
|
||||
// 关键断言:处置由固定底栏承载,滚动内容区不得遗留重复入口。
|
||||
expect(wrapper.find('[data-testid="intake-parse-reparse"]').exists()).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,146 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewIntakeParsePanel.vue
|
||||
用途:在接收解析阶段展示当前 Case 已授权的邮件正文、当前附件及安全预览。
|
||||
依赖:vue、vue-i18n、ShippingOrderReviewIntakeParseContext。
|
||||
逻辑:只消费父级按 Case 获取的受控上下文;仅 PDF 可请求/渲染 iframe;处置操作只 emit,
|
||||
由父页沿用既有确认弹窗和 Case 命令。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderReviewIntakeParseContext } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
context: ShippingOrderReviewIntakeParseContext | null;
|
||||
loading: boolean;
|
||||
loadFailed: boolean;
|
||||
previewUrl: string | null;
|
||||
previewLoading: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'retry-context': [];
|
||||
'load-preview': [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 当前附件为 PDF 且尚无受控 Blob 时,通知父级使用当前 Case 加载预览。
|
||||
* 仅 Case context 改变时触发,禁止对不受支持文件发起预览请求。
|
||||
*/
|
||||
watch(
|
||||
() => props.context,
|
||||
(context) => {
|
||||
if (context?.attachment.preview_kind === 'pdf' && !props.previewUrl) {
|
||||
emit('load-preview');
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="space-y-4"
|
||||
data-testid="intake-parse-panel"
|
||||
>
|
||||
<div
|
||||
v-if="loading"
|
||||
class="rounded-xl border border-dashed border-slate-300 bg-slate-50 p-4 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-300"
|
||||
data-testid="intake-parse-loading"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.loading') }}
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else-if="loadFailed"
|
||||
class="rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-900 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-100"
|
||||
data-testid="intake-parse-load-failed"
|
||||
>
|
||||
<p>{{ t('chat.shippingOrderReview.lifecycle.intakeParse.loadFailed') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 rounded border border-rose-300 px-2.5 py-1 text-xs hover:bg-rose-100 dark:border-rose-800 dark:hover:bg-rose-950"
|
||||
data-testid="intake-parse-retry-context"
|
||||
@click="emit('retry-context')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.retry') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<template v-else-if="context">
|
||||
<section class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900">
|
||||
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.lifecycle.intakeParse.email') }}</h2>
|
||||
<template v-if="context.email">
|
||||
<p class="mt-1 text-xs text-slate-500">{{ context.email.filename }}</p>
|
||||
<iframe
|
||||
v-if="context.email.render_kind === 'safe_html' && context.email.preview_url"
|
||||
:src="context.email.preview_url"
|
||||
sandbox=""
|
||||
referrerpolicy="no-referrer"
|
||||
:title="t('chat.shippingOrderReview.lifecycle.intakeParse.emailPreviewTitle')"
|
||||
class="mt-3 h-72 w-full rounded border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-950"
|
||||
data-testid="intake-parse-email-html"
|
||||
/>
|
||||
<pre
|
||||
v-else
|
||||
class="mt-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-slate-50 p-3 text-xs text-slate-700 dark:bg-slate-950/50 dark:text-slate-200"
|
||||
data-testid="intake-parse-email-body"
|
||||
>{{ context.email.text }}</pre>
|
||||
</template>
|
||||
<p
|
||||
v-else
|
||||
class="mt-2 text-sm text-slate-500"
|
||||
data-testid="intake-parse-no-email"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.noEmail') }}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900">
|
||||
<h2 class="text-sm font-semibold" data-testid="intake-parse-attachment-heading">
|
||||
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.attachment') }} ·
|
||||
<span class="font-normal text-slate-500 dark:text-slate-400">{{ context.attachment.filename }}</span>
|
||||
</h2>
|
||||
|
||||
<div
|
||||
v-if="context.attachment.preview_kind === 'pdf'"
|
||||
class="mt-3"
|
||||
data-testid="intake-parse-attachment-preview"
|
||||
>
|
||||
<p
|
||||
v-if="previewLoading"
|
||||
class="mt-2 text-sm text-slate-500"
|
||||
data-testid="intake-parse-preview-loading"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.previewLoading') }}
|
||||
</p>
|
||||
<iframe
|
||||
v-else-if="previewUrl"
|
||||
:src="previewUrl"
|
||||
:title="context.attachment.filename"
|
||||
class="mt-2 h-[32rem] w-full rounded border border-slate-200 dark:border-slate-700"
|
||||
/>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="mt-2 rounded border border-slate-300 px-2.5 py-1 text-xs hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800"
|
||||
data-testid="intake-parse-load-preview"
|
||||
@click="emit('load-preview')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.loadPreview') }}
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
v-else
|
||||
class="mt-4 rounded bg-slate-50 p-3 text-sm text-slate-500 dark:bg-slate-950/50"
|
||||
data-testid="intake-parse-preview-unsupported"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.previewUnsupported') }}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
+6
-13
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewInventoryCandidatesPanel.spec.ts
|
||||
* 用途:验证库存路由面板在服务端刷新后重置本地表单,并展示规则码/源编码以满足可追溯。
|
||||
* 用途:验证库存路由面板展示服务端规则结果、规则码与源编码以满足可追溯。
|
||||
* 依赖:Vitest、Vue Test Utils、vue-i18n、chat 文案。
|
||||
* 逻辑:构造带技术编码的行投影;断言显示名+编码与命中规则;两列标签卡可扫描;
|
||||
* 变更候选后本地勾选被重置。
|
||||
* 自动重算意图只透传 line_key,不允许出现人工候选表单。
|
||||
*/
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
@@ -31,7 +31,6 @@ function line(
|
||||
rule_suggestion_source_codes: ['DSV360_AWSDU'],
|
||||
matched_rules: [{ rule_code: 'ROUTE_HINT_AWSSG', version: 1 }],
|
||||
rule_versions: [{ rule_code: 'INVENTORY_RULE_18', version: 18 }],
|
||||
manual_reason: 'initial reason',
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -82,24 +81,19 @@ describe('ReviewInventoryCandidatesPanel', () => {
|
||||
expect(wrapper.text()).toContain('新加坡仓');
|
||||
});
|
||||
|
||||
it('resets local form when server candidates change for the same line_key', async () => {
|
||||
it('renders refreshed rule candidates without exposing manual selection inputs', async () => {
|
||||
const wrapper = mount(ReviewInventoryCandidatesPanel, {
|
||||
props: {
|
||||
lines: [line({ candidate_inventory_source_codes: ['DSV360_AWSDU'], manual_reason: 'old' })],
|
||||
lines: [line({ candidate_inventory_source_codes: ['DSV360_AWSDU'] })],
|
||||
sourceLabels: { DSV360_AWSDU: '杜塞尔多夫仓', DSV360_AWSBI: '伯明翰仓' },
|
||||
editable: true,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
const textarea = wrapper.get('textarea');
|
||||
await textarea.setValue('user typed reason');
|
||||
expect((textarea.element as HTMLTextAreaElement).value).toBe('user typed reason');
|
||||
|
||||
await wrapper.setProps({
|
||||
lines: [line({
|
||||
candidate_inventory_source_codes: ['DSV360_AWSBI'],
|
||||
manual_reason: 'server refreshed',
|
||||
raw_rule_source_codes: ['DSV360_AWSBI'],
|
||||
unavailable_source_codes: [],
|
||||
rule_suggestion_source_codes: ['DSV360_AWSBI'],
|
||||
@@ -107,11 +101,10 @@ describe('ReviewInventoryCandidatesPanel', () => {
|
||||
})],
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const refreshed = wrapper.get('textarea');
|
||||
expect((refreshed.element as HTMLTextAreaElement).value).toBe('server refreshed');
|
||||
expect(wrapper.text()).toContain('伯明翰仓');
|
||||
expect(wrapper.text()).toContain('DSV360_AWSBI');
|
||||
expect(wrapper.text()).toContain('ROUTE_HINT_AWSBI');
|
||||
expect(wrapper.find('textarea').exists()).toBe(false);
|
||||
expect(wrapper.find('input[type="checkbox"]').exists()).toBe(false);
|
||||
});
|
||||
});
|
||||
+3
-194
@@ -1,20 +1,16 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewInventoryCandidatesPanel.vue
|
||||
用途:库存路由恢复面板——展示规则建议/不可用源,支持 reroute、采纳建议、保留人工与多选提交。
|
||||
用途:库存路由恢复面板——展示发布规则结果、不可用源并支持自动重算。
|
||||
依赖:vue-i18n、ShippingOrderReviewBuildEligibilityLineProjection 类型。
|
||||
逻辑:接收 recovery / suggestion_pending 行;规则候选优先,零候选回退已启用源;
|
||||
服务端行指纹变化时重置本地表单;业务名与等宽 source_code 始终可见;
|
||||
原始/不可用/建议候选用两列标签卡降低密度;emit 由 composable 写 API。
|
||||
逻辑:只展示服务端规则裁决;服务端行指纹变化时刷新显示;业务名与等宽 source_code 始终可见;
|
||||
原始/不可用/有效候选用两列标签卡降低密度;仅 emit 自动重算意图。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { reactive, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderReviewBuildEligibilityLineProjection } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
lines: ShippingOrderReviewBuildEligibilityLineProjection[];
|
||||
/** 已启用库存源;规则零候选时作为可选列表 */
|
||||
enabledSourceCodes?: string[];
|
||||
/** 库存源编码 → 业务显示名;提交仍使用编码 */
|
||||
sourceLabels?: Record<string, string>;
|
||||
editable?: boolean;
|
||||
@@ -22,30 +18,11 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'submit', payload: { lineKey: string; sourceCodes: string[]; reason: string }): void;
|
||||
(e: 'reroute', lineKey?: string): void;
|
||||
(e: 'adopt', payload: { lineKey: string; reason?: string }): void;
|
||||
(e: 'keep', payload: { lineKey: string; reason?: string }): void;
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
/** 每行本地表单状态:已选候选与原因。 */
|
||||
const formState = reactive<Record<string, { selected: string[]; reason: string }>>({});
|
||||
|
||||
/**
|
||||
* 行级可选源:规则候选优先,否则回退已启用库存源。
|
||||
*/
|
||||
function selectableCodes(line: ShippingOrderReviewBuildEligibilityLineProjection): string[] {
|
||||
const candidates = (line.candidate_inventory_source_codes || [])
|
||||
.map((code) => String(code || '').trim().toUpperCase())
|
||||
.filter(Boolean);
|
||||
if (candidates.length) return candidates;
|
||||
return (props.enabledSourceCodes || [])
|
||||
.map((code) => String(code || '').trim().toUpperCase())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则建议可用源编码。
|
||||
*/
|
||||
@@ -56,63 +33,6 @@ function ruleSuggestionCodes(line: ShippingOrderReviewBuildEligibilityLineProjec
|
||||
|| [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端行投影指纹;变化时用于重置本地表单,避免提交过期候选/原因。
|
||||
*/
|
||||
function lineServerFingerprint(line: ShippingOrderReviewBuildEligibilityLineProjection): string {
|
||||
return JSON.stringify({
|
||||
line_key: String(line.line_key || line.line_index || ''),
|
||||
candidates: (line.candidate_inventory_source_codes || []).map(String),
|
||||
reason: String(line.manual_reason || ''),
|
||||
suggestion_pending: Boolean(line.suggestion_pending),
|
||||
rule: ruleSuggestionCodes(line).map(String),
|
||||
unavailable: (line.unavailable_source_codes || []).map(String),
|
||||
raw: (line.raw_rule_source_codes || []).map(String),
|
||||
block_reason: String(line.block_reason || ''),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空本地表单缓存(下次 getForm 按服务端投影重新初始化)。
|
||||
*/
|
||||
function resetFormState() {
|
||||
for (const key of Object.keys(formState)) {
|
||||
delete formState[key];
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => (props.lines || []).map(lineServerFingerprint).join('\n'),
|
||||
() => {
|
||||
resetFormState();
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* 获取或初始化某行的表单状态。
|
||||
*/
|
||||
function getForm(line: ShippingOrderReviewBuildEligibilityLineProjection) {
|
||||
const key = String(line.line_key || (line.line_index ?? ''));
|
||||
if (!formState[key]) {
|
||||
const ruleCandidates = (line.candidate_inventory_source_codes || []).map(String);
|
||||
formState[key] = {
|
||||
selected: [...ruleCandidates],
|
||||
reason: String(line.manual_reason || ''),
|
||||
};
|
||||
}
|
||||
return formState[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换候选编码勾选状态。
|
||||
*/
|
||||
function toggleCode(line: ShippingOrderReviewBuildEligibilityLineProjection, code: string) {
|
||||
const form = getForm(line);
|
||||
const index = form.selected.indexOf(code);
|
||||
if (index >= 0) form.selected.splice(index, 1);
|
||||
else form.selected.push(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析阻断原因展示文案。
|
||||
*/
|
||||
@@ -160,20 +80,6 @@ function unavailableReasonLabel(line: ShippingOrderReviewBuildEligibilityLinePro
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.inventoryRouting.unavailableReasonUnknown');
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并提交指定行的人工候选选择。
|
||||
*/
|
||||
function submitLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
|
||||
const lineKey = String(line.line_key || '').trim();
|
||||
if (!lineKey) return;
|
||||
const form = getForm(line);
|
||||
emit('submit', {
|
||||
lineKey,
|
||||
sourceCodes: [...form.selected],
|
||||
reason: form.reason.trim(),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发行级重新匹配路由。
|
||||
*/
|
||||
@@ -182,25 +88,6 @@ function rerouteLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
|
||||
emit('reroute', lineKey || undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采纳待决规则建议。
|
||||
*/
|
||||
function adoptLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
|
||||
const lineKey = String(line.line_key || '').trim();
|
||||
if (!lineKey) return;
|
||||
const reason = getForm(line).reason.trim();
|
||||
emit('adopt', { lineKey, ...(reason ? { reason } : {}) });
|
||||
}
|
||||
|
||||
/**
|
||||
* 保留当前人工路由结果。
|
||||
*/
|
||||
function keepLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
|
||||
const lineKey = String(line.line_key || '').trim();
|
||||
if (!lineKey) return;
|
||||
const reason = getForm(line).reason.trim();
|
||||
emit('keep', { lineKey, ...(reason ? { reason } : {}) });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -313,55 +200,6 @@ function keepLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="line.suggestion_pending"
|
||||
class="mt-2 rounded border border-amber-200 bg-amber-50 px-2 py-1 text-xs text-amber-900 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
data-testid="review-inventory-suggestion-pending"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.inventoryRouting.suggestionPending') }}
|
||||
</p>
|
||||
|
||||
<div v-if="selectableCodes(line).length" class="mt-3">
|
||||
<div class="text-xs font-medium text-slate-600 dark:text-slate-300">
|
||||
{{
|
||||
(line.candidate_inventory_source_codes || []).length
|
||||
? t('chat.shippingOrderReview.inventoryCandidates.selectSources')
|
||||
: t('chat.shippingOrderReview.inventoryCandidates.selectEnabledSources')
|
||||
}}
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<label
|
||||
v-for="code in selectableCodes(line)"
|
||||
:key="code"
|
||||
class="inline-flex cursor-pointer items-center gap-1.5 rounded border border-slate-200 px-2 py-1 text-xs dark:border-slate-600"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="getForm(line).selected.includes(code)"
|
||||
:disabled="!editable || saving"
|
||||
@change="toggleCode(line, code)"
|
||||
>
|
||||
<span>{{ sourceBusinessName(code) }}</span>
|
||||
<span class="font-mono text-[11px] text-slate-500">{{ sourceCodeLabel(code) }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="mt-2 text-xs text-rose-600 dark:text-rose-300">
|
||||
{{ t('chat.shippingOrderReview.inventoryCandidates.noEnabledSources') }}
|
||||
</p>
|
||||
|
||||
<label class="mt-3 block text-xs font-medium text-slate-600 dark:text-slate-300">
|
||||
{{ t('chat.shippingOrderReview.inventoryCandidates.reasonLabel') }}
|
||||
<textarea
|
||||
:value="getForm(line).reason"
|
||||
:disabled="!editable || saving"
|
||||
rows="2"
|
||||
class="mt-1 w-full rounded-md border border-slate-300 bg-white px-2 py-1.5 text-xs dark:border-slate-600 dark:bg-slate-950"
|
||||
:placeholder="t('chat.shippingOrderReview.inventoryCandidates.reasonPlaceholder')"
|
||||
@input="getForm(line).reason = ($event.target as HTMLTextAreaElement).value"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div class="mt-3 flex flex-wrap items-center justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
@@ -372,35 +210,6 @@ function keepLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.inventoryRouting.reroute') }}
|
||||
</button>
|
||||
<template v-if="line.suggestion_pending">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 disabled:opacity-50 dark:border-amber-800 dark:bg-amber-950/50 dark:text-amber-100"
|
||||
data-testid="review-inventory-routing-adopt"
|
||||
:disabled="!editable || saving"
|
||||
@click="adoptLine(line)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.inventoryRouting.adoptSuggestion') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-slate-300 bg-white px-3 py-1.5 text-xs text-slate-700 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-950 dark:text-slate-200"
|
||||
data-testid="review-inventory-routing-keep"
|
||||
:disabled="!editable || saving"
|
||||
@click="keepLine(line)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.inventoryRouting.keepManual') }}
|
||||
</button>
|
||||
</template>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded bg-sky-600 px-3 py-1.5 text-xs text-white disabled:opacity-50"
|
||||
data-testid="review-inventory-candidates-submit"
|
||||
:disabled="!editable || saving || !getForm(line).selected.length || !getForm(line).reason.trim()"
|
||||
@click="submitLine(line)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.inventoryCandidates.submit') }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { inventoryActionLabelKey } from '@/features/shipping-progress/actionPresentation';
|
||||
|
||||
export interface InventoryIssueFallback {
|
||||
kind?: string | null;
|
||||
@@ -70,7 +71,7 @@ const reasonLabel = computed(() => {
|
||||
:disabled="busy"
|
||||
@click="emit('retry-preparation')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.lineOps.retryPreparation') }}
|
||||
{{ t(inventoryActionLabelKey('retry_inventory_preparation')!) }}
|
||||
</button>
|
||||
</section>
|
||||
</template>
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewLifecycleStageNavigation.spec.ts
|
||||
* 用途:验收订单生命周期阶段导航的只读查看与前置阻断交互。
|
||||
* 依赖:ReviewLifecycleStageNavigation;Vue Test Utils 与 Vue I18n 测试运行时。
|
||||
* 逻辑:阶段状态由父级传入;本测试只验证组件不会绕过 blocked 状态发出选择事件。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import ReviewLifecycleStageNavigation, {
|
||||
type ReviewLifecycleStageItem,
|
||||
} from './ReviewLifecycleStageNavigation.vue';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
lifecycle: {
|
||||
navigation: '订单生命周期阶段',
|
||||
current: '当前可处理',
|
||||
completed: '已完成,可查看',
|
||||
blocked: '前置未完成',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const stages: ReviewLifecycleStageItem[] = [
|
||||
{ code: 'order_review', label: '订单复核', state: 'completed' },
|
||||
{ code: 'fulfillment_prep', label: '通知准备', state: 'current' },
|
||||
{ code: 'upload_complete', label: '通知完成', state: 'blocked', reason: '请先完成通知准备' },
|
||||
];
|
||||
|
||||
/** 挂载导航,复用真实 i18n 以覆盖状态文案渲染。 */
|
||||
function mountNavigation() {
|
||||
return mount(ReviewLifecycleStageNavigation, {
|
||||
props: { stages, activeCode: 'fulfillment_prep' },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('ReviewLifecycleStageNavigation', () => {
|
||||
it('renders intake_parse as the first lifecycle stage', () => {
|
||||
const wrapper = mount(ReviewLifecycleStageNavigation, {
|
||||
props: {
|
||||
stages: [
|
||||
{ code: 'intake_parse' as ReviewLifecycleStageItem['code'], label: '接收解析', state: 'current' },
|
||||
...stages,
|
||||
],
|
||||
activeCode: 'intake_parse' as ReviewLifecycleStageItem['code'],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
const nodes = wrapper.findAll('div[data-testid^="review-lifecycle-stage-"]');
|
||||
// 关键断言:接收解析必须在用户生命周期导航首位,不得回退为三阶段。
|
||||
expect(nodes.map((node) => node.attributes('data-testid'))).toEqual([
|
||||
'review-lifecycle-stage-intake_parse',
|
||||
'review-lifecycle-stage-order_review',
|
||||
'review-lifecycle-stage-fulfillment_prep',
|
||||
'review-lifecycle-stage-upload_complete',
|
||||
]);
|
||||
expect(wrapper.find('[data-testid="review-lifecycle-stage-navigation"] > div').classes()).toContain('sm:grid-cols-4');
|
||||
});
|
||||
|
||||
it('allows opening a completed stage for inspection', async () => {
|
||||
const wrapper = mountNavigation();
|
||||
await wrapper.get('[data-testid="review-lifecycle-stage-order_review"]').findAll('button')[1].trigger('click');
|
||||
// 关键断言:完成的阶段可回看,不会因已完成而被禁用。
|
||||
expect(wrapper.emitted('select')).toEqual([['order_review']]);
|
||||
});
|
||||
|
||||
it('disables a future stage and does not emit a selection', async () => {
|
||||
const wrapper = mountNavigation();
|
||||
const future = wrapper.get('[data-testid="review-lifecycle-stage-upload_complete"]');
|
||||
// 关键断言:前置未完成只展示原因,不能通过前端导航越过后端阶段。
|
||||
expect(future.text()).toContain('请先完成通知准备');
|
||||
await future.findAll('button')[1].trigger('click');
|
||||
expect(wrapper.emitted('select')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('opens process details from the stage label without reserving a separate row', async () => {
|
||||
const wrapper = mountNavigation();
|
||||
const detail = wrapper.get('[data-testid="review-lifecycle-stage-detail-fulfillment_prep"]');
|
||||
// 关键断言:阶段名称本身是流程详情入口,不额外占用工作台一整行。
|
||||
await detail.trigger('click');
|
||||
expect(wrapper.emitted('open-detail')).toEqual([['fulfillment_prep']]);
|
||||
});
|
||||
});
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewLifecycleStageNavigation.vue
|
||||
用途:订单生命周期工作台的四阶段导航,只呈现父级已裁决的阶段状态。
|
||||
依赖:父级 ShippingOrderReviewView 提供阶段、状态和阻断原因;lucide-vue-next 图标。
|
||||
逻辑:用户可打开当前或已完成阶段查看;后续阶段由父级传入 blocked 并禁用,本组件不写业务状态。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { Check, LockKeyhole } from 'lucide-vue-next';
|
||||
|
||||
export type ReviewLifecycleStageCode = 'intake_parse' | 'order_review' | 'fulfillment_prep' | 'upload_complete';
|
||||
export type ReviewLifecycleStageState = 'current' | 'completed' | 'blocked';
|
||||
|
||||
export interface ReviewLifecycleStageItem {
|
||||
code: ReviewLifecycleStageCode;
|
||||
label: string;
|
||||
state: ReviewLifecycleStageState;
|
||||
reason?: string | null;
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
stages: ReviewLifecycleStageItem[];
|
||||
/** 后端尚未下发入口时为空;导航只能展示加载/未授权态,不能自行指定订单复核。 */
|
||||
activeCode: ReviewLifecycleStageCode | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
select: [code: ReviewLifecycleStageCode];
|
||||
'open-detail': [code: ReviewLifecycleStageCode];
|
||||
}>();
|
||||
|
||||
/**
|
||||
* 阶段导航只允许进入当前或已完成阶段;blocked 仅说明前置条件,不替代后端 Gate 判定。
|
||||
*/
|
||||
function selectStage(stage: ReviewLifecycleStageItem) {
|
||||
if (stage.state === 'blocked') return;
|
||||
emit('select', stage.code);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<nav
|
||||
class="rounded-xl border border-default bg-surface p-2"
|
||||
:aria-label="$t('chat.shippingOrderReview.lifecycle.navigation')"
|
||||
data-testid="review-lifecycle-stage-navigation"
|
||||
>
|
||||
<div class="grid gap-2 sm:grid-cols-4">
|
||||
<div
|
||||
v-for="stage in props.stages"
|
||||
:key="stage.code"
|
||||
class="min-w-0 rounded-lg border px-3 py-2 text-left transition-colors"
|
||||
:class="[
|
||||
stage.code === props.activeCode
|
||||
? 'border-brand-500 bg-brand-50 text-brand-950 dark:bg-brand-950/30 dark:text-brand-50'
|
||||
: 'border-transparent hover:bg-surface-soft',
|
||||
stage.state === 'blocked' ? 'opacity-60' : '',
|
||||
]"
|
||||
:data-testid="`review-lifecycle-stage-${stage.code}`"
|
||||
>
|
||||
<span class="flex items-center gap-2 text-sm font-semibold">
|
||||
<Check v-if="stage.state === 'completed'" class="h-4 w-4 shrink-0 text-emerald-600" />
|
||||
<LockKeyhole v-else-if="stage.state === 'blocked'" class="h-4 w-4 shrink-0 text-muted" />
|
||||
<span v-else class="h-2 w-2 shrink-0 rounded-full bg-brand-600" aria-hidden="true" />
|
||||
<button
|
||||
type="button"
|
||||
class="truncate text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500"
|
||||
:data-testid="`review-lifecycle-stage-detail-${stage.code}`"
|
||||
@click="emit('open-detail', stage.code)"
|
||||
>{{ stage.label }}</button>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-1 block w-full truncate text-left text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 disabled:cursor-not-allowed"
|
||||
:class="stage.state === 'blocked' ? 'text-muted' : 'text-secondary'"
|
||||
:title="stage.reason || undefined"
|
||||
:disabled="stage.state === 'blocked'"
|
||||
@click="selectStage(stage)"
|
||||
>
|
||||
{{ stage.state === 'current'
|
||||
? $t('chat.shippingOrderReview.lifecycle.current')
|
||||
: stage.state === 'completed'
|
||||
? $t('chat.shippingOrderReview.lifecycle.completed')
|
||||
: (stage.reason || $t('chat.shippingOrderReview.lifecycle.blocked')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</template>
|
||||
+12
-2
@@ -34,8 +34,8 @@ function mountPanel(needsReview = false) {
|
||||
needs_review: needsReview,
|
||||
selected_profile: { profile_code: 'ODP-A', display_name: '客户订单模板', version: 1 },
|
||||
candidates: [
|
||||
{ profile_code: 'ODP-A', score: 0.99 },
|
||||
{ profile_code: 'ODP-B', score: 0.98 },
|
||||
{ profile_code: 'ODP-A', display_name: '客户订单模板', score: 0.99 },
|
||||
{ profile_code: 'ODP-B', display_name: '客户订单模板(旧版)', score: 0.98 },
|
||||
],
|
||||
fallback_reason_codes: [],
|
||||
},
|
||||
@@ -59,4 +59,14 @@ describe('ReviewProfileMatchPanel', () => {
|
||||
await wrapper.get('[data-testid="review-profile-match-candidates-toggle"]').trigger('click');
|
||||
expect(wrapper.find('[data-testid="review-profile-match-candidates"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('候选模板优先展示模板名称,不把内部编号作为主文案', async () => {
|
||||
const wrapper = mountPanel(true);
|
||||
|
||||
await wrapper.get('[data-testid="review-profile-match-candidates-toggle"]').trigger('click');
|
||||
|
||||
// 关键断言:业务用户辨认模板依赖 display_name,ODP 编号不应出现在候选列表主展示中。
|
||||
expect(wrapper.get('[data-testid="review-profile-match-candidates"]').text()).toContain('客户订单模板');
|
||||
expect(wrapper.get('[data-testid="review-profile-match-candidates"]').text()).not.toContain('ODP-A');
|
||||
});
|
||||
});
|
||||
@@ -57,7 +57,7 @@ const selectedLabel = computed(() => {
|
||||
if (!selected) {
|
||||
return t('chat.shippingOrderReview.profileMatch.noSelected');
|
||||
}
|
||||
const name = String(selected.display_name || selected.profile_code || '').trim();
|
||||
const name = String(selected.display_name || '').trim();
|
||||
if (!name) return t('chat.shippingOrderReview.profileMatch.noSelected');
|
||||
if (!isAdminView.value) return name;
|
||||
const version = selected.version != null ? ` v${selected.version}` : '';
|
||||
@@ -128,7 +128,7 @@ const selectedLabel = computed(() => {
|
||||
:key="`${item.profile_code}-${item.version}-${idx}`"
|
||||
class="rounded-lg border border-default bg-surface-soft px-2.5 py-1.5 text-[11px] text-secondary"
|
||||
>
|
||||
<span class="font-mono">{{ item.profile_code }}</span>
|
||||
<span>{{ item.display_name || t('chat.shippingOrderReview.profileMatch.noSelected') }}</span>
|
||||
<span v-if="item.score != null" class="ml-2 text-muted">{{ item.score }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewWorkbenchFooter.spec.ts
|
||||
* 用途:验证字段冲突的 Gate 主动作只由右栏当前任务卡承载,底栏不得重复展示。
|
||||
* 依赖:Vitest、Vue Test Utils、Vue I18n、ReviewWorkbenchFooter。
|
||||
* 逻辑:订单复核底栏只保留保存校验,不展示已由当前任务卡或阶段页承载的流程动作。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import ReviewWorkbenchFooter from './ReviewWorkbenchFooter.vue';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingProcessing: { action: { resolve_field_conflicts: '处理字段冲突', view_result: '查看结果', none: '无操作' } },
|
||||
shippingOrderReview: { unsavedSwitch: { unsavedCount: '未保存 {count} 项' } },
|
||||
},
|
||||
workspace: { shippingNotice: { processGate: { actions: {} } } },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
describe('ReviewWorkbenchFooter', () => {
|
||||
it('keeps intake parse dispositions in the sticky footer without replacement upload', () => {
|
||||
const wrapper = mount(ReviewWorkbenchFooter, {
|
||||
props: {
|
||||
availableActions: ['mark_non_order', 'mark_quality_issue', 'reparse', 'validate'],
|
||||
canConfirmBuild: false, saving: false, isReadOnly: false, hasDraft: true,
|
||||
showParseDispositions: true, showValidate: false,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 关键断言:接收解析动作与订单复核使用同一 sticky 底栏;业务不支持替代 PDF 上传。
|
||||
expect(wrapper.get('[data-testid="review-footer-actions"]').classes()).toEqual(expect.arrayContaining(['sticky', 'bottom-0']));
|
||||
expect(wrapper.text()).toContain('chat.shippingOrderReview.markNonOrder');
|
||||
expect(wrapper.text()).toContain('chat.shippingOrderReview.markQualityIssue');
|
||||
expect(wrapper.text()).toContain('chat.shippingOrderReview.reparse');
|
||||
expect(wrapper.text()).not.toContain('chat.shippingOrderReview.saveOrderAndValidate');
|
||||
});
|
||||
|
||||
it('does not duplicate current-case flow actions in the order-review footer', () => {
|
||||
const wrapper = mount(ReviewWorkbenchFooter, {
|
||||
props: {
|
||||
availableActions: [], canConfirmBuild: false, saving: false, isReadOnly: false, hasDraft: true,
|
||||
flowPresentation: {
|
||||
primary: { intent: 'resolve_field_conflicts', actionCode: 'resolve_field_conflicts', labelKey: 'chat.shippingProcessing.action.resolve_field_conflicts' },
|
||||
secondary: { intent: 'view_result', actionCode: 'view_result', labelKey: 'chat.shippingProcessing.action.view_result' },
|
||||
overflow: [],
|
||||
},
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 关键断言:字段冲突、重试和查看结果各有上游上下文,复核底栏不得重复它们。
|
||||
expect(wrapper.find('[data-testid="review-footer-flow-resolve_field_conflicts"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-footer-flow-view_result"]').exists()).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@
|
||||
用途:订单处理工作台底部唯一写操作栏(处置 / 保存 / 统一流程动作)。
|
||||
依赖:vue-i18n、lucide-vue-next、ActionPresentation。
|
||||
逻辑:ShippingOrderReviewView 传入 available_actions 与流程动作投影;sticky bottom;
|
||||
只读查看时仍可展示 view_result/view_record;写按钮受 actionsExecutable 约束;
|
||||
订单复核只保留保存校验;流程动作由所属阶段或当前任务卡承载;写按钮受 actionsExecutable 约束;
|
||||
流程写操作经 flow-action emit(与 Resolver 同链);flowBusy||saving 时禁用。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
@@ -36,6 +36,10 @@ const props = withDefaults(defineProps<{
|
||||
actionsExecutable?: boolean;
|
||||
/** 统一流程动作提交中 */
|
||||
flowBusy?: boolean;
|
||||
/** 解析处置入口由接收解析工作面承载时,订单复核底栏隐藏四项解析操作。 */
|
||||
showParseDispositions?: boolean;
|
||||
/** 保存并校验只属于订单复核表单,接收解析阶段必须隐藏。 */
|
||||
showValidate?: boolean;
|
||||
}>(), {
|
||||
unsavedCount: 0,
|
||||
flowPresentation: null,
|
||||
@@ -46,20 +50,21 @@ const props = withDefaults(defineProps<{
|
||||
autoGateHint: '',
|
||||
actionsExecutable: true,
|
||||
flowBusy: false,
|
||||
showParseDispositions: true,
|
||||
showValidate: true,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
'mark-non-order': [];
|
||||
'mark-quality-issue': [];
|
||||
reparse: [];
|
||||
'upload-replacement': [event: Event];
|
||||
validate: [];
|
||||
confirm: [];
|
||||
'retry-stp': [];
|
||||
'flow-action': [item: ActionPresentationItem];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 判断某 action 是否在当前 Case 可用。
|
||||
@@ -68,40 +73,25 @@ function hasAction(action: string): boolean {
|
||||
return props.availableActions.includes(action);
|
||||
}
|
||||
|
||||
const flowItems = computed((): ActionPresentationItem[] => {
|
||||
const presentation = props.flowPresentation;
|
||||
if (!presentation) return [];
|
||||
const items: ActionPresentationItem[] = [];
|
||||
if (presentation.primary) items.push(presentation.primary);
|
||||
if (presentation.secondary) items.push(presentation.secondary);
|
||||
items.push(...presentation.overflow);
|
||||
// 刷新留给顶部只读区;底栏不重复。
|
||||
return items.filter((item) => item.intent !== 'refresh');
|
||||
});
|
||||
/**
|
||||
* 订单复核底栏不承载流程投影动作。
|
||||
*
|
||||
* 核心逻辑:保存并校验是表单级提交,固定放在这里;字段裁决、重试、查看结果等
|
||||
* Case/阶段级动作必须留在其业务上下文中,避免同一动作在顶栏、右栏和底栏重复出现。
|
||||
*/
|
||||
const footerFlowItems = computed((): ActionPresentationItem[] => []);
|
||||
|
||||
const hasViewOnlyFlow = computed(() => flowItems.value.some((item) => (
|
||||
item.intent === 'view_result'
|
||||
|| item.intent === 'view_record'
|
||||
|| item.intent === 'open_profile_review'
|
||||
)));
|
||||
/** 保留统一动作的文案解析,供后续恢复 Footer 流程动作时复用。 */
|
||||
function flowLabel(item: ActionPresentationItem): string {
|
||||
return t(item.labelKey);
|
||||
}
|
||||
|
||||
/** 可编辑底栏,或只读但仍有导航/查看类流程动作。 */
|
||||
const showFooter = computed(() => (
|
||||
props.hasDraft && (!props.isReadOnly || hasViewOnlyFlow.value)
|
||||
));
|
||||
/** 仅可编辑草稿显示表单提交底栏;只读版本不显示无上下文的流程按钮。 */
|
||||
const showFooter = computed(() => props.hasDraft && !props.isReadOnly);
|
||||
|
||||
const controlsBusy = computed(() => props.saving || props.flowBusy);
|
||||
const canWriteCaseActions = computed(() => props.actionsExecutable && !props.isReadOnly);
|
||||
|
||||
/**
|
||||
* 流程动作文案。
|
||||
*/
|
||||
function flowLabel(item: ActionPresentationItem): string {
|
||||
if (te(item.labelKey)) return t(item.labelKey);
|
||||
const gateKey = `workspace.shippingNotice.processGate.actions.${item.actionCode}`;
|
||||
if (te(gateKey)) return t(gateKey);
|
||||
return t('chat.shippingProcessing.action.none');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -116,7 +106,7 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
<div class="order-1 flex flex-wrap items-center gap-2 sm:order-1">
|
||||
<template v-if="!automating && canWriteCaseActions">
|
||||
<button
|
||||
v-if="hasAction('mark_non_order')"
|
||||
v-if="showParseDispositions && hasAction('mark_non_order')"
|
||||
type="button"
|
||||
:disabled="controlsBusy"
|
||||
class="rounded border border-rose-200 px-3 py-2 text-sm text-rose-700 hover:bg-rose-50 disabled:opacity-50 dark:border-rose-900 dark:text-rose-300 dark:hover:bg-rose-950/40"
|
||||
@@ -125,7 +115,7 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
{{ t('chat.shippingOrderReview.markNonOrder') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('mark_quality_issue')"
|
||||
v-if="showParseDispositions && hasAction('mark_quality_issue')"
|
||||
type="button"
|
||||
:disabled="controlsBusy"
|
||||
class="rounded border border-amber-200 px-3 py-2 text-sm text-amber-800 hover:bg-amber-50 disabled:opacity-50 dark:border-amber-900 dark:text-amber-200 dark:hover:bg-amber-950/40"
|
||||
@@ -134,7 +124,7 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
{{ t('chat.shippingOrderReview.markQualityIssue') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('reparse')"
|
||||
v-if="showParseDispositions && hasAction('reparse')"
|
||||
type="button"
|
||||
:disabled="controlsBusy"
|
||||
class="inline-flex items-center gap-1 rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
@@ -142,24 +132,10 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.reparse') }}
|
||||
</button>
|
||||
<label
|
||||
v-if="hasAction('mark_quality_issue')"
|
||||
class="cursor-pointer rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
:class="controlsBusy ? 'pointer-events-none opacity-50' : ''"
|
||||
>
|
||||
<input
|
||||
class="sr-only"
|
||||
type="file"
|
||||
accept="application/pdf,.pdf"
|
||||
:disabled="controlsBusy"
|
||||
@change="emit('upload-replacement', $event)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.uploadReplacement') }}
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<button
|
||||
v-for="item in flowItems"
|
||||
v-for="item in footerFlowItems"
|
||||
:key="`${item.intent}-${item.actionCode}`"
|
||||
type="button"
|
||||
:disabled="controlsBusy"
|
||||
@@ -196,23 +172,13 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
</p>
|
||||
<template v-if="!automating && canWriteCaseActions">
|
||||
<button
|
||||
v-if="showStpRetry || hasAction('retry_stp_auto_create')"
|
||||
type="button"
|
||||
:disabled="controlsBusy"
|
||||
class="inline-flex items-center gap-1 rounded border border-amber-400 bg-amber-50 px-3 py-2 text-sm text-amber-950 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
data-testid="review-retry-stp-auto-create"
|
||||
@click="emit('retry-stp')"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.autoProgress.retryObject') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('validate')"
|
||||
v-if="showValidate && hasAction('validate')"
|
||||
type="button"
|
||||
:disabled="controlsBusy"
|
||||
class="inline-flex items-center gap-1 rounded bg-sky-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
@click="emit('validate')"
|
||||
>
|
||||
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveNow') }}
|
||||
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveOrderAndValidate') }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
@@ -1,60 +1,33 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewWorkbenchHeader.vue
|
||||
用途:订单复核工作台顶栏——对话级动作、审计/版本入口与保存状态。
|
||||
用途:订单复核工作台顶栏——审计/版本入口与保存状态。
|
||||
依赖:vue-i18n、lucide-vue-next。
|
||||
逻辑:仅当后端 conversation_allowed_actions 含 retry_auto_progress 时渲染对话级按钮;
|
||||
审计/版本为查看入口;「已保存」为状态文本;不含单个任务单写操作。
|
||||
逻辑:审计/版本为查看入口;「已保存」为状态文本;不含单个任务单写操作。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { ArrowLeft, RefreshCw } from 'lucide-vue-next';
|
||||
import { ArrowLeft } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const props = defineProps<{
|
||||
runNo: string;
|
||||
itemNo?: string | null;
|
||||
versionLabel?: string;
|
||||
selectedOrderSummary?: string | null;
|
||||
saving: boolean;
|
||||
saveFailed: boolean;
|
||||
draftConflict: boolean;
|
||||
isReadOnly: boolean;
|
||||
showVersionHistory?: boolean;
|
||||
showAuditTrail?: boolean;
|
||||
/** 对话级「重试自动推进」;仅 eligible_count>0 时由父级置 true */
|
||||
showConversationRetry?: boolean;
|
||||
conversationRetryEligibleCount?: number;
|
||||
conversationRetrying?: boolean;
|
||||
conversationRetryDisabled?: boolean;
|
||||
hasConversationRetryResult?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
back: [];
|
||||
'open-version-history': [];
|
||||
'open-audit-trail': [];
|
||||
'retry-conversation-auto-progress': [];
|
||||
'open-conversation-retry-result': [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 副标题:优先工作项编号与版本,否则识别批次号。
|
||||
*/
|
||||
const subtitle = computed(() => {
|
||||
if (props.itemNo) {
|
||||
return t('chat.shippingOrderReview.workItemHeader', {
|
||||
itemNo: props.itemNo,
|
||||
version: props.versionLabel || '',
|
||||
});
|
||||
}
|
||||
return t('chat.shippingOrderReview.run', { runNo: props.runNo });
|
||||
});
|
||||
|
||||
const showRetry = computed(() => (
|
||||
Boolean(props.showConversationRetry)
|
||||
&& Number(props.conversationRetryEligibleCount || 0) > 0
|
||||
));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -69,36 +42,12 @@ const showRetry = computed(() => (
|
||||
</button>
|
||||
<div class="min-w-0 flex-1">
|
||||
<h1 class="text-base font-semibold">{{ t('chat.shippingOrderReview.title') }}</h1>
|
||||
<p class="truncate text-xs text-slate-500 dark:text-slate-400">{{ subtitle }}</p>
|
||||
<p
|
||||
v-if="selectedOrderSummary"
|
||||
class="truncate text-xs text-slate-600 dark:text-slate-300"
|
||||
data-testid="review-selected-order-summary"
|
||||
>{{ selectedOrderSummary }}</p>
|
||||
</div>
|
||||
<button
|
||||
v-if="showRetry"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded border border-amber-400 bg-amber-50 px-2.5 py-1.5 text-xs font-medium text-amber-950 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
data-testid="review-conversation-retry-auto-progress"
|
||||
:disabled="conversationRetrying || conversationRetryDisabled || isReadOnly"
|
||||
@click="emit('retry-conversation-auto-progress')"
|
||||
>
|
||||
<RefreshCw
|
||||
class="h-3.5 w-3.5"
|
||||
:class="conversationRetrying ? 'animate-spin' : ''"
|
||||
/>
|
||||
{{ conversationRetrying ? t('chat.shippingOrderReview.conversationRetry.retrying') : t('chat.shippingOrderReview.autoProgress.retry') }}
|
||||
<span
|
||||
v-if="conversationRetryEligibleCount"
|
||||
class="rounded bg-amber-200/80 px-1 text-[10px] dark:bg-amber-900/60"
|
||||
>{{ conversationRetryEligibleCount }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="hasConversationRetryResult"
|
||||
type="button"
|
||||
class="relative rounded border border-slate-200 px-2.5 py-1.5 text-xs hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800"
|
||||
data-testid="review-open-conversation-retry-result"
|
||||
@click="emit('open-conversation-retry-result')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.conversationRetry.viewResult') }}
|
||||
<span class="absolute -right-1 -top-1 h-2 w-2 rounded-full bg-rose-500" />
|
||||
</button>
|
||||
<button
|
||||
v-if="showAuditTrail"
|
||||
type="button"
|
||||
|
||||
+335
-17
@@ -117,6 +117,210 @@ function buildWorkItem(
|
||||
}
|
||||
|
||||
describe('ShippingConversationProcessingCard', () => {
|
||||
it('only exposes file cancellation when the backend explicitly authorizes cancel_unit', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'OT-CANCEL-UNIT', group: 'processing', status_label: 'extracting',
|
||||
file_count: 1, run_no: 'RUN-CANCEL-UNIT', can_append: false,
|
||||
objects: [{ kind: 'document', object_key: 'DOC-9', label: 'cancel.pdf', filename: 'cancel.pdf',
|
||||
document_id: 9, root_document_id: 9, status_label: 'extracting' }],
|
||||
}];
|
||||
const workItem = buildWorkItem('OT-CANCEL-UNIT', {
|
||||
availableActions: ['cancel_unit'],
|
||||
sourceSummary: { ...buildWorkItem('OT-CANCEL-UNIT').sourceSummary, documentId: 9 },
|
||||
uiState: {
|
||||
status: 'running',
|
||||
stage: 'document_parsing',
|
||||
blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [{ code: 'cancel_unit', enabled: true }],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
await wrapper.find('summary').trigger('click');
|
||||
await wrapper.find('[data-testid="shipping-processing-file-cancel"]').trigger('click');
|
||||
expect(wrapper.emitted('fileAction')?.[0]?.[0]).toMatchObject({
|
||||
action: 'cancel_unit', projection: { workItemNo: 'OT-CANCEL-UNIT' },
|
||||
});
|
||||
});
|
||||
|
||||
it('does not fall back to legacy cancellation when ui_state revokes it', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'OT-CANCEL-REVOKED', group: 'processing', status_label: 'extracting',
|
||||
file_count: 1, run_no: 'RUN-CANCEL-REVOKED', can_append: false,
|
||||
objects: [{ kind: 'document', object_key: 'DOC-10', label: 'revoked.pdf', filename: 'revoked.pdf',
|
||||
document_id: 10, root_document_id: 10, status_label: 'extracting' }],
|
||||
}];
|
||||
const workItem = buildWorkItem('OT-CANCEL-REVOKED', {
|
||||
availableActions: ['cancel_unit'],
|
||||
sourceSummary: { ...buildWorkItem('OT-CANCEL-REVOKED').sourceSummary, documentId: 10 },
|
||||
uiState: {
|
||||
status: 'running',
|
||||
stage: 'document_parsing',
|
||||
blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// ui_state 已出现即表示后端完成了正式动作裁决;遗留 availableActions 不得重新授权。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-cancel"]').exists()).toBe(false);
|
||||
expect(wrapper.emitted('fileAction')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('does not render legacy document_names as a batch file row without a live leaf projection', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'OT-HISTORICAL-SNAPSHOT', group: 'processing', status_label: 'extracting',
|
||||
title: 'legacy-run.pdf', document_names: ['legacy-run.pdf'], file_count: 1,
|
||||
run_no: 'RUN-HISTORICAL-SNAPSHOT', can_append: false,
|
||||
}];
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// 批次中心没有实时叶子投影时不得由历史 Run 快照补造文件行或操作入口。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-OT-HISTORICAL-SNAPSHOT-document-0"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).not.toContain('legacy-run.pdf');
|
||||
});
|
||||
|
||||
it('uses the live leaf summary instead of a stale task object in batch mode', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'OT-LIVE-LEAF', group: 'processing', status_label: 'extracting',
|
||||
title: 'snapshot-old-name.pdf', file_count: 1, run_no: 'RUN-LIVE-LEAF', can_append: false,
|
||||
objects: [{
|
||||
kind: 'document', object_key: 'DOC-88', label: 'snapshot-old-name.pdf',
|
||||
filename: 'snapshot-old-name.pdf', document_id: 88, root_document_id: 88,
|
||||
status_label: 'pending_review',
|
||||
}],
|
||||
}];
|
||||
const live = buildWorkItem('OT-LIVE-LEAF', {
|
||||
runNo: 'RUN-LIVE-LEAF',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'realtime-name.pdf', documentId: 88,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-REALTIME',
|
||||
},
|
||||
uiState: {
|
||||
status: 'running', stage: 'order_review', lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' }],
|
||||
blocking_reason: null, primary_action: null, secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [live], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.get('[data-testid="shipping-processing-file-DOC-88"]');
|
||||
expect(row.text()).toContain('realtime-name.pdf');
|
||||
expect(row.text()).toContain('PO:PO-REALTIME');
|
||||
expect(row.text()).not.toContain('snapshot-old-name.pdf');
|
||||
});
|
||||
|
||||
it('expands EML files only from the live aggregate work item', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'INTAKE:EML-LIVE', group: 'processing', status_label: 'extracting',
|
||||
title: 'snapshot-mail.eml', document_names: ['snapshot-attachment.pdf'],
|
||||
file_count: 1, run_no: 'RUN-EML-LIVE', can_append: false,
|
||||
aggregateChildren: [],
|
||||
}];
|
||||
const liveChild = buildWorkItem('DOCUMENT:77', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-LIVE', runNo: 'RUN-EML-LIVE',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'live-attachment.pdf', documentId: 77,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-EML-LIVE',
|
||||
},
|
||||
uiState: {
|
||||
status: 'running', stage: 'order_review', lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' }],
|
||||
blocking_reason: null, primary_action: null, secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const liveEmlRoot = buildWorkItem('INTAKE:EML-LIVE', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-LIVE', runNo: 'RUN-EML-LIVE',
|
||||
sourceSummary: {
|
||||
emailSubject: 'Live mail', filename: 'live-mail.eml', documentId: null,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: null,
|
||||
},
|
||||
aggregateChildren: [liveChild],
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [liveEmlRoot], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.get('[data-testid="shipping-processing-file-DOC-77"]');
|
||||
expect(row.text()).toContain('live-attachment.pdf');
|
||||
expect(row.text()).toContain('PO:PO-EML-LIVE');
|
||||
expect(wrapper.text()).not.toContain('snapshot-attachment.pdf');
|
||||
});
|
||||
|
||||
it('keeps an EML attachment when it has a linked child order task', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'INTAKE:EML-WITH-CHILD-OT', group: 'processing', status_label: 'extracting',
|
||||
title: 'mail.eml', file_count: 2, run_no: 'RUN-EML-WITH-CHILD-OT', can_append: false,
|
||||
}];
|
||||
const firstAttachment = buildWorkItem('OT-EML-WITH-CHILD-OT', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-WITH-CHILD-OT',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'first.pdf', documentId: 266,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-FIRST',
|
||||
},
|
||||
childOrderTasks: [{
|
||||
orderTaskNo: 'OT-EML-WITH-CHILD-OT-C1', status: 'blocked', stage: 'inventory_matching',
|
||||
customerName: null, poNumber: 'PO-SECOND', lastActivityAt: null,
|
||||
}],
|
||||
});
|
||||
const secondAttachment = buildWorkItem('OT-EML-WITH-CHILD-OT-C1', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-WITH-CHILD-OT',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'second.pdf', documentId: 267,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-SECOND',
|
||||
},
|
||||
});
|
||||
const liveEmlRoot = buildWorkItem('INTAKE:EML-WITH-CHILD-OT', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-WITH-CHILD-OT',
|
||||
sourceSummary: {
|
||||
emailSubject: 'Mail', filename: 'mail.eml', documentId: null,
|
||||
documentCount: 2, parsedDocumentCount: 2, candidateCount: 2,
|
||||
customerName: null, poNumber: null,
|
||||
},
|
||||
aggregateChildren: [firstAttachment, secondAttachment],
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [liveEmlRoot], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-DOC-266"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-DOC-267"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('处理中 · 2 个文件');
|
||||
});
|
||||
|
||||
it('renders needs_action / processing groups and collapsible processing records with three subsections', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection: buildProjection() },
|
||||
@@ -125,10 +329,11 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-conversation-processing-card"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-needs_action"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-failed"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-processing"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('需要你处理 · 1 个任务');
|
||||
expect(wrapper.text()).toContain('系统处理中 · 1 个任务');
|
||||
// 批次中心统一按文件计数;旧任务数文案不再是页面统计口径。
|
||||
expect(wrapper.text()).toContain('异常 · 0 个文件');
|
||||
expect(wrapper.text()).toContain('处理中 · 0 个文件');
|
||||
expect(wrapper.text()).toContain('刚刚创建');
|
||||
|
||||
// 处理记录默认折叠;标题 count = completed + history 返回条数。
|
||||
@@ -441,20 +646,36 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(wrapper.findAll('[data-testid="shipping-conversation-processing-card"]')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('renders pending order_intake work items above task groups', async () => {
|
||||
it('renders an EML order_intake in the unified failed group rather than the removed intake side path', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: null,
|
||||
projection: {
|
||||
summary: { total_tasks: 1, total_files: 1, processing: 0, needs_action: 1, completed: 0, history: 0 },
|
||||
needs_action: [{
|
||||
user_task_no: 'SNI-1',
|
||||
group: 'needs_action',
|
||||
userGroup: 'failed',
|
||||
status_label: 'failed',
|
||||
title: 'mail.eml',
|
||||
file_count: 1,
|
||||
run_no: null,
|
||||
can_append: false,
|
||||
}],
|
||||
processing: [],
|
||||
completed: [],
|
||||
history: [],
|
||||
},
|
||||
workItems: [{
|
||||
workItemType: 'order_intake',
|
||||
workItemNo: 'SNI-1',
|
||||
sourceType: 'direct_pdf',
|
||||
sourceType: 'eml',
|
||||
rootOrderTaskNo: null,
|
||||
shippingNoticeNo: null,
|
||||
conversationId: 'conv-1',
|
||||
submissionNo: 'SOS-1',
|
||||
intakeNo: 'SNI-1',
|
||||
status: 'failed',
|
||||
userGroup: 'failed',
|
||||
stage: 'document_parsing',
|
||||
progressVersion: 1,
|
||||
lastActivityAt: '2026-08-04T12:00:00Z',
|
||||
@@ -484,16 +705,10 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-order-intake"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-intake-SNI-1"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('po.pdf');
|
||||
expect(wrapper.find('[data-testid="shipping-processing-intake-recovery"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('SHIPPING_NOTICE.INTAKE_PARSE_FAILED');
|
||||
await wrapper.find('[data-testid="shipping-processing-intake-action-retry_parse"]').trigger('click');
|
||||
expect(wrapper.emitted('intakeAction')?.[0]?.[0]).toMatchObject({
|
||||
action: 'retry_parse',
|
||||
item: { workItemNo: 'SNI-1' },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-failed"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-SNI-1"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-order-intake"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).toContain('重试解析');
|
||||
});
|
||||
|
||||
it('keeps a human Gate action visible before and after selecting its task', async () => {
|
||||
@@ -549,7 +764,110 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.text()).toContain('待复核');
|
||||
// 旧聚合卡不再显示内部 Case 状态;工作台文件行才展示后端 ui_state。
|
||||
expect(wrapper.text()).not.toContain('review_case_draft');
|
||||
expect(wrapper.text()).not.toContain('review_case_draft');
|
||||
});
|
||||
|
||||
it('renders a compact V3 file row with named lifecycle entries', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
...projection.processing[0],
|
||||
user_task_no: 'OT-LIFECYCLE',
|
||||
run_no: 'RUN-LIFECYCLE',
|
||||
file_count: 1,
|
||||
}];
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection,
|
||||
workbenchMode: true,
|
||||
workItems: [buildWorkItem('OT-LIFECYCLE', {
|
||||
runNo: 'RUN-LIFECYCLE',
|
||||
caseNo: 'CASE-LIFECYCLE',
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'lifecycle.pdf',
|
||||
documentId: 9,
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: 'PO-LIFECYCLE',
|
||||
},
|
||||
uiState: {
|
||||
status: 'running',
|
||||
stage: 'inventory_match',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [
|
||||
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
|
||||
],
|
||||
blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
})],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.find('[data-testid="shipping-processing-file-DOC-9"]');
|
||||
expect(row.exists()).toBe(true);
|
||||
expect(row.text()).toContain('lifecycle.pdf');
|
||||
expect(row.text()).toContain('PO:PO-LIFECYCLE');
|
||||
expect(row.text()).toContain('通知准备');
|
||||
expect(row.text()).toContain('订单复核 · 可进入');
|
||||
expect(row.text()).toContain('通知准备 · 当前可处理');
|
||||
expect(row.text()).toContain('通知完成 · 前置未完成');
|
||||
});
|
||||
|
||||
it('fails closed when a lifecycle entry has an unknown backend state', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
...projection.processing[0],
|
||||
user_task_no: 'OT-LIFECYCLE-UNKNOWN',
|
||||
run_no: 'RUN-LIFECYCLE-UNKNOWN',
|
||||
file_count: 1,
|
||||
}];
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection,
|
||||
workbenchMode: true,
|
||||
workItems: [buildWorkItem('OT-LIFECYCLE-UNKNOWN', {
|
||||
runNo: 'RUN-LIFECYCLE-UNKNOWN',
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'unknown-entry.pdf',
|
||||
documentId: 10,
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: 'PO-UNKNOWN',
|
||||
},
|
||||
uiState: {
|
||||
status: 'running',
|
||||
stage: 'inventory_match',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [
|
||||
{ code: 'order_review', state: 'paused', targetSurface: 'order_lifecycle_workbench' },
|
||||
] as unknown as ShippingProcessingProjection['uiState']['lifecycleEntries'],
|
||||
blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
})],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.find('[data-testid="shipping-processing-file-DOC-10"]');
|
||||
const orderReview = row.findAll('button').find((button) => button.text().includes('订单复核'));
|
||||
expect(orderReview?.attributes('disabled')).toBeDefined();
|
||||
await orderReview?.trigger('click');
|
||||
expect(wrapper.emitted('openLifecycleStage')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
+528
-199
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingConversationProcessingCard.vue
|
||||
* 用途:右侧「本次处理中」顶层任务卡——needs_action / processing / 处理记录。
|
||||
* 用途:右侧「批次进度中心」顶层任务卡——needs_action / processing / 处理记录。
|
||||
* 依赖:vue-i18n、ConversationProcessingProjection、conversationProcessingState、
|
||||
* conversationProcessingDisplay、actionPresentation、shippingProcessingLabels、SidebarProgressInline。
|
||||
* 逻辑:由 ShippingWorkflowTimeline 嵌入;只消费统一 projection / workItems;
|
||||
@@ -13,10 +13,11 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ChevronDown, ChevronRight } from 'lucide-vue-next';
|
||||
import { ChevronDown, ChevronRight, MoreHorizontal } from 'lucide-vue-next';
|
||||
import type {
|
||||
ConversationProcessingProjection,
|
||||
ConversationProcessingUserTask,
|
||||
ShippingProcessingLifecycleEntry,
|
||||
ShippingProcessingProjection,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { getPrimaryDocumentName } from '@/features/chat/shipping/conversationProcessingDisplay';
|
||||
@@ -30,11 +31,12 @@ import {
|
||||
} from '@/features/chat/shipping/conversationProcessingState';
|
||||
import {
|
||||
resolveShippingProcessingMessage,
|
||||
resolveShippingProcessingReasonLabel,
|
||||
resolveShippingProcessingStageLabel,
|
||||
resolveShippingProcessingStatusLabel,
|
||||
shippingProcessingSourceTypeKey,
|
||||
shippingProcessingStageKey,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveConversationTaskActionPresentation } from '@/features/shipping-progress/actionPresentation';
|
||||
import { flattenBusinessFileProjections } from '@/features/chat/shipping/conversationProcessingProjection';
|
||||
import { resolveConversationTaskActionPresentation, resolveProcessingActionPresentation } from '@/features/shipping-progress/actionPresentation';
|
||||
import SidebarProgressInline from '@/features/shipping-progress/components/SidebarProgressInline.vue';
|
||||
import type { ActionPresentation, ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
|
||||
@@ -46,6 +48,15 @@ const props = defineProps<{
|
||||
conversationId?: string | null;
|
||||
/** 后端截断提示:history 还有未返回内容时在处理记录底部展示 */
|
||||
hasMoreHistory?: boolean;
|
||||
/** 批次中心按状态 → EML → 文件展示,不再嵌入任务级 15 节点进度。 */
|
||||
workbenchMode?: boolean;
|
||||
/** 批次四阶段筛选;保留状态/EML 分组,仅隐藏不属于当前阶段的任务。 */
|
||||
lifecycleFilter?: 'all' | 'intake_parse' | 'order_review' | 'fulfillment_prep' | 'upload_complete';
|
||||
/** 批次中心本地搜索:只筛叶子文件,父 EML 卡仍保留。 */
|
||||
fileSearchQuery?: string;
|
||||
/** 后端已授权下载的正式 Excel 对应 OT。 */
|
||||
downloadableTaskNos?: string[];
|
||||
selectedDownloadTaskNos?: string[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -59,6 +70,12 @@ const emit = defineEmits<{
|
||||
intakeAction: [payload: { item: ShippingProcessingProjection; action: string }];
|
||||
/** OT 卡内统一进度动作。 */
|
||||
projectionAction: [payload: { projection: ShippingProcessingProjection; item: ActionPresentationItem }];
|
||||
downloadArtifact: [taskNo: string];
|
||||
toggleDownloadSelection: [taskNo: string];
|
||||
/** 文件级生命周期入口;父级只切换工作台展示,不在导航时写入业务状态。 */
|
||||
openLifecycleStage: [payload: { projection: ShippingProcessingProjection; entry: ShippingProcessingLifecycleEntry }];
|
||||
/** 单文件低频操作;仅当后端明确授权该动作时才发出。 */
|
||||
fileAction: [payload: { projection: ShippingProcessingProjection; action: string }];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -66,27 +83,63 @@ const uiState = createConversationProcessingUiState();
|
||||
/** 处理记录整组默认折叠。 */
|
||||
const historySectionExpanded = ref(false);
|
||||
|
||||
/** 批次中心文件叶子行;EML 仅是聚合容器,文件状态、原因与动作必须取叶子自身投影。 */
|
||||
type WorkbenchFileRow = {
|
||||
kind: 'document';
|
||||
object_key: string;
|
||||
label: string;
|
||||
filename?: string | null;
|
||||
document_id?: number | null;
|
||||
status_label?: string | null;
|
||||
po_number?: string | null;
|
||||
projection?: ShippingProcessingProjection;
|
||||
};
|
||||
const LIFECYCLE_STAGE_CODES = ['intake_parse', 'order_review', 'fulfillment_prep', 'upload_complete'] as const;
|
||||
type LifecycleStageCode = typeof LIFECYCLE_STAGE_CODES[number];
|
||||
const LIFECYCLE_STAGE_LABEL_KEYS: Record<string, string> = {
|
||||
intake_parse: 'intakeParse',
|
||||
order_review: 'orderReview',
|
||||
fulfillment_prep: 'fulfillmentPrep',
|
||||
upload_complete: 'uploadComplete',
|
||||
};
|
||||
|
||||
/** 唯一进度源:统一 conversation_processing / work_items 合成投影。 */
|
||||
const activeProjection = computed((): ConversationProcessingProjection | null => (
|
||||
props.projection || null
|
||||
));
|
||||
|
||||
/** 尚未建 OT、仍应展示在「待处理材料」的 Intake 工作项。 */
|
||||
const pendingIntakeItems = computed((): ShippingProcessingProjection[] => {
|
||||
const items = Array.isArray(props.workItems) ? props.workItems : [];
|
||||
return items.filter((item) => {
|
||||
if (item.workItemType !== 'order_intake') return false;
|
||||
return !['completed', 'cancelled'].includes(String(item.status || ''));
|
||||
});
|
||||
});
|
||||
|
||||
const hasContent = computed(() => Boolean(
|
||||
activeProjection.value
|
||||
|| pendingIntakeItems.value.length,
|
||||
activeProjection.value,
|
||||
));
|
||||
|
||||
const completedTasks = computed(() => activeProjection.value?.completed || []);
|
||||
const historyTasks = computed(() => activeProjection.value?.history || []);
|
||||
const statusGroups = computed(() => activeProjection.value?.status_groups || null);
|
||||
const completedTasks = computed(() => statusGroups.value?.completed || activeProjection.value?.completed || []);
|
||||
const historyTasks = computed(() => statusGroups.value
|
||||
? [...statusGroups.value.cancelled, ...statusGroups.value.archived]
|
||||
: (activeProjection.value?.history || []));
|
||||
/** EML 卡必须由后端 userGroup 分入独立用户区;旧任务保留 needs_action 兼容归属。 */
|
||||
const failedTasks = computed(() => statusGroups.value?.failed
|
||||
|| (activeProjection.value?.needs_action || []).filter((task) => task.userGroup === 'failed' || !task.userGroup));
|
||||
const waitingHumanTasks = computed(() => statusGroups.value?.waiting_human
|
||||
|| (activeProjection.value?.needs_action || []).filter((task) => task.userGroup === 'waiting_human'));
|
||||
const processingTasks = computed(() => statusGroups.value?.processing || activeProjection.value?.processing || []);
|
||||
|
||||
/** 任务只要含一个命中附件即保留,避免筛选后打散同一封 EML 的上下文。 */
|
||||
function taskMatchesLifecycleFilter(task: ConversationProcessingUserTask): boolean {
|
||||
const filter = props.lifecycleFilter || 'all';
|
||||
const query = String(props.fileSearchQuery || '').trim().toLowerCase();
|
||||
// 非批次中心保留历史任务卡兼容展示;只有批次中心才按叶子文件筛选。
|
||||
if (!props.workbenchMode && filter === 'all' && !query) return true;
|
||||
return workbenchFileRows(task).some((file) => {
|
||||
if (filter !== 'all' && String(file.projection?.uiState?.lifecycleStage || '') !== filter) return false;
|
||||
return !query || [file.filename, file.label, file.po_number]
|
||||
.some((value) => String(value || '').toLowerCase().includes(query));
|
||||
});
|
||||
}
|
||||
const visibleFailedTasks = computed(() => failedTasks.value.filter(taskMatchesLifecycleFilter));
|
||||
const visibleWaitingHumanTasks = computed(() => waitingHumanTasks.value.filter(taskMatchesLifecycleFilter));
|
||||
const visibleProcessingTasks = computed(() => processingTasks.value.filter(taskMatchesLifecycleFilter));
|
||||
const visibleCompletedTasks = computed(() => completedTasks.value.filter(taskMatchesLifecycleFilter));
|
||||
|
||||
/** history 中非取消 →「历史版本」。 */
|
||||
const historyVersionTasks = computed(() => historyTasks.value.filter(
|
||||
@@ -97,6 +150,8 @@ const historyVersionTasks = computed(() => historyTasks.value.filter(
|
||||
const cancelledHistoryTasks = computed(() => historyTasks.value.filter(
|
||||
(task) => String(task.status_label || '').trim().toLowerCase() === 'cancelled',
|
||||
));
|
||||
const visibleHistoryVersionTasks = computed(() => historyVersionTasks.value.filter(taskMatchesLifecycleFilter));
|
||||
const visibleCancelledHistoryTasks = computed(() => cancelledHistoryTasks.value.filter(taskMatchesLifecycleFilter));
|
||||
|
||||
/** 处理记录标题计数:当前返回的 completed + history。 */
|
||||
const recordTaskCount = computed(() => (
|
||||
@@ -123,7 +178,7 @@ function projectionForTask(task: ConversationProcessingUserTask): ShippingProces
|
||||
if (!taskNo) return null;
|
||||
const items = Array.isArray(props.workItems) ? props.workItems : [];
|
||||
return items.find((item) => (
|
||||
item.workItemType === 'order_task'
|
||||
(item.workItemType === 'order_task' || item.workItemType === 'order_intake')
|
||||
&& String(item.workItemNo || '').trim() === taskNo
|
||||
)) || null;
|
||||
}
|
||||
@@ -187,6 +242,7 @@ function canExpandFileDetails(task: ConversationProcessingUserTask): boolean {
|
||||
* 处理记录(completed/history)永不展实时进度。
|
||||
*/
|
||||
function progressModeForTask(task: ConversationProcessingUserTask): 'full' | 'compact' | 'hidden' {
|
||||
if (props.workbenchMode) return 'hidden';
|
||||
if (!projectionForTask(task)) return 'hidden';
|
||||
const group = String(task.group || '').trim();
|
||||
if (group === 'completed' || group === 'history') return 'hidden';
|
||||
@@ -204,6 +260,249 @@ function taskLabel(_task: ConversationProcessingUserTask): string {
|
||||
return t('chat.shippingProcessing.multiPdfTaskTitle');
|
||||
}
|
||||
|
||||
/** EML 聚合标题优先使用后端邮件文件名,普通文件则显示主文件名。 */
|
||||
function groupTitle(task: ConversationProcessingUserTask): string {
|
||||
const projection = projectionForTask(task);
|
||||
const children = task.aggregateChildren || [];
|
||||
const projectionFilename = String(projection?.sourceSummary?.filename || '').trim();
|
||||
const emlChild = children.find((child) => (
|
||||
String(child.sourceSummary?.filename || '').trim().toLowerCase().endsWith('.eml')
|
||||
));
|
||||
const emailChild = children.find((child) => Boolean(child.sourceSummary?.emailSubject));
|
||||
const isEml = projection?.sourceType === 'eml'
|
||||
&& Boolean(
|
||||
emlChild
|
||||
|| emailChild
|
||||
|| projection?.sourceSummary?.emailSubject
|
||||
|| projectionFilename.toLowerCase().endsWith('.eml'),
|
||||
);
|
||||
if (!isEml) return projection?.sourceSummary?.filename || task.title || taskLabel(task);
|
||||
// 后端在 EML 聚合根 sourceSummary 写入 Intake 原始邮件资产名;子附件列表不含
|
||||
// 邮件本体时仍必须显示该 .eml,不能回退成 Intake 编号或任一 PDF 文件名。
|
||||
if (projectionFilename.toLowerCase().endsWith('.eml')) return projectionFilename;
|
||||
if (emlChild?.sourceSummary?.filename) return emlChild.sourceSummary.filename;
|
||||
if (projection?.sourceSummary?.emailSubject) return `EML · ${projection.sourceSummary.emailSubject}`;
|
||||
if (emailChild?.sourceSummary?.emailSubject) return `EML · ${emailChild.sourceSummary.emailSubject}`;
|
||||
if (task.aggregateSummary?.intakeNo) {
|
||||
return `EML · ${task.aggregateSummary?.intakeNo || task.user_task_no}`;
|
||||
}
|
||||
return task.title || taskLabel(task);
|
||||
}
|
||||
|
||||
/** 工作台文件行:只展示后端 document objects,避免用任务标题冒充文件。 */
|
||||
function workbenchFileRows(task: ConversationProcessingUserTask): WorkbenchFileRow[] {
|
||||
const children = task.aggregateChildren || [];
|
||||
// [AUTHORITY] 批次模式只以实时 work_items 作为文件行真相。Conversation task 的
|
||||
// children / objects / document_names 是 Run 级兼容快照,可用于非批次卡历史展示,
|
||||
// 但不得重建批次中的文件名、状态、阶段或操作。
|
||||
if (props.workbenchMode) {
|
||||
const taskNo = String(task.user_task_no || '').trim();
|
||||
const liveLeaves = (props.workItems || []).flatMap((item) => {
|
||||
const isTaskRoot = String(item.rootOrderTaskNo || '').trim() === taskNo
|
||||
|| String(item.workItemNo || '').trim() === taskNo;
|
||||
if (!isTaskRoot) return [];
|
||||
// EML 父项的实时附件只存在于 aggregateChildren;展开同一份后端 work_item,
|
||||
// 不读取 conversation task 兼容快照。
|
||||
return item.sourceType === 'eml'
|
||||
? flattenBusinessFileProjections([item])
|
||||
: [item];
|
||||
}).filter((item) => (
|
||||
Number(item.sourceSummary?.documentId || 0) > 0
|
||||
));
|
||||
const seenLiveDocumentIds = new Set<number>();
|
||||
const uniqueLiveLeaves = liveLeaves.filter((item) => {
|
||||
const documentId = Number(item.sourceSummary?.documentId || 0);
|
||||
if (seenLiveDocumentIds.has(documentId)) return false;
|
||||
seenLiveDocumentIds.add(documentId);
|
||||
return true;
|
||||
});
|
||||
return uniqueLiveLeaves.map((item, index) => {
|
||||
const documentId = Number(item.sourceSummary?.documentId || 0);
|
||||
const filename = String(item.sourceSummary?.filename || '').trim();
|
||||
return {
|
||||
kind: 'document' as const,
|
||||
object_key: documentId ? `DOC-${documentId}` : `${taskNo}-live-${item.workItemNo || index}`,
|
||||
label: filename || item.workItemNo || `文件 ${index + 1}`,
|
||||
filename: filename || item.workItemNo || `文件 ${index + 1}`,
|
||||
document_id: documentId || null,
|
||||
status_label: String(item.uiState?.status || item.userStatus || item.status || ''),
|
||||
po_number: item.sourceSummary?.poNumber || null,
|
||||
projection: item,
|
||||
};
|
||||
});
|
||||
}
|
||||
if (children.length) {
|
||||
return flattenBusinessFileProjections(children).map((child, index) => {
|
||||
const filename = String(child.sourceSummary?.filename || '').trim();
|
||||
const documentId = Number(child.sourceSummary?.documentId || 0) || 0;
|
||||
return {
|
||||
kind: 'document' as const,
|
||||
object_key: documentId ? `DOC-${documentId}` : `${task.user_task_no}-aggregate-${child.workItemNo || index}`,
|
||||
label: filename || child.workItemNo || `文件 ${index + 1}`,
|
||||
filename: filename || child.workItemNo || `文件 ${index + 1}`,
|
||||
status_label: String(child.uiState?.status || child.userStatus || child.status || ''),
|
||||
po_number: child.sourceSummary?.poNumber || null,
|
||||
projection: child,
|
||||
};
|
||||
});
|
||||
}
|
||||
const documents = (task.objects || []).filter((item) => (
|
||||
item.kind === 'document'
|
||||
&& !String(item.filename || item.label || '').trim().toLowerCase().endsWith('.eml')
|
||||
));
|
||||
if (documents.length) {
|
||||
// direct_pdf 没有 EML aggregate_children;将唯一根 work_item 绑定到其文件行,
|
||||
// 使状态、原因和操作仍然来自同一份后端 ui_state,而不是丢失操作或回退 legacy 字段。
|
||||
const directFileProjection = projectionForTask(task);
|
||||
return documents.map((item) => ({
|
||||
kind: 'document' as const,
|
||||
object_key: item.object_key,
|
||||
label: item.label,
|
||||
filename: item.filename,
|
||||
document_id: item.document_id,
|
||||
status_label: item.status_label,
|
||||
po_number: directFileProjection?.sourceSummary?.poNumber || null,
|
||||
projection: directFileProjection?.sourceType === 'direct_pdf'
|
||||
? directFileProjection
|
||||
: undefined,
|
||||
}));
|
||||
}
|
||||
const taskName = String(task.title || '').trim().toLowerCase();
|
||||
if (taskName.endsWith('.eml') || task.aggregateSummary?.intakeNo) return [];
|
||||
// 新版实时投影可只返回 work_items,不重复旧 task.objects;此时以同一 OT 的叶子
|
||||
// document 投影生成行,确保文件状态、阶段和按钮仍完全来自后端。
|
||||
const taskNo = String(task.user_task_no || '').trim();
|
||||
const liveLeaves = (props.workItems || []).filter((item) => (
|
||||
String(item.rootOrderTaskNo || '').trim() === taskNo
|
||||
&& Number(item.sourceSummary?.documentId || 0) > 0
|
||||
&& !item.childOrderTasks?.length
|
||||
));
|
||||
if (liveLeaves.length) {
|
||||
return liveLeaves.map((item, index) => {
|
||||
const documentId = Number(item.sourceSummary?.documentId || 0);
|
||||
const filename = String(item.sourceSummary?.filename || '').trim();
|
||||
return {
|
||||
kind: 'document' as const,
|
||||
object_key: documentId ? `DOC-${documentId}` : `${taskNo}-live-${item.workItemNo || index}`,
|
||||
label: filename || item.workItemNo || `文件 ${index + 1}`,
|
||||
filename: filename || item.workItemNo || `文件 ${index + 1}`,
|
||||
document_id: documentId || null,
|
||||
status_label: String(item.uiState?.status || item.userStatus || item.status || ''),
|
||||
po_number: item.sourceSummary?.poNumber || null,
|
||||
projection: item,
|
||||
};
|
||||
});
|
||||
}
|
||||
return (task.document_names || []).map((filename, index) => ({
|
||||
kind: 'document' as const,
|
||||
object_key: `${task.user_task_no}-document-${index}`,
|
||||
label: filename,
|
||||
filename,
|
||||
status_label: task.status_label,
|
||||
po_number: null,
|
||||
}));
|
||||
}
|
||||
|
||||
/** 阶段筛选只收窄附件行,EML 卡本身仍保留以便用户识别邮件来源。 */
|
||||
function visibleWorkbenchFileRows(task: ConversationProcessingUserTask): WorkbenchFileRow[] {
|
||||
const filter = props.lifecycleFilter || 'all';
|
||||
const rows = workbenchFileRows(task);
|
||||
const query = String(props.fileSearchQuery || '').trim().toLowerCase();
|
||||
return rows.filter((file) => {
|
||||
if (filter !== 'all' && String(file.projection?.uiState?.lifecycleStage || '') !== filter) return false;
|
||||
if (!query) return true;
|
||||
return [file.filename, file.label, file.po_number].some((value) => String(value || '').toLowerCase().includes(query));
|
||||
});
|
||||
}
|
||||
|
||||
function fileDownloadTaskNo(file: WorkbenchFileRow): string | null {
|
||||
const taskNo = String(file.projection?.rootOrderTaskNo || '').trim();
|
||||
return taskNo && (props.downloadableTaskNos || []).includes(taskNo) ? taskNo : null;
|
||||
}
|
||||
function isDownloadSelected(taskNo: string): boolean {
|
||||
return (props.selectedDownloadTaskNos || []).includes(taskNo);
|
||||
}
|
||||
|
||||
/** 状态组标题按文件计数,与批次总览保持同一口径。 */
|
||||
function groupFileCount(tasks: ConversationProcessingUserTask[]): number {
|
||||
const seen = new Set<string>();
|
||||
return tasks.reduce((total, task) => total + workbenchFileRows(task).reduce((count, file) => {
|
||||
const filename = String(file.filename || file.label || '').trim().toLowerCase();
|
||||
if (filename.endsWith('.eml')) return count;
|
||||
const key = String(('document_id' in file ? file.document_id : undefined)
|
||||
|| file.object_key || file.filename || file.label || '').trim();
|
||||
if (!key || seen.has(key)) return count;
|
||||
seen.add(key);
|
||||
return count + 1;
|
||||
}, 0), 0);
|
||||
}
|
||||
|
||||
function workbenchFileStatus(file: WorkbenchFileRow, task: ConversationProcessingUserTask): string {
|
||||
const status = file.projection
|
||||
? (file.projection.uiState?.status || file.projection.userStatus || file.projection.status)
|
||||
: (file.status_label || task.status_label || '');
|
||||
return resolveShippingProcessingStatusLabel(String(status), te, t);
|
||||
}
|
||||
|
||||
function workbenchFileReason(file: WorkbenchFileRow, task: ConversationProcessingUserTask): string {
|
||||
if (file.projection) {
|
||||
const reason = file.projection.uiState
|
||||
? file.projection.uiState.blocking_reason
|
||||
: file.projection.blockingReason;
|
||||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||||
}
|
||||
return taskReasonLabel(task);
|
||||
}
|
||||
|
||||
/** 文件工作面显示四阶段业务语义;技术 stage 仍保留给进度诊断,不用于入口可达性。 */
|
||||
function workbenchFileLifecycleStage(file: WorkbenchFileRow): string {
|
||||
const code = String(file.projection?.uiState?.lifecycleStage || '').trim();
|
||||
const key = LIFECYCLE_STAGE_LABEL_KEYS[code];
|
||||
return key
|
||||
? t(`chat.shippingNoticeUi.stage.${key}`)
|
||||
: t('chat.shippingProcessing.stageLabel.waiting_system_start');
|
||||
}
|
||||
|
||||
/** 生命周期入口仅消费后端投影;禁止按候选、Case 或阶段顺序二次裁决。 */
|
||||
function lifecycleEntries(file: WorkbenchFileRow): ShippingProcessingLifecycleEntry[] {
|
||||
return file.projection?.uiState?.lifecycleEntries || [];
|
||||
}
|
||||
|
||||
function lifecycleEntry(file: WorkbenchFileRow, target: LifecycleStageCode): ShippingProcessingLifecycleEntry | null {
|
||||
return lifecycleEntries(file).find((entry) => entry.code === target) || null;
|
||||
}
|
||||
|
||||
function lifecycleEntryState(file: WorkbenchFileRow, target: LifecycleStageCode): 'available' | 'current' | 'unavailable' {
|
||||
const state = lifecycleEntry(file, target)?.state;
|
||||
// [FAIL-CLOSED] 服务端新增或异常状态不得被 UI 当作可进入工作台。
|
||||
return state === 'available' || state === 'current' ? state : 'unavailable';
|
||||
}
|
||||
|
||||
function lifecycleEntryLabel(file: WorkbenchFileRow, target: LifecycleStageCode): string {
|
||||
void file;
|
||||
// 阶段状态由按钮颜色和 disabled 表达,避免重复的“当前可处理/前置未完成”文案挤占文件行。
|
||||
return t(`chat.shippingNoticeUi.stage.${LIFECYCLE_STAGE_LABEL_KEYS[target]}`);
|
||||
}
|
||||
|
||||
function onOpenLifecycleStage(file: WorkbenchFileRow, lifecycleStage: LifecycleStageCode) {
|
||||
const entry = lifecycleEntry(file, lifecycleStage);
|
||||
if (!file.projection || !entry) return;
|
||||
if (lifecycleEntryState(file, lifecycleStage) === 'unavailable') return;
|
||||
emit('openLifecycleStage', { projection: file.projection, entry });
|
||||
}
|
||||
|
||||
/** 叶子文件动作由自身 ui_state 裁决;没有叶子投影时不伪造可操作按钮。 */
|
||||
function filePrimaryActionItem(file: WorkbenchFileRow): ActionPresentationItem | null {
|
||||
return file.projection
|
||||
? resolveProcessingActionPresentation(file.projection, { surface: 'right' }).primary
|
||||
: null;
|
||||
}
|
||||
|
||||
function onFileProjectionAction(file: WorkbenchFileRow) {
|
||||
const action = filePrimaryActionItem(file);
|
||||
if (file.projection && action) emit('projectionAction', { projection: file.projection, item: action });
|
||||
}
|
||||
|
||||
/**
|
||||
* 主文件副标题:有主文件名时渲染「主文件:{name}」。
|
||||
*/
|
||||
@@ -229,7 +528,38 @@ function fileCountLabel(task: ConversationProcessingUserTask): string {
|
||||
* 任务状态文案:优先统一 shippingProcessing,回退 shippingWorkflow。
|
||||
*/
|
||||
function statusLabel(task: ConversationProcessingUserTask): string {
|
||||
return resolveShippingProcessingStatusLabel(String(task.status_label || ''), te, t);
|
||||
return resolveShippingProcessingStatusLabel(
|
||||
String(task.uiState?.status || task.userStatus || task.status_label || ''),
|
||||
te,
|
||||
t,
|
||||
);
|
||||
}
|
||||
|
||||
/** 展示统一投影的真实履约阶段;识别候选不再冒充最终完成。 */
|
||||
function stageLabel(task: ConversationProcessingUserTask): string {
|
||||
const projection = projectionForTask(task);
|
||||
if (!projection) return '';
|
||||
return intakeStageLabel(projection);
|
||||
}
|
||||
|
||||
/** 展示后端 ui_state 已裁决的阻断原因;i18n 仅负责翻译,不映射或猜测业务原因。 */
|
||||
function taskReasonLabel(task: ConversationProcessingUserTask): string {
|
||||
const reason = task.uiState
|
||||
? task.uiState.blocking_reason
|
||||
: task.blockingReason;
|
||||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||||
}
|
||||
|
||||
/** 同一 EML 聚合卡状态计数;仅用后端下发的 aggregateSummary,不从 UI 状态推导。 */
|
||||
function aggregateStatusLabel(task: ConversationProcessingUserTask): string {
|
||||
const summary = task.aggregateSummary;
|
||||
if (!summary) return '';
|
||||
const parts: string[] = [];
|
||||
if (summary.completed) parts.push(t('chat.shippingProcessing.aggregate.completed', { count: summary.completed }));
|
||||
if (summary.processing) parts.push(t('chat.shippingProcessing.aggregate.processing', { count: summary.processing }));
|
||||
if (summary.needsAction) parts.push(t('chat.shippingProcessing.aggregate.needsAction', { count: summary.needsAction }));
|
||||
if (summary.failed) parts.push(t('chat.shippingProcessing.aggregate.failed', { count: summary.failed }));
|
||||
return parts.join(' · ');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,6 +586,16 @@ function taskActionPresentation(task: ConversationProcessingUserTask): ActionPre
|
||||
return resolveConversationTaskActionPresentation(task, { surface: 'right' });
|
||||
}
|
||||
|
||||
/**
|
||||
* 待确认分组的批次重解析入口:仅消费该分组任务的后端授权,避免按钮脱离业务上下文。
|
||||
*/
|
||||
function waitingHumanBatchReparseTask(): ConversationProcessingUserTask | null {
|
||||
return visibleWaitingHumanTasks.value.find((task) => (
|
||||
task.available_actions?.includes('reparse_batch')
|
||||
&& String(task.run_no || '').trim()
|
||||
)) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 唯一主 CTA(实心按钮);处理记录只读卡不调用。
|
||||
*/
|
||||
@@ -270,10 +610,14 @@ function currentNeedLabel(task: ConversationProcessingUserTask): string {
|
||||
primaryAction?: { code?: string } | null;
|
||||
};
|
||||
const action = String(
|
||||
typedTask.primaryAction?.code
|
||||
?? task.primary_action
|
||||
?? task.available_actions?.[0]
|
||||
?? '',
|
||||
task.uiState
|
||||
? (task.uiState.primary_action?.code
|
||||
?? task.uiState.secondary_actions.find((item) => item.enabled)?.code
|
||||
?? '')
|
||||
: (typedTask.primaryAction?.code
|
||||
?? task.primary_action
|
||||
?? task.available_actions?.[0]
|
||||
?? ''),
|
||||
).trim().toLowerCase();
|
||||
const labels: Record<string, string> = {
|
||||
confirm_customer: 'chat.shippingProcessing.currentNeed.confirmCustomer',
|
||||
@@ -326,6 +670,7 @@ function shouldShowOverflowActions(_task: ConversationProcessingUserTask): boole
|
||||
* 是否渲染任务级主/次动作区(不含「展开文件详情」文件控制)。
|
||||
*/
|
||||
function shouldShowTaskLevelActions(task: ConversationProcessingUserTask): boolean {
|
||||
if (props.workbenchMode) return Boolean(primaryActionItem(task));
|
||||
if (projectionForTask(task)) return false;
|
||||
return Boolean(primaryActionItem(task) || secondaryActionItem(task));
|
||||
}
|
||||
@@ -364,7 +709,27 @@ function presentationActionLabel(task: ConversationProcessingUserTask, item: Act
|
||||
if (key && te(key)) return t(key);
|
||||
const extractionKey = `chat.shippingOrderExtractionAction.${code}`;
|
||||
if (te(extractionKey)) return t(extractionKey);
|
||||
return code;
|
||||
return t('chat.shippingProcessing.action.unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件低频操作优先读取正式 ui_state;旧 availableActions 仅兼容未下发 ui_state 的旧投影。
|
||||
* 一旦后端提供 ui_state,遗留字段绝不能重新授予已撤销的操作。
|
||||
*/
|
||||
function canCancelFile(file: WorkbenchFileRow): boolean {
|
||||
const projection = file.projection;
|
||||
if (!projection) return false;
|
||||
if (projection.uiState) {
|
||||
return projection.uiState.secondary_actions.some(
|
||||
(action) => action.enabled && action.code === 'cancel_unit',
|
||||
);
|
||||
}
|
||||
return projection.availableActions.includes('cancel_unit');
|
||||
}
|
||||
|
||||
function onFileAction(file: WorkbenchFileRow, action: string) {
|
||||
if (!file.projection || action !== 'cancel_unit' || !canCancelFile(file)) return;
|
||||
emit('fileAction', { projection: file.projection, action });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,93 +756,11 @@ function toggleHistorySection() {
|
||||
historySectionExpanded.value = !historySectionExpanded.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Intake 材料标题:文件名 / 邮件主题 / Intake 编号。
|
||||
*/
|
||||
function intakeTitle(item: ShippingProcessingProjection): string {
|
||||
return String(
|
||||
item.sourceSummary?.filename
|
||||
|| item.sourceSummary?.emailSubject
|
||||
|| item.workItemNo
|
||||
|| '',
|
||||
).trim() || item.workItemNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Intake 状态文案。
|
||||
*/
|
||||
function intakeStatusLabel(item: ShippingProcessingProjection): string {
|
||||
return resolveShippingProcessingStatusLabel(item.status, te, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Intake 阶段文案。
|
||||
*/
|
||||
function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
const key = shippingProcessingStageKey(item.stage);
|
||||
return te(key) ? t(key) : String(item.stage || '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Intake 来源类型文案。
|
||||
*/
|
||||
function intakeSourceLabel(item: ShippingProcessingProjection): string {
|
||||
const key = shippingProcessingSourceTypeKey(item.sourceType);
|
||||
return te(key) ? t(key) : String(item.sourceType || '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Intake / OT 门禁与失败恢复元信息(Gate / Attempt / 资产状态)。
|
||||
*/
|
||||
function intakeRecoveryMeta(item: ShippingProcessingProjection): string[] {
|
||||
const parts: string[] = [];
|
||||
const gate = item.currentGate;
|
||||
const reason = String(
|
||||
gate?.blockingReasonCode
|
||||
|| item.sourceSummary?.failureReasonCode
|
||||
|| '',
|
||||
).trim();
|
||||
if (reason) {
|
||||
parts.push(t('chat.shippingProcessing.failureReason', { code: reason }));
|
||||
}
|
||||
const attempt = gate?.attemptNo ?? item.sourceSummary?.parseAttemptCount;
|
||||
if (attempt != null && Number(attempt) > 0) {
|
||||
parts.push(t('chat.shippingProcessing.parseAttempt', { count: Number(attempt) }));
|
||||
}
|
||||
const assetStatus = String(item.sourceSummary?.assetStatus || '').trim();
|
||||
if (assetStatus) {
|
||||
const key = `chat.shippingProcessing.assetStatus.${assetStatus}`;
|
||||
parts.push(te(key) ? t(key) : t('chat.shippingProcessing.assetStatusLabel', { status: assetStatus }));
|
||||
}
|
||||
if (gate?.gateCode) {
|
||||
parts.push(t('chat.shippingProcessing.gateCode', { code: gate.gateCode }));
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Intake 可见动作(仅展示 retry_parse)。
|
||||
*/
|
||||
function visibleIntakeActions(item: ShippingProcessingProjection): string[] {
|
||||
const actions = Array.isArray(item.availableActions) ? item.availableActions : [];
|
||||
return actions.filter((code) => code === 'retry_parse');
|
||||
}
|
||||
|
||||
/**
|
||||
* Intake 动作文案。
|
||||
*/
|
||||
function intakeActionLabel(action: string): string {
|
||||
if (action === 'retry_parse') return t('chat.shippingProcessing.retryFromFailure');
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发 Intake 级动作。
|
||||
*/
|
||||
function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
const code = String(action || '').trim();
|
||||
if (!code) return;
|
||||
emit('intakeAction', { item, action: code });
|
||||
return resolveShippingProcessingStageLabel(item.stage, te, t);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -488,70 +771,15 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
data-testid="shipping-conversation-processing-card"
|
||||
>
|
||||
<section
|
||||
v-if="pendingIntakeItems.length"
|
||||
data-testid="shipping-processing-group-order-intake"
|
||||
>
|
||||
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-violet-700 dark:text-violet-300">
|
||||
{{ t('chat.shippingProcessing.pendingMaterials') }}
|
||||
· {{ pendingIntakeItems.length }}
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="item in pendingIntakeItems"
|
||||
:key="item.workItemNo"
|
||||
class="rounded-lg border border-default bg-surface px-2.5 py-2"
|
||||
:data-testid="`shipping-processing-intake-${item.workItemNo}`"
|
||||
:data-source-type="item.sourceType"
|
||||
:data-status="item.status"
|
||||
>
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ intakeTitle(item) }}
|
||||
</div>
|
||||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<span>{{ intakeSourceLabel(item) }}</span>
|
||||
<span>{{ intakeStatusLabel(item) }}</span>
|
||||
<span v-if="intakeStageLabel(item)">{{ intakeStageLabel(item) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="intakeRecoveryMeta(item).length"
|
||||
class="mt-1 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-rose-700 dark:text-rose-300"
|
||||
data-testid="shipping-processing-intake-recovery"
|
||||
>
|
||||
<span
|
||||
v-for="(meta, idx) in intakeRecoveryMeta(item)"
|
||||
:key="`${item.workItemNo}-meta-${idx}`"
|
||||
>{{ meta }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="visibleIntakeActions(item).length"
|
||||
class="mt-1.5 flex flex-wrap gap-1.5"
|
||||
data-testid="shipping-processing-intake-actions"
|
||||
>
|
||||
<button
|
||||
v-for="action in visibleIntakeActions(item)"
|
||||
:key="`${item.workItemNo}-${action}`"
|
||||
type="button"
|
||||
class="rounded-md border border-default bg-surface px-2 py-0.5 text-[11px] text-secondary hover:text-primary"
|
||||
:data-testid="`shipping-processing-intake-action-${action}`"
|
||||
@click="onIntakeAction(item, action)"
|
||||
>
|
||||
{{ intakeActionLabel(action) }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="activeProjection?.needs_action.length"
|
||||
data-testid="shipping-processing-group-needs_action"
|
||||
v-if="visibleFailedTasks.length"
|
||||
data-testid="shipping-processing-group-failed"
|
||||
>
|
||||
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300">
|
||||
{{ resolveShippingProcessingMessage('groupNeedsAction', te, t, { count: activeProjection.needs_action.length }) }}
|
||||
{{ t('chat.shippingProcessing.batchWorkbench.groups.failed', { count: groupFileCount(visibleFailedTasks) }) }}
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in activeProjection.needs_action"
|
||||
v-for="task in visibleFailedTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border px-2.5 py-2 transition"
|
||||
:class="[
|
||||
@@ -569,19 +797,24 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
@click="onSelectTask(task)"
|
||||
>
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||||
{{ workbenchMode ? groupTitle(task) : resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||||
</div>
|
||||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<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>
|
||||
<span>{{ statusLabel(task) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="primaryFileLabel(task)"
|
||||
v-if="!workbenchMode && primaryFileLabel(task)"
|
||||
class="mt-0.5 truncate text-[11px] text-muted"
|
||||
data-testid="shipping-processing-task-primary-file"
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div v-if="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>
|
||||
<div
|
||||
v-if="task.recent_append_count"
|
||||
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
|
||||
@@ -595,27 +828,41 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
v-if="task.group === 'needs_action' && currentNeedLabel(task)"
|
||||
class="mt-1 text-[11px] text-secondary"
|
||||
data-testid="shipping-processing-current-need"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.progress.currentNeedLabel') }}{{ currentNeedLabel(task) }}
|
||||
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-rose-200/70 pt-2">
|
||||
<div v-for="file in visibleWorkbenchFileRows(task)" :key="file.object_key" class="grid gap-x-3 gap-y-1 rounded-md bg-white/70 px-2 py-1.5 text-[11px] sm:grid-cols-[minmax(10rem,1fr)_auto_auto] sm:items-center dark:bg-slate-950/30" :data-testid="`shipping-processing-file-${file.object_key}`">
|
||||
<div class="min-w-0"><span class="truncate font-medium text-primary">{{ file.filename || file.label }}</span><span class="ml-1 text-secondary">· {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.po', { value: file.po_number || '-' }) }}</span></div>
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-1">
|
||||
<span class="w-fit shrink-0 rounded-full bg-rose-100 px-2 py-0.5 font-medium text-rose-700">{{ workbenchFileStatus(file, task) || t('chat.shippingProcessing.batchWorkbench.groups.failedFallback') }}</span>
|
||||
<button v-if="filePrimaryActionItem(file)" type="button" class="rounded-md border border-rose-300 px-2 py-0.5 font-medium text-rose-700 hover:bg-rose-50" @click="onFileProjectionAction(file)">{{ presentationActionLabel(task, filePrimaryActionItem(file)!) }}</button>
|
||||
<label v-if="fileDownloadTaskNo(file)" class="inline-flex items-center gap-1 text-secondary"><input type="checkbox" :checked="isDownloadSelected(fileDownloadTaskNo(file)!)" @change="emit('toggleDownloadSelection', fileDownloadTaskNo(file)!)"><span class="sr-only">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.select') }}</span></label>
|
||||
<button v-if="fileDownloadTaskNo(file)" type="button" class="rounded-md border border-emerald-300 px-2 py-0.5 font-medium text-emerald-700 hover:bg-emerald-50" @click="emit('downloadArtifact', fileDownloadTaskNo(file)!)">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.download') }}</button>
|
||||
</div>
|
||||
<div class="col-span-full flex min-h-7 items-center justify-between gap-3 border-t border-default pt-1.5">
|
||||
<div class="min-w-0 truncate text-secondary"><span>{{ t('chat.shippingProcessing.batchWorkbench.fileEntries.stage', { value: workbenchFileLifecycleStage(file) }) }}</span><span v-if="workbenchFileReason(file, task)" class="text-rose-600 dark:text-rose-300" :title="workbenchFileReason(file, task)"> · {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.blocker', { value: workbenchFileReason(file, task) }) }}</span></div>
|
||||
<div v-if="lifecycleEntries(file).length" class="flex shrink-0 flex-wrap justify-end gap-1">
|
||||
<button v-for="stage in LIFECYCLE_STAGE_CODES" :key="stage" type="button" class="rounded border px-1.5 py-1 text-[11px] font-medium disabled:cursor-not-allowed" :class="lifecycleEntryState(file, stage) === 'current' ? 'border-brand-600 bg-brand-600 text-white hover:bg-brand-700' : lifecycleEntryState(file, stage) === 'available' ? 'border-emerald-300 bg-emerald-50 text-emerald-800 hover:bg-emerald-100' : 'border-default bg-surface-muted text-muted'" :disabled="lifecycleEntryState(file, stage) === 'unavailable'" :title="lifecycleEntryState(file, stage) === 'unavailable' ? t('chat.shippingProcessing.batchWorkbench.fileEntries.unavailable') : undefined" @click="onOpenLifecycleStage(file, stage)">{{ lifecycleEntryLabel(file, stage) }}</button>
|
||||
</div>
|
||||
<details v-if="canCancelFile(file)" class="relative shrink-0">
|
||||
<summary class="list-none rounded border border-default p-1 text-secondary hover:bg-surface-muted" :aria-label="t('chat.shippingProcessing.action.more')"><MoreHorizontal class="h-3.5 w-3.5" /></summary>
|
||||
<button type="button" class="absolute right-0 top-7 z-10 whitespace-nowrap rounded border border-rose-200 bg-surface px-2 py-1 text-[11px] text-rose-700 shadow-sm hover:bg-rose-50" data-testid="shipping-processing-file-cancel" @click="onFileAction(file, 'cancel_unit')">{{ t('chat.shippingProcessing.actions.cancelFile') }}</button>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<SidebarProgressInline
|
||||
v-if="progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||||
v-if="!workbenchMode && progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||||
class="mt-1.5 border-t border-current/10 pt-1.5"
|
||||
:projection="projectionForTask(task)!"
|
||||
:compact="progressModeForTask(task) === 'compact'"
|
||||
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
|
||||
/>
|
||||
<div
|
||||
v-if="shouldShowTaskLevelActions(task) || (!projectionForTask(task) && canExpandFileDetails(task))"
|
||||
v-if="shouldShowTaskLevelActions(task) || (!workbenchMode && !projectionForTask(task) && canExpandFileDetails(task))"
|
||||
class="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1"
|
||||
data-testid="shipping-processing-task-actions"
|
||||
>
|
||||
<button
|
||||
v-if="!projectionForTask(task) && primaryActionItem(task)"
|
||||
v-if="(!workbenchMode && !projectionForTask(task)) && primaryActionItem(task)"
|
||||
type="button"
|
||||
class="rounded-md border border-brand-300 bg-brand-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-brand-700 dark:border-brand-700 dark:bg-brand-700 dark:hover:bg-brand-600"
|
||||
:data-testid="`shipping-processing-action-${primaryActionItem(task)!.actionCode}`"
|
||||
@@ -630,15 +877,75 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="activeProjection?.processing.length"
|
||||
data-testid="shipping-processing-group-processing"
|
||||
v-if="visibleWaitingHumanTasks.length"
|
||||
data-testid="shipping-processing-group-waiting_human"
|
||||
>
|
||||
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-sky-700 dark:text-sky-300">
|
||||
{{ resolveShippingProcessingMessage('groupProcessing', te, t, { count: activeProjection.processing.length }) }}
|
||||
<div class="mb-1.5 flex items-center justify-between gap-2 text-[11px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300">
|
||||
{{ t('chat.shippingProcessing.batchWorkbench.groups.waitingHuman', { count: groupFileCount(visibleWaitingHumanTasks) }) }}
|
||||
<button
|
||||
v-if="workbenchMode && waitingHumanBatchReparseTask()"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2.5 py-1 text-[11px] font-medium normal-case text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:bg-amber-950/30 dark:text-amber-200"
|
||||
data-testid="shipping-processing-batch-reparse"
|
||||
@click="onTaskAction(waitingHumanBatchReparseTask()!, 'reparse_batch')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.lineOps.reparse_batch') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in activeProjection.processing"
|
||||
v-for="task in visibleWaitingHumanTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border border-amber-400 bg-amber-50/80 px-2.5 py-2 transition dark:border-amber-700 dark:bg-amber-950/30"
|
||||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||||
:data-focused="focusedTaskNo === task.user_task_no ? '1' : '0'"
|
||||
>
|
||||
<button type="button" class="w-full text-left" @click="onSelectTask(task)">
|
||||
<div class="text-sm font-semibold text-primary">{{ workbenchMode ? groupTitle(task) : resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}</div>
|
||||
<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="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">
|
||||
<div v-for="file in visibleWorkbenchFileRows(task)" :key="file.object_key" class="grid gap-x-3 gap-y-1 rounded-md bg-white/70 px-2 py-1.5 text-[11px] sm:grid-cols-[minmax(10rem,1fr)_auto_auto] sm:items-center dark:bg-slate-950/30" :data-testid="`shipping-processing-file-${file.object_key}`">
|
||||
<div class="min-w-0"><span class="truncate font-medium text-primary">{{ file.filename || file.label }}</span><span class="ml-1 text-secondary">· {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.po', { value: file.po_number || '-' }) }}</span></div>
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-1"><span class="w-fit shrink-0 rounded-full bg-amber-100 px-2 py-0.5 font-medium text-amber-800">{{ workbenchFileStatus(file, task) || t('chat.shippingProcessing.batchWorkbench.groups.waitingFallback') }}</span><button v-if="filePrimaryActionItem(file)" type="button" class="rounded-md bg-brand-600 px-2 py-0.5 font-medium text-white hover:bg-brand-700" @click="onFileProjectionAction(file)">{{ presentationActionLabel(task, filePrimaryActionItem(file)!) }}</button><label v-if="fileDownloadTaskNo(file)" class="inline-flex items-center gap-1 text-secondary"><input type="checkbox" :checked="isDownloadSelected(fileDownloadTaskNo(file)!)" @change="emit('toggleDownloadSelection', fileDownloadTaskNo(file)!)"><span class="sr-only">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.select') }}</span></label><button v-if="fileDownloadTaskNo(file)" type="button" class="rounded-md border border-emerald-300 px-2 py-0.5 font-medium text-emerald-700 hover:bg-emerald-50" @click="emit('downloadArtifact', fileDownloadTaskNo(file)!)">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.download') }}</button></div>
|
||||
<div class="col-span-full flex min-h-7 items-center justify-between gap-3 border-t border-default pt-1.5"><div class="min-w-0 truncate text-secondary"><span>{{ t('chat.shippingProcessing.batchWorkbench.fileEntries.stage', { value: workbenchFileLifecycleStage(file) }) }}</span><span v-if="workbenchFileReason(file, task)" class="text-rose-600 dark:text-rose-300" :title="workbenchFileReason(file, task)"> · {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.blocker', { value: workbenchFileReason(file, task) }) }}</span></div><div v-if="lifecycleEntries(file).length" class="flex shrink-0 flex-wrap justify-end gap-1">
|
||||
<button v-for="stage in LIFECYCLE_STAGE_CODES" :key="stage" type="button" class="rounded border px-1.5 py-1 text-[11px] font-medium disabled:cursor-not-allowed" :class="lifecycleEntryState(file, stage) === 'current' ? 'border-brand-600 bg-brand-600 text-white hover:bg-brand-700' : lifecycleEntryState(file, stage) === 'available' ? 'border-emerald-300 bg-emerald-50 text-emerald-800 hover:bg-emerald-100' : 'border-default bg-surface-muted text-muted'" :disabled="lifecycleEntryState(file, stage) === 'unavailable'" :title="lifecycleEntryState(file, stage) === 'unavailable' ? t('chat.shippingProcessing.batchWorkbench.fileEntries.unavailable') : undefined" @click="onOpenLifecycleStage(file, stage)">{{ lifecycleEntryLabel(file, stage) }}</button>
|
||||
</div><details v-if="canCancelFile(file)" class="relative shrink-0"><summary class="list-none rounded border border-default p-1 text-secondary hover:bg-surface-muted" :aria-label="t('chat.shippingProcessing.action.more')"><MoreHorizontal class="h-3.5 w-3.5" /></summary><button type="button" class="absolute right-0 top-7 z-10 whitespace-nowrap rounded border border-rose-200 bg-surface px-2 py-1 text-[11px] text-rose-700 shadow-sm hover:bg-rose-50" data-testid="shipping-processing-file-cancel" @click="onFileAction(file, 'cancel_unit')">{{ t('chat.shippingProcessing.actions.cancelFile') }}</button></details></div>
|
||||
</div>
|
||||
</div>
|
||||
<SidebarProgressInline
|
||||
v-if="!workbenchMode && projectionForTask(task)"
|
||||
class="mt-1.5 border-t border-current/10 pt-1.5"
|
||||
:projection="projectionForTask(task)!"
|
||||
:compact="false"
|
||||
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
|
||||
/>
|
||||
<button
|
||||
v-if="!workbenchMode && primaryActionItem(task)"
|
||||
type="button"
|
||||
class="mt-2 rounded-md bg-brand-600 px-2.5 py-1.5 text-[11px] font-medium text-white hover:bg-brand-700"
|
||||
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
|
||||
</button>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="visibleProcessingTasks.length"
|
||||
data-testid="shipping-processing-group-processing"
|
||||
>
|
||||
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-sky-700 dark:text-sky-300">
|
||||
{{ t('chat.shippingProcessing.batchWorkbench.groups.processing', { count: groupFileCount(visibleProcessingTasks) }) }}
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in visibleProcessingTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border border-default bg-surface px-2.5 py-2"
|
||||
:class="focusedTaskNo === task.user_task_no
|
||||
@@ -653,19 +960,21 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
@click="onSelectTask(task)"
|
||||
>
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||||
{{ workbenchMode ? groupTitle(task) : resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||||
</div>
|
||||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<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>
|
||||
<span>{{ statusLabel(task) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="primaryFileLabel(task)"
|
||||
v-if="!workbenchMode && primaryFileLabel(task)"
|
||||
class="mt-0.5 truncate text-[11px] text-muted"
|
||||
data-testid="shipping-processing-task-primary-file"
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">
|
||||
{{ aggregateStatusLabel(task) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="task.recent_append_count"
|
||||
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
|
||||
@@ -679,8 +988,16 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
|
||||
</div>
|
||||
</button>
|
||||
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-sky-200/70 pt-2">
|
||||
<div v-for="file in visibleWorkbenchFileRows(task)" :key="file.object_key" class="grid gap-x-3 gap-y-1 rounded-md bg-surface-muted/40 px-2 py-1.5 text-[11px] sm:grid-cols-[minmax(10rem,1fr)_auto_auto] sm:items-center" :data-testid="`shipping-processing-file-${file.object_key}`">
|
||||
<div class="min-w-0"><span class="truncate font-medium text-primary">{{ file.filename || file.label }}</span><span class="ml-1 text-secondary">· {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.po', { value: file.po_number || '-' }) }}</span></div><div class="flex min-w-0 flex-wrap items-center gap-1"><span class="w-fit shrink-0 rounded-full bg-sky-100 px-2 py-0.5 font-medium text-sky-700">{{ workbenchFileStatus(file, task) || t('chat.shippingProcessing.batchWorkbench.groups.processingFallback') }}</span><button v-if="filePrimaryActionItem(file)" type="button" class="rounded-md border border-brand-300 px-2 py-0.5 font-medium text-brand-700 hover:bg-brand-50" @click="onFileProjectionAction(file)">{{ presentationActionLabel(task, filePrimaryActionItem(file)!) }}</button><label v-if="fileDownloadTaskNo(file)" class="inline-flex items-center gap-1 text-secondary"><input type="checkbox" :checked="isDownloadSelected(fileDownloadTaskNo(file)!)" @change="emit('toggleDownloadSelection', fileDownloadTaskNo(file)!)"><span class="sr-only">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.select') }}</span></label><button v-if="fileDownloadTaskNo(file)" type="button" class="rounded-md border border-emerald-300 px-2 py-0.5 font-medium text-emerald-700 hover:bg-emerald-50" @click="emit('downloadArtifact', fileDownloadTaskNo(file)!)">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.download') }}</button></div>
|
||||
<div class="col-span-full flex min-h-7 items-center justify-between gap-3 border-t border-default pt-1.5"><div class="min-w-0 truncate text-secondary"><span>{{ t('chat.shippingProcessing.batchWorkbench.fileEntries.stage', { value: workbenchFileLifecycleStage(file) }) }}</span><span v-if="workbenchFileReason(file, task)" class="text-rose-600" :title="workbenchFileReason(file, task)"> · {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.blocker', { value: workbenchFileReason(file, task) }) }}</span></div><div v-if="lifecycleEntries(file).length" class="flex shrink-0 flex-wrap justify-end gap-1">
|
||||
<button v-for="stage in LIFECYCLE_STAGE_CODES" :key="stage" type="button" class="rounded border px-1.5 py-1 text-[11px] font-medium disabled:cursor-not-allowed" :class="lifecycleEntryState(file, stage) === 'current' ? 'border-brand-600 bg-brand-600 text-white hover:bg-brand-700' : lifecycleEntryState(file, stage) === 'available' ? 'border-emerald-300 bg-emerald-50 text-emerald-800 hover:bg-emerald-100' : 'border-default bg-surface-muted text-muted'" :disabled="lifecycleEntryState(file, stage) === 'unavailable'" :title="lifecycleEntryState(file, stage) === 'unavailable' ? t('chat.shippingProcessing.batchWorkbench.fileEntries.unavailable') : undefined" @click="onOpenLifecycleStage(file, stage)">{{ lifecycleEntryLabel(file, stage) }}</button>
|
||||
</div><details v-if="canCancelFile(file)" class="relative shrink-0"><summary class="list-none rounded border border-default p-1 text-secondary hover:bg-surface-muted" :aria-label="t('chat.shippingProcessing.action.more')"><MoreHorizontal class="h-3.5 w-3.5" /></summary><button type="button" class="absolute right-0 top-7 z-10 whitespace-nowrap rounded border border-rose-200 bg-surface px-2 py-1 text-[11px] text-rose-700 shadow-sm hover:bg-rose-50" data-testid="shipping-processing-file-cancel" @click="onFileAction(file, 'cancel_unit')">{{ t('chat.shippingProcessing.actions.cancelFile') }}</button></details></div>
|
||||
</div>
|
||||
</div>
|
||||
<SidebarProgressInline
|
||||
v-if="progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||||
v-if="!workbenchMode && progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||||
class="mt-1.5 border-t border-current/10 pt-1.5"
|
||||
:projection="projectionForTask(task)!"
|
||||
:compact="progressModeForTask(task) === 'compact'"
|
||||
@@ -692,7 +1009,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
data-testid="shipping-processing-task-actions"
|
||||
>
|
||||
<button
|
||||
v-if="!projectionForTask(task) && primaryActionItem(task)"
|
||||
v-if="!workbenchMode && !projectionForTask(task) && primaryActionItem(task)"
|
||||
type="button"
|
||||
class="rounded-md border border-brand-300 bg-brand-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-brand-700 dark:border-brand-700 dark:bg-brand-700 dark:hover:bg-brand-600"
|
||||
:data-testid="`shipping-processing-action-${primaryActionItem(task)!.actionCode}`"
|
||||
@@ -701,7 +1018,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canExpandFileDetails(task)"
|
||||
v-if="!workbenchMode && canExpandFileDetails(task)"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
data-testid="shipping-processing-expand-files"
|
||||
@@ -724,7 +1041,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
v-else-if="canExpandFileDetails(task)"
|
||||
v-else-if="!workbenchMode && canExpandFileDetails(task)"
|
||||
type="button"
|
||||
class="mt-1.5 inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
data-testid="shipping-processing-expand-files"
|
||||
@@ -785,7 +1102,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
data-testid="shipping-processing-history-body"
|
||||
>
|
||||
<div
|
||||
v-if="completedTasks.length"
|
||||
v-if="visibleCompletedTasks.length"
|
||||
data-testid="shipping-processing-history-completed"
|
||||
>
|
||||
<div class="mb-1 text-[11px] font-medium text-emerald-700 dark:text-emerald-300">
|
||||
@@ -793,7 +1110,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in completedTasks"
|
||||
v-for="task in visibleCompletedTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border border-default bg-surface/80 px-2.5 py-2"
|
||||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||||
@@ -805,6 +1122,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
<div 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>
|
||||
<span>{{ statusLabel(task) }}</span>
|
||||
<span v-if="stageLabel(task)">· {{ stageLabel(task) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="primaryFileLabel(task)"
|
||||
@@ -813,6 +1131,17 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div v-if="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">
|
||||
<div v-for="file in visibleWorkbenchFileRows(task)" :key="file.object_key" class="grid gap-x-3 gap-y-1 rounded-md bg-emerald-50/40 px-2 py-1.5 text-[11px] sm:grid-cols-[minmax(10rem,1fr)_auto_auto] sm:items-center" :data-testid="`shipping-processing-file-${file.object_key}`">
|
||||
<div class="min-w-0"><span class="truncate font-medium text-primary">{{ file.filename || file.label }}</span><span class="ml-1 text-secondary">· {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.po', { value: file.po_number || '-' }) }}</span></div><div class="flex min-w-0 flex-wrap items-center gap-1"><span class="w-fit shrink-0 rounded-full bg-emerald-100 px-2 py-0.5 font-medium text-emerald-700">{{ workbenchFileStatus(file, task) }}</span><label v-if="fileDownloadTaskNo(file)" class="inline-flex items-center gap-1 text-secondary"><input type="checkbox" :checked="isDownloadSelected(fileDownloadTaskNo(file)!)" @change="emit('toggleDownloadSelection', fileDownloadTaskNo(file)!)"><span class="sr-only">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.select') }}</span></label><button v-if="fileDownloadTaskNo(file)" type="button" class="rounded-md border border-emerald-300 px-2 py-0.5 font-medium text-emerald-700 hover:bg-emerald-50" @click="emit('downloadArtifact', fileDownloadTaskNo(file)!)">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.download') }}</button></div>
|
||||
<div class="col-span-full flex min-h-7 items-center justify-between gap-3 border-t border-default pt-1.5"><div class="min-w-0 truncate text-secondary"><span>{{ t('chat.shippingProcessing.batchWorkbench.fileEntries.stage', { value: workbenchFileLifecycleStage(file) }) }}</span><span v-if="workbenchFileReason(file, task)" class="text-rose-600" :title="workbenchFileReason(file, task)"> · {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.blocker', { value: workbenchFileReason(file, task) }) }}</span></div><div v-if="lifecycleEntries(file).length" class="flex shrink-0 flex-wrap justify-end gap-1">
|
||||
<button v-for="stage in LIFECYCLE_STAGE_CODES" :key="stage" type="button" class="rounded border px-1.5 py-1 text-[11px] font-medium disabled:cursor-not-allowed" :class="lifecycleEntryState(file, stage) === 'current' ? 'border-brand-600 bg-brand-600 text-white hover:bg-brand-700' : lifecycleEntryState(file, stage) === 'available' ? 'border-emerald-300 bg-emerald-50 text-emerald-800 hover:bg-emerald-100' : 'border-default bg-surface-muted text-muted'" :disabled="lifecycleEntryState(file, stage) === 'unavailable'" :title="lifecycleEntryState(file, stage) === 'unavailable' ? t('chat.shippingProcessing.batchWorkbench.fileEntries.unavailable') : undefined" @click="onOpenLifecycleStage(file, stage)">{{ lifecycleEntryLabel(file, stage) }}</button>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
v-if="recordViewDetailsItem(task)"
|
||||
type="button"
|
||||
@@ -827,7 +1156,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="historyVersionTasks.length"
|
||||
v-if="visibleHistoryVersionTasks.length"
|
||||
data-testid="shipping-processing-history-versions"
|
||||
>
|
||||
<div class="mb-1 text-[11px] font-medium text-slate-600 dark:text-slate-300">
|
||||
@@ -835,7 +1164,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in historyVersionTasks"
|
||||
v-for="task in visibleHistoryVersionTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border border-default bg-surface/80 px-2.5 py-2"
|
||||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||||
@@ -869,7 +1198,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="cancelledHistoryTasks.length"
|
||||
v-if="visibleCancelledHistoryTasks.length"
|
||||
data-testid="shipping-processing-history-cancelled"
|
||||
>
|
||||
<div class="mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400">
|
||||
@@ -877,7 +1206,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in cancelledHistoryTasks"
|
||||
v-for="task in visibleCancelledHistoryTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border border-dashed border-default bg-surface/60 px-2.5 py-2 opacity-90"
|
||||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||||
|
||||
+487
-16
@@ -5,11 +5,13 @@
|
||||
* 逻辑:断言不再渲染进度列表/刷新取消/完整 handling 卡片;失败重试与需处理继续处理互斥。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { ref } from 'vue';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import chatZhCn from '@/locales/zh-CN/chat.json';
|
||||
import ShippingOrderExtractionCard from './ShippingOrderExtractionCard.vue';
|
||||
import type { ShippingOrderExtractionState } from '../../types/chat.types';
|
||||
import { SHIPPING_WORKFLOW_KEY } from '../../shipping/useShippingNoticeWorkflow';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
@@ -51,6 +53,477 @@ const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): Shipping
|
||||
});
|
||||
|
||||
describe('ShippingOrderExtractionCard', () => {
|
||||
it('opens the authoritative conversation batch even when no single run number is available', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState() },
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
provide: {
|
||||
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref({
|
||||
status_groups: {
|
||||
failed: [], waiting_human: [], processing: [{
|
||||
user_task_no: 'INTAKE:SNI-BATCH', title: 'batch.eml', file_count: 1,
|
||||
userGroup: 'processing', group: 'processing', aggregateChildren: [],
|
||||
}], completed: [], cancelled: [], archived: [],
|
||||
},
|
||||
}),
|
||||
processingWorkItems: ref([]),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('does not present historical handling items or CTA as current work when the live projection exists', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
status: 'review_required',
|
||||
availableActions: ['review_candidate'],
|
||||
primaryNotice: 'candidate_confirmation',
|
||||
handlingItems: [{
|
||||
category: 'candidate_confirmation', count: 2, reasonCodes: [],
|
||||
affectedRefs: [], primaryAction: 'review_candidate',
|
||||
}],
|
||||
}),
|
||||
},
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
provide: {
|
||||
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref({
|
||||
ui_state: { status: 'running' },
|
||||
summary: { total_files: 1, completed_files: 0, waiting_human_files: 0, failed_files: 0 },
|
||||
status_groups: {
|
||||
failed: [], waiting_human: [], processing: [{
|
||||
user_task_no: 'OT-LIVE', title: 'live.pdf', file_count: 1,
|
||||
userGroup: 'processing', group: 'processing', aggregateChildren: [],
|
||||
}], completed: [], cancelled: [], archived: [],
|
||||
},
|
||||
}),
|
||||
processingWorkItems: ref([]),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.text()).not.toContain('候选待人工确认');
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-handling-summary"]').exists()).toBe(false);
|
||||
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',
|
||||
shippingNoticeNo: null, runNo: 'SNER-EML', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-1',
|
||||
status: 'processing', stage: 'candidate_creating', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [],
|
||||
sourceSummary: { emailSubject: null, filename: 'forwarder.eml', documentCount: 3, parsedDocumentCount: 3, candidateCount: 2, customerName: null, poNumber: null }, childOrderTasks: [],
|
||||
userStatus: 'running', userStage: 'candidate_creating', facts: { uploadState: 'not_created' },
|
||||
aggregateSummary: { intakeNo: 'SNI-1', total: 3, completed: 1, processing: 1, needsAction: 0, failed: 1, stages: ['completed', 'candidate_creating'], reasonCodes: ['upload_rpa_failed'] },
|
||||
aggregateChildren: [
|
||||
{ workItemType: 'order_task', workItemNo: 'OT-1', sourceType: 'eml', rootOrderTaskNo: 'OT-1', shippingNoticeNo: null, runNo: 'SNER-EML', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-1', status: 'completed', stage: 'completed', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [], sourceSummary: { emailSubject: null, filename: 'done.pdf', documentCount: 1, parsedDocumentCount: 1, candidateCount: 1, customerName: null, poNumber: null }, childOrderTasks: [], userStatus: 'completed', userStage: 'completed', facts: { uploadState: 'succeeded' } },
|
||||
{ workItemType: 'order_task', workItemNo: 'OT-2', sourceType: 'eml', rootOrderTaskNo: 'OT-1', shippingNoticeNo: null, runNo: 'SNER-EML', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-1', status: 'processing', stage: 'candidate_creating', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [], sourceSummary: { emailSubject: null, filename: 'candidate.pdf', documentCount: 1, parsedDocumentCount: 1, candidateCount: 1, customerName: null, poNumber: null }, childOrderTasks: [], userStatus: 'running', userStage: 'candidate_creating', facts: { uploadState: 'not_created' } },
|
||||
],
|
||||
} as any;
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-EML' },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([aggregate]) } } },
|
||||
});
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-aggregate"]').text()).toContain('已上传完成 1 · 处理中 1 · 异常 1');
|
||||
expect(wrapper.text()).not.toContain('已生成候选 3 个文件');
|
||||
await wrapper.get('[data-testid="shipping-order-extraction-eml-aggregate"] button').trigger('click');
|
||||
expect(wrapper.text()).toContain('candidate.pdf');
|
||||
expect(wrapper.text()).toContain('处理中 1');
|
||||
});
|
||||
|
||||
it('uses the current three PDF rows instead of stale Run review totals', () => {
|
||||
const currentPdfRows = ['4210020274.pdf', '4210020272.pdf', '4210020273.pdf'].map((fileName, index) => ({
|
||||
unitId: index + 1,
|
||||
documentId: index + 101,
|
||||
intakeId: 1,
|
||||
documentType: 'attachment',
|
||||
fileName,
|
||||
status: 'candidate_ready' as const,
|
||||
userVisibleStage: 'candidate_ready',
|
||||
reasonCode: null,
|
||||
}));
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
runNo: 'SNER-STALE-COUNTS',
|
||||
state: buildState({
|
||||
// 历史 Run/Case 累计不能污染当前邮件的三份有效 PDF 统计。
|
||||
summary: {
|
||||
totalDocuments: 20,
|
||||
pendingDocuments: 0,
|
||||
processingDocuments: 0,
|
||||
completedDocuments: 2,
|
||||
reviewRequiredDocuments: 21,
|
||||
failedDocuments: 0,
|
||||
cancelledDocuments: 0,
|
||||
candidateCount: 3,
|
||||
},
|
||||
documents: currentPdfRows,
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([]) } } },
|
||||
});
|
||||
|
||||
// 当前卡片的总数、完成率和候选列表必须来自同一份有效 PDF 清单。
|
||||
expect(wrapper.text()).toContain('共 3 个文件');
|
||||
expect(wrapper.text()).toContain('0/3 已处理');
|
||||
expect(wrapper.text()).toContain('已生成候选 3 个文件');
|
||||
expect(wrapper.text()).not.toContain('23/20 已处理');
|
||||
expect(wrapper.text()).not.toContain('100% 完成');
|
||||
});
|
||||
|
||||
it('keeps its matched EML card when the side-panel poll temporarily omits the intake', async () => {
|
||||
const workItems = ref<any[]>([{
|
||||
workItemType: 'order_task', workItemNo: 'INTAKE:SNI-STABLE', sourceType: 'eml', rootOrderTaskNo: 'OT-STABLE',
|
||||
shippingNoticeNo: null, runNo: 'SNER-STABLE', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-STABLE',
|
||||
status: 'processing', stage: 'candidate_creating', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [],
|
||||
sourceSummary: { emailSubject: null, filename: 'stable.eml', documentCount: 2, parsedDocumentCount: 2, candidateCount: 0, customerName: null, poNumber: null },
|
||||
childOrderTasks: [], userStatus: 'running', userStage: 'candidate_creating', facts: { uploadState: 'not_created' },
|
||||
aggregateSummary: { intakeNo: 'SNI-STABLE', total: 2, completed: 0, processing: 2, needsAction: 0, failed: 0, stages: ['candidate_creating'], reasonCodes: [] },
|
||||
aggregateChildren: [],
|
||||
}]);
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-STABLE' },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: workItems } } },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-aggregate"]').text()).toContain('stable.eml');
|
||||
// 关键断言:右侧轮询暂时省略本 Intake 时,中间消息卡仍保留其自身的 EML 形态。
|
||||
workItems.value = [];
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-aggregate"]').text()).toContain('stable.eml');
|
||||
});
|
||||
|
||||
it('does not render a historical EML snapshot while the authoritative conversation projection is loading', () => {
|
||||
const historicalAggregate = {
|
||||
workItemType: 'order_task', workItemNo: 'INTAKE:SNI-HISTORY', sourceType: 'eml', intakeNo: 'SNI-HISTORY',
|
||||
sourceSummary: { filename: 'historical.eml', documentCount: 3 },
|
||||
aggregateSummary: { intakeNo: 'SNI-HISTORY', total: 3, completed: 0, processing: 3, needsAction: 0, failed: 0, stages: [], reasonCodes: [] },
|
||||
aggregateChildren: [],
|
||||
} as any;
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-HISTORY' },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref(null),
|
||||
processingWorkItems: ref([historicalAggregate]),
|
||||
initialLoading: ref(true),
|
||||
loading: ref(true),
|
||||
} } },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-eml-aggregate"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-projection-loading"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).not.toContain('historical.eml');
|
||||
expect(wrapper.text()).not.toContain('系统处理中');
|
||||
});
|
||||
|
||||
it('does not render message document rows while the authoritative projection is loading', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState({
|
||||
documents: [{
|
||||
unitId: 91,
|
||||
documentId: 191,
|
||||
documentType: 'attachment',
|
||||
fileName: 'message-snapshot.pdf',
|
||||
status: 'review_required',
|
||||
}],
|
||||
}) },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref(null),
|
||||
processingWorkItems: ref([]),
|
||||
initialLoading: ref(true),
|
||||
loading: ref(true),
|
||||
} } },
|
||||
});
|
||||
|
||||
expect(wrapper.text()).not.toContain('message-snapshot.pdf');
|
||||
expect(wrapper.text()).not.toContain('系统处理中');
|
||||
});
|
||||
|
||||
it('expands an EML inside its status group and shows every child attachment state', async () => {
|
||||
const child = {
|
||||
workItemType: 'order_task', workItemNo: 'OT-CHILD-1', sourceType: 'eml', rootOrderTaskNo: 'OT-ROOT',
|
||||
shippingNoticeNo: null, runNo: 'SNER-DETAIL', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-DETAIL',
|
||||
status: 'failed', stage: 'document_parsing', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [],
|
||||
sourceSummary: { emailSubject: null, filename: 'failed.pdf', documentCount: 1, parsedDocumentCount: 0, candidateCount: 0, customerName: null, poNumber: null },
|
||||
childOrderTasks: [], userStatus: 'running', userStage: 'document_parsing', facts: { uploadState: 'not_created' },
|
||||
// 后端新裁决与旧 userStatus 冲突时,摘要卡必须使用 ui_state,不能显示成“处理中”。
|
||||
uiState: { status: 'failed', stage: 'document_parsing', blocking_reason: { code: 'PARSE_FAILED' }, primary_action: null, secondary_actions: [] },
|
||||
blockingReason: { code: 'PARSE_FAILED' },
|
||||
} as any;
|
||||
const task = { user_task_no: 'INTAKE:SNI-DETAIL', title: 'mail.eml', file_count: 1, userGroup: 'failed', group: 'needs_action', aggregateChildren: [child], aggregateSummary: { intakeNo: 'SNI-DETAIL', total: 1, completed: 0, processing: 0, needsAction: 0, failed: 1, stages: ['document_parsing'], reasonCodes: ['PARSE_FAILED'] } } as any;
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-DETAIL' },
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
provide: {
|
||||
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref({ status_groups: { failed: [task], waiting_human: [], processing: [], completed: [], cancelled: [], archived: [] } }),
|
||||
processingWorkItems: ref([]),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
await wrapper.get('[data-testid="shipping-order-extraction-eml-failed-INTAKE:SNI-DETAIL"] button').trigger('click');
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-children"]').text()).toContain('failed.pdf');
|
||||
expect(wrapper.text()).toContain('异常 1');
|
||||
expect(wrapper.text()).toContain('当前步骤需要人工处理');
|
||||
expect(wrapper.text()).not.toContain('PARSE_FAILED');
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-child-status-OT-CHILD-1"]')
|
||||
.classes()).toContain('text-rose-600');
|
||||
});
|
||||
|
||||
it('does not supplement an authoritative EML group from a second work-item snapshot', async () => {
|
||||
const child = {
|
||||
workItemType: 'order_task', workItemNo: 'OT-FALLBACK-1', sourceType: 'eml', rootOrderTaskNo: 'OT-FALLBACK',
|
||||
shippingNoticeNo: null, runNo: 'SNER-FALLBACK', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-FALLBACK',
|
||||
status: 'processing', stage: 'document_parsing', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [],
|
||||
sourceSummary: { emailSubject: null, filename: 'inside.eml.pdf', documentCount: 1, parsedDocumentCount: 1, candidateCount: 0, customerName: null, poNumber: null },
|
||||
childOrderTasks: [], userStatus: 'running', userStage: 'document_parsing', facts: { uploadState: 'not_created' },
|
||||
} as any;
|
||||
const task = { user_task_no: 'INTAKE:SNI-FALLBACK', title: 'inside.eml', file_count: 1, userGroup: 'processing', group: 'processing', aggregateChildren: [], aggregateSummary: { intakeNo: 'SNI-FALLBACK', total: 1, completed: 0, processing: 1, needsAction: 0, failed: 0, stages: ['document_parsing'], reasonCodes: [] } } as any;
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-FALLBACK' },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref({ status_groups: { failed: [], waiting_human: [], processing: [task], completed: [], cancelled: [], archived: [] } }),
|
||||
processingWorkItems: ref([{ workItemType: 'order_intake', workItemNo: 'INTAKE:SNI-FALLBACK', sourceType: 'eml', intakeNo: 'SNI-FALLBACK', aggregateChildren: [child] } as any]),
|
||||
} } },
|
||||
});
|
||||
await wrapper.get('[data-testid="shipping-order-extraction-eml-processing-INTAKE:SNI-FALLBACK"] button').trigger('click');
|
||||
// 状态组出现后,子文件必须完全来自该组;不能用另一份 work_items 补数。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-eml-children"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).not.toContain('inside.eml.pdf');
|
||||
});
|
||||
|
||||
it('uses the conversation projection total instead of the message Run snapshot total', () => {
|
||||
const task = {
|
||||
user_task_no: 'INTAKE:SNI-TOTAL', title: 'mail-total.eml', file_count: 2,
|
||||
userGroup: 'waiting_human', group: 'needs_action', aggregateChildren: [],
|
||||
aggregateSummary: { intakeNo: 'SNI-TOTAL', total: 2, completed: 0, processing: 0, needsAction: 2, failed: 0, stages: ['order_review'], reasonCodes: [] },
|
||||
} as any;
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState({ summary: { ...buildState().summary, totalDocuments: 6 } }), runNo: 'SNER-TOTAL' },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref({
|
||||
summary: { total_files: 2, completed_files: 0, waiting_human_files: 2, failed_files: 0 },
|
||||
ui_state: { status: 'waiting_human' },
|
||||
status_groups: { failed: [], waiting_human: [task], processing: [], completed: [], cancelled: [], archived: [] },
|
||||
}),
|
||||
processingWorkItems: ref([{ sourceType: 'eml', intakeNo: 'SNI-TOTAL', aggregateChildren: [{ sourceSummary: { filename: 'stale.pdf' } }] }]),
|
||||
} } },
|
||||
});
|
||||
|
||||
expect(wrapper.text()).toContain('共 2 个文件');
|
||||
// 关键断言:待人工处理不是完成,聊天摘要必须与批次中心 completed_files 同口径。
|
||||
expect(wrapper.text()).toContain('0/2 已处理');
|
||||
expect(wrapper.text()).not.toContain('共 6 个文件');
|
||||
expect(wrapper.text()).not.toContain('stale.pdf');
|
||||
});
|
||||
|
||||
it('counts unique EML attachment children instead of task rows', async () => {
|
||||
const childA = { workItemType: 'order_task', workItemNo: 'OT-A', sourceType: 'eml', intakeNo: 'SNI-COUNT', sourceSummary: { filename: 'a.pdf', documentId: 101, documentCount: 1 }, status: 'processing', stage: 'document_parsing', userStatus: 'running', facts: { uploadState: 'not_created' } } as any;
|
||||
const childB = { ...childA, workItemNo: 'OT-B', sourceSummary: { filename: 'b.pdf', documentId: 102, documentCount: 1 } } as any;
|
||||
const task = { user_task_no: 'INTAKE:SNI-COUNT', title: 'count.eml', file_count: 2, userGroup: 'processing', group: 'processing', aggregateChildren: [childA, childB], aggregateSummary: { intakeNo: 'SNI-COUNT', total: 2, completed: 0, processing: 2, needsAction: 0, failed: 0, stages: [], reasonCodes: [] } } as any;
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-COUNT' },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processing: ref({ status_groups: { failed: [], waiting_human: [], processing: [task], completed: [], cancelled: [], archived: [] } }), processingWorkItems: ref([]) } } },
|
||||
});
|
||||
expect(wrapper.text()).toContain('2 个文件');
|
||||
});
|
||||
|
||||
it('renders every projected file when the batch has two documents', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
summary: {
|
||||
totalDocuments: 2,
|
||||
pendingDocuments: 0,
|
||||
processingDocuments: 0,
|
||||
completedDocuments: 0,
|
||||
reviewRequiredDocuments: 2,
|
||||
failedDocuments: 0,
|
||||
candidateCount: 0,
|
||||
},
|
||||
documents: [
|
||||
{ unitId: 1, documentId: 11, fileName: '4518838154.pdf', status: 'review_required' },
|
||||
{ unitId: 2, documentId: 12, fileName: '4518838152.pdf', status: 'review_required' },
|
||||
],
|
||||
availableActions: ['enter_manual_review'],
|
||||
healthTips: [],
|
||||
}),
|
||||
runNo: 'SNER-2',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).toContain('4518838154.pdf');
|
||||
expect(wrapper.text()).toContain('4518838152.pdf');
|
||||
});
|
||||
|
||||
it('groups completed attachments under their EML intake instead of mixing unrelated files', async () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
documents: [
|
||||
{ unitId: 1, documentId: 11, intakeId: 7, documentType: 'email_body', fileName: 'Forwarder_A.eml', status: 'processing' },
|
||||
{ unitId: 2, documentId: 12, intakeId: 7, documentType: 'attachment', fileName: 'Packing_List.pdf', status: 'candidate_ready' },
|
||||
{ unitId: 3, documentId: 13, intakeId: 8, documentType: 'attachment', fileName: 'Customs_Form.pdf', status: 'processing' },
|
||||
],
|
||||
healthTips: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await wrapper.find('button').trigger('click');
|
||||
const text = wrapper.text();
|
||||
expect(text.indexOf('Forwarder_A.eml')).toBeLessThan(text.indexOf('Packing_List.pdf'));
|
||||
expect(text).toContain('Customs_Form.pdf');
|
||||
expect(text.match(/Packing_List\.pdf/g)?.length).toBe(1);
|
||||
});
|
||||
|
||||
it('groups by email_body document type and renders parse failure as failed', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
status: 'failed',
|
||||
summary: {
|
||||
totalDocuments: 2,
|
||||
pendingDocuments: 0,
|
||||
processingDocuments: 0,
|
||||
completedDocuments: 0,
|
||||
reviewRequiredDocuments: 0,
|
||||
failedDocuments: 1,
|
||||
candidateCount: 0,
|
||||
},
|
||||
documents: [
|
||||
{ unitId: -7, documentId: 7, intakeId: 7, documentType: 'email_body', fileName: 'forwarder-message', status: 'failed', reasonCode: 'intake_parse_failed' },
|
||||
{ unitId: 8, documentId: 8, intakeId: 7, documentType: 'attachment', fileName: 'po.pdf', status: 'failed', reasonCode: 'intake_parse_failed' },
|
||||
],
|
||||
healthTips: [],
|
||||
currentActivity: null,
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const text = wrapper.text();
|
||||
expect(text).toContain('forwarder-message');
|
||||
expect(text).toContain('po.pdf');
|
||||
expect(text).toContain('异常');
|
||||
expect(wrapper.findAll('.animate-spin').length).toBe(0);
|
||||
});
|
||||
|
||||
it('does not render completed files again as standalone cards', async () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
summary: {
|
||||
totalDocuments: 2,
|
||||
pendingDocuments: 0,
|
||||
processingDocuments: 0,
|
||||
completedDocuments: 2,
|
||||
reviewRequiredDocuments: 0,
|
||||
failedDocuments: 0,
|
||||
candidateCount: 2,
|
||||
},
|
||||
documents: [
|
||||
{ unitId: 1, documentId: 11, fileName: '4518838152.pdf', status: 'candidate_ready' },
|
||||
{ unitId: 2, documentId: 12, fileName: '4518838154.pdf', status: 'candidate_ready' },
|
||||
],
|
||||
healthTips: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const accordion = wrapper.find('button');
|
||||
await accordion.trigger('click');
|
||||
expect(wrapper.text().match(/4518838152\.pdf/g)?.length).toBe(1);
|
||||
});
|
||||
|
||||
it('aggregates a fully completed EML intake only inside the completed section', async () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
summary: {
|
||||
totalDocuments: 2,
|
||||
pendingDocuments: 0,
|
||||
processingDocuments: 0,
|
||||
completedDocuments: 2,
|
||||
reviewRequiredDocuments: 0,
|
||||
failedDocuments: 0,
|
||||
candidateCount: 2,
|
||||
},
|
||||
documents: [
|
||||
{ unitId: -7, documentId: 7, intakeId: 7, documentType: 'email_body', fileName: 'forwarder.eml', status: 'processing' },
|
||||
{ unitId: 8, documentId: 8, intakeId: 7, documentType: 'attachment', fileName: 'packing.pdf', status: 'candidate_ready' },
|
||||
],
|
||||
healthTips: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).not.toContain('forwarder.eml');
|
||||
expect(wrapper.text()).not.toContain('packing.pdf');
|
||||
await wrapper.find('button').trigger('click');
|
||||
expect(wrapper.text()).toContain('forwarder.eml');
|
||||
expect(wrapper.text()).toContain('packing.pdf');
|
||||
expect(wrapper.text().match(/forwarder\.eml/g)?.length).toBe(1);
|
||||
expect(wrapper.text().match(/packing\.pdf/g)?.length).toBe(1);
|
||||
expect(wrapper.text()).toContain('已提取');
|
||||
});
|
||||
|
||||
it('keeps a partially completed EML intake outside the completed section', async () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
documents: [
|
||||
{ unitId: -7, documentId: 7, intakeId: 7, documentType: 'email_body', fileName: 'forwarder.eml', status: 'processing' },
|
||||
{ unitId: 8, documentId: 8, intakeId: 7, documentType: 'attachment', fileName: 'packing.pdf', status: 'candidate_ready' },
|
||||
{ unitId: 9, documentId: 9, intakeId: 7, documentType: 'attachment', fileName: 'invoice.pdf', status: 'processing' },
|
||||
],
|
||||
healthTips: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await wrapper.find('button').trigger('click');
|
||||
expect(wrapper.text()).toContain('forwarder.eml');
|
||||
expect(wrapper.text()).toContain('invoice.pdf');
|
||||
expect(wrapper.text().match(/packing\.pdf/g)?.length).toBe(1);
|
||||
});
|
||||
|
||||
it('shows an EML as exception when a child failed even if the parent status is processing', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
documents: [
|
||||
{ unitId: -7, documentId: 7, intakeId: 7, documentType: 'email_body', fileName: 'forwarder.eml', status: 'processing' },
|
||||
{ unitId: 8, documentId: 8, intakeId: 7, documentType: 'attachment', fileName: 'packing.pdf', status: 'failed', reasonCode: 'intake_parse_failed' },
|
||||
],
|
||||
healthTips: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).toContain('异常');
|
||||
expect(wrapper.text()).not.toContain('解析附件中');
|
||||
});
|
||||
|
||||
it('renders summary title, file count, system processing and no progress/refresh/cancel', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-1' },
|
||||
@@ -61,7 +534,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).toContain('3 个文件');
|
||||
expect(wrapper.text()).toContain('系统处理中');
|
||||
expect(wrapper.text()).toContain('处理时间偏长');
|
||||
expect(wrapper.text()).toContain('查看详情');
|
||||
expect(wrapper.text()).toContain('打开批次进度中心');
|
||||
expect(wrapper.text()).not.toContain('刷新状态');
|
||||
expect(wrapper.text()).not.toContain('取消本次识别');
|
||||
expect(wrapper.text()).not.toContain('PO-450003.pdf');
|
||||
@@ -134,7 +607,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
});
|
||||
expect(wrapper.text()).toContain('订单候选已生成');
|
||||
expect(wrapper.text()).toContain('候选待人工确认 · 2 项');
|
||||
expect(wrapper.text()).toContain('继续处理');
|
||||
expect(wrapper.text()).toContain('打开批次进度中心');
|
||||
expect(wrapper.text()).not.toContain('部分附件需人工处理');
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
|
||||
});
|
||||
@@ -193,11 +666,11 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).not.toContain('ST-88');
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-primary-action"]').length).toBe(0);
|
||||
// 失败优先:唯一主 CTA 为重试解析。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').text()).toContain('重试解析');
|
||||
// 当前原型将执行入口统一收敛到批次进度中心,旧消息卡不再保留重试 CTA。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('shows continue CTA for review-required without retry', () => {
|
||||
it('keeps only the batch workbench CTA for review-required without retry', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -227,8 +700,9 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').text()).toContain('继续处理');
|
||||
expect(wrapper.text()).not.toContain('重试解析');
|
||||
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);
|
||||
});
|
||||
|
||||
it('does not render multi-OT ChatProgressSummary list', () => {
|
||||
@@ -292,10 +766,10 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
});
|
||||
expect(wrapper.findAll('[data-testid="chat-progress-summary-list"]').length).toBe(0);
|
||||
expect(wrapper.text()).not.toContain('PO.pdf');
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').text()).toContain('继续处理');
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('emits retry for failed attachments via primary CTA', async () => {
|
||||
it('keeps retry actions out of the bottom action bar', async () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -315,13 +789,11 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const retryBtn = wrapper.find('[data-testid="shipping-order-extraction-primary-action"]');
|
||||
expect(retryBtn.text()).toContain('重试解析');
|
||||
await retryBtn.trigger('click');
|
||||
expect(wrapper.emitted('retry')?.length).toBe(1);
|
||||
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);
|
||||
});
|
||||
|
||||
it('keeps view details as secondary text link only', () => {
|
||||
it('does not render the removed view details link', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -333,8 +805,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const details = wrapper.find('[data-testid="shipping-order-extraction-view-details"]');
|
||||
expect(details.exists()).toBe(true);
|
||||
expect(details.classes().join(' ')).toContain('underline-offset-2');
|
||||
expect(details.exists()).toBe(false);
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-primary-action"]').length).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -2,15 +2,16 @@
|
||||
* features/chat/components/shipping/ShippingOrderExtractionCard.vue
|
||||
* 用途:聊天主区「订单识别任务」摘要卡——标题、文件数+状态、一行 handling 摘要、唯一主 CTA、查看详情。
|
||||
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、vue-router、vue-i18n。
|
||||
* 逻辑:对话区只做任务摘要;长进度/Gate/刷新取消由右侧栏承接;详情抽屉仅由次要「查看详情」打开。
|
||||
* 逻辑:对话区默认展示状态-EML 聚合;批次工作台打开后切换为紧凑摘要,长进度/Gate/刷新取消由工作台承接。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { CircleCheck, CircleX, LoaderCircle, TriangleAlert } from 'lucide-vue-next';
|
||||
import { AlertCircle, ArrowRight, CheckCircle2, ChevronDown, CircleX, FileText, LoaderCircle, Mail, RefreshCw, TriangleAlert } from 'lucide-vue-next';
|
||||
import type {
|
||||
ShippingOrderExtractionHandlingItemState,
|
||||
ShippingOrderExtractionFileState,
|
||||
ShippingOrderExtractionState,
|
||||
} from '../../types/chat.types';
|
||||
import type {
|
||||
@@ -18,6 +19,11 @@ import type {
|
||||
ShippingOrderExtractionProgressEvent,
|
||||
} from '../../types/shipping.api.types';
|
||||
import type { ShippingProcessingProjection } from '../../types/shipping.api.types';
|
||||
import { SHIPPING_WORKFLOW_KEY } from '../../shipping/useShippingNoticeWorkflow';
|
||||
import {
|
||||
resolveShippingProcessingReasonLabel,
|
||||
resolveShippingProcessingStageLabel,
|
||||
} from '../../shipping/shippingProcessingLabels';
|
||||
import {
|
||||
listWorkspaceShippingOrderExtractionDocuments,
|
||||
listWorkspaceShippingOrderExtractionProgressEvents,
|
||||
@@ -35,17 +41,199 @@ 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();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const shippingWorkflow = inject(SHIPPING_WORKFLOW_KEY, null);
|
||||
|
||||
type ConversationStatusGroups = NonNullable<import('../../types/shipping.api.types').ConversationProcessingProjection['status_groups']>;
|
||||
type ConversationProcessing = import('../../types/shipping.api.types').ConversationProcessingProjection;
|
||||
const conversationProcessing = computed<ConversationProcessing | null>(() => (
|
||||
(shippingWorkflow as { processing?: { value?: ConversationProcessing | null } | null } | null)?.processing?.value || null
|
||||
));
|
||||
const conversationProjectionLoading = computed(() => Boolean(
|
||||
(shippingWorkflow as { initialLoading?: { value?: boolean } | null } | null)?.initialLoading?.value,
|
||||
));
|
||||
const conversationStatusGroups = computed<ConversationStatusGroups | null>(() => conversationProcessing.value?.status_groups || null);
|
||||
const hasConversationStatusGroups = computed(() => Boolean(conversationStatusGroups.value));
|
||||
const statusGroupDefs = [
|
||||
{ key: 'failed', label: 'chat.shippingProcessing.groupFailed' },
|
||||
{ key: 'waiting_human', label: 'chat.shippingProcessing.groupWaitingHuman' },
|
||||
{ key: 'processing', label: 'chat.shippingProcessing.groupProcessing' },
|
||||
{ key: 'completed', label: 'chat.shippingProcessing.groupCompleted' },
|
||||
{ key: 'cancelled', label: 'chat.shippingProcessing.groupCancelled' },
|
||||
{ key: 'archived', label: 'chat.shippingProcessing.groupHistoryRecords' },
|
||||
] as const;
|
||||
const expandedStatusGroups = ref(new Set<string>(['failed', 'waiting_human', 'processing']));
|
||||
const expandedEmlTasks = ref(new Set<string>());
|
||||
function statusGroupTasks(key: typeof statusGroupDefs[number]['key']) {
|
||||
return conversationStatusGroups.value?.[key] || [];
|
||||
}
|
||||
function statusGroupLabel(key: typeof statusGroupDefs[number]['key']) {
|
||||
const count = statusGroupTasks(key).length;
|
||||
return t(statusGroupDefs.find((item) => item.key === key)!.label, { count });
|
||||
}
|
||||
function toggleStatusGroup(key: string) {
|
||||
const next = new Set(expandedStatusGroups.value);
|
||||
if (next.has(key)) next.delete(key); else next.add(key);
|
||||
expandedStatusGroups.value = next;
|
||||
}
|
||||
function toggleEmlTask(taskNo: string) {
|
||||
const next = new Set(expandedEmlTasks.value);
|
||||
if (next.has(taskNo)) next.delete(taskNo); else next.add(taskNo);
|
||||
expandedEmlTasks.value = next;
|
||||
}
|
||||
function taskChildren(task: { aggregateChildren?: ShippingProcessingProjection[]; user_task_no?: string | null; aggregateSummary?: { intakeNo?: string | null } | null }) {
|
||||
if (task.aggregateChildren?.length) return task.aggregateChildren;
|
||||
// [AUTHORITY] 新会话投影必须自带 EML 子文件;不能从 Run 快照或另一份 work_items 补齐,
|
||||
// 否则左右面板会出现不同文件数、不同状态的同一封邮件。
|
||||
if (hasConversationStatusGroups.value) return [];
|
||||
const projection = statusTaskProjection(task);
|
||||
if (!projection) return [];
|
||||
if (projection?.aggregateChildren?.length) return projection.aggregateChildren;
|
||||
// 后端未返回 aggregate_children 时只展示聚合摘要。禁止用 childOrderTasks 或
|
||||
// 历史聊天 Run 快照重新推导附件、Candidate、阶段或按钮。
|
||||
return [];
|
||||
}
|
||||
function taskFileCount(task: { aggregateChildren?: ShippingProcessingProjection[]; file_count?: number | null; aggregateSummary?: { intakeNo?: string | null } | null }) {
|
||||
// EML 是来源容器;统一只计其附件,避免聊天卡与批次中心相差一份 EML 本体。
|
||||
const children = taskChildren(task).filter((child) => !String(
|
||||
child.sourceSummary?.filename || '',
|
||||
).trim().toLowerCase().endsWith('.eml'));
|
||||
if (children.length) {
|
||||
const ids = new Set(children.map((child) => String(child.sourceSummary?.documentId || child.workItemNo || '').trim()).filter(Boolean));
|
||||
return ids.size || children.length;
|
||||
}
|
||||
if (hasConversationStatusGroups.value) return Math.max(0, Number(task.file_count || 0));
|
||||
const projection = statusTaskProjection(task);
|
||||
const sourceCount = Number(projection?.sourceSummary?.documentCount || 0);
|
||||
return sourceCount > 0 ? sourceCount : Math.max(0, Number(task.file_count || 0));
|
||||
}
|
||||
function childStatusLabel(child: ShippingProcessingProjection) {
|
||||
const status = displayProjectionStatus(child);
|
||||
if (status === 'completed' && child.facts?.uploadState === 'succeeded') return t('chat.shippingProcessing.aggregate.completed', { count: 1 });
|
||||
if (status === 'failed' || status === 'retryable') return t('chat.shippingProcessing.aggregate.failed', { count: 1 });
|
||||
if (status === 'waiting_human') return t('chat.shippingProcessing.aggregate.needsAction', { count: 1 });
|
||||
return t('chat.shippingProcessing.aggregate.processing', { count: 1 });
|
||||
}
|
||||
function displayReason(
|
||||
reason?: import('../../types/shipping.api.types').ShippingProcessingBlockingReason | null,
|
||||
) {
|
||||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||||
}
|
||||
/** 新投影有 ui_state 时严格消费其状态;旧响应才回退 userStatus / status。 */
|
||||
function displayProjectionStatus(item: ShippingProcessingProjection): string {
|
||||
return String(item.uiState
|
||||
? item.uiState.status
|
||||
: (item.userStatus || item.status || '')).trim().toLowerCase();
|
||||
}
|
||||
function isFailedProjection(item: ShippingProcessingProjection): boolean {
|
||||
const status = displayProjectionStatus(item);
|
||||
return status === 'failed' || status === 'retryable';
|
||||
}
|
||||
function isWaitingProjection(item: ShippingProcessingProjection): boolean {
|
||||
return displayProjectionStatus(item) === 'waiting_human';
|
||||
}
|
||||
function isCompletedProjection(item: ShippingProcessingProjection): boolean {
|
||||
return displayProjectionStatus(item) === 'completed' && item.facts?.uploadState === 'succeeded';
|
||||
}
|
||||
function taskReason(task: { uiState?: { blocking_reason: import('../../types/shipping.api.types').ShippingProcessingBlockingReason | null }; blockingReason?: import('../../types/shipping.api.types').ShippingProcessingBlockingReason | null }) {
|
||||
return task.uiState ? task.uiState.blocking_reason : task.blockingReason;
|
||||
}
|
||||
function childStageLabel(child: ShippingProcessingProjection) {
|
||||
const stage = String(child.uiState?.stage || child.userStage || child.stage || '').trim();
|
||||
return resolveShippingProcessingStageLabel(stage, te, t);
|
||||
}
|
||||
function statusTaskProjection(task: { user_task_no?: string | null; aggregateSummary?: { intakeNo?: string | null } | null }) {
|
||||
const items = shippingWorkflow?.processingWorkItems.value || [];
|
||||
const intakeNo = String(task.aggregateSummary?.intakeNo || '').trim();
|
||||
if (intakeNo) {
|
||||
const intakeMatch = items.find((item) => (
|
||||
item.sourceType === 'eml'
|
||||
&& String(item.intakeNo || '').trim() === intakeNo
|
||||
));
|
||||
if (intakeMatch) return intakeMatch;
|
||||
}
|
||||
return items.find((item) => (
|
||||
(item.workItemType === 'order_task' || item.workItemType === 'order_intake')
|
||||
&& String(item.workItemNo || '').trim() === String((task as any).user_task_no || '').trim()
|
||||
)) || null;
|
||||
}
|
||||
function aggregateStatusLabelFromSummary(summary: NonNullable<import('../../types/shipping.api.types').ConversationProcessingUserTask['aggregateSummary']>) {
|
||||
const parts: string[] = [];
|
||||
if (summary.completed) parts.push(t('chat.shippingProcessing.aggregate.completed', { count: summary.completed }));
|
||||
if (summary.processing) parts.push(t('chat.shippingProcessing.aggregate.processing', { count: summary.processing }));
|
||||
if (summary.needsAction) parts.push(t('chat.shippingProcessing.aggregate.needsAction', { count: summary.needsAction }));
|
||||
if (summary.failed) parts.push(t('chat.shippingProcessing.aggregate.failed', { count: summary.failed }));
|
||||
return parts.join(' · ');
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前 Run 对应的 EML Intake 聚合项。
|
||||
*
|
||||
* 右侧投影轮询是增量可见的:一次响应暂未带回该 Intake 不能让聊天消息卡
|
||||
* 降级为旧 Run 卡。消息卡保留最后一次同 Run/用户任务命中的聚合快照,只有
|
||||
* 同一绑定再次命中时才更新;右侧面板仍直接消费实时投影。
|
||||
*/
|
||||
const matchedEmlAggregate = computed(() => {
|
||||
const runNo = String(props.runNo || props.state.runNo || '').trim();
|
||||
const userTaskNo = String(props.state.userTaskNo || '').trim();
|
||||
const items = shippingWorkflow?.processingWorkItems.value || [];
|
||||
return items.find((item) => (
|
||||
item.workItemType === 'order_task'
|
||||
&& item.sourceType === 'eml'
|
||||
&& Boolean(item.aggregateSummary)
|
||||
&& (
|
||||
String(item.runNo || '').trim() === runNo
|
||||
|| (Boolean(userTaskNo) && String(item.rootOrderTaskNo || '').trim() === userTaskNo)
|
||||
)
|
||||
)) || null;
|
||||
});
|
||||
const lastMatchedEmlAggregate = ref<ShippingProcessingProjection | null>(null);
|
||||
watch(matchedEmlAggregate, (item) => {
|
||||
if (item) lastMatchedEmlAggregate.value = item;
|
||||
}, { immediate: true });
|
||||
const emlAggregate = computed(() => (
|
||||
// [AUTHORITY] 切换会话时先等待该会话的统一投影,禁止旧聊天消息 Run 快照抢占首屏;
|
||||
// 请求完成后仍只消费后端 Projection,失败则保留既有兼容摘要。
|
||||
hasConversationStatusGroups.value || conversationProjectionLoading.value
|
||||
? null
|
||||
: (matchedEmlAggregate.value || lastMatchedEmlAggregate.value)
|
||||
));
|
||||
const emlAggregateChildren = computed(() => emlAggregate.value?.aggregateChildren || []);
|
||||
const emlAggregateExpanded = ref(false);
|
||||
function aggregateStageLabel(item: ShippingProcessingProjection): string {
|
||||
const stage = String(item.uiState ? item.uiState.stage : (item.userStage || item.stage || '')).trim();
|
||||
return resolveShippingProcessingStageLabel(stage, te, t);
|
||||
}
|
||||
function aggregateChildStatusLabel(item: ShippingProcessingProjection): string {
|
||||
const status = displayProjectionStatus(item);
|
||||
if (status === 'completed' && item.facts?.uploadState === 'succeeded') return t('chat.shippingProcessing.aggregate.completed', { count: 1 });
|
||||
if (status === 'failed' || status === 'retryable') return t('chat.shippingProcessing.aggregate.failed', { count: 1 });
|
||||
if (status === 'waiting_human') return t('chat.shippingProcessing.aggregate.needsAction', { count: 1 });
|
||||
return t('chat.shippingProcessing.aggregate.processing', { count: 1 });
|
||||
}
|
||||
function aggregateSummaryLabel(item: ShippingProcessingProjection): string {
|
||||
const summary = item.aggregateSummary;
|
||||
if (!summary) return '';
|
||||
const parts: string[] = [];
|
||||
if (summary.completed) parts.push(t('chat.shippingProcessing.aggregate.completed', { count: summary.completed }));
|
||||
if (summary.processing) parts.push(t('chat.shippingProcessing.aggregate.processing', { count: summary.processing }));
|
||||
if (summary.needsAction) parts.push(t('chat.shippingProcessing.aggregate.needsAction', { count: summary.needsAction }));
|
||||
if (summary.failed) parts.push(t('chat.shippingProcessing.aggregate.failed', { count: summary.failed }));
|
||||
return parts.join(' · ');
|
||||
}
|
||||
|
||||
const detailsOpen = ref(false);
|
||||
const detailsLoading = ref(false);
|
||||
@@ -57,7 +245,110 @@ const progressEvents = ref<ShippingOrderExtractionProgressEvent[]>([]);
|
||||
|
||||
const displaySummary = computed(() => props.state.summary);
|
||||
|
||||
const handlingItems = computed(() => props.state.handlingItems || []);
|
||||
/**
|
||||
* 旧聊天消息中的 handlingItems 是当时的 Run 快照;实时会话投影已返回时,
|
||||
* 绝不能把它重新展示成当前待办或用它决定 CTA。当前待办仅由后端 work_items
|
||||
* 与其 ui_state 裁决,旧卡在此模式下只保留历史消息本身。
|
||||
*/
|
||||
const handlingItems = computed(() => (
|
||||
hasConversationStatusGroups.value ? [] : (props.state.handlingItems || [])
|
||||
));
|
||||
const fileRows = computed(() => props.state.documents || []);
|
||||
const isEmailRow = (row: ShippingOrderExtractionFileState) => (
|
||||
row.documentType === 'email_body' || row.fileName?.toLowerCase().endsWith('.eml')
|
||||
);
|
||||
/**
|
||||
* 返回当前 Run 快照中的唯一业务 PDF,隔离历史 Unit/Review Case 汇总。
|
||||
* 核心逻辑:优先用稳定 documentId 去重;旧快照缺失时才回退 unitId 或文件名。
|
||||
*/
|
||||
const currentBusinessFileRows = computed(() => {
|
||||
const seen = new Set<string>();
|
||||
return fileRows.value.filter((row) => {
|
||||
if (isEmailRow(row)) return false;
|
||||
const key = row.documentId > 0
|
||||
? `document:${row.documentId}`
|
||||
: row.unitId > 0
|
||||
? `unit:${row.unitId}`
|
||||
: `filename:${String(row.fileName || '').trim().toLowerCase()}`;
|
||||
if (seen.has(key)) return false;
|
||||
seen.add(key);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
const hasCurrentBusinessFileRows = computed(() => currentBusinessFileRows.value.length > 0);
|
||||
const emailRows = computed(() => fileRows.value.filter(isEmailRow));
|
||||
const isFailedParseRow = (row: ShippingOrderExtractionFileState) => (
|
||||
row.status === 'failed'
|
||||
|| row.reasonCode === 'intake_parse_failed'
|
||||
|| row.userVisibleStage === 'parse_failed'
|
||||
);
|
||||
const childRows = (email: ShippingOrderExtractionFileState) => fileRows.value.filter((row) => (
|
||||
row.unitId !== email.unitId
|
||||
&& row.intakeId != null
|
||||
&& row.intakeId === email.intakeId
|
||||
&& !isEmailRow(row)
|
||||
));
|
||||
const candidateEmailGroups = computed(() => emailRows.value
|
||||
.map((parent) => ({ parent, children: childRows(parent) }))
|
||||
.filter((group) => group.children.length > 0 && group.children.every((child) => child.status === 'candidate_ready')));
|
||||
const emailHasFailedChild = (email: ShippingOrderExtractionFileState) => childRows(email).some(isFailedParseRow);
|
||||
const emailIsCompleted = (email: ShippingOrderExtractionFileState) => {
|
||||
const children = childRows(email);
|
||||
return children.length > 0 && children.every((child) => child.status === 'candidate_ready');
|
||||
};
|
||||
const candidateEmailUnitIds = computed(() => new Set(
|
||||
candidateEmailGroups.value.flatMap((group) => [group.parent.unitId, ...group.children.map((child) => child.unitId)]),
|
||||
));
|
||||
const candidateStandaloneRows = computed(() => fileRows.value.filter((row) => (
|
||||
!isEmailRow(row)
|
||||
&& row.status === 'candidate_ready'
|
||||
&& !emailRows.value.some((email) => childRows(email).some((child) => child.unitId === row.unitId))
|
||||
)));
|
||||
const candidateFileCount = computed(() => (
|
||||
candidateEmailGroups.value.reduce((count, group) => count + group.children.length, 0)
|
||||
+ candidateStandaloneRows.value.length
|
||||
));
|
||||
const activeEmailRows = computed(() => emailRows.value.filter((row) => !candidateEmailUnitIds.value.has(row.unitId)));
|
||||
const standaloneRows = computed(() => fileRows.value.filter((row) => (
|
||||
!isEmailRow(row)
|
||||
&& row.status !== 'candidate_ready'
|
||||
&& !isFailedParseRow(row)
|
||||
&& !candidateEmailUnitIds.value.has(row.unitId)
|
||||
&& !emailRows.value.some((email) => childRows(email).some((child) => child.unitId === row.unitId))
|
||||
)));
|
||||
const failedRows = computed(() => fileRows.value.filter((row) => (
|
||||
isFailedParseRow(row)
|
||||
&& !candidateEmailUnitIds.value.has(row.unitId)
|
||||
&& !emailRows.value.some((email) => childRows(email).some((child) => child.unitId === row.unitId))
|
||||
)));
|
||||
const processedCount = computed(() => {
|
||||
if (hasConversationStatusGroups.value) {
|
||||
const summary = conversationProcessing.value?.summary;
|
||||
// [AUTHORITY] “已处理/完成率”只表示已经完成通知生命周期的业务文件。
|
||||
// waiting_human / failed 只是后端裁决出的待处理事项,不能借用历史 Run 的
|
||||
// “处理过”口径累计为完成,否则会与批次进度中心的 completed_files 冲突。
|
||||
return Math.max(0, Number(summary?.completed_files || 0));
|
||||
}
|
||||
// 当前 Run 仅表达抽取/候选状态,不能把 candidate_ready 或历史复核 Case 伪装成
|
||||
// 已完成通知生命周期;生命周期完成数只由会话权威投影下发。
|
||||
if (hasCurrentBusinessFileRows.value) return 0;
|
||||
return emlAggregate.value?.aggregateSummary?.completed
|
||||
?? (props.state.summary.completedDocuments + props.state.summary.reviewRequiredDocuments);
|
||||
});
|
||||
const progressPercent = computed(() => {
|
||||
const total = batchFileCount.value;
|
||||
return total > 0 ? Math.min(100, Math.round((processedCount.value / total) * 100)) : 0;
|
||||
});
|
||||
const completedExpanded = ref(false);
|
||||
|
||||
/** 新版会话批次的业务文件数由后端汇总;旧 Run 卡仍保留历史兼容计数。 */
|
||||
const batchFileCount = computed(() => {
|
||||
if (hasConversationStatusGroups.value) {
|
||||
return Math.max(0, Number(conversationProcessing.value?.summary?.total_files || 0));
|
||||
}
|
||||
if (hasCurrentBusinessFileRows.value) return currentBusinessFileRows.value.length;
|
||||
return Math.max(0, Number(emlAggregate.value?.sourceSummary.documentCount ?? props.state.summary.totalDocuments));
|
||||
});
|
||||
|
||||
/**
|
||||
* 是否为「仅重复关联已有任务、无需人工复核」终态通知。
|
||||
@@ -83,26 +374,20 @@ const isCandidateConfirmationNotice = computed(() => (
|
||||
)
|
||||
));
|
||||
|
||||
const toneClass = computed(() => {
|
||||
if (isDuplicateOnlyNotice.value) {
|
||||
return 'border-violet-200 bg-violet-50/80 text-violet-950 dark:border-violet-800 dark:bg-violet-950/35 dark:text-violet-100';
|
||||
}
|
||||
if (isCandidateConfirmationNotice.value) {
|
||||
return 'border-teal-200 bg-teal-50/80 text-teal-950 dark:border-teal-800 dark:bg-teal-950/35 dark:text-teal-100';
|
||||
}
|
||||
switch (props.state.status) {
|
||||
case 'completed':
|
||||
return 'border-emerald-200 bg-emerald-50/80 text-emerald-950 dark:border-emerald-800 dark:bg-emerald-950/35 dark:text-emerald-100';
|
||||
case 'partially_completed':
|
||||
case 'review_required':
|
||||
return 'border-amber-200 bg-amber-50/80 text-amber-950 dark:border-amber-800 dark:bg-amber-950/35 dark:text-amber-100';
|
||||
case 'failed':
|
||||
case 'cancelled':
|
||||
return 'border-rose-200 bg-rose-50/80 text-rose-900 dark:border-rose-800 dark:bg-rose-950/35 dark:text-rose-100';
|
||||
default:
|
||||
return 'border-sky-200 bg-sky-50/80 text-sky-900 dark:border-sky-800 dark:bg-sky-950/35 dark:text-sky-100';
|
||||
}
|
||||
});
|
||||
function rowStatusLabel(row: ShippingOrderExtractionFileState): string {
|
||||
if (row.status === 'candidate_ready') return t('chat.shippingProcessing.candidateReady');
|
||||
if (isFailedParseRow(row)) return t('chat.shippingProcessing.batchException');
|
||||
if (row.status === 'review_required') return t('chat.shippingProcessing.waitingReview');
|
||||
const stageKey = `chat.shippingOrderExtractionUserStage.${String(row.userVisibleStage || '').trim()}`;
|
||||
if (row.userVisibleStage && te(stageKey)) return t(stageKey);
|
||||
return t('chat.shippingProcessing.batchProcessing');
|
||||
}
|
||||
|
||||
function rowStatusClass(row: ShippingOrderExtractionFileState): string {
|
||||
if (row.status === 'candidate_ready') return 'text-emerald-500';
|
||||
if (isFailedParseRow(row)) return 'text-rose-500';
|
||||
return 'text-blue-500';
|
||||
}
|
||||
|
||||
/**
|
||||
* 将处理事项类别映射为一句过程通知文案。
|
||||
@@ -126,6 +411,20 @@ function handlingTitle(item: ShippingOrderExtractionHandlingItemState): string {
|
||||
* 状态短句:排队/处理中仅「系统处理中」;其余用过程通知,不含文件阶段耗时。
|
||||
*/
|
||||
const statusNotice = computed(() => {
|
||||
if (hasConversationStatusGroups.value) {
|
||||
const status = String(conversationProcessing.value?.ui_state?.status || '').trim().toLowerCase();
|
||||
if (status === 'completed') return t('chat.shippingSessionSummary.processNoticeCompleted');
|
||||
if (status === 'failed' || status === 'retryable') return t('chat.shippingSessionSummary.processNoticeFailed');
|
||||
if (status === 'waiting_human') return t('chat.shippingSessionSummary.processNoticeNeedsAction');
|
||||
return t('chat.shippingProcessing.systemProcessing');
|
||||
}
|
||||
if (emlAggregate.value) {
|
||||
const status = String(emlAggregate.value.userStatus || '').trim().toLowerCase();
|
||||
if (status === 'completed') return t('chat.shippingSessionSummary.processNoticeCompleted');
|
||||
if (status === 'failed' || status === 'retryable') return t('chat.shippingSessionSummary.processNoticeFailed');
|
||||
if (status === 'waiting_human') return t('chat.shippingSessionSummary.processNoticeNeedsAction');
|
||||
return t('chat.shippingProcessing.systemProcessing');
|
||||
}
|
||||
if (props.state.cancellation?.requested && !props.state.cancellation?.completedAt && !props.state.terminal) {
|
||||
return t('chat.shippingOrderExtractionUserStage.cancellation_requested');
|
||||
}
|
||||
@@ -177,6 +476,9 @@ const handlingSummaryLine = computed(() => {
|
||||
if (!first) return '';
|
||||
const totalCount = items.reduce((sum, item) => sum + Math.max(0, Number(item.count || 0)), 0);
|
||||
const count = totalCount > 0 ? totalCount : items.length;
|
||||
// 旧 Run 的 Case 是跨版本历史记录。当前卡片已有 PDF 快照时,数目不一致即说明
|
||||
// handling 来自另一集合,不能在“本批文件”标题下误导为当前待复核文件。
|
||||
if (hasCurrentBusinessFileRows.value && count !== currentBusinessFileRows.value.length) return '';
|
||||
return t('chat.shippingOrderExtractionHandling.summaryLine', {
|
||||
title: handlingTitle(first),
|
||||
count,
|
||||
@@ -187,7 +489,7 @@ const handlingSummaryLine = computed(() => {
|
||||
* 唯一主 CTA:失败→重试解析;需处理→继续处理;否则不展示。
|
||||
*/
|
||||
const primaryChatAction = computed((): { kind: 'retry' | 'continue'; label: string } | null => {
|
||||
if (props.readonly) return null;
|
||||
if (props.readonly || hasConversationStatusGroups.value) return null;
|
||||
const actions = props.state.availableActions || [];
|
||||
const canRetry = actions.includes('retry_failed_attachments')
|
||||
|| actions.includes('retry_failed_documents')
|
||||
@@ -261,7 +563,7 @@ async function loadDetailsDocuments() {
|
||||
detailsLoading.value = true;
|
||||
detailsLoadFailed.value = false;
|
||||
try {
|
||||
const docsRes = await listWorkspaceShippingOrderExtractionDocuments(runNo).catch(() => null);
|
||||
const docsRes = await listWorkspaceShippingOrderExtractionDocuments(runNo, props.state.uploadBatchId).catch(() => null);
|
||||
if (docsRes) {
|
||||
detailsDocuments.value = Array.isArray(docsRes.items) ? docsRes.items : [];
|
||||
} else {
|
||||
@@ -286,7 +588,7 @@ async function loadDetailsProgress() {
|
||||
progressLoading.value = true;
|
||||
progressLoadFailed.value = false;
|
||||
try {
|
||||
const eventsRes = await listWorkspaceShippingOrderExtractionProgressEvents(runNo).catch(() => null);
|
||||
const eventsRes = await listWorkspaceShippingOrderExtractionProgressEvents(runNo, props.state.uploadBatchId).catch(() => null);
|
||||
if (eventsRes) {
|
||||
progressEvents.value = Array.isArray(eventsRes.items) ? eventsRes.items : [];
|
||||
} else {
|
||||
@@ -347,25 +649,151 @@ async function onPrimaryChatAction() {
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="mb-3 rounded-lg border px-3.5 py-2.5"
|
||||
:class="toneClass"
|
||||
v-if="conversationProjectionLoading"
|
||||
class="mb-3 animate-pulse overflow-hidden rounded-xl border border-slate-200 bg-white/90 shadow-md dark:border-slate-700 dark:bg-slate-900/90"
|
||||
data-testid="shipping-order-extraction-projection-loading"
|
||||
>
|
||||
<!-- 读取权威 Projection 不是业务状态;只显示结构骨架,避免伪造“系统处理中”。 -->
|
||||
<div class="border-b border-slate-200 bg-indigo-50/70 px-5 py-4 dark:border-slate-700 dark:bg-indigo-950/30">
|
||||
<div class="h-6 w-36 rounded bg-slate-200 dark:bg-slate-700" />
|
||||
<div class="mt-3 h-4 w-2/3 rounded bg-slate-200 dark:bg-slate-700" />
|
||||
<div class="mt-5 h-2 w-full rounded bg-slate-200 dark:bg-slate-700" />
|
||||
</div>
|
||||
<div class="space-y-3 p-4">
|
||||
<div class="h-12 rounded-lg bg-slate-100 dark:bg-slate-800" />
|
||||
<div class="h-12 rounded-lg bg-slate-100 dark:bg-slate-800" />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="mb-3 overflow-hidden rounded-xl border border-slate-200 bg-white/90 text-slate-900 shadow-md backdrop-blur-sm dark:border-slate-700 dark:bg-slate-900/90 dark:text-slate-100"
|
||||
data-testid="shipping-order-extraction-card"
|
||||
>
|
||||
<div class="flex items-start gap-3">
|
||||
<LoaderCircle
|
||||
v-if="state.status === 'queued' || state.status === 'processing'"
|
||||
class="mt-0.5 h-4 w-4 shrink-0 animate-spin"
|
||||
/>
|
||||
<CircleCheck
|
||||
v-else-if="state.status === 'completed' || isDuplicateOnlyNotice || isCandidateConfirmationNotice"
|
||||
class="mt-0.5 h-4 w-4 shrink-0"
|
||||
/>
|
||||
<TriangleAlert
|
||||
v-else-if="state.status === 'partially_completed' || state.status === 'review_required'"
|
||||
class="mt-0.5 h-4 w-4 shrink-0"
|
||||
/>
|
||||
<CircleX v-else class="mt-0.5 h-4 w-4 shrink-0" />
|
||||
<div class="border-b border-slate-200 bg-indigo-50/70 px-5 py-4 dark:border-slate-700 dark:bg-indigo-950/30">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-2 text-lg font-semibold">
|
||||
<LoaderCircle v-if="hasConversationStatusGroups ? conversationProcessing?.ui_state?.status === 'running' : emlAggregate ? emlAggregate.userStatus === 'running' : state.status === 'queued' || state.status === 'processing'" class="h-5 w-5 animate-spin text-blue-600" />
|
||||
<CheckCircle2 v-else-if="hasConversationStatusGroups ? conversationProcessing?.ui_state?.status === 'completed' : emlAggregate ? emlAggregate.userStatus === 'completed' && emlAggregate.facts?.uploadState === 'succeeded' : state.status === 'completed'" class="h-5 w-5 text-emerald-500" />
|
||||
<TriangleAlert v-else class="h-5 w-5 text-amber-500" />
|
||||
<span>{{ t('chat.shippingProcessing.multiPdfTaskTitle') }}</span>
|
||||
</div>
|
||||
<span class="rounded-full bg-slate-200 px-3 py-1 text-xs font-medium text-slate-600 dark:bg-slate-700 dark:text-slate-200">
|
||||
{{ t('chat.shippingProcessing.batchFilesTotal', { count: batchFileCount }) }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="mt-1 text-sm text-slate-600 dark:text-slate-300">{{ t('chat.shippingProcessing.batchStatusTitle') }} · {{ statusNotice }}</p>
|
||||
<div v-for="tip in healthTips" :key="tip.code" class="mt-1 text-sm font-medium text-amber-600">{{ t(`chat.shippingOrderExtractionHealthTip.${tip.code}`) }}</div>
|
||||
<div v-if="handlingSummaryLine" class="mt-1 text-sm text-slate-600 dark:text-slate-300">{{ handlingSummaryLine }}</div>
|
||||
<div class="mt-4 flex items-end justify-between">
|
||||
<span class="text-lg font-medium text-blue-600">{{ progressPercent }}% {{ t('chat.shippingProcessing.batchComplete') }}</span>
|
||||
<span class="text-sm text-slate-600 dark:text-slate-300">{{ processedCount }}/{{ batchFileCount }} {{ t('chat.shippingProcessing.batchProcessed') }}</span>
|
||||
</div>
|
||||
<div class="mt-3 h-2 overflow-hidden rounded-full bg-slate-200 dark:bg-slate-700">
|
||||
<div class="h-full rounded-full bg-blue-600 transition-all" :style="{ width: `${progressPercent}%` }" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="hasConversationStatusGroups && !compactProgress" class="flex flex-col gap-2 bg-slate-50 p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-status-groups">
|
||||
<template v-for="group in statusGroupDefs" :key="group.key">
|
||||
<section v-if="statusGroupTasks(group.key).length" class="overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900">
|
||||
<button type="button" class="flex w-full items-center justify-between px-3 py-3 text-left" @click="toggleStatusGroup(group.key)">
|
||||
<span class="text-sm font-semibold" :class="group.key === 'failed' ? 'text-rose-600' : group.key === 'waiting_human' ? 'text-amber-700' : group.key === 'completed' ? 'text-emerald-600' : 'text-slate-700 dark:text-slate-200'">{{ statusGroupLabel(group.key) }}</span>
|
||||
<ChevronDown class="h-4 w-4 transition-transform" :class="expandedStatusGroups.has(group.key) ? 'rotate-180' : ''" />
|
||||
</button>
|
||||
<div v-if="expandedStatusGroups.has(group.key)" class="space-y-2 border-t border-slate-200 p-2 dark:border-slate-700">
|
||||
<article v-for="task in statusGroupTasks(group.key)" :key="task.user_task_no" class="rounded-lg border border-slate-200 bg-slate-50 dark:border-slate-700 dark:bg-slate-950/30" :data-testid="`shipping-order-extraction-eml-${group.key}-${task.user_task_no}`">
|
||||
<div class="flex items-start gap-2">
|
||||
<Mail class="mt-0.5 h-4 w-4 text-blue-600" />
|
||||
<div class="min-w-0 flex-1">
|
||||
<button type="button" class="flex w-full items-center justify-between gap-2 text-left" @click="toggleEmlTask(task.user_task_no)">
|
||||
<span class="truncate text-sm font-medium">{{ task.title || task.user_task_no }}</span>
|
||||
<ChevronDown class="h-4 w-4 shrink-0 transition-transform" :class="expandedEmlTasks.has(task.user_task_no) ? 'rotate-180' : ''" />
|
||||
</button>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ t('chat.shippingProcessing.taskFiles', { count: taskFileCount(task) }) }}<span v-if="task.aggregateSummary"> · {{ aggregateStatusLabelFromSummary(task.aggregateSummary) }}</span></div>
|
||||
<div v-if="taskReason(task)" class="mt-1 text-xs text-rose-600">{{ displayReason(taskReason(task)) }}</div>
|
||||
<div v-if="expandedEmlTasks.has(task.user_task_no) && taskChildren(task).length" class="mt-2 space-y-1 border-t border-slate-200 pt-2 dark:border-slate-700" data-testid="shipping-order-extraction-eml-children">
|
||||
<div v-for="child in taskChildren(task).filter((item) => !String(item.sourceSummary?.filename || '').toLowerCase().endsWith('.eml'))" :key="child.workItemNo" class="flex items-start justify-between gap-3 rounded-md bg-white px-2 py-1.5 text-xs dark:bg-slate-900">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-medium">{{ child.sourceSummary.filename || child.workItemNo }}</div>
|
||||
<div class="text-[11px] text-slate-500">{{ childStageLabel(child) }}</div>
|
||||
<div v-if="taskReason(child)" class="text-[11px] text-rose-600">{{ displayReason(taskReason(child)) }}</div>
|
||||
</div>
|
||||
<span :data-testid="`shipping-order-extraction-child-status-${child.workItemNo}`" class="shrink-0" :class="isFailedProjection(child) ? 'text-rose-600' : isWaitingProjection(child) ? 'text-amber-700' : isCompletedProjection(child) ? 'text-emerald-600' : 'text-blue-600'">{{ childStatusLabel(child) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else-if="!compactProgress && emlAggregate" class="flex flex-col gap-2 bg-slate-50 p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-eml-aggregate">
|
||||
<article class="overflow-hidden rounded-lg border border-slate-300 bg-white shadow-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="flex items-start gap-3 border-b border-slate-200 bg-blue-50/50 p-3 dark:border-slate-700 dark:bg-blue-950/20">
|
||||
<Mail class="mt-0.5 h-5 w-5 text-blue-600" />
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<span class="truncate font-medium">{{ t('chat.shippingProcessing.emailPrefix') }}{{ emlAggregate.sourceSummary.filename || emlAggregate.intakeNo }}</span>
|
||||
<span class="rounded border px-2 py-0.5 text-xs" :class="emlAggregate.userStatus === 'failed' || emlAggregate.userStatus === 'retryable' ? 'border-rose-200 bg-rose-100/70 text-rose-600' : emlAggregate.userStatus === 'waiting_human' ? 'border-amber-200 bg-amber-100/70 text-amber-700' : emlAggregate.userStatus === 'completed' ? 'border-emerald-200 bg-emerald-100/70 text-emerald-600' : 'border-blue-200 bg-blue-100/70 text-blue-600'">
|
||||
{{ emlAggregate.userStatus === 'completed' ? t('chat.shippingProcessing.aggregate.completed', { count: emlAggregate.aggregateSummary?.completed || 0 }) : emlAggregate.userStatus === 'failed' || emlAggregate.userStatus === 'retryable' ? t('chat.shippingProcessing.batchException') : emlAggregate.userStatus === 'waiting_human' ? t('chat.shippingProcessing.waitingReview') : t('chat.shippingProcessing.systemProcessing') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-1 text-xs text-slate-600 dark:text-slate-300">{{ aggregateSummaryLabel(emlAggregate) }}</div>
|
||||
<div v-if="taskReason(emlAggregate)" class="mt-1 text-xs text-rose-600">{{ displayReason(taskReason(emlAggregate)) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="flex w-full items-center justify-between px-3 py-2 text-left text-sm" @click="emlAggregateExpanded = !emlAggregateExpanded">
|
||||
<span>{{ t('chat.shippingProcessing.taskFiles', { count: emlAggregate.sourceSummary.documentCount || 0 }) }}</span>
|
||||
<ChevronDown class="h-4 w-4 transition-transform" :class="emlAggregateExpanded ? 'rotate-180' : ''" />
|
||||
</button>
|
||||
<div v-if="emlAggregateExpanded" class="space-y-1 border-t border-slate-200 px-3 py-2 dark:border-slate-700">
|
||||
<div v-for="child in emlAggregateChildren" :key="child.workItemNo" class="flex items-center justify-between gap-3 py-1 text-sm">
|
||||
<span class="min-w-0 truncate">{{ child.sourceSummary.filename || child.workItemNo }}</span>
|
||||
<span class="shrink-0 text-xs" :class="isFailedProjection(child) ? 'text-rose-600' : isWaitingProjection(child) ? 'text-amber-700' : isCompletedProjection(child) ? 'text-emerald-600' : 'text-blue-600'">{{ aggregateChildStatusLabel(child) }} · {{ aggregateStageLabel(child) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<div v-else-if="!compactProgress" class="flex flex-col gap-2 bg-slate-50 p-2 dark:bg-slate-950/30">
|
||||
<button type="button" class="flex items-center justify-between rounded-lg border border-slate-200 bg-white px-3 py-3 text-left dark:border-slate-700 dark:bg-slate-900" @click="completedExpanded = !completedExpanded">
|
||||
<span class="flex items-center gap-3 text-base font-medium"><span class="flex h-7 w-7 items-center justify-center rounded-full bg-blue-100 text-blue-600"><CheckCircle2 class="h-4 w-4" /></span>{{ t('chat.shippingProcessing.candidateFiles', { count: candidateFileCount }) }}</span>
|
||||
<ChevronDown class="h-5 w-5 transition-transform" :class="completedExpanded ? 'rotate-180' : ''" />
|
||||
</button>
|
||||
<div v-if="completedExpanded && candidateFileCount" class="space-y-2 rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<div v-for="group in candidateEmailGroups" :key="`candidate-email-${group.parent.unitId}`" class="rounded-md border border-blue-100 bg-blue-50/50 px-3 py-2 dark:border-blue-900 dark:bg-blue-950/20">
|
||||
<div class="flex items-center gap-2 font-medium text-slate-700 dark:text-slate-200"><Mail class="h-4 w-4 text-blue-600" />{{ t('chat.shippingProcessing.emailPrefix') }}{{ group.parent.fileName }}<span class="ml-auto text-emerald-500">{{ t('chat.shippingProcessing.batchExtracted') }}</span></div>
|
||||
<div class="mt-1 space-y-1 border-l-2 border-blue-200 pl-3 dark:border-blue-800">
|
||||
<div v-for="row in group.children" :key="`candidate-child-${row.unitId}`" class="flex items-center gap-2 py-1 text-slate-600 dark:text-slate-300"><CheckCircle2 class="h-4 w-4 text-blue-500" />{{ row.fileName }}<span class="ml-auto text-blue-500">{{ rowStatusLabel(row) }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-for="row in candidateStandaloneRows" :key="`candidate-${row.unitId}`" class="flex items-center gap-2 py-1 text-slate-600 dark:text-slate-300"><CheckCircle2 class="h-4 w-4 text-blue-500" />{{ row.fileName }}<span class="ml-auto text-blue-500">{{ rowStatusLabel(row) }}</span></div>
|
||||
</div>
|
||||
<div v-for="row in activeEmailRows" :key="row.unitId" class="overflow-hidden rounded-lg border border-slate-300 bg-white shadow-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="flex items-start gap-3 border-b border-slate-200 bg-blue-50/50 p-3 dark:border-slate-700 dark:bg-blue-950/20"><Mail class="mt-0.5 h-5 w-5 text-blue-600" /><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-blue-200 bg-blue-100/70 text-blue-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-slate-500">{{ t('chat.shippingProcessing.emailMeta') }}</span></div></div>
|
||||
<div class="mx-4 my-2 flex flex-col gap-2 border-l-2 border-blue-200 bg-slate-50 p-3 pl-4 dark:border-blue-800 dark:bg-blue-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-blue-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>
|
||||
</div>
|
||||
<div v-for="row in standaloneRows" :key="row.unitId" class="flex items-center justify-between gap-3 rounded-lg border border-slate-200 bg-white p-3 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-900"><span class="flex min-w-0 items-center gap-3"><FileText class="h-5 w-5 text-slate-500" /><span class="truncate">{{ row.fileName }}</span></span><span class="flex items-center gap-2" :class="rowStatusClass(row)">{{ rowStatusLabel(row) }}<RefreshCw v-if="!isFailedParseRow(row)" class="h-4 w-4 animate-spin" /></span></div>
|
||||
<div v-if="!fileRows.length" class="rounded-lg border border-slate-200 bg-white p-3 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900">{{ t('chat.shippingProcessing.batchFilesUnavailable') }}</div>
|
||||
<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-slate-200 bg-indigo-50/60 p-3 dark:border-slate-700 dark:bg-indigo-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-blue-600 px-5 py-2.5 text-sm font-medium text-white shadow-sm hover:bg-blue-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">
|
||||
<div
|
||||
v-if="readonly"
|
||||
@@ -394,7 +822,7 @@ async function onPrimaryChatAction() {
|
||||
class="mt-1 text-[11px] opacity-80"
|
||||
data-testid="shipping-order-extraction-error-request-id"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionErrorRequestId', { id: state.errorExplainability.request_id }) }}
|
||||
{{ t('chat.shippingOrderExtractionErrorRequestId', { id: state.errorExplainability?.request_id }) }}
|
||||
</p>
|
||||
|
||||
<div
|
||||
@@ -424,12 +852,12 @@ async function onPrimaryChatAction() {
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
data-testid="shipping-order-extraction-primary-action"
|
||||
:disabled="primaryChatAction.kind === 'retry' && retrying"
|
||||
:disabled="primaryChatAction?.kind === 'retry' && retrying"
|
||||
@click="onPrimaryChatAction"
|
||||
>
|
||||
{{ primaryChatAction.kind === 'retry' && retrying
|
||||
{{ primaryChatAction?.kind === 'retry' && retrying
|
||||
? t('chat.shippingOrderExtractionRetrying')
|
||||
: primaryChatAction.label }}
|
||||
: primaryChatAction?.label }}
|
||||
</button>
|
||||
<button
|
||||
v-if="String(props.runNo || '').trim()"
|
||||
|
||||
+26
-23
@@ -7,7 +7,7 @@
|
||||
* 以模态对话框语义呈现(初始焦点、Tab 陷阱、Escape/关闭后焦点恢复);
|
||||
* 文档与时间线加载失败分别提供就地重试;内部错误码不向普通用户展示。
|
||||
*/
|
||||
import { nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { X } from 'lucide-vue-next';
|
||||
import type { ShippingOrderExtractionState } from '../../types/chat.types';
|
||||
@@ -42,6 +42,19 @@ const closeButtonRef = ref<HTMLButtonElement | null>(null);
|
||||
let previouslyFocused: HTMLElement | null = null;
|
||||
const timelineOpen = ref(false);
|
||||
|
||||
const timelineGroups = computed(() => {
|
||||
const groups = new Map<string, { documentId: number | null; fileName: string; events: ShippingOrderExtractionProgressEvent[] }>();
|
||||
for (const event of props.progressEvents) {
|
||||
const documentId = event.document_id != null ? Number(event.document_id) : null;
|
||||
const document = documentId == null ? null : props.documents.find((item) => Number(item.document_id) === documentId);
|
||||
const key = documentId == null ? 'run' : `document-${documentId}`;
|
||||
const group = groups.get(key) || { documentId, fileName: document?.file_name || (documentId == null ? t('chat.shippingOrderExtractionTimelineRunScope') : `Document ${documentId}`), events: [] };
|
||||
group.events.push(event);
|
||||
groups.set(key, group);
|
||||
}
|
||||
return [...groups.values()];
|
||||
});
|
||||
|
||||
const FOCUSABLE_SELECTOR = [
|
||||
'a[href]',
|
||||
'button:not([disabled])',
|
||||
@@ -314,28 +327,18 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionTimelineEmpty') }}
|
||||
</div>
|
||||
<ol v-else class="mt-3 space-y-3">
|
||||
<li
|
||||
v-for="event in progressEvents"
|
||||
:key="`${event.event_code}-${event.unit_id || 0}-${event.document_id || 0}-${event.occurred_at}`"
|
||||
class="border-l-2 border-slate-200 pl-3 text-xs text-slate-700 dark:border-slate-700 dark:text-slate-200"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="rounded-full bg-slate-100 px-2 py-0.5 text-[11px] font-medium text-slate-700 dark:bg-slate-800 dark:text-slate-200">
|
||||
{{ t(eventCategoryKey(event)) }}
|
||||
</span>
|
||||
<div class="font-medium text-slate-900 dark:text-slate-100">
|
||||
{{ eventActivityLabel(event) }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="eventContextLabel(event)" class="mt-1 opacity-85">
|
||||
{{ eventContextLabel(event) }}
|
||||
</div>
|
||||
<div class="mt-1 opacity-70">
|
||||
{{ eventOccurredAtLabel(event.occurred_at) }}
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
<div v-else class="mt-3 space-y-3">
|
||||
<section v-for="group in timelineGroups" :key="group.documentId == null ? 'run' : group.documentId" class="rounded-md border border-slate-200 px-3 py-2 dark:border-slate-700">
|
||||
<h4 class="text-xs font-semibold text-slate-900 dark:text-slate-100">{{ group.fileName }}</h4>
|
||||
<ol class="mt-2 space-y-3">
|
||||
<li v-for="event in group.events" :key="`${event.event_code}-${event.unit_id || 0}-${event.document_id || 0}-${event.occurred_at}`" class="border-l-2 border-slate-200 pl-3 text-xs text-slate-700 dark:border-slate-700 dark:text-slate-200">
|
||||
<div class="flex flex-wrap items-center gap-2"><span class="rounded-full bg-slate-100 px-2 py-0.5 text-[11px] font-medium text-slate-700 dark:bg-slate-800 dark:text-slate-200">{{ t(eventCategoryKey(event)) }}</span><div class="font-medium text-slate-900 dark:text-slate-100">{{ eventActivityLabel(event) }}</div></div>
|
||||
<div v-if="eventContextLabel(event)" class="mt-1 opacity-85">{{ eventContextLabel(event) }}</div>
|
||||
<div class="mt-1 opacity-70">{{ eventOccurredAtLabel(event.occurred_at) }}</div>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
+26
-1
@@ -30,6 +30,7 @@ function buildItem(patch: Partial<ShippingWorkflowItem> = {}): ShippingWorkflowI
|
||||
current_run_no: 'SNER-9',
|
||||
lifecycle_status: 'extracting',
|
||||
current_stage: 'extracting',
|
||||
available_actions: ['cancel'],
|
||||
lock_version: 1,
|
||||
events: [
|
||||
{
|
||||
@@ -113,11 +114,35 @@ describe('ShippingWorkflowItemDetailDrawer', () => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('does not infer any write or lifecycle entry from a local file status', () => {
|
||||
const wrapper = mount(ShippingWorkflowItemDetailDrawer, {
|
||||
props: {
|
||||
open: true,
|
||||
item: buildItem({
|
||||
lifecycle_status: 'pending_review',
|
||||
available_actions: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
attachTo: document.body,
|
||||
});
|
||||
|
||||
// 空动作契约表示后端没有授予操作;状态名不得让前端补造入口。
|
||||
expect(drawerRoot()?.querySelector('[data-testid="shipping-workflow-action-open-review"]')).toBeNull();
|
||||
expect(drawerRoot()?.querySelector('[data-testid="shipping-workflow-item-drawer-reparse"]')).toBeNull();
|
||||
expect(drawerRoot()?.querySelector('[data-testid="shipping-workflow-item-drawer-cancel"]')).toBeNull();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('hides cancel for closed items and emits close', async () => {
|
||||
const wrapper = mount(ShippingWorkflowItemDetailDrawer, {
|
||||
props: {
|
||||
open: true,
|
||||
item: buildItem({ lifecycle_status: 'closed', closed_reason: 'user_cancelled' }),
|
||||
item: buildItem({
|
||||
lifecycle_status: 'closed',
|
||||
closed_reason: 'user_cancelled',
|
||||
available_actions: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
attachTo: document.body,
|
||||
|
||||
+5
-14
@@ -52,17 +52,13 @@ const events = computed((): ShippingWorkflowEvent[] => (
|
||||
|
||||
const canCancel = computed(() => {
|
||||
const actions = props.item?.available_actions;
|
||||
if (Array.isArray(actions)) return actions.includes('cancel') || Boolean(props.item);
|
||||
const status = String(props.item?.lifecycle_status || '').trim();
|
||||
return Boolean(props.item) && !['closed', 'cancelled'].includes(status);
|
||||
// [AUTHORITY] 文件动作只能由文档级 available_actions 授权;空数组就是明确无权限。
|
||||
return Array.isArray(actions) && actions.includes('cancel');
|
||||
});
|
||||
|
||||
const canReparse = computed(() => {
|
||||
const actions = props.item?.available_actions;
|
||||
if (Array.isArray(actions)) return actions.includes('reparse')
|
||||
|| ['failed', 'reparse_failed'].includes(String(props.item?.lifecycle_status || '').trim());
|
||||
// 无契约时 fail-closed,禁止仅凭 pending_review 展示。
|
||||
return false;
|
||||
return Array.isArray(actions) && actions.includes('reparse');
|
||||
});
|
||||
|
||||
const reparseActionLabel = computed(() => {
|
||||
@@ -75,13 +71,8 @@ const reparseActionLabel = computed(() => {
|
||||
const canOpenReview = computed(() => {
|
||||
if (!props.item) return false;
|
||||
const actions = props.item.available_actions;
|
||||
const status = String(props.item.lifecycle_status || '').trim();
|
||||
if (Array.isArray(actions)) {
|
||||
return actions.includes('view_details')
|
||||
|| actions.includes('enter_manual_review')
|
||||
|| status === 'pending_review';
|
||||
}
|
||||
return status === 'pending_review';
|
||||
// 生命周期工作台是独立授权,详情/人工复核动作不得隐式升级为生命周期入口。
|
||||
return Array.isArray(actions) && actions.includes('open_order_review');
|
||||
});
|
||||
|
||||
const filename = computed(() => {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
export type ShippingWorkflowReasonAction = 'cancel' | 'reparse';
|
||||
export type ShippingWorkflowReasonAction = 'cancel' | 'reparse' | 'reparse_batch';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
modelValue: boolean;
|
||||
@@ -31,13 +31,17 @@ const reasonMissing = ref(false);
|
||||
const reasonInputRef = ref<HTMLTextAreaElement | null>(null);
|
||||
|
||||
const title = computed(() => (
|
||||
props.action === 'reparse'
|
||||
props.action === 'reparse_batch'
|
||||
? t('chat.shippingProcessing.reasonDialog.reparseBatchTitle')
|
||||
: props.action === 'reparse'
|
||||
? t('chat.shippingProcessing.reasonDialog.reparseTitle')
|
||||
: t('chat.shippingProcessing.reasonDialog.cancelTitle')
|
||||
));
|
||||
|
||||
const confirmLabel = computed(() => (
|
||||
props.action === 'reparse'
|
||||
props.action === 'reparse_batch'
|
||||
? t('chat.shippingProcessing.reasonDialog.reparseBatchConfirm')
|
||||
: props.action === 'reparse'
|
||||
? t('chat.shippingProcessing.reasonDialog.reparseConfirm')
|
||||
: t('chat.shippingProcessing.reasonDialog.cancelConfirm')
|
||||
));
|
||||
@@ -149,7 +153,7 @@ onBeforeUnmount(() => {
|
||||
</p>
|
||||
|
||||
<label
|
||||
v-if="action === 'reparse'"
|
||||
v-if="action === 'reparse' || action === 'reparse_batch'"
|
||||
class="mt-2 block text-xs text-secondary"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.reasonDialog.commentOptional') }}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user