feat(shipping-notice): 收敛复核状态隔离、STP 重试幂等与 XFA 合成预览标注

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-07 02:58:28 +08:00
1 parent 84a881b554
commit 74270adc22
149 files changed
+20111 -3871

No files matched your search

@@ -27,6 +27,10 @@ function mountSummary(eligibility: ShippingOrderReviewBuildEligibility, customer
canBuildYes: '可建单',
canBuildNo: '待处理',
blockReasons: { require_manual_review: '需人工确认', unknown: '未知阻断' },
gates: {
customer_confirmed: '客户已确认',
required_fields_complete: '必填字段完整',
},
},
workbench: {
primaryBlock: '首要阻断原因',
@@ -95,6 +99,25 @@ describe('ReviewBuildEligibilitySummary', () => {
expect(wrapper.find('[data-testid="review-eligibility-gate-checklist"]').text()).toContain('✓');
});
it('ignores failed_gates customer_confirmed when customer is already resolved', () => {
// 关键断言:客户已确认后不得再把「客户已确认」门禁文案投影为优先处理。
const wrapper = mountSummary({
can_build: false,
status: 'blocked',
issues: [],
failed_gates: ['customer_confirmed', 'required_fields_complete'],
gates: {
customer_confirmed: true,
required_fields_complete: false,
},
line_projections: [],
}, true);
const block = wrapper.find('[data-testid="review-eligibility-primary-block"]');
expect(block.exists()).toBe(true);
expect(block.text()).not.toContain('客户已确认');
});
it('projects concrete manual review facts before falling back to generic copy', () => {
const wrapper = mountSummary({
can_build: false,
@@ -122,8 +145,9 @@ describe('ReviewBuildEligibilitySummary', () => {
line_projections: [],
});
// 有门禁 i18n 时优先展示业务门禁名,禁止露出内部 gate code。
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').text())
.toContain('未知问题');
.toContain('必填字段完整');
expect(wrapper.text()).not.toContain('required_fields_complete');
});
@@ -140,4 +164,164 @@ describe('ReviewBuildEligibilitySummary', () => {
expect(wrapper.text()).not.toContain('can_build');
expect(wrapper.text()).not.toContain('can_auto_create');
});
it('hides primary-block under focusBuildability for inventory combo (UI-03)', () => {
// 关键断言:库存阻断由 Gate 卡表达时,资格摘要不得再输出首要阻断标题。
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
chat: {
shippingOrderReview: {
issues: '问题',
exceptionNav: { prev: '上', next: '下', prevHint: '', nextHint: '' },
issueCodes: { unknown: '未知问题' },
buildEligibility: {
title: '订单检查',
canBuildYes: '可建单',
canBuildNo: '待处理',
blockReasons: { require_manual_review: '需人工确认', unknown: '未知阻断' },
gates: { required_fields_complete: '必填字段完整' },
},
workbench: {
primaryBlock: '首要阻断原因',
blockCount: '阻断项 {count} 项',
viewFullChecks: '查看完整检查',
manualReview: {
customer: '请确认客户',
field: '请确认字段:{field}',
lineInventory: '第 {line} 行:请确认库存来源(候选:{candidates})',
noCandidates: '暂无候选',
},
},
},
},
},
},
});
const wrapper = mount(ReviewBuildEligibilitySummary, {
props: {
eligibility: {
can_build: false,
status: 'blocked',
issues: [{
code: 'require_manual_review',
severity: 'blocking',
explainability: { message: '库存来源待确认' },
}],
line_projections: [],
},
focusBuildability: true,
exceptionCount: 2,
},
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-exception-nav"]').exists()).toBe(true);
});
it('hides primary-block under focusBuildability for field completeness combo (UI-03)', () => {
// 关键断言:字段阻断组合态下资格卡只保留摘要与异常导航,不输出第二份首要阻断。
const wrapper = mount(ReviewBuildEligibilitySummary, {
props: {
eligibility: {
can_build: false,
status: 'blocked',
issues: [{
code: 'required_field_missing',
severity: 'blocking',
field_code: 'po_number',
}],
assessment: { missing_required_fields: ['po_number'], invalid_lines: [] },
line_projections: [],
},
fieldLabels: { po_number: 'PO' },
focusBuildability: true,
exceptionCount: 1,
},
global: {
plugins: [createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
chat: {
shippingOrderReview: {
issueCodes: { unknown: '未知' },
issues: '问题',
exceptionNav: { prev: '上', next: '下', prevHint: '', nextHint: '' },
buildEligibility: {
title: '订单检查',
canBuildYes: '可建单',
canBuildNo: '待处理',
gates: {},
blockReasons: { unknown: '未知' },
},
workbench: {
primaryBlock: '首要阻断原因',
blockCount: '{count}',
viewFullChecks: '查看完整检查',
missingRequiredFields: '缺失必填',
conflictFields: '冲突',
manualReview: {
customer: '',
field: '请确认字段:{field}',
lineInventory: '',
noCandidates: '',
},
},
},
},
},
},
})],
},
});
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').exists()).toBe(false);
});
it('hides primary-block when technical_auto_only leaves business gate inactive (UI-03)', () => {
// 关键断言:仅技术 Gate pending 时 focusBuildability=false,资格卡可展示阻断;本测验证开启 focus 时仍唯一。
const wrapper = mount(ReviewBuildEligibilitySummary, {
props: {
eligibility: {
can_build: true,
can_auto_create: true,
status: 'qualified',
issues: [],
line_projections: [],
},
focusBuildability: true,
},
global: {
plugins: [createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
chat: {
shippingOrderReview: {
buildEligibility: {
title: '订单检查',
canBuildYes: '可建单',
canBuildNo: '待处理',
gates: {},
},
workbench: {
primaryBlock: '首要阻断原因',
viewFullChecks: '查看完整检查',
},
},
},
},
},
})],
},
});
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-build-eligibility-badge"]').text()).toContain('可建单');
});
});
@@ -66,7 +66,7 @@ const blockingIssueCount = computed(() => {
return blocking.length || issues.length;
});
/** 首要阻断文案。 */
/** 首要阻断文案:仅来自当前未解决业务问题;客户已确认时不得再显示客户确认阻断。 */
const primaryBlockMessage = computed(() => {
const issues = effectiveIssues.value;
const primary = issues.find((item) => String(item.severity || '') === 'blocking') || issues[0];
@@ -78,7 +78,13 @@ const primaryBlockMessage = computed(() => {
return !reason.startsWith('customer_');
});
if (!blockedLines.length) {
const failedGate = (props.eligibility?.failed_gates || [])[0];
const failedGate = (props.eligibility?.failed_gates || []).find((gate) => {
const code = String(gate || '').trim().toLowerCase();
if (props.customerResolved === true && (code === 'customer_confirmed' || code === 'customer_resolution')) {
return false;
}
return true;
});
if (!failedGate) return '';
const gateKey = `chat.shippingOrderReview.buildEligibility.gates.${failedGate}`;
return te(gateKey) ? t(gateKey) : t('chat.shippingOrderReview.issueCodes.unknown');
@@ -116,7 +122,13 @@ const primaryBlockMessage = computed(() => {
if (message) return message;
const key = `chat.shippingOrderReview.issueCodes.${code}`;
if (code && te(key)) return t(key);
const failedGate = (props.eligibility?.failed_gates || [])[0];
const failedGate = (props.eligibility?.failed_gates || []).find((gate) => {
const gateCode = String(gate || '').trim().toLowerCase();
if (props.customerResolved === true && (gateCode === 'customer_confirmed' || gateCode === 'customer_resolution')) {
return false;
}
return true;
});
if (failedGate) {
const gateKey = `chat.shippingOrderReview.buildEligibility.gates.${failedGate}`;
return te(gateKey) ? t(gateKey) : t('chat.shippingOrderReview.issueCodes.unknown');
@@ -97,6 +97,10 @@ async function openSelectDialog() {
}
}
defineExpose({
openSelectDialog,
});
/**
* 按关键词搜索标准客户。
*/
@@ -117,6 +117,24 @@ async function onRefresh() {
busy.value = false;
}
}
/**
* 聚焦裁决区并短暂高亮动作按钮(Footer / Resolver 委托)。
*/
function focusAdjudication() {
const root = document.querySelector('[data-testid="review-duplicate-panel"]');
root?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
const actions = document.querySelector('[data-testid="review-duplicate-actions"]');
if (!(actions instanceof HTMLElement)) return;
actions.classList.add('ring-2', 'ring-amber-400');
window.setTimeout(() => {
actions.classList.remove('ring-2', 'ring-amber-400');
}, 1600);
}
defineExpose({
focusAdjudication,
});
</script>
<template>
@@ -168,7 +186,11 @@ async function onRefresh() {
</span>
</p>
<div v-if="editable && duplicate?.needs_adjudication" class="mt-3 space-y-2">
<div
v-if="editable && duplicate?.needs_adjudication"
class="mt-3 space-y-2 rounded-lg transition-shadow"
data-testid="review-duplicate-actions"
>
<div class="flex flex-wrap gap-2">
<button
v-if="allowed.has('open_existing')"
@@ -71,6 +71,24 @@ function onFocus(conflict: ShippingOrderReviewFieldConflict) {
});
}
/**
* 聚焦第一个未解决冲突(Footer / Resolver 委托)。
*/
function focusFirstConflict() {
const first = openConflicts.value[0];
if (!first) return;
onFocus(first);
void Promise.resolve().then(() => {
document
.querySelector(`[data-testid="review-field-conflict-${first.conflict_key}"]`)
?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
});
}
defineExpose({
focusFirstConflict,
});
/**
* 采用某一候选值。
*/
@@ -1,9 +1,10 @@
<!--
features/chat/components/shipping-review/ReviewWorkbenchFooter.vue
用途:订单处理工作台底部唯一写操作栏(处置 / 保存 / 流程恢复动作)。
用途:订单处理工作台底部唯一写操作栏(处置 / 保存 / 统一流程动作)。
依赖:vue-i18n、lucide-vue-next、ActionPresentation。
逻辑:ShippingOrderReviewView 传入 available_actions 与流程动作投影;sticky bottom;
系统自动推进中隐藏无效主写按钮;流程写操作经 flow-action emit。
只读查看时仍可展示 view_result/view_record;写按钮受 actionsExecutable 约束;
流程写操作经 flow-action emit(与 Resolver 同链);flowBusy||saving 时禁用。
-->
<script setup lang="ts">
import { computed } from 'vue';
@@ -17,19 +18,34 @@ const props = withDefaults(defineProps<{
saving: boolean;
isReadOnly: boolean;
hasDraft: boolean;
/** can_build && can_auto_create 时隐藏确认按钮并展示自动推进提示 */
/** queued|running 时隐藏确认按钮 */
hideConfirmBecauseAutoGate?: boolean;
/** waiting/queued/running 时展示自动建单提示(可与确认按钮并存) */
showAutoGateHint?: boolean;
/** failed/manual_fallback 时展示「重试自动推进」 */
showStpRetry?: boolean;
/** 自动资格提示文案(等待启动 / 正在推进);由父级按真实 Job 状态计算 */
autoGateHint?: string;
/** 未保存本地修改计数(硬拦截与底栏提示同源) */
unsavedCount?: number;
/** 统一流程动作(原进度条 ActionBar);surface=review */
flowPresentation?: ActionPresentation | null;
/** 系统自动推进中:隐藏主写按钮 */
automating?: boolean;
/** 是否允许业务写(只读查看为 false) */
actionsExecutable?: boolean;
/** 统一流程动作提交中 */
flowBusy?: boolean;
}>(), {
unsavedCount: 0,
flowPresentation: null,
automating: false,
hideConfirmBecauseAutoGate: false,
showAutoGateHint: false,
showStpRetry: false,
autoGateHint: '',
actionsExecutable: true,
flowBusy: false,
});
const emit = defineEmits<{
@@ -39,6 +55,7 @@ const emit = defineEmits<{
'upload-replacement': [event: Event];
validate: [];
confirm: [];
'retry-stp': [];
'flow-action': [item: ActionPresentationItem];
}>();
@@ -51,8 +68,6 @@ function hasAction(action: string): boolean {
return props.availableActions.includes(action);
}
const showFooter = computed(() => props.hasDraft && !props.isReadOnly);
const flowItems = computed((): ActionPresentationItem[] => {
const presentation = props.flowPresentation;
if (!presentation) return [];
@@ -64,6 +79,20 @@ const flowItems = computed((): ActionPresentationItem[] => {
return items.filter((item) => item.intent !== 'refresh');
});
const hasViewOnlyFlow = computed(() => flowItems.value.some((item) => (
item.intent === 'view_result'
|| item.intent === 'view_record'
|| item.intent === 'open_profile_review'
)));
/** 可编辑底栏,或只读但仍有导航/查看类流程动作。 */
const showFooter = computed(() => (
props.hasDraft && (!props.isReadOnly || hasViewOnlyFlow.value)
));
const controlsBusy = computed(() => props.saving || props.flowBusy);
const canWriteCaseActions = computed(() => props.actionsExecutable && !props.isReadOnly);
/**
* 流程动作文案。
*/
@@ -71,7 +100,7 @@ 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 item.actionCode;
return t('chat.shippingProcessing.action.none');
}
</script>
@@ -81,13 +110,15 @@ function flowLabel(item: ActionPresentationItem): string {
class="sticky bottom-0 z-20 flex shrink-0 flex-col gap-3 border-t border-slate-200 bg-white/95 p-3 shadow-[0_-4px_12px_rgba(15,23,42,0.06)] backdrop-blur sm:flex-row sm:items-center sm:justify-between dark:border-slate-800 dark:bg-slate-900/95"
data-testid="review-footer-actions"
:data-automating="automating ? '1' : '0'"
:data-flow-busy="flowBusy ? '1' : '0'"
:data-actions-executable="actionsExecutable ? '1' : '0'"
>
<div class="order-1 flex flex-wrap items-center gap-2 sm:order-1">
<template v-if="!automating">
<template v-if="!automating && canWriteCaseActions">
<button
v-if="hasAction('mark_non_order')"
type="button"
:disabled="saving"
: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"
@click="emit('mark-non-order')"
>
@@ -96,7 +127,7 @@ function flowLabel(item: ActionPresentationItem): string {
<button
v-if="hasAction('mark_quality_issue')"
type="button"
:disabled="saving"
: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"
@click="emit('mark-quality-issue')"
>
@@ -105,7 +136,7 @@ function flowLabel(item: ActionPresentationItem): string {
<button
v-if="hasAction('reparse')"
type="button"
:disabled="saving"
: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"
@click="emit('reparse')"
>
@@ -114,12 +145,13 @@ function flowLabel(item: ActionPresentationItem): string {
<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="saving"
:disabled="controlsBusy"
@change="emit('upload-replacement', $event)"
>
{{ t('chat.shippingOrderReview.uploadReplacement') }}
@@ -130,7 +162,7 @@ function flowLabel(item: ActionPresentationItem): string {
v-for="item in flowItems"
:key="`${item.intent}-${item.actionCode}`"
type="button"
:disabled="saving"
:disabled="controlsBusy"
class="rounded border border-slate-300 px-3 py-2 text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
:data-testid="`review-footer-flow-${item.intent}`"
:data-intent="item.intent"
@@ -156,17 +188,27 @@ function flowLabel(item: ActionPresentationItem): string {
{{ t('chat.shippingOrderReview.workflowProgress.automatingFooterHint') }}
</p>
<p
v-else-if="hideConfirmBecauseAutoGate"
v-else-if="showAutoGateHint && canWriteCaseActions"
class="text-xs text-muted"
data-testid="review-auto-gate-hint"
>
{{ t('chat.shippingOrderReview.buildEligibility.autoGateProgressHint') }}
{{ autoGateHint || t('chat.shippingOrderReview.buildEligibility.autoGateWaitingHint') }}
</p>
<template v-if="!automating">
<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.retryStp') }}
</button>
<button
v-if="hasAction('validate')"
type="button"
:disabled="saving"
: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')"
>
@@ -175,7 +217,7 @@ function flowLabel(item: ActionPresentationItem): string {
<button
v-if="hasAction('confirm') && !hideConfirmBecauseAutoGate"
type="button"
:disabled="saving || !canConfirmBuild"
:disabled="controlsBusy || !canConfirmBuild"
class="rounded bg-emerald-600 px-3 py-2 text-sm font-medium text-white disabled:opacity-50"
data-testid="review-confirm-create"
:title="!canConfirmBuild ? t('chat.shippingOrderReview.buildEligibility.confirmBlocked') : undefined"
@@ -1,8 +1,8 @@
/**
* features/chat/components/shipping-review/ReviewWorkflowProgressPanel.spec.ts
* 用途:订单处理台进度面板——紧凑五域条;人工入口仅 Gate 动作。
* 用途:订单处理台进度面板——压缩 Strip;人工入口仅 Gate 动作。
* 依赖:vitest、@vue/test-utils、vue-i18n stub、RouterLink stub。
* 逻辑:有 processingProjection 才渲染 ReviewProgressStrip;无页内 15 阶展开;manual upload 入口需 nextActionCode。
* 逻辑:有 processingProjection 才渲染 ReviewProgressStrip;无五域芯片;manual upload 入口需 nextActionCode。
*/
import { describe, expect, it } from 'vitest';
import { mount } from '@vue/test-utils';
@@ -12,6 +12,7 @@ import type {
ShippingProcessingProjection,
ShippingReviewProgressContext,
} from '@/features/chat/types/shipping.api.types';
import { SHIPPING_PROCESSING_STAGES } from '@/features/chat/types/shipping.api.types';
const messages = {
en: {
@@ -36,14 +37,12 @@ const messages = {
completedOfTotal: '{done} of {total} done',
remainingHint: '{count} remaining',
positionOfTotal: '{current} / {total}',
domainReceiveParse: 'Receive',
domainCandidateIdentity: 'Candidate',
domainOrderConfirm: 'Confirm',
domainInventoryHandle: 'Inventory',
domainFulfillmentShip: 'Ship',
currentNeedLabel: 'Need: ',
systemProcessingNeed: 'System processing',
progressTitleWithStage: 'Order processing · {stage}',
systemProcessingWithStage: 'System processing · {stage}',
viewProcessDetails: 'View process details',
viewFullProcess: 'View full process',
stageNodesUnavailable: 'Progress details unavailable',
},
gateReasons: { generic: 'Needs action' },
status: {
@@ -51,10 +50,7 @@ const messages = {
blocked: 'Blocked',
processing: 'Processing',
},
stage: {
freight_uploading: 'Uploading to freight',
excel_generating: 'Generating Excel',
},
stage: Object.fromEntries(SHIPPING_PROCESSING_STAGES.map((s) => [s, s])),
action: {
refresh: 'Refresh',
},
@@ -72,6 +68,20 @@ const messages = {
},
};
/**
* 构造含权威 15 阶的最小投影片段。
*/
function withStageNodes(
partial: Partial<ShippingProcessingProjection>,
): Partial<ShippingProcessingProjection> {
const stageNodes = SHIPPING_PROCESSING_STAGES.map((stage, absoluteIndex) => ({
stage,
absoluteIndex,
status: (absoluteIndex < 5 ? 'passed' : absoluteIndex === 5 ? 'running' : 'pending') as const,
}));
return { stageNodes, ...partial };
}
/**
* 挂载进度面板。
*/
@@ -81,12 +91,17 @@ function mountPanel(extras?: {
processingProjection?: Partial<ShippingProcessingProjection> | null;
}) {
const i18n = createI18n({ legacy: false, locale: 'en', messages });
const projection = extras?.processingProjection === null
? null
: extras?.processingProjection
? withStageNodes(extras.processingProjection)
: null;
return mount(ReviewWorkflowProgressPanel, {
props: {
item: null as ShippingReviewProgressContext | null,
taskNo: extras?.taskNo ?? 'SN-1',
polling: extras?.polling ?? true,
processingProjection: (extras?.processingProjection || null) as ShippingProcessingProjection | null,
processingProjection: projection as ShippingProcessingProjection | null,
},
global: {
plugins: [i18n],
@@ -109,21 +124,29 @@ describe('ReviewWorkflowProgressPanel', () => {
expect(wrapper.find('[data-testid="review-open-task-workbench"]').exists()).toBe(false);
});
it('renders compact domain strip without inline 15-node expand', () => {
it('renders compressed strip with 15 nodes and without domain chips', () => {
const wrapper = mountPanel({
polling: false,
processingProjection: {
status: 'processing',
stage: 'excel_generating',
status: 'waiting_review',
stage: 'waiting_review',
sourceType: 'eml',
currentGate: {
gateCode: 'order_review',
status: 'blocked',
nextActionCode: 'confirm_customer',
blockingReasonCode: 'generic',
},
},
});
expect(wrapper.find('[data-testid="review-progress-unavailable"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-progress-strip"]').exists()).toBe(true);
expect(wrapper.findAll('[data-testid="review-progress-domains"] [data-domain]').length).toBe(5);
expect(wrapper.find('[data-testid="review-progress-domains"]').exists()).toBe(false);
expect(wrapper.findAll('[data-testid="review-progress-stage-nodes"] [data-stage]')).toHaveLength(15);
expect(wrapper.find('[data-testid="review-progress-expand-full"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="unified-action-bar"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-progress-open-details"]').exists()).toBe(true);
expect(wrapper.get('[data-testid="review-progress-title"]').text()).toContain('Order processing');
});
it('hides manual CTA while automating freight upload', () => {
@@ -133,9 +156,13 @@ describe('ReviewWorkflowProgressPanel', () => {
status: 'automating',
stage: 'freight_uploading',
sourceType: 'eml',
currentGate: null,
},
});
expect(wrapper.find('[data-testid="review-progress-strip"]').exists()).toBe(true);
expect(wrapper.get('[data-testid="review-progress-title"]').text()).toContain('System processing');
expect(wrapper.find('[data-testid="review-progress-refresh"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-progress-current-need"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-open-task-workbench"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-manual-upload-next-steps"]').exists()).toBe(false);
});
@@ -178,5 +205,26 @@ describe('ReviewWorkflowProgressPanel', () => {
});
expect(wrapper.find('[data-testid="review-manual-upload-next-steps"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-open-task-workbench"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-generic-next-steps"]').exists()).toBe(false);
});
it('never renders generic next-steps for blocked non-upload gates', () => {
const wrapper = mountPanel({
polling: false,
processingProjection: {
status: 'blocked',
stage: 'waiting_review',
sourceType: 'eml',
currentGate: {
gateCode: 'order_review',
status: 'blocked',
nextActionCode: 'confirm_customer',
blockingReasonCode: 'generic',
},
},
});
expect(wrapper.find('[data-testid="review-progress-current-need"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-generic-next-steps"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-manual-upload-next-steps"]').exists()).toBe(false);
});
});
@@ -1,8 +1,9 @@
<!--
features/chat/components/shipping-review/ReviewWorkflowProgressPanel.vue
用途:订单处理工作台只读进度区(ReviewProgressStrip)+ Gate / 人工上传下一步提示。
依赖:vue-i18n、ShippingProcessingProjection、ReviewProgressStrip。
逻辑:节点高亮只读统一投影;打开流程详情 / 刷新 emit 给宿主;写操作不在本面板。
用途:订单处理工作台只读进度区外壳——挂载压缩版 ReviewProgressStrip + 人工上传入口。
依赖:vue-i18n、ShippingProcessingProjection、ReviewProgressStrip、shippingProcessingFulfillment。
逻辑:标题与「当前需要」由 Strip 统一渲染;surface=review 永不渲染 review-generic-next-steps;
仅人工上传保留任务台跳转;其他 Gate 只靠 Strip + Footer;写操作不在本面板。
-->
<script setup lang="ts">
import { computed } from 'vue';
@@ -15,10 +16,6 @@ import type {
import {
projectionRequiresManualUploadWorkbench,
} from '@/features/chat/shipping/shippingProcessingFulfillment';
import {
resolveShippingProcessingStatusLabel,
shippingProcessingStageKey,
} from '@/features/chat/shipping/shippingProcessingLabels';
import ReviewProgressStrip from '@/features/shipping-progress/components/ReviewProgressStrip.vue';
const props = defineProps<{
@@ -34,52 +31,18 @@ const emit = defineEmits<{
refresh: [];
}>();
const { t, te } = useI18n();
const { t } = useI18n();
const hasProjection = computed(() => Boolean(props.processingProjection));
const unifiedStatusLabel = computed(() => {
const status = props.processingProjection?.status;
if (!status) return '';
return resolveShippingProcessingStatusLabel(status, te, t);
});
const unifiedStageLabel = computed(() => {
const stage = props.processingProjection?.stage;
if (!stage) return '';
const key = shippingProcessingStageKey(stage);
return te(key) ? t(key) : stage;
});
/**
* 仅当 Gate next_action 明确指人工上传且非 RPA 阶段时展示任务台入口。
* 仅当 Gate next_action 明确指人工上传且非 RPA 阶段时展示任务台入口(非纯文案重复)。
*/
const showTaskWorkbenchLink = computed(() => {
if (!props.processingProjection) return false;
if (!projectionRequiresManualUploadWorkbench(props.processingProjection)) return false;
return Boolean(String(props.taskNo || '').trim());
});
/**
* blocked 且非人工上传时展示通用下一步提示(来自 Gate 动作 i18n)。
*/
const showGenericNextSteps = computed(() => {
const projection = props.processingProjection;
if (!projection || showTaskWorkbenchLink.value) return false;
const nextAction = String(projection.currentGate?.nextActionCode || '').trim();
if (!nextAction) return false;
const status = String(projection.status || '').trim().toLowerCase();
return status === 'blocked' || status === 'needs_action';
});
const genericNextStepMessage = computed(() => {
const code = String(props.processingProjection?.currentGate?.nextActionCode || '').trim();
if (code) {
const gateKey = `workspace.shippingNotice.processGate.actions.${code}`;
if (te(gateKey)) return t(gateKey);
}
return t('chat.shippingOrderReview.workflowProgress.nextStepsGeneric');
});
</script>
<template>
@@ -87,50 +50,21 @@ const genericNextStepMessage = computed(() => {
class="rounded-xl border border-default bg-surface-soft/60 p-3"
data-testid="review-workflow-progress-panel"
>
<div class="flex items-start justify-between gap-2">
<div class="min-w-0">
<div class="text-sm font-semibold text-primary">
{{ t('chat.shippingOrderReview.workflowProgress.title') }}
</div>
<div
v-if="hasProjection && (unifiedStatusLabel || unifiedStageLabel)"
class="mt-0.5 text-[11px] text-secondary"
data-testid="review-progress-unified-label"
>
<span v-if="unifiedStatusLabel">{{ unifiedStatusLabel }}</span>
<span v-if="unifiedStageLabel"> · {{ unifiedStageLabel }}</span>
</div>
<div
v-else-if="!hasProjection"
class="mt-0.5 text-[11px] text-amber-700 dark:text-amber-300"
data-testid="review-progress-unavailable"
>
{{ t('chat.shippingOrderReview.workflowProgress.progressUnavailable') }}
</div>
<div v-else class="mt-0.5 text-[11px] text-secondary">
{{ t('chat.shippingOrderReview.workflowProgress.subtitle') }}
</div>
</div>
<span
v-if="polling"
class="shrink-0 text-[11px] text-muted"
data-testid="review-workflow-progress-polling"
>
{{ t('chat.shippingOrderReview.workflowProgress.polling') }}
</span>
<div
v-if="!hasProjection"
class="text-[11px] text-amber-700 dark:text-amber-300"
data-testid="review-progress-unavailable"
>
{{ t('chat.shippingOrderReview.workflowProgress.progressUnavailable') }}
</div>
<div
v-if="processingProjection"
class="mt-3"
data-testid="review-progress-nodes"
>
<ReviewProgressStrip
:projection="processingProjection"
@open-process-details="emit('open-process-details')"
@refresh="emit('refresh')"
/>
</div>
<ReviewProgressStrip
v-else-if="processingProjection"
:projection="processingProjection"
:polling="polling"
@open-process-details="emit('open-process-details')"
@refresh="emit('refresh')"
/>
<div
v-if="showTaskWorkbenchLink"
@@ -146,12 +80,5 @@ const genericNextStepMessage = computed(() => {
{{ t('chat.shippingOrderReview.workflowProgress.openTaskWorkbench') }}
</RouterLink>
</div>
<div
v-else-if="showGenericNextSteps"
class="mt-3 rounded-md border border-default bg-surface-soft px-2.5 py-2 text-[11px] text-secondary"
data-testid="review-generic-next-steps"
>
<p>{{ genericNextStepMessage }}</p>
</div>
</section>
</template>
@@ -1,8 +1,9 @@
/**
* features/chat/components/shipping/ShippingConversationProcessingCard.spec.ts
* 用途:验收右侧任务分组卡——needs_action/processing 与短时反馈标签。
* 用途:验收右侧任务分组卡——needs_action / processing / 处理记录三子段与动作层级。
* 依赖:Vitest、Vue Test Utils、vue-i18n、ShippingConversationProcessingCard。
* 逻辑:构造 ConversationProcessingProjection;断言分组、焦点 emit;右侧不渲染 history。
* 逻辑:构造 ConversationProcessingProjection;断言分组文案、处理记录折叠与三类子段、
* UI-02 单一详情入口、UI-03 history 截断角标、有 workItem 时无任务级主/次按钮。
*/
import { mount, flushPromises } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
@@ -22,7 +23,7 @@ const i18n = createI18n({
function buildProjection(): ConversationProcessingProjection {
return {
summary: { total_tasks: 3, processing: 1, needs_action: 1, completed: 1, history: 0 },
summary: { total_tasks: 3, processing: 1, needs_action: 1, completed: 1, history: 2 },
focused_task_no: 'OT-PROC',
recent_task_no: 'OT-PROC',
needs_action: [{
@@ -55,15 +56,28 @@ function buildProjection(): ConversationProcessingProjection {
can_append: false,
available_actions: ['view_details'],
}],
history: [{
user_task_no: 'OT-HIST',
group: 'history',
status_label: 'completed',
file_count: 1,
run_no: 'RUN-HIST',
can_append: false,
viewed: true,
}],
history: [
{
user_task_no: 'OT-HIST',
group: 'history',
status_label: 'completed',
file_count: 1,
run_no: 'RUN-HIST',
can_append: false,
viewed: true,
available_actions: ['view_details'],
},
{
user_task_no: 'OT-CANCEL',
group: 'history',
status_label: 'cancelled',
file_count: 1,
run_no: 'RUN-CANCEL',
can_append: false,
viewed: true,
available_actions: ['view_details'],
},
],
};
}
@@ -103,7 +117,7 @@ function buildWorkItem(
}
describe('ShippingConversationProcessingCard', () => {
it('renders needs_action / processing / completed groups, hides history on the right panel', async () => {
it('renders needs_action / processing groups and collapsible processing records with three subsections', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: { projection: buildProjection() },
global: { plugins: [i18n] },
@@ -113,18 +127,88 @@ describe('ShippingConversationProcessingCard', () => {
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-processing"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-group-completed"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').exists()).toBe(true);
expect(wrapper.text()).toContain('需要你处理 · 1 个任务');
expect(wrapper.text()).toContain('系统处理中 · 1 个任务');
expect(wrapper.text()).toContain('刚刚创建');
expect(wrapper.text()).toContain('已完成');
// UI-04:右侧不展示处理记录分组。
expect(wrapper.find('[data-testid="shipping-processing-group-history"]').exists()).toBe(false);
// 处理记录默认折叠;标题 count = completed + history 返回条数。
const historyGroup = wrapper.find('[data-testid="shipping-processing-group-history"]');
expect(historyGroup.exists()).toBe(true);
expect(historyGroup.text()).toContain('处理记录 · 3');
expect(wrapper.find('[data-testid="shipping-processing-history-body"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-HIST"]').exists()).toBe(false);
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-history-body"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-history-completed"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-history-versions"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-history-cancelled"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-HIST"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-CANCEL"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-history-completed"]').text()).toContain('已完成');
expect(wrapper.find('[data-testid="shipping-processing-history-versions"]').text()).toContain('历史版本');
expect(wrapper.find('[data-testid="shipping-processing-history-cancelled"]').text()).toContain('已取消');
});
it('renders multi-PDF task title instead of first filename', async () => {
it('shows history more badge when summary.history exceeds returned history length', async () => {
const projection = buildProjection();
projection.summary.history = 14;
const wrapper = mount(ShippingConversationProcessingCard, {
props: { projection },
global: { plugins: [i18n] },
});
await flushPromises();
// UI-03:折叠态即可看到「还有 N 条」。
expect(wrapper.find('[data-testid="shipping-processing-history-more"]').text()).toContain('还有 12 条');
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-history-truncated"]').text())
.toContain('仅展示最近 2 条,另有 12 条未显示');
});
it('falls back to generic truncated hint when hasMoreHistory but no reliable hidden count', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: buildProjection(),
hasMoreHistory: true,
},
global: { plugins: [i18n] },
});
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-history-more"]').exists()).toBe(false);
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-history-truncated"]').text())
.toContain('列表已截断,仅展示最近任务');
});
it('keeps processing-record cards read-only without primary CTA or progress', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: buildProjection(),
workItems: [
buildWorkItem('OT-DONE', { status: 'completed', stage: 'completed' }),
],
},
global: { plugins: [i18n] },
});
await flushPromises();
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
await flushPromises();
const doneCard = wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]');
expect(doneCard.find('[data-testid="sidebar-progress-inline"]').exists()).toBe(false);
expect(doneCard.find('[data-testid="shipping-processing-task-actions"]').exists()).toBe(false);
expect(doneCard.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(true);
expect(doneCard.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(false);
});
it('uses expand-files as the only detail entry when canExpandFileDetails', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: {
@@ -151,12 +235,49 @@ describe('ShippingConversationProcessingCard', () => {
await flushPromises();
expect(wrapper.text()).toContain('订单识别任务');
expect(wrapper.text()).toContain('2 个 PDF');
expect(wrapper.text()).toContain('4518838152.pdf、4518838154.pdf');
expect(wrapper.text()).toContain('取消整个任务');
// 主标题不得单独伪装成首个 PDF 文件名任务。
expect(wrapper.text()).toContain('主文件:4518838152.pdf');
const titleEl = wrapper.find('[data-testid="shipping-processing-task-OT-MULTI"] .text-sm.font-semibold');
expect(titleEl.text()).toContain('订单识别任务');
expect(titleEl.text()).not.toContain('4518838152.pdf');
// UI-02:有文件对象时不双开「查看详情」与「展开文件详情」。
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(false);
await wrapper.find('[data-testid="shipping-processing-expand-files"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').text()).toContain('取消整个任务');
});
it('shows view_details when task cannot expand file details, and keeps cancel as overflow', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: {
summary: { total_tasks: 1, processing: 0, needs_action: 1, completed: 0, history: 0 },
needs_action: [{
user_task_no: 'OT-SINGLE',
group: 'needs_action',
status_label: 'pending_review',
file_count: 1,
run_no: 'RUN-SINGLE',
can_append: false,
available_actions: ['view_details', 'cancel_task'],
objects: [],
}],
processing: [],
completed: [],
history: [],
},
},
global: { plugins: [i18n] },
});
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(true);
// 无文件对象时取消可直接挂在卡上(低频文字链,非主 CTA)。
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(true);
});
it('shows multi-document title from authoritative projection without workflow fallback', async () => {
@@ -192,7 +313,7 @@ describe('ShippingConversationProcessingCard', () => {
expect(titleEl.text()).not.toContain('4518838152.pdf');
});
it('falls back to unnamed PDF instead of internal OT number', async () => {
it('uses unified order recognition title instead of internal OT number', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: {
@@ -214,7 +335,7 @@ describe('ShippingConversationProcessingCard', () => {
global: { plugins: [i18n] },
});
await flushPromises();
expect(wrapper.text()).toContain('未命名 PDF');
expect(wrapper.text()).toContain('订单识别任务');
expect(wrapper.text()).not.toContain('20260803-A13F95D2');
});
@@ -242,7 +363,6 @@ describe('ShippingConversationProcessingCard', () => {
});
await flushPromises();
const needCard = wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]');
// 关键断言:待操作聚焦卡必须有用户可见 ring,不能只写 data-focused。
expect(needCard.attributes('data-focused')).toBe('1');
expect(needCard.classes().join(' ')).toContain('ring-brand-400');
const other = wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]');
@@ -264,12 +384,10 @@ describe('ShippingConversationProcessingCard', () => {
global: { plugins: [i18n] },
});
await flushPromises();
const taskRoot = wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]');
const buttons = taskRoot.findAll('button');
// 最后一个按钮是展开/收起文件详情
await buttons[buttons.length - 1].trigger('click');
const expandBtn = wrapper.find('[data-testid="shipping-processing-expand-files"]');
await expandBtn.trigger('click');
expect(wrapper.emitted('expandFiles')?.[0]?.[0]).toMatchObject({ user_task_no: 'OT-NEED' });
await buttons[buttons.length - 1].trigger('click');
await expandBtn.trigger('click');
expect(wrapper.emitted('collapseFiles')).toBeTruthy();
});
@@ -294,7 +412,7 @@ describe('ShippingConversationProcessingCard', () => {
global: { plugins: [i18n] },
});
await flushPromises();
expect(wrapper.findAll('[data-testid^="shipping-processing-task-"]')).toHaveLength(20);
expect(wrapper.findAll('article[data-testid^="shipping-processing-task-"]')).toHaveLength(20);
expect(wrapper.findAll('[data-testid="shipping-conversation-processing-card"]')).toHaveLength(1);
});
@@ -344,7 +462,6 @@ describe('ShippingConversationProcessingCard', () => {
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');
// 关键断言:失败恢复元信息(原因 / Attempt / 资产)出现在材料卡。
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');
@@ -354,7 +471,7 @@ describe('ShippingConversationProcessingCard', () => {
});
});
it('renders each PDF task with its own compact projection, including completed tasks', async () => {
it('hides task-level primary/secondary when workItem exists but keeps expand-files entry', async () => {
const projection = buildProjection();
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
@@ -367,23 +484,19 @@ describe('ShippingConversationProcessingCard', () => {
buildWorkItem('OT-PROC', {
stage: 'inventory_matching',
}),
buildWorkItem('OT-DONE', {
status: 'completed',
stage: 'completed',
}),
],
},
global: { plugins: [i18n] },
});
await flushPromises();
// 未聚焦时:needs_action/processing 显示紧凑进度;已完成默认收起(UI-05)。
expect(wrapper.findAll('[data-testid="sidebar-progress-inline"]')).toHaveLength(2);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"] [data-testid="sidebar-progress-inline"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').text()).toContain('待复核');
expect(wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]').text()).toContain('库存匹配');
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').text()).toContain('已完成');
expect(wrapper.findAll('[data-testid="shipping-processing-task-actions"]')).toHaveLength(0);
// UI-02:有 workItem 时仍保留展开文件详情(OT-NEED 为多文件)。
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-expand-files"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
});
it('maps internal review_case_draft status to a user-facing review label', async () => {
@@ -1,15 +1,16 @@
/**
* features/chat/components/shipping/ShippingConversationProcessingCard.vue
* 用途:右侧「本次处理中」顶层任务卡——按 needs_action / processing / completed 展示。
* 用途:右侧「本次处理中」顶层任务卡——needs_action / processing / 处理记录。
* 依赖:vue-i18n、ConversationProcessingProjection、conversationProcessingState、
* shippingProcessingLabels、SidebarProgressInline。
* 逻辑:由 ShippingWorkflowTimeline 嵌入;只消费统一 projection / workItems,禁止 Workflow fallback;
* 单 PDF 主标题用文件名,多 PDF 用「订单识别任务」;右侧不渲染 history;
* 仅聚焦卡展开完整 SidebarProgressInline,未聚焦显示紧凑单行,已完成默认收起(UI-05);
* 单 PDF 不展示「展开文件详情」。
* conversationProcessingDisplay、actionPresentation、shippingProcessingLabels、SidebarProgressInline。
* 逻辑:由 ShippingWorkflowTimeline 嵌入;只消费统一 projection / workItems;
* 统一「订单识别任务」+ 主文件副标题;处理记录默认折叠(已完成/历史版本/已取消);
* UI-02:有文件对象时次要入口仅为「展开文件详情」,无文件对象时才「查看详情」;
* 有 workItem 时不渲染任务级主/次按钮,仍可保留展开文件入口;
* UI-03:history 截断时折叠标题显示「还有 N 条」,展开底部显示明细截断文案。
*/
<script setup lang="ts">
import { computed, watch } from 'vue';
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { ChevronDown, ChevronRight } from 'lucide-vue-next';
import type {
@@ -17,6 +18,7 @@ import type {
ConversationProcessingUserTask,
ShippingProcessingProjection,
} from '@/features/chat/types/shipping.api.types';
import { getPrimaryDocumentName } from '@/features/chat/shipping/conversationProcessingDisplay';
import {
createConversationProcessingUiState,
focusTaskManually,
@@ -32,8 +34,9 @@ import {
shippingProcessingSourceTypeKey,
shippingProcessingStageKey,
} from '@/features/chat/shipping/shippingProcessingLabels';
import { resolveConversationTaskActionPresentation } from '@/features/shipping-progress/actionPresentation';
import SidebarProgressInline from '@/features/shipping-progress/components/SidebarProgressInline.vue';
import type { ActionPresentationItem } from '@/features/shipping-progress/types';
import type { ActionPresentation, ActionPresentationItem } from '@/features/shipping-progress/types';
const props = defineProps<{
projection: ConversationProcessingProjection | null;
@@ -41,6 +44,8 @@ const props = defineProps<{
workItems?: ShippingProcessingProjection[] | null;
/** 当前会话 ID;切换时重置本地焦点/展开状态 */
conversationId?: string | null;
/** 后端截断提示:history 还有未返回内容时在处理记录底部展示 */
hasMoreHistory?: boolean;
}>();
const emit = defineEmits<{
@@ -60,6 +65,8 @@ const emit = defineEmits<{
const { t, te } = useI18n();
const uiState = createConversationProcessingUiState();
/** 处理记录整组默认折叠。 */
const historySectionExpanded = ref(false);
/** 唯一进度源:统一 conversation_processing / work_items 合成投影。 */
const activeProjection = computed((): ConversationProcessingProjection | null => (
@@ -81,6 +88,31 @@ const hasContent = computed(() => Boolean(
));
const completedTasks = computed(() => activeProjection.value?.completed || []);
const historyTasks = computed(() => activeProjection.value?.history || []);
/** history 中非取消 →「历史版本」。 */
const historyVersionTasks = computed(() => historyTasks.value.filter(
(task) => String(task.status_label || '').trim().toLowerCase() !== 'cancelled',
));
/** history 中明确 cancelled →「已取消」。 */
const cancelledHistoryTasks = computed(() => historyTasks.value.filter(
(task) => String(task.status_label || '').trim().toLowerCase() === 'cancelled',
));
/** 处理记录标题计数:当前返回的 completed + history。 */
const recordTaskCount = computed(() => (
completedTasks.value.length + historyTasks.value.length
));
/**
* history 未返回条数:summary.history - 当前 history[];不可靠时为 0(不猜数)。
*/
const hiddenHistoryCount = computed(() => {
const summaryTotal = Number(activeProjection.value?.summary?.history || 0);
if (!Number.isFinite(summaryTotal) || summaryTotal <= 0) return 0;
return Math.max(0, summaryTotal - historyTasks.value.length);
});
const focusedTaskNo = computed(() => resolveFocusedTask(uiState, {
serverFocusedTaskNo: activeProjection.value?.focused_task_no,
@@ -106,6 +138,7 @@ watch(
(next, prev) => {
if (next === prev) return;
resetConversationProcessingUiState(uiState);
historySectionExpanded.value = false;
},
);
@@ -151,48 +184,35 @@ function isMultiDocumentTask(task: ConversationProcessingUserTask): boolean {
function canExpandFileDetails(task: ConversationProcessingUserTask): boolean {
if (isMultiDocumentTask(task)) return true;
const objects = Array.isArray(task.objects) ? task.objects : [];
return objects.length > 1;
return objects.length > 0;
}
/**
* UI-05:仅聚焦且非已完成卡展开完整进度;未聚焦显示紧凑单行;已完成默认不展进度。
* 活跃卡进度:聚焦全量 / 未聚焦紧凑;处理记录(completed/history)永不展实时进度。
*/
function progressModeForTask(task: ConversationProcessingUserTask): 'full' | 'compact' | 'hidden' {
if (!projectionForTask(task)) return 'hidden';
const group = String(task.group || '').trim();
if (group === 'completed' || group === 'history') return 'hidden';
const focused = focusedTaskNo.value === task.user_task_no;
const completed = String(task.group || '').trim() === 'completed'
|| String(task.status_label || '').trim().toLowerCase() === 'completed';
if (completed && !focused) return 'hidden';
if (focused) return 'full';
return 'compact';
}
/**
* 任务主标题:单 PDF 用文件名;多 PDF 用 i18n「订单识别任务」;禁止 OT/Run 编号。
* 任务主标题:统一「订单识别任务」;禁止用 filename / task.title / OT 编号。
*/
function taskLabel(task: ConversationProcessingUserTask): string {
if (isMultiDocumentTask(task)) {
return t('chat.shippingProcessing.multiPdfTaskTitle');
}
const title = String(task.title || '').trim();
if (title) return title;
return t('chat.shippingProcessing.unnamedPdf');
function taskLabel(_task: ConversationProcessingUserTask): string {
return t('chat.shippingProcessing.multiPdfTaskTitle');
}
/**
* 多 PDF 副标题:前两个文件名;超过两个时追加「等 N 个 PDF」。
* 主文件副标题:有主文件名时渲染「主文件:{name}」。
*/
function documentNamesPreview(task: ConversationProcessingUserTask): string {
const names = (Array.isArray(task.document_names) ? task.document_names : [])
.map((name) => String(name || '').trim())
.filter(Boolean);
if (names.length <= 1) return '';
const head = names.slice(0, 2).join(t('chat.shippingProcessing.multiPdfNameSeparator'));
if (names.length === 2) return head;
return t('chat.shippingProcessing.multiPdfNamesMore', {
names: head,
count: names.length,
});
function primaryFileLabel(task: ConversationProcessingUserTask): string {
const name = getPrimaryDocumentName(task);
if (!name) return '';
return t('chat.shippingProcessing.primaryFile', { name });
}
/**
@@ -214,32 +234,6 @@ function statusLabel(task: ConversationProcessingUserTask): string {
return resolveShippingProcessingStatusLabel(String(task.status_label || ''), te, t);
}
/**
* 最近活动时间:当天仅时分;昨天带「昨天」;更早带月日。
*/
function activityLabel(task: ConversationProcessingUserTask): string {
const raw = String(task.last_activity_at || '').trim();
if (!raw) return '';
const date = new Date(raw);
if (Number.isNaN(date.getTime())) return '';
const hh = String(date.getHours()).padStart(2, '0');
const mm = String(date.getMinutes()).padStart(2, '0');
const time = `${hh}:${mm}`;
const now = new Date();
const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const startOfTarget = new Date(date.getFullYear(), date.getMonth(), date.getDate());
const dayDiff = Math.round((startOfToday.getTime() - startOfTarget.getTime()) / 86400000);
if (dayDiff === 0) {
return t('chat.shippingProcessing.updatedAt', { time });
}
if (dayDiff === 1) {
return t('chat.shippingProcessing.updatedYesterday', { time });
}
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return t('chat.shippingProcessing.updatedOnDate', { date: `${month}-${day}`, time });
}
/**
* 是否高亮 needs_action 任务。
*/
@@ -258,81 +252,141 @@ function isDetailsExpanded(task: ConversationProcessingUserTask): boolean {
}
/**
* 任务级可见操作:只展示后端权威动作中的业务入口。
* 解析任务卡 ActionPresentation(cancel/view_details 不作主 CTA)。
*/
function visibleTaskActions(task: ConversationProcessingUserTask): string[] {
const actions = Array.isArray(task.available_actions) ? task.available_actions : [];
const preferred = [
'view_details',
'open_review',
'enter_manual_review',
'retry_failed_documents',
'retry_failed_attachments',
'cancel_task',
'cancel_run',
];
const seen = new Set<string>();
const result: string[] = [];
for (const code of preferred) {
if (!actions.includes(code) || seen.has(code)) continue;
// 别名去重:只保留一套展示
if (code === 'open_review' && seen.has('enter_manual_review')) continue;
if (code === 'enter_manual_review' && seen.has('open_review')) continue;
if (code === 'retry_failed_documents' && seen.has('retry_failed_attachments')) continue;
if (code === 'retry_failed_attachments' && seen.has('retry_failed_documents')) continue;
if (code === 'cancel_task' && seen.has('cancel_run')) continue;
if (code === 'cancel_run' && seen.has('cancel_task')) continue;
seen.add(code);
result.push(code);
}
return result;
function taskActionPresentation(task: ConversationProcessingUserTask): ActionPresentation {
return resolveConversationTaskActionPresentation(task, { surface: 'right' });
}
/**
* 动作按钮文案:任务级取消在多 PDF 时明确为「取消整个任务」。
* 唯一主 CTA(实心按钮);处理记录只读卡不调用。
*/
function actionLabel(task: ConversationProcessingUserTask, action: string): string {
const code = String(action || '').trim();
function primaryActionItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
return taskActionPresentation(task).primary;
}
/**
* 次要文字链:有文件对象时可展开 → 不返回 view_details(改由展开文件入口承载);
* 无文件对象时优先 view_details,否则取非 cancel 的 presentation.secondary。
*/
function secondaryActionItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
if (canExpandFileDetails(task)) return null;
const presentation = taskActionPresentation(task);
const candidates = [
presentation.secondary,
...presentation.overflow,
].filter((item): item is ActionPresentationItem => Boolean(item));
const viewDetails = candidates.find(
(item) => String(item.actionCode || '').trim().toLowerCase() === 'view_details',
);
if (viewDetails) return viewDetails;
const secondary = presentation.secondary;
if (!secondary) return null;
const code = String(secondary.actionCode || '').trim().toLowerCase();
if (code === 'cancel_task' || code === 'cancel_run' || code === 'view_details') return null;
return secondary;
}
/**
* 低频溢出动作:排除已展示的主/次 CTA 与 view_details。
*/
function overflowActionItems(task: ConversationProcessingUserTask): ActionPresentationItem[] {
const presentation = taskActionPresentation(task);
const shown = new Set(
[primaryActionItem(task)?.actionCode, secondaryActionItem(task)?.actionCode]
.map((code) => String(code || '').trim().toLowerCase())
.filter(Boolean),
);
shown.add('view_details');
return [presentation.secondary, ...presentation.overflow]
.filter((item): item is ActionPresentationItem => Boolean(item))
.filter((item) => {
const code = String(item.actionCode || '').trim().toLowerCase();
return Boolean(code) && !shown.has(code);
});
}
/**
* 是否展示低频溢出:有文件对象时仅展开后显示;无文件对象时直接挂在卡上(如取消)。
* 有 workItem 时不渲染任务级溢出(动作由进度条负责)。
*/
function shouldShowOverflowActions(task: ConversationProcessingUserTask): boolean {
if (projectionForTask(task)) return false;
if (!overflowActionItems(task).length) return false;
if (canExpandFileDetails(task)) return isDetailsExpanded(task);
return true;
}
/**
* 是否渲染任务级主/次动作区(不含「展开文件详情」文件控制)。
*/
function shouldShowTaskLevelActions(task: ConversationProcessingUserTask): boolean {
if (projectionForTask(task)) return false;
return Boolean(primaryActionItem(task) || secondaryActionItem(task));
}
/**
* 处理记录只读卡:仅保留 view_details 文字链(无主 CTA / 取消 / 重解析)。
*/
function recordViewDetailsItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
const presentation = taskActionPresentation(task);
const candidates = [
presentation.primary,
presentation.secondary,
...presentation.overflow,
].filter((item): item is ActionPresentationItem => Boolean(item));
return candidates.find(
(item) => String(item.actionCode || '').trim().toLowerCase() === 'view_details',
) || null;
}
/**
* 动作按钮文案:优先 presentation labelKey;多 PDF 取消明确为「取消整个任务」。
*/
function presentationActionLabel(task: ConversationProcessingUserTask, item: ActionPresentationItem): string {
const code = String(item.actionCode || '').trim();
if (
(code === 'cancel_task' || code === 'cancel_run')
&& isMultiDocumentTask(task)
) {
return t('chat.shippingProcessing.cancelEntireTask');
}
if (code === 'cancel_task' || code === 'cancel_run') {
return t('chat.shippingProcessing.cancelEntireTaskSingle');
}
const key = String(item.labelKey || '').trim();
if (key && te(key)) return t(key);
const extractionKey = `chat.shippingOrderExtractionAction.${code}`;
if (te(extractionKey)) return t(extractionKey);
const aliases: Record<string, string> = {
open_review: 'chat.shippingOrderExtractionAction.enter_manual_review',
retry_failed_documents: 'chat.shippingOrderExtractionAction.retry_failed_attachments',
};
const alias = aliases[code];
if (alias && te(alias)) return t(alias);
return code;
}
/**
* 执行任务级动作:view_details 展开文件;其余交给父级。
* 执行任务级动作:view_details / focus_task 本地聚焦;其余交给父级。
* 非权威任务号禁止向后端 focus/viewed 写接口。
*/
function onTaskAction(task: ConversationProcessingUserTask, action: string) {
const code = String(action || '').trim();
if (!code) return;
if (code === 'view_details') {
focusTaskManually(uiState, task.user_task_no, { expandDetails: true });
markTaskViewed(uiState, task.user_task_no);
emit('expandFiles', task);
if (code === 'view_details' || code === 'focus_task') {
focusTaskManually(uiState, task.user_task_no, { expandDetails: code === 'view_details' });
if (code === 'view_details') {
markTaskViewed(uiState, task.user_task_no);
emit('expandFiles', task);
}
if (task.user_task_authoritative !== false) {
emit('focus', task.user_task_no);
emit('viewed', task.user_task_no);
if (code === 'view_details') emit('viewed', task.user_task_no);
}
return;
}
emit('taskAction', { task, action: code });
}
/**
* 切换处理记录整组折叠。
*/
function toggleHistorySection() {
historySectionExpanded.value = !historySectionExpanded.value;
}
/**
* Intake 材料标题:文件名 / 邮件主题 / Intake 编号。
*/
@@ -516,14 +570,13 @@ 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="activityLabel(task)">{{ activityLabel(task) }}</span>
</div>
<div
v-if="documentNamesPreview(task)"
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-document-names"
data-testid="shipping-processing-task-primary-file"
>
{{ documentNamesPreview(task) }}
{{ primaryFileLabel(task) }}
</div>
<div
v-if="task.recent_append_count"
@@ -546,25 +599,47 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
/>
<div
v-if="visibleTaskActions(task).length && !projectionForTask(task)"
class="mt-1.5 flex flex-wrap gap-1.5"
v-if="shouldShowTaskLevelActions(task) || (!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-for="action in visibleTaskActions(task)"
:key="`${task.user_task_no}-${action}`"
v-if="!projectionForTask(task) && primaryActionItem(task)"
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-action-${action}`"
@click="onTaskAction(task, action)"
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}`"
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
>
{{ actionLabel(task, action) }}
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
</button>
<button
v-if="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"
@click="onToggleDetails(task)"
>
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
<ChevronRight v-else class="h-3 w-3" />
{{ isDetailsExpanded(task)
? t('chat.shippingProcessing.collapseFileDetails')
: t('chat.shippingProcessing.expandFileDetails') }}
</button>
<button
v-else-if="secondaryActionItem(task)"
type="button"
class="text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${secondaryActionItem(task)!.actionCode}`"
@click="onTaskAction(task, secondaryActionItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, secondaryActionItem(task)!) }}
</button>
</div>
<button
v-if="canExpandFileDetails(task)"
v-else-if="canExpandFileDetails(task)"
type="button"
class="mt-1.5 flex items-center gap-1 text-[11px] text-secondary hover:text-primary"
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"
@click="onToggleDetails(task)"
>
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
@@ -573,6 +648,22 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
? t('chat.shippingProcessing.collapseFileDetails')
: t('chat.shippingProcessing.expandFileDetails') }}
</button>
<div
v-if="shouldShowOverflowActions(task)"
class="mt-1.5 flex flex-wrap gap-x-3 gap-y-1"
data-testid="shipping-processing-task-overflow-actions"
>
<button
v-for="item in overflowActionItems(task)"
:key="`${task.user_task_no}-overflow-${item.actionCode}`"
type="button"
class="text-[11px] text-muted underline-offset-2 hover:text-secondary hover:underline"
:data-testid="`shipping-processing-action-${item.actionCode}`"
@click="onTaskAction(task, item.actionCode)"
>
{{ presentationActionLabel(task, item) }}
</button>
</div>
</article>
</div>
</section>
@@ -606,14 +697,13 @@ 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="activityLabel(task)">{{ activityLabel(task) }}</span>
</div>
<div
v-if="documentNamesPreview(task)"
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-document-names"
data-testid="shipping-processing-task-primary-file"
>
{{ documentNamesPreview(task) }}
{{ primaryFileLabel(task) }}
</div>
<div
v-if="task.recent_append_count"
@@ -636,25 +726,47 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
/>
<div
v-if="visibleTaskActions(task).length && !projectionForTask(task)"
class="mt-1.5 flex flex-wrap gap-1.5"
v-if="shouldShowTaskLevelActions(task) || (!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-for="action in visibleTaskActions(task)"
:key="`${task.user_task_no}-${action}`"
v-if="!projectionForTask(task) && primaryActionItem(task)"
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-action-${action}`"
@click="onTaskAction(task, action)"
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}`"
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
>
{{ actionLabel(task, action) }}
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
</button>
<button
v-if="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"
@click="onToggleDetails(task)"
>
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
<ChevronRight v-else class="h-3 w-3" />
{{ isDetailsExpanded(task)
? t('chat.shippingProcessing.collapseFileDetails')
: t('chat.shippingProcessing.expandFileDetails') }}
</button>
<button
v-else-if="secondaryActionItem(task)"
type="button"
class="text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${secondaryActionItem(task)!.actionCode}`"
@click="onTaskAction(task, secondaryActionItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, secondaryActionItem(task)!) }}
</button>
</div>
<button
v-if="canExpandFileDetails(task)"
v-else-if="canExpandFileDetails(task)"
type="button"
class="mt-1.5 flex items-center gap-1 text-[11px] text-secondary hover:text-primary"
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"
@click="onToggleDetails(task)"
>
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
@@ -663,85 +775,197 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
? t('chat.shippingProcessing.collapseFileDetails')
: t('chat.shippingProcessing.expandFileDetails') }}
</button>
<div
v-if="shouldShowOverflowActions(task)"
class="mt-1.5 flex flex-wrap gap-x-3 gap-y-1"
data-testid="shipping-processing-task-overflow-actions"
>
<button
v-for="item in overflowActionItems(task)"
:key="`${task.user_task_no}-overflow-${item.actionCode}`"
type="button"
class="text-[11px] text-muted underline-offset-2 hover:text-secondary hover:underline"
:data-testid="`shipping-processing-action-${item.actionCode}`"
@click="onTaskAction(task, item.actionCode)"
>
{{ presentationActionLabel(task, item) }}
</button>
</div>
</article>
</div>
</section>
<section
v-if="completedTasks.length"
data-testid="shipping-processing-group-completed"
v-if="recordTaskCount > 0"
data-testid="shipping-processing-group-history"
>
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-emerald-700 dark:text-emerald-300">
{{ resolveShippingProcessingMessage('groupCompleted', te, t, { count: completedTasks.length }) }}
</div>
<div class="space-y-2">
<article
v-for="task in completedTasks"
:key="task.user_task_no"
class="rounded-lg border border-default bg-surface px-2.5 py-2"
:class="focusedTaskNo === task.user_task_no
? 'ring-1 ring-brand-400'
: ''"
:data-testid="`shipping-processing-task-${task.user_task_no}`"
:data-focused="focusedTaskNo === task.user_task_no ? '1' : '0'"
<button
type="button"
class="mb-1.5 flex w-full items-center justify-between gap-2 text-left text-[11px] font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-300"
data-testid="shipping-processing-history-toggle"
@click="toggleHistorySection"
>
<span class="inline-flex min-w-0 items-center gap-1">
<ChevronDown v-if="historySectionExpanded" class="h-3 w-3 shrink-0" />
<ChevronRight v-else class="h-3 w-3 shrink-0" />
<span>{{ resolveShippingProcessingMessage('groupProcessingRecords', te, t, { count: recordTaskCount }) }}</span>
</span>
<span
v-if="hiddenHistoryCount > 0"
class="shrink-0 font-medium normal-case tracking-normal text-muted"
data-testid="shipping-processing-history-more"
>
<button
type="button"
class="w-full text-left"
@click="onSelectTask(task)"
>
<div class="text-sm font-semibold text-primary">
{{ 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">
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
<span>{{ statusLabel(task) }}</span>
<span v-if="activityLabel(task)">{{ activityLabel(task) }}</span>
</div>
<div
v-if="documentNamesPreview(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-document-names"
>
{{ documentNamesPreview(task) }}
</div>
</button>
<SidebarProgressInline
v-if="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="visibleTaskActions(task).length && !projectionForTask(task)"
class="mt-1.5 flex flex-wrap gap-1.5"
data-testid="shipping-processing-task-actions"
>
<button
v-for="action in visibleTaskActions(task)"
:key="`${task.user_task_no}-${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-action-${action}`"
@click="onTaskAction(task, action)"
>
{{ actionLabel(task, action) }}
</button>
{{ t('chat.shippingProcessing.historyMoreCount', { count: hiddenHistoryCount }) }}
</span>
</button>
<div
v-if="historySectionExpanded"
class="space-y-3"
data-testid="shipping-processing-history-body"
>
<div
v-if="completedTasks.length"
data-testid="shipping-processing-history-completed"
>
<div class="mb-1 text-[11px] font-medium text-emerald-700 dark:text-emerald-300">
{{ resolveShippingProcessingMessage('groupRecordCompleted', te, t) }}
</div>
<button
v-if="canExpandFileDetails(task)"
type="button"
class="mt-1.5 flex items-center gap-1 text-[11px] text-secondary hover:text-primary"
@click="onToggleDetails(task)"
>
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
<ChevronRight v-else class="h-3 w-3" />
{{ isDetailsExpanded(task)
? t('chat.shippingProcessing.collapseFileDetails')
: t('chat.shippingProcessing.expandFileDetails') }}
</button>
</article>
<div class="space-y-2">
<article
v-for="task in completedTasks"
: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}`"
data-record="1"
>
<div class="text-sm font-semibold text-primary">
{{ 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">
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
<span>{{ statusLabel(task) }}</span>
</div>
<div
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-primary-file"
>
{{ primaryFileLabel(task) }}
</div>
<button
v-if="recordViewDetailsItem(task)"
type="button"
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
</button>
</article>
</div>
</div>
<div
v-if="historyVersionTasks.length"
data-testid="shipping-processing-history-versions"
>
<div class="mb-1 text-[11px] font-medium text-slate-600 dark:text-slate-300">
{{ resolveShippingProcessingMessage('groupRecordHistoryVersions', te, t) }}
</div>
<div class="space-y-2">
<article
v-for="task in historyVersionTasks"
: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}`"
data-record="1"
>
<div class="text-sm font-semibold text-primary">
{{ 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">
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
<span>{{ statusLabel(task) }}</span>
</div>
<div
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-primary-file"
>
{{ primaryFileLabel(task) }}
</div>
<button
v-if="recordViewDetailsItem(task)"
type="button"
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
</button>
</article>
</div>
</div>
<div
v-if="cancelledHistoryTasks.length"
data-testid="shipping-processing-history-cancelled"
>
<div class="mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400">
{{ resolveShippingProcessingMessage('groupRecordCancelled', te, t) }}
</div>
<div class="space-y-2">
<article
v-for="task in cancelledHistoryTasks"
: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}`"
data-record="1"
>
<div class="text-sm font-semibold text-primary">
{{ 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">
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
<span>{{ statusLabel(task) }}</span>
</div>
<div
v-if="primaryFileLabel(task)"
class="mt-0.5 truncate text-[11px] text-muted"
data-testid="shipping-processing-task-primary-file"
>
{{ primaryFileLabel(task) }}
</div>
<button
v-if="recordViewDetailsItem(task)"
type="button"
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
</button>
</article>
</div>
</div>
<div
v-if="hiddenHistoryCount > 0"
class="text-[11px] text-muted"
data-testid="shipping-processing-history-truncated"
>
{{ t('chat.shippingProcessing.historyTruncatedDetail', {
shown: historyTasks.length,
hidden: hiddenHistoryCount,
}) }}
</div>
<div
v-else-if="hasMoreHistory"
class="text-[11px] text-muted"
data-testid="shipping-processing-history-truncated"
>
{{ t('chat.shippingProcessing.summaryTruncatedHint') }}
</div>
</div>
</section>
</div>
@@ -1,18 +1,15 @@
/**
* features/chat/components/shipping/ShippingOrderExtractionCard.spec.ts
* 用途:覆盖批次进度卡摘要、阶段、健康提醒与刷新/取消/重试动作。
* 用途:覆盖对话区订单识别摘要卡——标题、状态行、handling 一行摘要、唯一主 CTA、查看详情。
* 依赖:Vitest、Vue Test Utils、vue-i18n、本域组件与 DTO 类型。
* 逻辑:断言过程通知、摘要计数、取消确认与重试;逐 PDF 深链仍由右侧面板承担。
* 逻辑:断言不再渲染进度列表/刷新取消/完整 handling 卡片;失败重试与需处理继续处理互斥。
*/
import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import { ref } from 'vue';
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 type { ShippingProcessingProjection } from '../../types/shipping.api.types';
import { SHIPPING_WORKFLOW_KEY } from '../../shipping/useShippingNoticeWorkflow';
const i18n = createI18n({
legacy: false,
@@ -43,7 +40,7 @@ const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): Shipping
userVisibleStage: 'extracting',
elapsedSeconds: 75,
},
availableActions: ['refresh_status', 'cancel_run'],
availableActions: ['refresh_status', 'cancel_run', 'view_details'],
healthTips: [{ code: 'processing_slow', thresholdSeconds: 60, idleOrElapsedSeconds: 90 }],
terminal: false,
refreshFailed: false,
@@ -54,17 +51,23 @@ const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): Shipping
});
describe('ShippingOrderExtractionCard', () => {
it('renders batch summary, current stage, health tip and action buttons', () => {
// 冷启动 transform 较慢时放宽超时,避免首测误伤。
it('renders summary title, file count, system processing and no progress/refresh/cancel', () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: { state: buildState(), runNo: 'SNER-1' },
global: { plugins: [i18n] },
});
expect(wrapper.text()).toContain('PO-450003.pdf');
expect(wrapper.text()).toContain('提取订单字段中');
// 关键断言:对话卡只保留摘要标题与系统处理中状态。
expect(wrapper.text()).toContain('订单识别任务');
expect(wrapper.text()).toContain('3 个文件');
expect(wrapper.text()).toContain('系统处理中');
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');
expect(wrapper.text()).not.toContain('提取订单字段中');
expect(wrapper.findAll('[data-testid="chat-progress-summary-list"]').length).toBe(0);
expect(wrapper.findAll('[data-testid="shipping-order-extraction-summary"]').length).toBe(0);
expect(wrapper.findAll('[data-testid="shipping-order-document-result"]').length).toBe(0);
}, 30_000);
@@ -91,12 +94,12 @@ describe('ShippingOrderExtractionCard', () => {
},
global: { plugins: [i18n] },
});
expect(wrapper.text()).toContain('发现重复文件');
expect(wrapper.text()).toContain('订单识别任务');
expect(wrapper.text()).toContain('已关联已有任务');
expect(wrapper.text()).not.toContain('需人工处理');
});
it('does not label generated candidates as manual-review exceptions', () => {
it('renders candidate confirmation as status notice with continue CTA', () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({
@@ -129,13 +132,14 @@ describe('ShippingOrderExtractionCard', () => {
stubs: { 'router-link': true },
},
});
// 关键断言:成功候选可待人工确认,但绝不能提示为识别异常。
expect(wrapper.text()).toContain('订单候选已生成');
expect(wrapper.text()).toContain('候选待人工确认');
expect(wrapper.text()).toContain('候选待人工确认 · 2 项');
expect(wrapper.text()).toContain('继续处理');
expect(wrapper.text()).not.toContain('部分附件需人工处理');
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
});
it('renders mixed handling items with reasons instead of a vague needs-action notice', () => {
it('renders one handling summary line without per-item actions or affected refs', () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({
@@ -183,17 +187,51 @@ describe('ShippingOrderExtractionCard', () => {
global: { plugins: [i18n] },
});
expect(wrapper.text()).toContain('部分附件处理失败');
expect(wrapper.text()).toContain('订单待补信息');
expect(wrapper.text()).toContain('自动冻结受阻');
expect(wrapper.text()).toContain('文件损坏、加密或无法读取');
expect(wrapper.text()).toContain('影响对象:');
expect(wrapper.text()).toContain('ST-88');
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(3);
// 无统一投影时仍允许 handlingItems 主按钮(过渡兜底)。
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-primary-action"]').length).toBeGreaterThan(0);
expect(wrapper.text()).toContain('附件处理失败 · 3 项');
expect(wrapper.text()).not.toContain('订单待补信息');
expect(wrapper.text()).not.toContain('影响对象:');
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('重试解析');
});
it('hides handling primary actions when unified processing projection is present (UI-01)', () => {
it('shows continue CTA for review-required without retry', () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({
status: 'review_required',
availableActions: ['enter_manual_review', 'view_details'],
primaryNotice: 'candidate_confirmation',
handlingItems: [{
category: 'candidate_confirmation',
count: 1,
reasonCodes: [],
affectedRefs: [],
primaryAction: 'review_candidate',
}],
healthTips: [],
currentActivity: null,
summary: {
totalDocuments: 1,
pendingDocuments: 0,
processingDocuments: 0,
completedDocuments: 1,
reviewRequiredDocuments: 1,
failedDocuments: 0,
candidateCount: 1,
},
}),
runNo: 'SNER-REVIEW',
},
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').text()).toContain('继续处理');
expect(wrapper.text()).not.toContain('重试解析');
});
it('does not render multi-OT ChatProgressSummary list', () => {
const projection = {
workItemType: 'order_task' as const,
workItemNo: 'OT-UI01',
@@ -228,134 +266,36 @@ describe('ShippingOrderExtractionCard', () => {
userTaskNo: 'OT-UI01',
availableActions: ['review_candidate', 'view_details'],
primaryNotice: 'candidate_confirmation',
handlingItems: [
{
category: 'candidate_confirmation',
count: 1,
reasonCodes: [],
affectedRefs: [],
primaryAction: 'review_candidate',
},
{
category: 'parse_failed',
count: 1,
reasonCodes: ['layout_failed'],
affectedRefs: [],
primaryAction: 'retry_failed_documents',
},
],
handlingItems: [{
category: 'candidate_confirmation',
count: 1,
reasonCodes: [],
affectedRefs: [],
primaryAction: 'review_candidate',
}],
healthTips: [],
currentActivity: null,
summary: {
totalDocuments: 1,
pendingDocuments: 0,
processingDocuments: 0,
completedDocuments: 1,
reviewRequiredDocuments: 1,
failedDocuments: 0,
candidateCount: 1,
},
}),
runNo: 'SNER-UI01',
processingProjection: projection,
},
global: {
plugins: [i18n],
stubs: {
ChatProgressSummary: true,
ProcessGateRecoveryCard: true,
'router-link': true,
},
},
});
// 主操作只来自投影 Presenter;已被 Gate/进度表达的 handling 项不重复列出。
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-primary-action"]').length).toBe(0);
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(1);
});
it('renders one unified progress summary for each PDF under the same root task', () => {
const buildWorkItem = (
taskNo: string,
filename: string,
documentId: number,
): ShippingProcessingProjection => ({
workItemType: 'order_task',
workItemNo: taskNo,
sourceType: 'direct_pdf',
rootOrderTaskNo: 'OT-ROOT',
shippingNoticeNo: null,
conversationId: 'conv-1',
submissionNo: 'SUB-1',
intakeNo: 'INT-1',
status: 'processing',
stage: 'document_parsing',
progressVersion: 1,
lastActivityAt: '2026-08-06T00:00:00Z',
currentGate: null,
availableActions: ['view_details'],
sourceSummary: {
emailSubject: null,
filename,
documentId,
documentCount: 1,
parsedDocumentCount: 1,
candidateCount: 1,
customerName: null,
poNumber: null,
},
childOrderTasks: [],
});
const workItems = [
buildWorkItem('OT-ROOT', 'PO-001.pdf', 1),
buildWorkItem('OT-CHILD', 'PO-002.pdf', 2),
];
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({ userTaskNo: 'OT-ROOT' }),
runNo: 'SNER-MULTI-PDF',
},
global: {
plugins: [i18n],
provide: {
[SHIPPING_WORKFLOW_KEY as symbol]: {
processing: ref(null),
processingWorkItems: ref(workItems),
loading: ref(false),
error: ref(null),
refresh: async () => undefined,
focusConversationTask: async () => undefined,
markConversationTaskViewed: async () => undefined,
stop: () => undefined,
},
},
stubs: {
ChatProgressSummary: {
props: ['projection'],
template: '<div data-testid="chat-progress-summary">{{ projection.workItemNo }}</div>',
},
ProcessGateRecoveryCard: true,
},
},
});
expect(wrapper.findAll('[data-testid="chat-progress-summary"]')).toHaveLength(2);
expect(wrapper.text()).toContain('PO-001.pdf');
expect(wrapper.text()).toContain('PO-002.pdf');
});
it('emits cancel after confirmation', async () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({
availableActions: ['cancel_run', 'refresh_status'],
}),
runNo: 'SNER-1',
},
global: { plugins: [i18n] },
});
const cancelBtn = wrapper.findAll('button').find((b) => b.text().includes('取消本次识别'));
expect(cancelBtn).toBeTruthy();
await cancelBtn!.trigger('click');
expect(wrapper.text()).toContain('确认取消本次识别');
const textarea = wrapper.find('textarea');
await textarea.setValue('不再需要识别');
const confirmBtn = wrapper.findAll('button').find((b) => b.text() === '取消本次识别');
await confirmBtn!.trigger('click');
expect(wrapper.emitted('cancel')?.[0]).toEqual(['不再需要识别']);
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('继续处理');
});
it('emits retry for failed attachments', async () => {
it('emits retry for failed attachments via primary CTA', async () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({
@@ -375,8 +315,26 @@ describe('ShippingOrderExtractionCard', () => {
},
global: { plugins: [i18n] },
});
const retryBtn = wrapper.findAll('button').find((b) => b.text().includes('重试失败附件'));
await retryBtn!.trigger('click');
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);
});
it('keeps view details as secondary text link only', () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({
availableActions: ['view_details'],
healthTips: [],
}),
runNo: 'SNER-1',
},
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(wrapper.findAll('[data-testid="shipping-order-extraction-primary-action"]').length).toBe(0);
});
});
@@ -1,19 +1,14 @@
/**
* features/chat/components/shipping/ShippingOrderExtractionCard.vue
* 用途:聊天主区批次进度卡——摘要计数、Run 级诊断事项、当前文件阶段、健康提醒与动作。
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、
* orderExtractionProgressDisplay、vue-router、vue-i18n、ChatProgressSummary;
* ProcessGateRecoveryCard 仅兼容保留(runLevelProcessGate 当前恒为空)。
* 逻辑:有统一投影时按当前 Run 根 OT 展示全部 PDF/OT 紧凑进度,主操作仅来自投影;
* handlingItems 保留诊断信息,不再渲染与投影平级的 primaryAction 主按钮;
* Run 失败优先展示 errorExplainability.message;详情抽屉证据入口携带 focus+document_id。
* 用途:聊天主区「订单识别任务」摘要卡——标题、文件数+状态、一行 handling 摘要、唯一主 CTA、查看详情。
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、vue-router、vue-i18n。
* 逻辑:对话区只做任务摘要;长进度/Gate/刷新取消由右侧栏承接;详情抽屉仅由次要「查看详情」打开。
*/
<script setup lang="ts">
import { computed, inject, ref } from 'vue';
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { CircleCheck, CircleX, LoaderCircle, TriangleAlert } from 'lucide-vue-next';
import { CHAT_PAGE_KEY } from '@/features/chat/composables/chat.context';
import type {
ShippingOrderExtractionHandlingItemState,
ShippingOrderExtractionState,
@@ -21,28 +16,12 @@ import type {
import type {
ShippingOrderExtractionDocumentResult,
ShippingOrderExtractionProgressEvent,
ShippingProcessGateUserSummary,
} from '../../types/shipping.api.types';
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
import ChatProgressSummary from '@/features/shipping-progress/components/ChatProgressSummary.vue';
import {
SHIPPING_WORKFLOW_KEY,
} from '@/features/chat/shipping/useShippingNoticeWorkflow';
import type { ShippingProcessingProjection } from '../../types/shipping.api.types';
import type { ActionPresentationItem } from '@/features/shipping-progress/types';
import {
listWorkspaceShippingOrderExtractionDocuments,
listWorkspaceShippingOrderExtractionProgressEvents,
} from '../../api/shipping.api';
import {
formatOrderExtractionElapsed,
resolveOrderExtractionUserStageKey,
} from '../../shipping/orderExtractionProgressDisplay';
import {
listDisplayableHandlingAffectedRefs,
type ShippingHandlingAffectedRef,
type ShippingHandlingRefTarget,
} from '../../shipping/orderExtractionHandlingRefs';
import ShippingOrderExtractionDetailsDrawer from './ShippingOrderExtractionDetailsDrawer.vue';
const props = defineProps<{
@@ -54,7 +33,7 @@ const props = defineProps<{
/** 新版 Run 已替代旧版时,历史卡仅允许查看详情。 */
readonly?: boolean;
readonlyReason?: string | null;
/** 可选统一投影;缺省时从 SHIPPING_WORKFLOW_KEY 解析。 */
/** 可选统一投影;摘要卡不再渲染进度,仅保留 prop 兼容宿主。 */
processingProjection?: ShippingProcessingProjection | null;
}>();
@@ -67,74 +46,6 @@ const emit = defineEmits<{
const { t, te } = useI18n();
const route = useRoute();
const router = useRouter();
const chatPage = inject(CHAT_PAGE_KEY, null);
const shippingWorkflow = inject(SHIPPING_WORKFLOW_KEY, null);
/**
* 解析当前 Run/任务对应的全部统一 ShippingProcessing 投影。
* 核心逻辑:显式 prop 优先;根 OT 同时匹配自身与 rootOrderTaskNo 相同的兄弟 OT;
* Candidate 前回退本会话 order_intake,禁止用 find() 丢失同 Run 的其他 PDF。
*/
const resolvedProcessingProjections = computed((): ShippingProcessingProjection[] => {
if (props.processingProjection) return [props.processingProjection];
const items = shippingWorkflow?.processingWorkItems?.value || [];
if (!items.length) return [];
const taskNo = String(props.state.userTaskNo || '').trim();
if (taskNo) {
const matched = items.filter((item) => (
item.workItemType === 'order_task'
&& (
String(item.workItemNo || '').trim() === taskNo
|| String(item.rootOrderTaskNo || '').trim() === taskNo
)
));
if (matched.length) return matched;
}
return items.filter((item) => item.workItemType === 'order_intake');
});
const hasProcessingProjection = computed(() => resolvedProcessingProjections.value.length > 0);
/** 进度行标题优先使用 PDF 文件名,其次使用 PO,最后使用工作项号。 */
function processingProjectionTitle(item: ShippingProcessingProjection): string {
return String(
item.sourceSummary?.filename
|| item.sourceSummary?.poNumber
|| item.workItemNo,
).trim();
}
/**
* 统一进度摘要动作:刷新 / 进入复核等由宿主路由承接。
*/
function onChatProgressAction(item: ActionPresentationItem) {
if (item.intent === 'refresh') {
emit('refresh');
return;
}
if (item.intent === 'open_order_review') {
void openOrderReview();
}
}
const confirmCancelOpen = ref(false);
const cancelReason = ref('');
/**
* Gate 恢复卡「确认客户」:打开对话叠层客户选择弹窗。
*/
async function onGateConfirmCustomer(taskNo: string) {
await chatPage?.openShippingCustomerDialog?.(taskNo);
}
/**
* Run 级阻断 Gate:co8 后不再从 Workflow items 读取;由复核/Gate 主路径承接。
*/
const runLevelProcessGate = computed((): ShippingProcessGateUserSummary | null => null);
const gateNavigationContext = computed(() => ({
agentId: String(route.params.agentId || ''),
conversationId: String(route.query.conversation_id || ''),
}));
const detailsOpen = ref(false);
const detailsLoading = ref(false);
@@ -146,24 +57,7 @@ const progressEvents = ref<ShippingOrderExtractionProgressEvent[]>([]);
const displaySummary = computed(() => props.state.summary);
const workflowStageLabel = computed(() => '');
const workflowLastActivityLabel = computed(() => '');
const handlingItems = computed(() => {
const items = props.state.handlingItems || [];
// [UI-04] 有 OT 统一投影时,隐藏已被 Gate/进度表达的复核类事项,仅保留未归属异常。
if (!hasProcessingProjection.value) return items;
const covered = new Set([
'manual_review',
'field_conflict',
'customer_confirmation',
'candidate_confirmation',
'duplicate_check',
'inventory_source',
'review_required',
]);
return items.filter((item) => !covered.has(String(item.category || '').trim()));
});
const handlingItems = computed(() => props.state.handlingItems || []);
/**
* 是否为「仅重复关联已有任务、无需人工复核」终态通知。
@@ -178,7 +72,7 @@ const isDuplicateOnlyNotice = computed(() => {
});
/**
* 是否为纯候选确认场景;优先信任后端 primary_notice,避免用摘要计数掩盖混合原因。
* 是否为纯候选确认场景;优先信任后端 primary_notice。
*/
const isCandidateConfirmationNotice = computed(() => (
props.state.primaryNotice === 'candidate_confirmation'
@@ -210,18 +104,6 @@ const toneClass = computed(() => {
}
});
const stageLabel = computed(() => {
const key = resolveOrderExtractionUserStageKey(
props.state.currentActivity?.userVisibleStage || props.state.userVisibleStage,
props.state.currentActivity?.eventCode || props.state.status,
);
return te(key) ? t(key) : '';
});
const elapsedLabel = computed(() =>
formatOrderExtractionElapsed(props.state.currentActivity?.elapsedSeconds),
);
/**
* 将处理事项类别映射为一句过程通知文案。
* @param category - 后端 primary_notice / handling item category
@@ -232,12 +114,24 @@ function noticeForCategory(category: string): string {
}
/**
* 一句过程通知;有 handling_items 时以后端类别为准,不再笼统写「需人工处理」。
* 解析处理事项标题。
* @param item - 后端 handling item
*/
const compactLine = computed(() => {
function handlingTitle(item: ShippingOrderExtractionHandlingItemState): string {
const key = `chat.shippingOrderExtractionHandling.category.${item.category}`;
return te(key) ? t(key) : item.category;
}
/**
* 状态短句:排队/处理中仅「系统处理中」;其余用过程通知,不含文件阶段耗时。
*/
const statusNotice = computed(() => {
if (props.state.cancellation?.requested && !props.state.cancellation?.completedAt && !props.state.terminal) {
return t('chat.shippingOrderExtractionUserStage.cancellation_requested');
}
if (props.state.status === 'queued' || props.state.status === 'processing') {
return t('chat.shippingProcessing.systemProcessing');
}
if (isDuplicateOnlyNotice.value) {
return t('chat.shippingSessionSummary.processNoticeDuplicateLinked');
}
@@ -258,78 +152,78 @@ const compactLine = computed(() => {
if (explained) return explained;
return t('chat.shippingSessionSummary.processNoticeFailed');
}
default: {
if (props.state.status === 'queued' || props.state.status === 'processing') {
const parts: string[] = [];
const fileName = String(props.state.currentActivity?.fileName || '').trim();
if (fileName) {
parts.push(t('chat.shippingOrderExtractionCurrentFile', {
fileName: fileName || t('chat.shippingOrderExtractionUnknownDocument'),
}));
}
const stage = stageLabel.value;
if (stage) parts.push(stage);
const elapsed = elapsedLabel.value;
if (elapsed) parts.push(t('chat.shippingOrderExtractionElapsed', { elapsed }));
if (parts.length) return parts.join(' · ');
}
default:
return t('chat.shippingSessionSummary.processNoticeProcessing');
}
}
});
const activityKey = computed(() => {
const code = String(props.state.currentActivity?.eventCode || '').trim();
const key = `chat.shippingOrderExtractionActivity.${code}`;
return code && te(key) ? key : '';
/**
* 文件数 + 状态一行:`N 个文件 · 系统处理中`(或终态通知)。
*/
const statusLine = computed(() => {
const count = Math.max(0, Number(displaySummary.value.totalDocuments || 0));
const status = statusNotice.value;
if (count <= 0) return status;
return `${t('chat.shippingProcessing.taskFiles', { count })} · ${status}`;
});
/**
* 一行 handling 摘要(无操作按钮);无事项时为空。
*/
const handlingSummaryLine = computed(() => {
const items = handlingItems.value;
if (!items.length) return '';
const first = items[0];
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;
return t('chat.shippingOrderExtractionHandling.summaryLine', {
title: handlingTitle(first),
count,
});
});
/**
* 唯一主 CTA:失败→重试解析;需处理→继续处理;否则不展示。
*/
const primaryChatAction = computed((): { kind: 'retry' | 'continue'; label: string } | null => {
if (props.readonly) return null;
const actions = props.state.availableActions || [];
const canRetry = actions.includes('retry_failed_attachments')
|| actions.includes('retry_failed_documents')
|| displaySummary.value.failedDocuments > 0
|| props.state.status === 'failed';
if (canRetry) {
return {
kind: 'retry',
label: t('chat.shippingNoticeRetryParse'),
};
}
const needsContinue = actions.includes('enter_manual_review')
|| actions.includes('review_candidate')
|| actions.includes('open_order_review')
|| actions.includes('open_order_processing')
|| props.state.status === 'review_required'
|| props.state.status === 'partially_completed'
|| isCandidateConfirmationNotice.value;
if (needsContinue) {
return {
kind: 'continue',
label: t('chat.shippingProcessing.continueProcessing'),
};
}
return null;
});
const showRetry = computed(() => (
!props.readonly && (
props.state.availableActions.includes('retry_failed_attachments')
|| displaySummary.value.failedDocuments > 0
)
));
const showRefresh = computed(() => !props.readonly && props.state.availableActions.includes('refresh_status'));
const showCancel = computed(() => (
!props.readonly
&&
props.state.availableActions.includes('cancel_run')
&& !(props.state.cancellation?.requested && !props.state.cancellation?.completedAt)
));
const healthTips = computed(() => props.state.healthTips || []);
/**
* 解析处理事项标题。
* @param item - 后端 handling item
*/
function handlingTitle(item: ShippingOrderExtractionHandlingItemState): string {
const key = `chat.shippingOrderExtractionHandling.category.${item.category}`;
return te(key) ? t(key) : item.category;
}
/**
* 解析原因码文案;未知或内部技术码统一回退为可执行的业务提示。
* @param code - 原因码
*/
function reasonLabel(code: string): string {
const normalized = String(code || '').trim();
if (!normalized) return '';
const key = `chat.shippingOrderExtractionReason.${normalized}`;
if (te(key)) return t(key);
const freezeKey = `chat.shippingOrderExtractionHandling.reason.${normalized}`;
return te(freezeKey) ? t(freezeKey) : t('chat.shippingOrderExtractionReasonUnknown');
}
/**
* 打开订单复核工作台(Chat order-review 模式)。
* @param options.documentId - 可选,定位到具体 PDF
* @param options.candidateNo - 可选,写入 query 供复核页筛选
* @param options.focus - evidence=证据区;draft=草稿复核(默认)
*/
async function openOrderReview(options?: {
documentId?: number;
candidateNo?: string;
focus?: 'evidence' | 'draft';
}) {
const runNo = String(props.runNo || '').trim();
@@ -341,8 +235,6 @@ async function openOrderReview(options?: {
mode: 'order-review',
run_no: runNo,
};
const candidateNo = String(options?.candidateNo || '').trim();
if (candidateNo) query.candidate = candidateNo;
const documentId = Number(options?.documentId || 0);
if (documentId > 0) query.document_id = String(documentId);
const focus = options?.focus === 'evidence' || options?.focus === 'draft'
@@ -441,87 +333,15 @@ async function enterReviewFromDetails(payload?: { focus?: 'evidence' | 'draft';
}
/**
* 在对话侧聚焦 Task(双工作台主路径);Task 工作台仅作备用深链。
* 执行唯一主 CTA:重试解析或进入订单处理。
*/
async function focusTaskInChat(taskNo: string) {
const normalized = String(taskNo || '').trim();
if (!normalized) return;
const conversationId = String(route.query.conversation_id || '').trim();
await router.replace({
name: 'Chat',
params: { agentId: String(route.params.agentId || '') },
query: {
...route.query,
conversation_id: conversationId || undefined,
focus_task_no: normalized,
},
});
}
/**
* 按受影响对象引用跳转到对话聚焦或复核入口。
*/
async function openAffectedRef(target: ShippingHandlingRefTarget) {
if (target.kind === 'chat_focus_task') {
await focusTaskInChat(target.taskNo);
return;
}
if (target.kind === 'review') {
await openOrderReview({
documentId: target.documentId,
candidateNo: target.candidateNo,
focus: 'draft',
});
}
}
/**
* 列出事项下可展示的受影响对象。
*/
function affectedRows(item: ShippingOrderExtractionHandlingItemState) {
return listDisplayableHandlingAffectedRefs(item.affectedRefs as ShippingHandlingAffectedRef[]);
}
/**
* 按处理事项主动作跳转或触发重试;优先跳到首个受影响对象。
* @param item - 处理事项
*/
async function handleHandlingAction(item: ShippingOrderExtractionHandlingItemState) {
if (props.readonly) return;
const action = String(item.primaryAction || '').trim();
if (action === 'retry_failed_attachments') {
async function onPrimaryChatAction() {
if (!primaryChatAction.value || props.readonly) return;
if (primaryChatAction.value.kind === 'retry') {
emit('retry');
return;
}
const first = affectedRows(item)[0];
if (first && first.target.kind !== 'none') {
await openAffectedRef(first.target);
return;
}
if (action === 'view_details') {
await openDetailsDrawer();
return;
}
if (action === 'enter_manual_review' || action === 'review_candidate') {
await openOrderReview({ focus: 'draft' });
}
}
/**
* 确认后发出取消事件;取消是请求语义,由后端检查点生效。
*/
function confirmCancel() {
confirmCancelOpen.value = false;
const reason = String(cancelReason.value || '').trim();
cancelReason.value = '';
emit('cancel', reason || undefined);
}
/** 打开取消确认并清空上次填写的原因。 */
function openCancelConfirm() {
if (props.readonly) return;
cancelReason.value = '';
confirmCancelOpen.value = true;
await openOrderReview({ focus: 'draft' });
}
</script>
@@ -554,7 +374,21 @@ function openCancelConfirm() {
>
{{ t('chat.shippingOrderExtractionHistory.superseded') }}
</div>
<div class="text-sm font-medium">{{ compactLine }}</div>
<div
class="text-sm font-medium"
data-testid="shipping-order-extraction-title"
>
{{ t('chat.shippingProcessing.multiPdfTaskTitle') }}
</div>
<div
class="mt-0.5 text-xs opacity-90"
data-testid="shipping-order-extraction-status-line"
>
{{ statusLine }}
</div>
<p
v-if="state.errorExplainability?.request_id"
class="mt-1 text-[11px] opacity-80"
@@ -564,134 +398,11 @@ function openCancelConfirm() {
</p>
<div
v-if="displaySummary.totalDocuments > 0"
class="mt-1.5 flex flex-wrap gap-1.5 text-[11px] opacity-90"
data-testid="shipping-order-extraction-summary"
v-if="handlingSummaryLine"
class="mt-1.5 text-xs opacity-90"
data-testid="shipping-order-extraction-handling-summary"
>
<span>{{ t('chat.shippingOrderExtractionSummary.total', { count: displaySummary.totalDocuments }) }}</span>
<span v-if="displaySummary.processingDocuments > 0">
{{ t('chat.shippingOrderExtractionSummary.processing', { count: displaySummary.processingDocuments }) }}
</span>
<span v-if="displaySummary.pendingDocuments > 0">
{{ t('chat.shippingOrderExtractionSummary.pending', { count: displaySummary.pendingDocuments }) }}
</span>
<span v-if="displaySummary.completedDocuments > 0">
{{ t('chat.shippingOrderExtractionSummary.completed', { count: displaySummary.completedDocuments }) }}
</span>
<span v-if="displaySummary.reviewRequiredDocuments > 0">
{{ t('chat.shippingOrderExtractionSummary.reviewRequired', { count: displaySummary.reviewRequiredDocuments }) }}
</span>
<span v-if="displaySummary.failedDocuments > 0">
{{ t('chat.shippingOrderExtractionSummary.failed', { count: displaySummary.failedDocuments }) }}
</span>
<span v-if="(displaySummary.cancelledDocuments || 0) > 0">
{{ t('chat.shippingOrderExtractionSummary.cancelled', { count: displaySummary.cancelledDocuments }) }}
</span>
</div>
<div
v-if="workflowStageLabel || workflowLastActivityLabel"
class="mt-1 text-[11px] opacity-80"
data-testid="shipping-order-extraction-workflow-meta"
>
<span v-if="workflowStageLabel">{{ workflowStageLabel }}</span>
<span v-if="workflowLastActivityLabel" class="ml-1">· {{ workflowLastActivityLabel }}</span>
</div>
<ProcessGateRecoveryCard
v-if="runLevelProcessGate?.current_blocking_gate && !hasProcessingProjection"
class="mt-2"
:summary="runLevelProcessGate"
:can-handle="!readonly"
:navigation-context="gateNavigationContext"
@refreshed="emit('refresh')"
@refresh-needed="emit('refresh')"
@confirm-customer="(taskNo) => void onGateConfirmCustomer(taskNo)"
/>
<div
v-if="hasProcessingProjection"
class="mt-2 space-y-2"
data-testid="chat-progress-summary-list"
>
<div
v-for="projection in resolvedProcessingProjections"
:key="projection.workItemNo"
>
<div class="truncate text-[11px] font-semibold opacity-90">
{{ processingProjectionTitle(projection) }}
</div>
<ChatProgressSummary
:projection="projection"
@action="onChatProgressAction"
/>
</div>
</div>
<div
v-if="handlingItems.length"
class="mt-2 space-y-1.5"
data-testid="shipping-order-extraction-handling-items"
>
<div class="text-[11px] font-medium opacity-90">
{{ t('chat.shippingOrderExtractionHandling.title') }}
</div>
<div
v-for="item in handlingItems"
:key="item.category"
class="rounded-md border border-current/15 bg-black/5 px-2 py-1.5 text-xs dark:bg-white/5"
data-testid="shipping-order-extraction-handling-item"
>
<div class="flex flex-wrap items-center justify-between gap-2">
<div class="min-w-0 font-medium">
{{ handlingTitle(item) }}
<span class="ml-1 opacity-80">{{ t('chat.shippingOrderExtractionHandling.count', { count: item.count }) }}</span>
</div>
<button
v-if="item.primaryAction && !readonly && !hasProcessingProjection && (item.primaryAction !== 'review_candidate' || !handlingItems.some((other) => other.primaryAction === 'enter_manual_review'))"
type="button"
class="shrink-0 rounded-md border border-current/20 px-2 py-0.5 text-[11px] font-medium hover:bg-black/5 dark:hover:bg-white/5"
data-testid="shipping-order-extraction-handling-primary-action"
@click="handleHandlingAction(item)"
>
{{ (item.primaryAction === 'review_candidate' || item.primaryAction === 'enter_manual_review')
? t('chat.shippingOrderExtractionAction.enter_manual_review')
: te(`chat.shippingOrderExtractionAction.${item.primaryAction}`)
? t(`chat.shippingOrderExtractionAction.${item.primaryAction}`)
: t('chat.shippingOrderExtractionAction.view_details') }}
</button>
</div>
<div v-if="item.reasonCodes.length" class="mt-1 opacity-80">
{{ t('chat.shippingOrderExtractionHandling.reasonPrefix') }}
{{ item.reasonCodes.slice(0, 4).map(reasonLabel).join(';') }}
</div>
<div
v-if="affectedRows(item).length"
class="mt-1.5 flex flex-wrap gap-1"
data-testid="shipping-order-extraction-affected-refs"
>
<span class="opacity-80">{{ t('chat.shippingOrderExtractionHandling.affectedPrefix') }}</span>
<button
v-for="row in affectedRows(item)"
:key="row.key"
type="button"
class="rounded border border-current/20 px-1.5 py-0.5 text-[11px] font-medium underline-offset-2 hover:underline"
:disabled="readonly"
@click="openAffectedRef(row.target)"
>
{{ row.label }}
</button>
</div>
</div>
</div>
<div v-if="state.currentActivity?.fileName" class="mt-1 text-xs opacity-80">
{{ t('chat.shippingOrderExtractionCurrentFile', {
fileName: state.currentActivity.fileName || t('chat.shippingOrderExtractionUnknownDocument'),
}) }}
<span v-if="stageLabel"> · {{ stageLabel }}</span>
<span v-else-if="activityKey"> · {{ t(activityKey) }}</span>
<span v-if="elapsedLabel"> · {{ t('chat.shippingOrderExtractionElapsed', { elapsed: elapsedLabel }) }}</span>
{{ handlingSummaryLine }}
</div>
<div
@@ -707,80 +418,27 @@ function openCancelConfirm() {
{{ t('chat.shippingOrderExtractionRefreshFailed') }}
</div>
<div v-if="confirmCancelOpen" class="mt-2 rounded-md border border-current/20 bg-black/5 p-2 text-xs dark:bg-white/5">
<div class="font-medium">{{ t('chat.shippingOrderExtractionCancel.confirmTitle') }}</div>
<div class="mt-1 opacity-80">{{ t('chat.shippingOrderExtractionCancel.confirmImpact') }}</div>
<label class="mt-2 block opacity-90">
{{ t('chat.shippingOrderExtractionCancel.reasonOptional') }}
<textarea
v-model="cancelReason"
rows="2"
class="input-field mt-1 w-full py-1 text-xs"
:placeholder="t('chat.shippingOrderExtractionCancel.reasonOptional')"
/>
</label>
<div class="mt-2 flex flex-wrap gap-2">
<button
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"
:disabled="cancelling"
@click="confirmCancel"
>
{{ cancelling
? t('chat.shippingOrderExtractionCancel.submitting')
: t('chat.shippingOrderExtractionAction.cancel_run') }}
</button>
<button
type="button"
class="inline-flex items-center rounded-md px-2.5 py-1 text-xs font-medium opacity-80 hover:underline"
:disabled="cancelling"
@click="confirmCancelOpen = false; cancelReason = ''"
>
{{ t('chat.shippingOrderExtractionCancel.dismiss') }}
</button>
</div>
</div>
<div v-else class="mt-2 flex flex-wrap gap-2">
<div class="mt-2 flex flex-wrap items-center gap-3">
<button
v-if="primaryChatAction"
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"
@click="onPrimaryChatAction"
>
{{ primaryChatAction.kind === 'retry' && retrying
? t('chat.shippingOrderExtractionRetrying')
: primaryChatAction.label }}
</button>
<button
v-if="String(props.runNo || '').trim()"
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"
class="text-xs font-medium underline-offset-2 opacity-80 hover:underline"
data-testid="shipping-order-extraction-view-details"
@click="openDetailsDrawer"
>
{{ t('chat.shippingOrderExtractionAction.view_details') }}
</button>
<button
v-if="showRefresh"
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"
:disabled="refreshing"
@click="emit('refresh')"
>
{{ refreshing
? t('chat.shippingOrderExtractionRefreshing')
: t('chat.shippingOrderExtractionAction.refresh_status') }}
</button>
<button
v-if="showCancel"
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"
:disabled="cancelling"
@click="openCancelConfirm"
>
{{ t('chat.shippingOrderExtractionAction.cancel_run') }}
</button>
<button
v-if="showRetry"
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"
:disabled="retrying"
@click="emit('retry')"
>
{{ retrying
? t('chat.shippingOrderExtractionRetrying')
: t('chat.shippingOrderExtractionAction.retry_failed_attachments') }}
{{ t('chat.shippingProcessing.viewTaskDetails') }}
</button>
</div>
</div>
File diff suppressed because it is too large. Load diff
@@ -3,9 +3,10 @@
* 用途:聊天页右侧「本次处理中」面板——OT 任务卡 + 按需展开的文件明细。
* 依赖:vue-i18n、useMessage、useShippingNoticeWorkflow、ShippingConversationProcessingCard、
* conversationProcessingProjection、DetailDrawer、ReasonDialog、ProcessGateRecoveryCard。
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;每张 OT 卡内展示自己的紧凑进度与动作;
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;面板摘要为双行「N 任务 · M 文件」+
* 「待我处理 / 系统处理中」;截断时展示 has_more 提示;
* mapUserTaskObjectsToFileRows 合成文件行;取消/重识别走 Run API;
* 路由 focus_task_no / 服务端 focused_task_no 驱动选中卡与当前阶段摘要;
* 路由 focus_task_no / 服务端 focused_task_no 驱动选中卡;
* 详情抽屉仅用列表投影,不再请求 WorkflowItem 详情 API。
*/
<script setup lang="ts">
@@ -859,18 +860,30 @@ watch(
{{ t('chat.shippingProcessing.panelPinnedLabel') }}
</span>
</div>
<div class="mt-0.5 text-xs text-secondary" data-testid="shipping-workflow-panel-summary">
<div class="mt-0.5 space-y-0.5 text-xs text-secondary" data-testid="shipping-workflow-panel-summary">
<template v-if="loading && !displayProcessing">
{{ t('chat.shippingProcessing.loading') }}
</template>
<template v-else-if="displayProcessing">
{{ t('chat.shippingProcessing.summaryLine', {
total: displayProcessing.summary.total_files
|| displayProcessing.summary.total_tasks,
processing: displayProcessing.summary.processing,
needsAction: displayProcessing.summary.needs_action,
completed: displayProcessing.summary.completed || 0,
}) }}
<div data-testid="shipping-processing-summary-totals">
{{ t('chat.shippingProcessing.summaryTasksAndFiles', {
tasks: Number(displayProcessing.summary.total_tasks || 0),
files: Number(displayProcessing.summary.total_files || 0),
}) }}
</div>
<div data-testid="shipping-processing-summary-detail">
{{ t('chat.shippingProcessing.summaryLineDetail', {
needsAction: Number(displayProcessing.summary.needs_action || 0),
processing: Number(displayProcessing.summary.processing || 0),
}) }}
</div>
<div
v-if="displayProcessing.summary.has_more_active || displayProcessing.summary.has_more_history"
class="text-[11px] text-muted"
data-testid="shipping-processing-summary-truncated"
>
{{ t('chat.shippingProcessing.summaryTruncatedHint') }}
</div>
</template>
<template v-else>
{{ t('chat.shippingProcessing.compactSummary', {
@@ -912,6 +925,7 @@ watch(
:projection="displayProcessing"
:work-items="processingWorkItems"
:conversation-id="conversationId"
:has-more-history="Boolean(displayProcessing?.summary?.has_more_history)"
@focus="(taskNo) => void onProcessingFocus(taskNo)"
@viewed="(taskNo) => void onProcessingViewed(taskNo)"
@expand-files="onExpandTaskFiles"