feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码
This commit is contained in:
1 parent
935bf26fa6
commit
7cfd5d167e
230 files changed
+9337
-10989
No files matched your search
@@ -94,64 +94,23 @@ const shippingProcessing = useShippingNoticeWorkflow({
|
||||
});
|
||||
provide(SHIPPING_WORKFLOW_KEY, shippingProcessing);
|
||||
|
||||
/**
|
||||
* 当前货代工作台的会话身份。
|
||||
*
|
||||
* 核心逻辑:历史会话首帧时 page.conversationId 尚未由消息恢复链路回填,
|
||||
* 但 route.query.conversation_id 已是用户明确打开的会话。所有批次中心
|
||||
* 显隐、传参和会话切换边界必须使用同一个优先级,避免中心带空 ID 初始化。
|
||||
*/
|
||||
const activeShippingConversationId = computed(() => (
|
||||
String(route.query.conversation_id || page.conversationId || '').trim()
|
||||
));
|
||||
|
||||
const isOrderReviewMode = computed(() => route.query.mode === 'order-review' && typeof route.query.run_no === 'string' && route.query.run_no.length > 0);
|
||||
|
||||
const isTrainingAgentPage = computed(() => matchesTrainingAgent(page.currentAgent));
|
||||
|
||||
const isMaintenanceAgentPage = computed(() => agentHasIntentUiProfile(page.currentAgent, 'maintenance'));
|
||||
|
||||
const activeExtractionRunNo = computed(() => {
|
||||
|
||||
// [STEP 1] 优先从消息流中的抽取状态卡取 run_no(终态后仍在消息里)。
|
||||
// page 经 reactive provide 后 messages 已解包为数组,禁止再读 .value。
|
||||
const messages = Array.isArray(page.messages) ? page.messages : [];
|
||||
|
||||
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
||||
|
||||
const item = messages[i];
|
||||
|
||||
if (!item || item.role !== 'assistant') continue;
|
||||
|
||||
const payload = item.payload && typeof item.payload === 'object' ? item.payload : null;
|
||||
|
||||
const fromPayload = payload && typeof (payload as { order_extraction_run_no?: unknown }).order_extraction_run_no === 'string'
|
||||
|
||||
? String((payload as { order_extraction_run_no: string }).order_extraction_run_no).trim()
|
||||
|
||||
: '';
|
||||
|
||||
if (fromPayload) return fromPayload;
|
||||
|
||||
if (item.shipping_order_extraction_state) {
|
||||
|
||||
const fromGetter = String(page.getActiveOrderExtractionRunNo?.() || '').trim();
|
||||
|
||||
if (fromGetter) return fromGetter;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// [STEP 2] 回退活动 Run(轮询中)与路由深链。
|
||||
|
||||
try {
|
||||
|
||||
const fromActive = String(page.getActiveOrderExtractionRunNo?.() || '').trim();
|
||||
|
||||
if (fromActive) return fromActive;
|
||||
|
||||
} catch {
|
||||
|
||||
/* ignore */
|
||||
|
||||
}
|
||||
|
||||
const fromQuery = typeof route.query.run_no === 'string' ? route.query.run_no.trim() : '';
|
||||
|
||||
return fromQuery;
|
||||
|
||||
});
|
||||
|
||||
/** 批次进度工作台按需打开;关闭时不占用对话区右侧布局。 */
|
||||
const batchWorkbenchOpen = ref(false);
|
||||
|
||||
@@ -160,7 +119,7 @@ const batchWorkbenchOpen = ref(false);
|
||||
const showShippingWorkflowTimeline = computed(() => (
|
||||
page.isShippingNoticeAgent
|
||||
&& batchWorkbenchOpen.value
|
||||
&& Boolean(page.conversationId || activeExtractionRunNo.value)
|
||||
&& Boolean(activeShippingConversationId.value)
|
||||
));
|
||||
|
||||
const compactShippingProgress = computed(() => batchWorkbenchOpen.value);
|
||||
@@ -178,7 +137,7 @@ function closeBatchWorkbench() {
|
||||
* 否则旧会话的右侧投影会短暂占用新会话的对话区并造成“本次处理”串批错觉。
|
||||
*/
|
||||
watch(
|
||||
() => [String(page.conversationId || ''), Number(page.currentAgentId || 0)] as const,
|
||||
() => [activeShippingConversationId.value, Number(page.currentAgentId || 0)] as const,
|
||||
(next, previous) => {
|
||||
if (!previous || next[0] === previous[0] && next[1] === previous[1]) return;
|
||||
batchWorkbenchOpen.value = false;
|
||||
@@ -694,7 +653,7 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
<ShippingWorkflowTimeline
|
||||
v-if="showShippingWorkflowTimeline"
|
||||
:conversation-id="page.conversationId"
|
||||
:conversation-id="activeShippingConversationId"
|
||||
:refresh-trigger="page.workflowRefreshTrigger"
|
||||
:controller="shippingProcessing"
|
||||
|
||||
|
||||
@@ -112,16 +112,6 @@ async function handleQueryPreviewAssetImage(assetId: string, assetName: string)
|
||||
@confirm="page.handleDeleteConfirm"
|
||||
@cancel="page.closeDeleteConfirmDialog"
|
||||
/>
|
||||
<DeleteConfirmDialog
|
||||
v-model="page.showRetryFailedConfirmDialog"
|
||||
:title="page.t('chat.shippingNoticeUi.retryFailedConfirmTitle')"
|
||||
:message="page.t('chat.shippingNoticeUi.retryFailedConfirmMessage')"
|
||||
:confirm-text="page.t('chat.shippingNoticeUi.retryFailedConfirmAction')"
|
||||
:confirm-loading="page.retryingShippingPendingTasks"
|
||||
confirm-tone="primary"
|
||||
@confirm="page.handleRetryFailedConfirm"
|
||||
@cancel="page.closeRetryFailedConfirm"
|
||||
/>
|
||||
<div
|
||||
v-if="page.shippingToastMessage"
|
||||
class="pointer-events-none fixed inset-x-0 top-20 z-[145] flex justify-center px-4"
|
||||
|
||||
+9
-6
@@ -33,7 +33,7 @@ const i18n = createI18n({
|
||||
},
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
saveOrderAndValidate: '保存订单并校验',
|
||||
saveOrderAndValidate: '提交订单',
|
||||
currentProcessing: {
|
||||
waitingStart: '等待系统启动',
|
||||
},
|
||||
@@ -69,7 +69,10 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
|
||||
it('keeps the retry action for retryable states', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: { stageCode: 'inventory_preparation', userStatus: 'retryable', retryable: true },
|
||||
props: {
|
||||
stageCode: 'inventory_preparation', userStatus: 'retryable', retryable: true,
|
||||
primaryAction: { code: 'retry_inventory_preparation', i18nKey: 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryPreparation' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
@@ -104,7 +107,7 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').text()).toBe('重新库存匹配');
|
||||
expect(wrapper.find('[data-testid="review-current-processing-retry"]').text()).toBe('重新库存匹配');
|
||||
});
|
||||
|
||||
it('does not render save and validate as a current-task action', () => {
|
||||
@@ -116,9 +119,9 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 保存订单并校验是底栏唯一动作;未提交校验必须给出明确交接提示,不能显示系统处理中。
|
||||
// 提交订单是底栏唯一动作;未提交前必须给出明确交接提示,不能显示系统处理中。
|
||||
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
|
||||
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text()).toBe('保存订单并校验');
|
||||
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text()).toBe('提交订单');
|
||||
});
|
||||
|
||||
it('labels an unqueued automatic Gate as waiting for system start', () => {
|
||||
@@ -207,7 +210,7 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
await wrapper.get('[data-testid="review-current-task-primary-action"]').trigger('click');
|
||||
await wrapper.get('[data-testid="review-current-processing-retry"]').trigger('click');
|
||||
await wrapper.get('[data-testid="review-current-task-recovery-retry_inventory_preparation"]').trigger('click');
|
||||
|
||||
// 两个稳定 action 码分别进入 Gate API:重匹配不可误触 RPA,重新获取库存才会触发 RPA。
|
||||
|
||||
+4
-20
@@ -62,7 +62,6 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
retry: [];
|
||||
locate: [lineKey?: string | null, fieldId?: string | null];
|
||||
action: [code: string, parameters?: Record<string, unknown>];
|
||||
}>();
|
||||
@@ -219,8 +218,7 @@ function isNonTaskCapabilityAction(code: string): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务动作按钮:后端确认 retryable=true → 主按钮为「重试」;
|
||||
* 否则若 primary_action.code 非 retry 且不是工作台内自跳转 → 渲染对应人工动作。
|
||||
* 业务动作按钮只消费 primary_action;retryable 是状态,不是授权。
|
||||
*/
|
||||
const showBusinessAction = computed(() => {
|
||||
if (props.loading) return false;
|
||||
@@ -228,13 +226,12 @@ const showBusinessAction = computed(() => {
|
||||
// [STEP] 自动处理期间没有人工业务动作;只保留外层的刷新进度入口。
|
||||
// 防止正式任务编辑等历史 primary_action 穿透到库存获取运行态。
|
||||
if (props.userStatus === 'running') return false;
|
||||
if (props.retryable) return true;
|
||||
const code = String(props.primaryAction?.code || '').trim();
|
||||
if (isInternalInventoryAction(code)) return false;
|
||||
if (!code) return false;
|
||||
if (isNonTaskCapabilityAction(code)) return false;
|
||||
if (isHiddenWorkbenchNavigationAction(code)) return false;
|
||||
// retry 仅当 retryable=true 时展示(避免按钮闪烁矛盾)
|
||||
// 无对象边界的泛化 retry 永不展示。
|
||||
if (code === 'retry') return false;
|
||||
return true;
|
||||
});
|
||||
@@ -243,7 +240,6 @@ const businessActionLabel = computed(() => {
|
||||
const code = String(props.primaryAction?.code || '').trim();
|
||||
const inventoryKey = inventoryActionLabelKey(code);
|
||||
if (inventoryKey && te(inventoryKey)) return t(inventoryKey);
|
||||
if (props.retryable) return t('chat.shippingOrderReview.currentTask.actionRetry');
|
||||
const pa = props.primaryAction;
|
||||
if (!pa) return '';
|
||||
if (isNonTaskCapabilityAction(String(pa.code || ''))) return '';
|
||||
@@ -257,11 +253,6 @@ const businessActionLabel = computed(() => {
|
||||
if (i18nKey && te(i18nKey)) {
|
||||
return t(i18nKey);
|
||||
}
|
||||
// fallback 到 legacy chat.shippingProcessing.action
|
||||
const legacyKey = `chat.shippingProcessing.action.${pa.code}`;
|
||||
if (te(legacyKey)) {
|
||||
return t(legacyKey);
|
||||
}
|
||||
// 当前任务按钮没有受控文案时 fail-closed,禁止泄漏内部 action code。
|
||||
return '';
|
||||
});
|
||||
@@ -274,7 +265,7 @@ const businessActionTitle = computed(() => {
|
||||
return '';
|
||||
});
|
||||
|
||||
const actionIsRetry = computed(() => Boolean(props.retryable) || String(props.primaryAction?.code || '') === 'retry');
|
||||
const actionIsRetry = computed(() => String(props.primaryAction?.code || '').trim().startsWith('retry_'));
|
||||
const actionIsInventoryRpa = computed(() => String(props.primaryAction?.code || '').trim() === 'retry_inventory_preparation');
|
||||
const recoveryActions = computed(() => (props.recoveryActions || []).filter((action) => {
|
||||
const code = String(action.code || '').trim();
|
||||
@@ -301,14 +292,7 @@ function recoveryActionLabel(action: (typeof recoveryActions.value)[number]): st
|
||||
|
||||
function handleBusinessActionClick() {
|
||||
const primaryActionCode = String(props.primaryAction?.code || '').trim();
|
||||
if (props.retryable && primaryActionCode && primaryActionCode !== 'retry') {
|
||||
emit('action', primaryActionCode, props.primaryAction?.parameters ?? {});
|
||||
return;
|
||||
}
|
||||
if (actionIsRetry.value) {
|
||||
emit('retry');
|
||||
return;
|
||||
}
|
||||
if (!primaryActionCode || primaryActionCode === 'retry') return;
|
||||
emit('action', primaryActionCode, props.primaryAction?.parameters ?? {});
|
||||
}
|
||||
|
||||
|
||||
+16
-1
@@ -31,7 +31,8 @@ const i18n = createI18n({
|
||||
customValue: '手工值', customPlaceholder: '请输入', submitCustom: '确认手工值',
|
||||
resolveReason: '人工裁决', resolveFailed: '提交失败', resolveSuccess: '已处理',
|
||||
fields: { part_number: '料号' }, reasons: { field_conflict: '字段冲突' },
|
||||
evidenceRole: {}, optionLabel: '候选 {index}', adoptOption: '采用候选值',
|
||||
evidenceRole: {}, recoveryAction: { reparse_current_pdf: '建议操作:重新识别此 PDF' },
|
||||
optionLabel: '候选 {index}', adoptOption: '采用候选值',
|
||||
},
|
||||
resume: { autoCreated: '已自动建单', waitingManualConfirm: '待人工确认' },
|
||||
} },
|
||||
@@ -57,6 +58,20 @@ describe('ReviewFieldConflictPanel', () => {
|
||||
expect(wrapper.find('[data-testid="review-field-conflict-custom-toggle"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('shows the server-provided recovery action for a historical evidence gap', () => {
|
||||
const wrapper = mount(ReviewFieldConflictPanel, {
|
||||
props: {
|
||||
caseNo: 'SORC-1', draftVersion: 1, editable: true, conflicts: [],
|
||||
evidenceIssues: [{
|
||||
conflict_key: '-1:unit_price', field_code: 'unit_price', reason: 'supplement_conflict_evidence_insufficient',
|
||||
options: [], recovery_action: 'reparse_current_pdf',
|
||||
}],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.get('[data-testid="review-evidence-issue-recovery-action"]').text()).toContain('重新识别此 PDF');
|
||||
});
|
||||
|
||||
it('refreshes the case when confirming a stale manual value returns conflict-not-found', async () => {
|
||||
resolveFieldConflict.mockRejectedValueOnce(new BusinessError({
|
||||
message: 'Field conflict not found',
|
||||
|
||||
@@ -73,6 +73,16 @@ function evidenceRoleLabel(role: string | undefined | null): string {
|
||||
return te(key) ? t(key) : code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示服务端指定的恢复动作;页面只解释并复用既有顶部操作,不自行发起重识别。
|
||||
*/
|
||||
function recoveryActionLabel(action: string | undefined | null): string {
|
||||
const code = String(action || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `chat.shippingOrderReview.fieldConflict.recoveryAction.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位冲突字段到草稿/证据区。
|
||||
*/
|
||||
@@ -311,6 +321,13 @@ async function submitCustom(conflict: ShippingOrderReviewFieldConflict) {
|
||||
<span class="text-muted">{{ scopeLabel(issue.scope) }} · </span>
|
||||
<span class="font-mono">{{ fieldLabel(issue.field_code) }}</span>
|
||||
</span>
|
||||
<span
|
||||
v-if="recoveryActionLabel(issue.recovery_action)"
|
||||
class="text-[11px] text-amber-800 dark:text-amber-200"
|
||||
data-testid="review-evidence-issue-recovery-action"
|
||||
>
|
||||
{{ recoveryActionLabel(issue.recovery_action) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="text-[11px] text-primary underline-offset-2 hover:underline"
|
||||
|
||||
+19
-2
@@ -2,7 +2,7 @@
|
||||
* features/chat/components/shipping-review/ReviewWorkbenchFooter.spec.ts
|
||||
* 用途:验证字段冲突的 Gate 主动作只由右栏当前任务卡承载,底栏不得重复展示。
|
||||
* 依赖:Vitest、Vue Test Utils、Vue I18n、ReviewWorkbenchFooter。
|
||||
* 逻辑:订单复核底栏只保留保存校验,不展示已由当前任务卡或阶段页承载的流程动作。
|
||||
* 逻辑:订单复核底栏只保留提交订单,不展示已由当前任务卡或阶段页承载的流程动作。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
@@ -16,7 +16,11 @@ const i18n = createI18n({
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingProcessing: { action: { resolve_field_conflicts: '处理字段冲突', view_result: '查看结果', none: '无操作' } },
|
||||
shippingOrderReview: { unsavedSwitch: { unsavedCount: '未保存 {count} 项' } },
|
||||
shippingOrderReview: {
|
||||
saveOrderAndValidate: '提交订单',
|
||||
submitOrderHint: '提交后自动校验,满足条件将自动建单。',
|
||||
unsavedSwitch: { unsavedCount: '未保存 {count} 项' },
|
||||
},
|
||||
},
|
||||
workspace: { shippingNotice: { processGate: { actions: {} } } },
|
||||
},
|
||||
@@ -59,4 +63,17 @@ describe('ReviewWorkbenchFooter', () => {
|
||||
expect(wrapper.find('[data-testid="review-footer-flow-resolve_field_conflicts"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-footer-flow-view_result"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('uses submit-order wording and explains the automatic creation policy', () => {
|
||||
const wrapper = mount(ReviewWorkbenchFooter, {
|
||||
props: {
|
||||
availableActions: ['validate'], canConfirmBuild: false, saving: false, isReadOnly: false, hasDraft: true,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 关键断言:唯一写入口完成提交语义;资格通过后的自动建单是系统行为,不要求第二次确认。
|
||||
expect(wrapper.text()).toContain('提交订单');
|
||||
expect(wrapper.get('[data-testid="review-submit-order-hint"]').text()).toBe('提交后自动校验,满足条件将自动建单。');
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@
|
||||
用途:订单处理工作台底部唯一写操作栏(处置 / 保存 / 统一流程动作)。
|
||||
依赖:vue-i18n、lucide-vue-next、ActionPresentation。
|
||||
逻辑:ShippingOrderReviewView 传入 available_actions 与流程动作投影;sticky bottom;
|
||||
订单复核只保留保存校验;流程动作由所属阶段或当前任务卡承载;写按钮受 actionsExecutable 约束;
|
||||
订单复核只保留提交订单;流程动作由所属阶段或当前任务卡承载;写按钮受 actionsExecutable 约束;
|
||||
流程写操作经 flow-action emit(与 Resolver 同链);flowBusy||saving 时禁用。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
@@ -76,7 +76,7 @@ function hasAction(action: string): boolean {
|
||||
/**
|
||||
* 订单复核底栏不承载流程投影动作。
|
||||
*
|
||||
* 核心逻辑:保存并校验是表单级提交,固定放在这里;字段裁决、重试、查看结果等
|
||||
* 核心逻辑:提交订单是表单级提交,固定放在这里;字段裁决、重试、查看结果等
|
||||
* Case/阶段级动作必须留在其业务上下文中,避免同一动作在顶栏、右栏和底栏重复出现。
|
||||
*/
|
||||
const footerFlowItems = computed((): ActionPresentationItem[] => []);
|
||||
@@ -180,6 +180,13 @@ const canWriteCaseActions = computed(() => props.actionsExecutable && !props.isR
|
||||
>
|
||||
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveOrderAndValidate') }}
|
||||
</button>
|
||||
<p
|
||||
v-if="showValidate && hasAction('validate')"
|
||||
class="basis-full text-right text-xs text-muted"
|
||||
data-testid="review-submit-order-hint"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.submitOrderHint') }}
|
||||
</p>
|
||||
</template>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
+254
-144
@@ -22,65 +22,83 @@ const i18n = createI18n({
|
||||
});
|
||||
|
||||
function buildProjection(): ConversationProcessingProjection {
|
||||
const needsAction = {
|
||||
user_task_no: 'OT-NEED',
|
||||
group: 'needs_action' as const,
|
||||
status_label: 'pending_review',
|
||||
file_count: 2,
|
||||
run_no: 'RUN-NEED',
|
||||
can_append: false,
|
||||
recently_created: false,
|
||||
};
|
||||
const processing = {
|
||||
user_task_no: 'OT-PROC',
|
||||
submission_ordinal: 2,
|
||||
group: 'processing' as const,
|
||||
status_label: 'extracting',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-PROC',
|
||||
can_append: true,
|
||||
recently_created: true,
|
||||
focused: true,
|
||||
};
|
||||
const completed = {
|
||||
user_task_no: 'OT-DONE',
|
||||
group: 'completed' as const,
|
||||
status_label: 'completed',
|
||||
title: 'done.pdf',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-DONE',
|
||||
can_append: false,
|
||||
available_actions: ['view_details'],
|
||||
};
|
||||
const archived = {
|
||||
user_task_no: 'OT-HIST',
|
||||
group: 'history' as const,
|
||||
status_label: 'completed',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-HIST',
|
||||
can_append: false,
|
||||
viewed: true,
|
||||
available_actions: ['view_details'],
|
||||
};
|
||||
const cancelled = {
|
||||
user_task_no: 'OT-CANCEL',
|
||||
group: 'history' as const,
|
||||
status_label: 'cancelled',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-CANCEL',
|
||||
can_append: false,
|
||||
viewed: true,
|
||||
available_actions: ['view_details'],
|
||||
};
|
||||
return {
|
||||
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: [{
|
||||
user_task_no: 'OT-NEED',
|
||||
group: 'needs_action',
|
||||
status_label: 'pending_review',
|
||||
file_count: 2,
|
||||
run_no: 'RUN-NEED',
|
||||
can_append: false,
|
||||
recently_created: false,
|
||||
}],
|
||||
processing: [{
|
||||
user_task_no: 'OT-PROC',
|
||||
submission_ordinal: 2,
|
||||
group: 'processing',
|
||||
status_label: 'extracting',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-PROC',
|
||||
can_append: true,
|
||||
recently_created: true,
|
||||
focused: true,
|
||||
}],
|
||||
completed: [{
|
||||
user_task_no: 'OT-DONE',
|
||||
group: 'completed',
|
||||
status_label: 'completed',
|
||||
title: 'done.pdf',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-DONE',
|
||||
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,
|
||||
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'],
|
||||
},
|
||||
],
|
||||
status_groups: {
|
||||
failed: [needsAction], waiting_human: [], processing: [processing], completed: [completed],
|
||||
cancelled: [cancelled], archived: [archived],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** 测试仅构造权威 status_groups;禁止再把旧四组作为组件输入。 */
|
||||
function setStatusGroup(
|
||||
projection: ConversationProcessingProjection,
|
||||
key: keyof NonNullable<ConversationProcessingProjection['status_groups']>,
|
||||
tasks: NonNullable<ConversationProcessingProjection['status_groups']>[keyof NonNullable<ConversationProcessingProjection['status_groups']>],
|
||||
) {
|
||||
projection.status_groups![key] = tasks;
|
||||
}
|
||||
|
||||
function projectionWithGroups(
|
||||
summary: ConversationProcessingProjection['summary'],
|
||||
groups: NonNullable<ConversationProcessingProjection['status_groups']>,
|
||||
): ConversationProcessingProjection {
|
||||
return { summary, status_groups: groups };
|
||||
}
|
||||
|
||||
/** 构造任务卡使用的权威统一进度。 */
|
||||
function buildWorkItem(
|
||||
taskNo: string,
|
||||
@@ -119,12 +137,12 @@ function buildWorkItem(
|
||||
describe('ShippingConversationProcessingCard', () => {
|
||||
it('only exposes file cancellation when the backend explicitly authorizes cancel_unit', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
user_task_no: 'OT-CANCEL-UNIT', group: 'processing', status_label: 'extracting',
|
||||
file_count: 1, run_no: 'RUN-CANCEL-UNIT', can_append: false,
|
||||
objects: [{ kind: 'document', object_key: 'DOC-9', label: 'cancel.pdf', filename: 'cancel.pdf',
|
||||
document_id: 9, root_document_id: 9, status_label: 'extracting' }],
|
||||
}];
|
||||
}]);
|
||||
const workItem = buildWorkItem('OT-CANCEL-UNIT', {
|
||||
availableActions: ['cancel_unit'],
|
||||
sourceSummary: { ...buildWorkItem('OT-CANCEL-UNIT').sourceSummary, documentId: 9 },
|
||||
@@ -151,12 +169,12 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
|
||||
it('does not fall back to legacy cancellation when ui_state revokes it', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
user_task_no: 'OT-CANCEL-REVOKED', group: 'processing', status_label: 'extracting',
|
||||
file_count: 1, run_no: 'RUN-CANCEL-REVOKED', can_append: false,
|
||||
objects: [{ kind: 'document', object_key: 'DOC-10', label: 'revoked.pdf', filename: 'revoked.pdf',
|
||||
document_id: 10, root_document_id: 10, status_label: 'extracting' }],
|
||||
}];
|
||||
}]);
|
||||
const workItem = buildWorkItem('OT-CANCEL-REVOKED', {
|
||||
availableActions: ['cancel_unit'],
|
||||
sourceSummary: { ...buildWorkItem('OT-CANCEL-REVOKED').sourceSummary, documentId: 10 },
|
||||
@@ -181,11 +199,11 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
|
||||
it('does not render legacy document_names as a batch file row without a live leaf projection', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
user_task_no: 'OT-HISTORICAL-SNAPSHOT', group: 'processing', status_label: 'extracting',
|
||||
title: 'legacy-run.pdf', document_names: ['legacy-run.pdf'], file_count: 1,
|
||||
run_no: 'RUN-HISTORICAL-SNAPSHOT', can_append: false,
|
||||
}];
|
||||
}]);
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
@@ -199,7 +217,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
|
||||
it('uses the live leaf summary instead of a stale task object in batch mode', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
user_task_no: 'OT-LIVE-LEAF', group: 'processing', status_label: 'extracting',
|
||||
title: 'snapshot-old-name.pdf', file_count: 1, run_no: 'RUN-LIVE-LEAF', can_append: false,
|
||||
objects: [{
|
||||
@@ -207,7 +225,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
filename: 'snapshot-old-name.pdf', document_id: 88, root_document_id: 88,
|
||||
status_label: 'pending_review',
|
||||
}],
|
||||
}];
|
||||
}]);
|
||||
const live = buildWorkItem('OT-LIVE-LEAF', {
|
||||
runNo: 'RUN-LIVE-LEAF',
|
||||
sourceSummary: {
|
||||
@@ -235,12 +253,12 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
|
||||
it('expands EML files only from the live aggregate work item', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
user_task_no: 'INTAKE:EML-LIVE', group: 'processing', status_label: 'extracting',
|
||||
title: 'snapshot-mail.eml', document_names: ['snapshot-attachment.pdf'],
|
||||
file_count: 1, run_no: 'RUN-EML-LIVE', can_append: false,
|
||||
aggregateChildren: [],
|
||||
}];
|
||||
}]);
|
||||
const liveChild = buildWorkItem('DOCUMENT:77', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-LIVE', runNo: 'RUN-EML-LIVE',
|
||||
sourceSummary: {
|
||||
@@ -275,12 +293,49 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(wrapper.text()).not.toContain('snapshot-attachment.pdf');
|
||||
});
|
||||
|
||||
it('counts only stage-filtered EML leaves in the batch status heading', async () => {
|
||||
const projection = buildProjection();
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
user_task_no: 'INTAKE:MIXED-STAGES', group: 'processing', status_label: 'extracting',
|
||||
title: 'mixed-stages.eml', file_count: 2, run_no: 'RUN-MIXED-STAGES', can_append: false,
|
||||
}]);
|
||||
const orderReviewLeaf = buildWorkItem('DOCUMENT:401', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-MIXED-STAGES',
|
||||
sourceSummary: { ...buildWorkItem('DOCUMENT:401').sourceSummary, documentId: 401, filename: 'review.pdf' },
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'waiting_review', lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [], blocking_reason: null, primary_action: null, secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const freightLeaf = buildWorkItem('DOCUMENT:402', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-MIXED-STAGES',
|
||||
sourceSummary: { ...buildWorkItem('DOCUMENT:402').sourceSummary, documentId: 402, filename: 'upload.xlsx' },
|
||||
uiState: {
|
||||
status: 'running', stage: 'freight_uploading', lifecycleStage: 'freight_upload',
|
||||
lifecycleEntries: [], blocking_reason: null, primary_action: null, secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const root = buildWorkItem('INTAKE:MIXED-STAGES', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-MIXED-STAGES',
|
||||
aggregateChildren: [orderReviewLeaf, freightLeaf],
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [root], workbenchMode: true, lifecycleFilter: 'order_review' },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// 阶段卡与列表标题必须消费同一批可见叶子,不能把同一 EML 的其它阶段附件混入。
|
||||
expect(wrapper.get('[data-testid="shipping-processing-group-processing"]').text()).toContain('1 个文件');
|
||||
expect(wrapper.get('[data-testid="shipping-processing-group-processing"]').text()).not.toContain('2 个文件');
|
||||
});
|
||||
|
||||
it('keeps an EML attachment when it has a linked child order task', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
user_task_no: 'INTAKE:EML-WITH-CHILD-OT', group: 'processing', status_label: 'extracting',
|
||||
title: 'mail.eml', file_count: 2, run_no: 'RUN-EML-WITH-CHILD-OT', can_append: false,
|
||||
}];
|
||||
}]);
|
||||
const firstAttachment = buildWorkItem('OT-EML-WITH-CHILD-OT', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-WITH-CHILD-OT',
|
||||
sourceSummary: {
|
||||
@@ -416,9 +471,9 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
it('uses expand-files as the only detail entry when canExpandFileDetails', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
summary: { total_tasks: 1, processing: 0, needs_action: 1, completed: 0, history: 0 },
|
||||
needs_action: [{
|
||||
projection: projectionWithGroups(
|
||||
{ total_tasks: 1, processing: 0, needs_action: 1, completed: 0, history: 0 }, {
|
||||
failed: [{
|
||||
user_task_no: 'OT-MULTI',
|
||||
group: 'needs_action',
|
||||
status_label: 'pending_review',
|
||||
@@ -429,11 +484,8 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
run_no: 'RUN-MULTI',
|
||||
can_append: false,
|
||||
available_actions: ['view_details', 'cancel_task'],
|
||||
}],
|
||||
processing: [],
|
||||
completed: [],
|
||||
history: [],
|
||||
},
|
||||
}], waiting_human: [], processing: [], completed: [], cancelled: [], archived: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
@@ -455,9 +507,9 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
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: [{
|
||||
projection: projectionWithGroups(
|
||||
{ total_tasks: 1, processing: 0, needs_action: 1, completed: 0, history: 0 }, {
|
||||
failed: [{
|
||||
user_task_no: 'OT-SINGLE',
|
||||
group: 'needs_action',
|
||||
status_label: 'pending_review',
|
||||
@@ -466,11 +518,8 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
can_append: false,
|
||||
available_actions: ['view_details', 'cancel_task'],
|
||||
objects: [],
|
||||
}],
|
||||
processing: [],
|
||||
completed: [],
|
||||
history: [],
|
||||
},
|
||||
}], waiting_human: [], processing: [], completed: [], cancelled: [], archived: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
@@ -485,9 +534,9 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
it('shows multi-document title from authoritative projection without workflow fallback', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
summary: { total_tasks: 1, total_files: 2, processing: 0, needs_action: 1, completed: 0, history: 0 },
|
||||
needs_action: [{
|
||||
projection: projectionWithGroups(
|
||||
{ total_tasks: 1, total_files: 2, processing: 0, needs_action: 1, completed: 0, history: 0 }, {
|
||||
failed: [{
|
||||
user_task_no: 'OT-MULTI',
|
||||
group: 'needs_action',
|
||||
status_label: 'pending_review',
|
||||
@@ -499,11 +548,8 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
can_append: false,
|
||||
available_actions: ['view_details', 'cancel_task'],
|
||||
objects: [],
|
||||
}],
|
||||
processing: [],
|
||||
completed: [],
|
||||
history: [],
|
||||
},
|
||||
}], waiting_human: [], processing: [], completed: [], cancelled: [], archived: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
@@ -518,10 +564,9 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
it('uses unified order recognition title instead of internal OT number', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
summary: { total_tasks: 1, processing: 1, needs_action: 0, completed: 0, history: 0 },
|
||||
needs_action: [],
|
||||
processing: [{
|
||||
projection: projectionWithGroups(
|
||||
{ total_tasks: 1, processing: 1, needs_action: 0, completed: 0, history: 0 }, {
|
||||
failed: [], waiting_human: [], processing: [{
|
||||
user_task_no: 'OT-20260803-A13F95D2',
|
||||
group: 'processing',
|
||||
status_label: 'processing',
|
||||
@@ -529,10 +574,8 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
file_count: 1,
|
||||
run_no: 'SNER-X',
|
||||
can_append: false,
|
||||
}],
|
||||
completed: [],
|
||||
history: [],
|
||||
},
|
||||
}], completed: [], cancelled: [], archived: [],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
@@ -558,16 +601,17 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
summary: { total_tasks: 1, processing: 0, needs_action: 0, completed: 1, history: 0 },
|
||||
...projectionWithGroups(
|
||||
{ total_tasks: 1, processing: 0, needs_action: 0, completed: 1, history: 0 }, {
|
||||
failed: [], waiting_human: [], processing: [], completed: [{
|
||||
user_task_no: 'OT-DETAIL', group: 'completed', status_label: 'completed',
|
||||
file_count: 1, run_no: 'RUN-DETAIL', can_append: false,
|
||||
available_actions: ['view_details'],
|
||||
}], cancelled: [], archived: [],
|
||||
},
|
||||
),
|
||||
focused_task_no: null,
|
||||
recent_task_no: null,
|
||||
needs_action: [],
|
||||
completed: [{
|
||||
user_task_no: 'OT-DETAIL', group: 'completed', status_label: 'completed',
|
||||
file_count: 1, run_no: 'RUN-DETAIL', can_append: false,
|
||||
available_actions: ['view_details'],
|
||||
}],
|
||||
processing: [], history: [],
|
||||
},
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
@@ -609,10 +653,13 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
props: {
|
||||
projection: {
|
||||
...buildProjection(),
|
||||
needs_action: [{
|
||||
...buildProjection().needs_action[0],
|
||||
available_actions: ['view_details', 'open_review', 'cancel_task'],
|
||||
}],
|
||||
status_groups: {
|
||||
...buildProjection().status_groups!,
|
||||
failed: [{
|
||||
...buildProjection().status_groups!.failed[0],
|
||||
available_actions: ['view_details', 'open_review', 'cancel_task'],
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
@@ -632,12 +679,10 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
}));
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
summary: { total_tasks: 20, processing: 20, needs_action: 0, history: 0 },
|
||||
needs_action: [],
|
||||
processing,
|
||||
history: [],
|
||||
},
|
||||
projection: projectionWithGroups(
|
||||
{ total_tasks: 20, processing: 20, needs_action: 0, history: 0 },
|
||||
{ failed: [], waiting_human: [], processing, completed: [], cancelled: [], archived: [] },
|
||||
),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
@@ -649,9 +694,9 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
it('renders an EML order_intake in the unified failed group rather than the removed intake side path', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
summary: { total_tasks: 1, total_files: 1, processing: 0, needs_action: 1, completed: 0, history: 0 },
|
||||
needs_action: [{
|
||||
projection: projectionWithGroups(
|
||||
{ total_tasks: 1, total_files: 1, processing: 0, needs_action: 1, completed: 0, history: 0 }, {
|
||||
failed: [{
|
||||
user_task_no: 'SNI-1',
|
||||
group: 'needs_action',
|
||||
userGroup: 'failed',
|
||||
@@ -660,11 +705,8 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
file_count: 1,
|
||||
run_no: null,
|
||||
can_append: false,
|
||||
}],
|
||||
processing: [],
|
||||
completed: [],
|
||||
history: [],
|
||||
},
|
||||
}], waiting_human: [], processing: [], completed: [], cancelled: [], archived: [],
|
||||
}),
|
||||
workItems: [{
|
||||
workItemType: 'order_intake',
|
||||
workItemNo: 'SNI-1',
|
||||
@@ -687,6 +729,15 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
attemptNo: 2,
|
||||
},
|
||||
availableActions: ['view_details', 'retry_parse'],
|
||||
uiState: {
|
||||
status: 'failed',
|
||||
stage: 'document_parsing',
|
||||
lifecycleStage: 'intake_parse',
|
||||
lifecycleEntries: [],
|
||||
blocking_reason: { code: 'SHIPPING_NOTICE.INTAKE_PARSE_FAILED' },
|
||||
primary_action: { code: 'retry_parse', i18nKey: null, parameters: {}, executionMode: 'immediate' },
|
||||
secondary_actions: [],
|
||||
},
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'po.pdf',
|
||||
@@ -708,7 +759,9 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-failed"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-SNI-1"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-order-intake"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).toContain('重试解析');
|
||||
// Intake retry_parse 与 Case reparse 对用户统一展示为“重新解析”;
|
||||
// 后端 action_code 仍保留不同对象边界与执行接口。
|
||||
expect(wrapper.text()).toContain('重新解析');
|
||||
});
|
||||
|
||||
it('keeps a human Gate action visible before and after selecting its task', async () => {
|
||||
@@ -726,6 +779,15 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
blockingReasonCode: 'inventory_match_not_ready',
|
||||
},
|
||||
availableActions: ['open_inventory_match_review'],
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'waiting_review',
|
||||
lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [],
|
||||
blocking_reason: { code: 'inventory_match_not_ready' },
|
||||
primary_action: { code: 'open_inventory_match_review', i18nKey: null, parameters: {}, executionMode: 'immediate' },
|
||||
secondary_actions: [],
|
||||
},
|
||||
}),
|
||||
buildWorkItem('OT-PROC', {
|
||||
stage: 'inventory_matching',
|
||||
@@ -737,12 +799,12 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.findAll('[data-testid="sidebar-progress-inline"]')).toHaveLength(2);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').text()).toContain('待复核');
|
||||
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.findAll('[data-testid="shipping-processing-task-actions"]')).toHaveLength(0);
|
||||
const task = wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]');
|
||||
expect(task.find('[data-testid="unified-action-primary"]').exists()).toBe(true);
|
||||
expect(task.find('[data-testid="unified-action-primary"]').text()).toContain('库存');
|
||||
expect(task.find('[data-testid="unified-action-primary"]').text()).toContain('open_inventory_match_review');
|
||||
|
||||
await task.find('button').trigger('click');
|
||||
await flushPromises();
|
||||
@@ -754,10 +816,10 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
|
||||
it('maps internal review_case_draft status to a user-facing review label', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.needs_action = [{
|
||||
...projection.needs_action[0],
|
||||
setStatusGroup(projection, 'failed', [{
|
||||
...projection.status_groups!.failed[0],
|
||||
status_label: 'review_case_draft',
|
||||
}];
|
||||
}]);
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection },
|
||||
global: { plugins: [i18n] },
|
||||
@@ -771,12 +833,12 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
|
||||
it('renders a compact V3 file row with named lifecycle entries', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
...projection.processing[0],
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
...projection.status_groups!.processing[0],
|
||||
user_task_no: 'OT-LIFECYCLE',
|
||||
run_no: 'RUN-LIFECYCLE',
|
||||
file_count: 1,
|
||||
}];
|
||||
}]);
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection,
|
||||
@@ -798,7 +860,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
status: 'running',
|
||||
stage: 'inventory_match',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [
|
||||
lifecycle_entries: [
|
||||
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
|
||||
@@ -819,20 +881,71 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(row.text()).toContain('lifecycle.pdf');
|
||||
expect(row.text()).toContain('PO:PO-LIFECYCLE');
|
||||
expect(row.text()).toContain('通知准备');
|
||||
expect(row.text()).toContain('订单复核 · 可进入');
|
||||
expect(row.text()).toContain('通知准备 · 当前可处理');
|
||||
expect(row.text()).toContain('货代上传 · 前置未完成');
|
||||
expect(row.text()).toContain('通知完成 · 前置未完成');
|
||||
expect(row.text()).toContain('当前阶段:通知准备');
|
||||
});
|
||||
|
||||
it('keeps the file action slot for a real action but not for duplicate lifecycle navigation', async () => {
|
||||
const projection = buildProjection();
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
...projection.status_groups!.processing[0],
|
||||
user_task_no: 'OT-FILE-ACTION', run_no: 'RUN-FILE-ACTION', file_count: 1,
|
||||
}]);
|
||||
const navigationOnly = buildWorkItem('OT-FILE-ACTION', {
|
||||
runNo: 'RUN-FILE-ACTION',
|
||||
sourceSummary: { ...buildWorkItem('OT-FILE-ACTION').sourceSummary, documentId: 31 },
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'order_review', lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' }],
|
||||
blocking_reason: null,
|
||||
primary_action: {
|
||||
code: 'open_order_review', i18nKey: null, parameters: {}, executionMode: 'navigate',
|
||||
targetSurface: 'order_lifecycle_workbench', targetLifecycleStage: 'order_review',
|
||||
},
|
||||
secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [navigationOnly], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.get('[data-testid="shipping-processing-file-DOC-31"]');
|
||||
expect(row.text()).not.toContain('进入订单复核');
|
||||
|
||||
await wrapper.setProps({
|
||||
workItems: [buildWorkItem('OT-FILE-ACTION', {
|
||||
runNo: 'RUN-FILE-ACTION',
|
||||
sourceSummary: { ...buildWorkItem('OT-FILE-ACTION').sourceSummary, documentId: 31 },
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'order_review', lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' }],
|
||||
blocking_reason: null,
|
||||
primary_action: {
|
||||
code: 'create_draft', i18nKey: null, parameters: {}, executionMode: 'navigate',
|
||||
targetSurface: 'order_lifecycle_workbench', targetLifecycleStage: 'order_review',
|
||||
},
|
||||
secondary_actions: [],
|
||||
},
|
||||
})],
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(row.text()).toContain('创建草稿');
|
||||
await row.find('button').trigger('click');
|
||||
expect(wrapper.emitted('projectionAction')?.[0]?.[0]).toMatchObject({
|
||||
item: { actionCode: 'create_draft' },
|
||||
});
|
||||
});
|
||||
|
||||
it('fails closed when a lifecycle entry has an unknown backend state', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
...projection.processing[0],
|
||||
setStatusGroup(projection, 'processing', [{
|
||||
...projection.status_groups!.processing[0],
|
||||
user_task_no: 'OT-LIFECYCLE-UNKNOWN',
|
||||
run_no: 'RUN-LIFECYCLE-UNKNOWN',
|
||||
file_count: 1,
|
||||
}];
|
||||
}]);
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection,
|
||||
@@ -853,7 +966,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
status: 'running',
|
||||
stage: 'inventory_match',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [
|
||||
lifecycle_entries: [
|
||||
{ code: 'order_review', state: 'paused', targetSurface: 'order_lifecycle_workbench' },
|
||||
] as unknown as ShippingProcessingProjection['uiState']['lifecycleEntries'],
|
||||
blocking_reason: null,
|
||||
@@ -867,9 +980,6 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.find('[data-testid="shipping-processing-file-DOC-10"]');
|
||||
const orderReview = row.findAll('button').find((button) => button.text().includes('订单复核'));
|
||||
expect(orderReview?.attributes('disabled')).toBeDefined();
|
||||
await orderReview?.trigger('click');
|
||||
expect(wrapper.emitted('openLifecycleStage')).toBeUndefined();
|
||||
expect(row.findAll('button')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
+15
-13
@@ -36,7 +36,10 @@ import {
|
||||
resolveShippingProcessingStatusLabel,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { flattenBusinessFileProjections } from '@/features/chat/shipping/conversationProcessingProjection';
|
||||
import { resolveConversationTaskActionPresentation, resolveProcessingActionPresentation } from '@/features/shipping-progress/actionPresentation';
|
||||
import {
|
||||
resolveConversationTaskActionPresentation,
|
||||
resolveFilePrimaryActionPresentation,
|
||||
} from '@/features/shipping-progress/actionPresentation';
|
||||
import SidebarProgressInline from '@/features/shipping-progress/components/SidebarProgressInline.vue';
|
||||
import type { ActionPresentation, ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
|
||||
@@ -114,16 +117,15 @@ const hasContent = computed(() => Boolean(
|
||||
));
|
||||
|
||||
const statusGroups = computed(() => activeProjection.value?.status_groups || null);
|
||||
const completedTasks = computed(() => statusGroups.value?.completed || activeProjection.value?.completed || []);
|
||||
const historyTasks = computed(() => statusGroups.value
|
||||
? [...statusGroups.value.cancelled, ...statusGroups.value.archived]
|
||||
: (activeProjection.value?.history || []));
|
||||
/** EML 卡必须由后端 userGroup 分入独立用户区;旧任务保留 needs_action 兼容归属。 */
|
||||
const failedTasks = computed(() => statusGroups.value?.failed
|
||||
|| (activeProjection.value?.needs_action || []).filter((task) => task.userGroup === 'failed' || !task.userGroup));
|
||||
const waitingHumanTasks = computed(() => statusGroups.value?.waiting_human
|
||||
|| (activeProjection.value?.needs_action || []).filter((task) => task.userGroup === 'waiting_human'));
|
||||
const processingTasks = computed(() => statusGroups.value?.processing || activeProjection.value?.processing || []);
|
||||
const completedTasks = computed(() => statusGroups.value?.completed || []);
|
||||
const historyTasks = computed(() => [
|
||||
...(statusGroups.value?.cancelled || []),
|
||||
...(statusGroups.value?.archived || []),
|
||||
]);
|
||||
/** EML 卡的状态分区必须完全遵循后端 status_groups,禁止旧四组回退重判。 */
|
||||
const failedTasks = computed(() => statusGroups.value?.failed || []);
|
||||
const waitingHumanTasks = computed(() => statusGroups.value?.waiting_human || []);
|
||||
const processingTasks = computed(() => statusGroups.value?.processing || []);
|
||||
|
||||
/** 任务只要含一个命中附件即保留,避免筛选后打散同一封 EML 的上下文。 */
|
||||
function taskMatchesLifecycleFilter(task: ConversationProcessingUserTask): boolean {
|
||||
@@ -427,7 +429,7 @@ function isDownloadSelected(taskNo: string): boolean {
|
||||
/** 状态组标题按文件计数,与批次总览保持同一口径。 */
|
||||
function groupFileCount(tasks: ConversationProcessingUserTask[]): number {
|
||||
const seen = new Set<string>();
|
||||
return tasks.reduce((total, task) => total + workbenchFileRows(task).reduce((count, file) => {
|
||||
return tasks.reduce((total, task) => total + visibleWorkbenchFileRows(task).reduce((count, file) => {
|
||||
const filename = String(file.filename || file.label || '').trim().toLowerCase();
|
||||
if (filename.endsWith('.eml')) return count;
|
||||
const key = String(('document_id' in file ? file.document_id : undefined)
|
||||
@@ -495,7 +497,7 @@ function onOpenLifecycleStage(file: WorkbenchFileRow, lifecycleStage: LifecycleS
|
||||
/** 叶子文件动作由自身 ui_state 裁决;没有叶子投影时不伪造可操作按钮。 */
|
||||
function filePrimaryActionItem(file: WorkbenchFileRow): ActionPresentationItem | null {
|
||||
return file.projection
|
||||
? resolveProcessingActionPresentation(file.projection, { surface: 'right' }).primary
|
||||
? resolveFilePrimaryActionPresentation(file.projection)
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
+52
-14
@@ -149,7 +149,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).toContain('处理中 1');
|
||||
});
|
||||
|
||||
it('uses the current three PDF rows instead of stale Run review totals', () => {
|
||||
it('keeps historical candidate-ready attachments under their EML instead of creating a candidate group', () => {
|
||||
const currentPdfRows = ['4210020274.pdf', '4210020272.pdf', '4210020273.pdf'].map((fileName, index) => ({
|
||||
unitId: index + 1,
|
||||
documentId: index + 101,
|
||||
@@ -181,10 +181,11 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([]) } } },
|
||||
});
|
||||
|
||||
// 当前卡片的总数、完成率和候选列表必须来自同一份有效 PDF 清单。
|
||||
// 旧快照缺少会话级用户状态;candidate_ready 只能作为附件阶段,不能升格为顶层分组。
|
||||
expect(wrapper.text()).toContain('共 3 个文件');
|
||||
expect(wrapper.text()).toContain('0/3 已处理');
|
||||
expect(wrapper.text()).toContain('已生成候选 3 个文件');
|
||||
expect(wrapper.text()).not.toContain('已生成候选 3 个文件');
|
||||
expect(wrapper.text()).toContain('4210020274.pdf');
|
||||
expect(wrapper.text()).not.toContain('23/20 已处理');
|
||||
expect(wrapper.text()).not.toContain('100% 完成');
|
||||
});
|
||||
@@ -234,6 +235,21 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).not.toContain('系统处理中');
|
||||
});
|
||||
|
||||
it('does not fall back to one Run file when the authoritative conversation projection has not returned', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState({ summary: { ...buildState().summary, totalDocuments: 1 } }), runNo: 'SNER-SINGLE' },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
// 真实会话工作流已建立但读取超时/失败时,不能将最近 Run 的单文件当作整个批次。
|
||||
processing: ref(null),
|
||||
processingWorkItems: ref([]),
|
||||
initialLoading: ref(false),
|
||||
} } },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-projection-loading"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).not.toContain('共 1 个文件');
|
||||
});
|
||||
|
||||
it('does not render message document rows while the authoritative projection is loading', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState({
|
||||
@@ -337,6 +353,34 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).not.toContain('stale.pdf');
|
||||
});
|
||||
|
||||
it('uses the authoritative attachment total when a historical message only carries the EML task count', () => {
|
||||
const task = {
|
||||
user_task_no: 'INTAKE:SNI-MAILS', title: 'mail-batch.eml', file_count: 30,
|
||||
userGroup: 'waiting_human', group: 'needs_action', aggregateChildren: [],
|
||||
aggregateSummary: { intakeNo: 'SNI-MAILS', total: 30, completed: 0, processing: 0, needsAction: 30, failed: 0, stages: ['order_review'], reasonCodes: [] },
|
||||
} as any;
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
// 历史聊天消息记录的是 18 封 EML;不能把它当成 18 个业务附件。
|
||||
state: buildState({ summary: { ...buildState().summary, totalDocuments: 18 } }),
|
||||
runNo: 'SNER-ATTACHMENT-TOTAL',
|
||||
},
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref({
|
||||
summary: { total_files: 30, completed_files: 0, waiting_human_files: 30, failed_files: 0 },
|
||||
ui_state: { status: 'waiting_human' },
|
||||
status_groups: { failed: [], waiting_human: [task], processing: [], completed: [], cancelled: [], archived: [] },
|
||||
}),
|
||||
processingWorkItems: ref([]),
|
||||
} } },
|
||||
});
|
||||
|
||||
// 关键断言:有权威会话投影时,只能显示附件总数,禁止回退历史邮件任务数。
|
||||
expect(wrapper.text()).toContain('共 30 个文件');
|
||||
expect(wrapper.text()).toContain('0/30 已处理');
|
||||
expect(wrapper.text()).not.toContain('共 18 个文件');
|
||||
});
|
||||
|
||||
it('counts unique EML attachment children instead of task rows', async () => {
|
||||
const childA = { workItemType: 'order_task', workItemNo: 'OT-A', sourceType: 'eml', intakeNo: 'SNI-COUNT', sourceSummary: { filename: 'a.pdf', documentId: 101, documentCount: 1 }, status: 'processing', stage: 'document_parsing', userStatus: 'running', facts: { uploadState: 'not_created' } } as any;
|
||||
const childB = { ...childA, workItemNo: 'OT-B', sourceSummary: { filename: 'b.pdf', documentId: 102, documentCount: 1 } } as any;
|
||||
@@ -376,7 +420,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).toContain('4518838152.pdf');
|
||||
});
|
||||
|
||||
it('groups completed attachments under their EML intake instead of mixing unrelated files', async () => {
|
||||
it('keeps candidate-ready attachments under their EML instead of mixing unrelated files', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -390,7 +434,6 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await wrapper.find('button').trigger('click');
|
||||
const text = wrapper.text();
|
||||
expect(text.indexOf('Forwarder_A.eml')).toBeLessThan(text.indexOf('Packing_List.pdf'));
|
||||
expect(text).toContain('Customs_Form.pdf');
|
||||
@@ -428,7 +471,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.findAll('.animate-spin').length).toBe(0);
|
||||
});
|
||||
|
||||
it('does not render completed files again as standalone cards', async () => {
|
||||
it('renders candidate-ready standalone files once without creating a candidate group', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -450,12 +493,11 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const accordion = wrapper.find('button');
|
||||
await accordion.trigger('click');
|
||||
expect(wrapper.text().match(/4518838152\.pdf/g)?.length).toBe(1);
|
||||
expect(wrapper.text()).not.toContain('已生成候选 2 个文件');
|
||||
});
|
||||
|
||||
it('aggregates a fully completed EML intake only inside the completed section', async () => {
|
||||
it('keeps an all-candidate EML in the system-processing fallback group', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -477,9 +519,6 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).not.toContain('forwarder.eml');
|
||||
expect(wrapper.text()).not.toContain('packing.pdf');
|
||||
await wrapper.find('button').trigger('click');
|
||||
expect(wrapper.text()).toContain('forwarder.eml');
|
||||
expect(wrapper.text()).toContain('packing.pdf');
|
||||
expect(wrapper.text().match(/forwarder\.eml/g)?.length).toBe(1);
|
||||
@@ -487,7 +526,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).toContain('已提取');
|
||||
});
|
||||
|
||||
it('keeps a partially completed EML intake outside the completed section', async () => {
|
||||
it('keeps a mixed-stage EML in the system-processing fallback group', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -501,7 +540,6 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await wrapper.find('button').trigger('click');
|
||||
expect(wrapper.text()).toContain('forwarder.eml');
|
||||
expect(wrapper.text()).toContain('invoice.pdf');
|
||||
expect(wrapper.text().match(/packing\.pdf/g)?.length).toBe(1);
|
||||
|
||||
@@ -62,9 +62,12 @@ type ConversationProcessing = import('../../types/shipping.api.types').Conversat
|
||||
const conversationProcessing = computed<ConversationProcessing | null>(() => (
|
||||
(shippingWorkflow as { processing?: { value?: ConversationProcessing | null } | null } | null)?.processing?.value || null
|
||||
));
|
||||
const hasAuthoritativeConversationProvider = computed(() => Boolean(
|
||||
shippingWorkflow && 'processing' in shippingWorkflow,
|
||||
));
|
||||
const conversationProjectionLoading = computed(() => Boolean(
|
||||
(shippingWorkflow as { initialLoading?: { value?: boolean } | null } | null)?.initialLoading?.value,
|
||||
));
|
||||
) || (hasAuthoritativeConversationProvider.value && !conversationProcessing.value));
|
||||
const conversationStatusGroups = computed<ConversationStatusGroups | null>(() => conversationProcessing.value?.status_groups || null);
|
||||
const hasConversationStatusGroups = computed(() => Boolean(conversationStatusGroups.value));
|
||||
const statusGroupDefs = [
|
||||
@@ -288,37 +291,19 @@ const childRows = (email: ShippingOrderExtractionFileState) => fileRows.value.fi
|
||||
&& row.intakeId === email.intakeId
|
||||
&& !isEmailRow(row)
|
||||
));
|
||||
const candidateEmailGroups = computed(() => emailRows.value
|
||||
.map((parent) => ({ parent, children: childRows(parent) }))
|
||||
.filter((group) => group.children.length > 0 && group.children.every((child) => child.status === 'candidate_ready')));
|
||||
const emailHasFailedChild = (email: ShippingOrderExtractionFileState) => childRows(email).some(isFailedParseRow);
|
||||
const emailIsCompleted = (email: ShippingOrderExtractionFileState) => {
|
||||
const children = childRows(email);
|
||||
return children.length > 0 && children.every((child) => child.status === 'candidate_ready');
|
||||
};
|
||||
const candidateEmailUnitIds = computed(() => new Set(
|
||||
candidateEmailGroups.value.flatMap((group) => [group.parent.unitId, ...group.children.map((child) => child.unitId)]),
|
||||
));
|
||||
const candidateStandaloneRows = computed(() => fileRows.value.filter((row) => (
|
||||
!isEmailRow(row)
|
||||
&& row.status === 'candidate_ready'
|
||||
&& !emailRows.value.some((email) => childRows(email).some((child) => child.unitId === row.unitId))
|
||||
)));
|
||||
const candidateFileCount = computed(() => (
|
||||
candidateEmailGroups.value.reduce((count, group) => count + group.children.length, 0)
|
||||
+ candidateStandaloneRows.value.length
|
||||
));
|
||||
const activeEmailRows = computed(() => emailRows.value.filter((row) => !candidateEmailUnitIds.value.has(row.unitId)));
|
||||
const activeEmailRows = computed(() => emailRows.value);
|
||||
const standaloneRows = computed(() => fileRows.value.filter((row) => (
|
||||
!isEmailRow(row)
|
||||
&& row.status !== 'candidate_ready'
|
||||
&& !isFailedParseRow(row)
|
||||
&& !candidateEmailUnitIds.value.has(row.unitId)
|
||||
&& !emailRows.value.some((email) => childRows(email).some((child) => child.unitId === row.unitId))
|
||||
)));
|
||||
const failedRows = computed(() => fileRows.value.filter((row) => (
|
||||
isFailedParseRow(row)
|
||||
&& !candidateEmailUnitIds.value.has(row.unitId)
|
||||
&& !emailRows.value.some((email) => childRows(email).some((child) => child.unitId === row.unitId))
|
||||
)));
|
||||
const processedCount = computed(() => {
|
||||
@@ -339,8 +324,6 @@ const progressPercent = computed(() => {
|
||||
const total = batchFileCount.value;
|
||||
return total > 0 ? Math.min(100, Math.round((processedCount.value / total) * 100)) : 0;
|
||||
});
|
||||
const completedExpanded = ref(false);
|
||||
|
||||
/** 新版会话批次的业务文件数由后端汇总;旧 Run 卡仍保留历史兼容计数。 */
|
||||
const batchFileCount = computed(() => {
|
||||
if (hasConversationStatusGroups.value) {
|
||||
@@ -486,15 +469,13 @@ const handlingSummaryLine = computed(() => {
|
||||
});
|
||||
|
||||
/**
|
||||
* 唯一主 CTA:失败→重试解析;需处理→继续处理;否则不展示。
|
||||
* 唯一主 CTA 只读取服务端明确下发的动作;失败数量和 Run 状态不能自行授权重试。
|
||||
*/
|
||||
const primaryChatAction = computed((): { kind: 'retry' | 'continue'; label: string } | null => {
|
||||
if (props.readonly || hasConversationStatusGroups.value) return null;
|
||||
const actions = props.state.availableActions || [];
|
||||
const canRetry = actions.includes('retry_failed_attachments')
|
||||
|| actions.includes('retry_failed_documents')
|
||||
|| displaySummary.value.failedDocuments > 0
|
||||
|| props.state.status === 'failed';
|
||||
|| actions.includes('retry_failed_documents');
|
||||
if (canRetry) {
|
||||
return {
|
||||
kind: 'retry',
|
||||
@@ -701,26 +682,32 @@ async function onPrimaryChatAction() {
|
||||
<ChevronDown class="h-4 w-4 transition-transform" :class="expandedStatusGroups.has(group.key) ? 'rotate-180' : ''" />
|
||||
</button>
|
||||
<div v-if="expandedStatusGroups.has(group.key)" class="space-y-2 border-t border-slate-200 p-2 dark:border-slate-700">
|
||||
<article v-for="task in statusGroupTasks(group.key)" :key="task.user_task_no" class="rounded-lg border border-slate-200 bg-slate-50 dark:border-slate-700 dark:bg-slate-950/30" :data-testid="`shipping-order-extraction-eml-${group.key}-${task.user_task_no}`">
|
||||
<div class="flex items-start gap-2">
|
||||
<Mail class="mt-0.5 h-4 w-4 text-blue-600" />
|
||||
<article v-for="task in statusGroupTasks(group.key)" :key="task.user_task_no" class="overflow-hidden rounded-lg border border-slate-300 bg-white shadow-sm dark:border-slate-700 dark:bg-slate-900" :data-testid="`shipping-order-extraction-eml-${group.key}-${task.user_task_no}`">
|
||||
<div class="flex items-start gap-3 border-b border-slate-200 bg-blue-50/50 p-3 dark:border-slate-700 dark:bg-blue-950/20">
|
||||
<Mail class="mt-0.5 h-5 w-5 text-blue-600" />
|
||||
<div class="min-w-0 flex-1">
|
||||
<button type="button" class="flex w-full items-center justify-between gap-2 text-left" @click="toggleEmlTask(task.user_task_no)">
|
||||
<span class="truncate text-sm font-medium">{{ task.title || task.user_task_no }}</span>
|
||||
<button type="button" class="flex w-full items-center justify-between gap-3 text-left" @click="toggleEmlTask(task.user_task_no)">
|
||||
<span class="truncate font-medium">{{ task.title || task.user_task_no }}</span>
|
||||
<ChevronDown class="h-4 w-4 shrink-0 transition-transform" :class="expandedEmlTasks.has(task.user_task_no) ? 'rotate-180' : ''" />
|
||||
</button>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ t('chat.shippingProcessing.taskFiles', { count: taskFileCount(task) }) }}<span v-if="task.aggregateSummary"> · {{ aggregateStatusLabelFromSummary(task.aggregateSummary) }}</span></div>
|
||||
<div v-if="taskReason(task)" class="mt-1 text-xs text-rose-600">{{ displayReason(taskReason(task)) }}</div>
|
||||
<div v-if="expandedEmlTasks.has(task.user_task_no) && taskChildren(task).length" class="mt-2 space-y-1 border-t border-slate-200 pt-2 dark:border-slate-700" data-testid="shipping-order-extraction-eml-children">
|
||||
<div v-for="child in taskChildren(task).filter((item) => !String(item.sourceSummary?.filename || '').toLowerCase().endsWith('.eml'))" :key="child.workItemNo" class="flex items-start justify-between gap-3 rounded-md bg-white px-2 py-1.5 text-xs dark:bg-slate-900">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-medium">{{ child.sourceSummary.filename || child.workItemNo }}</div>
|
||||
<div class="text-[11px] text-slate-500">{{ childStageLabel(child) }}</div>
|
||||
<div v-if="taskReason(child)" class="text-[11px] text-rose-600">{{ displayReason(taskReason(child)) }}</div>
|
||||
</div>
|
||||
<span :data-testid="`shipping-order-extraction-child-status-${child.workItemNo}`" class="shrink-0" :class="isFailedProjection(child) ? 'text-rose-600' : isWaitingProjection(child) ? 'text-amber-700' : isCompletedProjection(child) ? 'text-emerald-600' : 'text-blue-600'">{{ childStatusLabel(child) }}</span>
|
||||
<div class="mt-1 text-xs text-slate-600 dark:text-slate-300">{{ t('chat.shippingProcessing.taskFiles', { count: taskFileCount(task) }) }}<span v-if="task.aggregateSummary"> · {{ aggregateStatusLabelFromSummary(task.aggregateSummary) }}</span></div>
|
||||
<div v-if="taskReason(task)" class="mt-1 text-xs text-rose-600">{{ displayReason(taskReason(task)) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="expandedEmlTasks.has(task.user_task_no) && taskChildren(task).length" class="mx-4 my-2 space-y-1 border-l-2 border-blue-200 bg-slate-50 p-3 pl-4 dark:border-blue-800 dark:bg-blue-950/30" data-testid="shipping-order-extraction-eml-children">
|
||||
<div v-for="child in taskChildren(task).filter((item) => !String(item.sourceSummary?.filename || '').toLowerCase().endsWith('.eml'))" :key="child.workItemNo" class="flex items-start justify-between gap-3 py-1 text-sm">
|
||||
<div class="flex min-w-0 items-start gap-2">
|
||||
<LoaderCircle v-if="!isFailedProjection(child) && !isWaitingProjection(child) && !isCompletedProjection(child)" class="mt-0.5 h-4 w-4 shrink-0 animate-spin text-blue-500" />
|
||||
<AlertCircle v-else-if="isFailedProjection(child)" class="mt-0.5 h-4 w-4 shrink-0 text-rose-500" />
|
||||
<CheckCircle2 v-else-if="isCompletedProjection(child)" class="mt-0.5 h-4 w-4 shrink-0 text-emerald-500" />
|
||||
<TriangleAlert v-else class="mt-0.5 h-4 w-4 shrink-0 text-amber-500" />
|
||||
<div class="min-w-0">
|
||||
<div class="truncate">{{ child.sourceSummary.filename || child.workItemNo }}</div>
|
||||
<div class="text-xs text-slate-500">{{ childStageLabel(child) }}</div>
|
||||
<div v-if="taskReason(child)" class="text-xs text-rose-600">{{ displayReason(taskReason(child)) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<span :data-testid="`shipping-order-extraction-child-status-${child.workItemNo}`" class="shrink-0" :class="isFailedProjection(child) ? 'text-rose-600' : isWaitingProjection(child) ? 'text-amber-700' : isCompletedProjection(child) ? 'text-emerald-600' : 'text-blue-600'">{{ childStatusLabel(child) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
@@ -756,19 +743,6 @@ async function onPrimaryChatAction() {
|
||||
</article>
|
||||
</div>
|
||||
<div v-else-if="!compactProgress" class="flex flex-col gap-2 bg-slate-50 p-2 dark:bg-slate-950/30">
|
||||
<button type="button" class="flex items-center justify-between rounded-lg border border-slate-200 bg-white px-3 py-3 text-left dark:border-slate-700 dark:bg-slate-900" @click="completedExpanded = !completedExpanded">
|
||||
<span class="flex items-center gap-3 text-base font-medium"><span class="flex h-7 w-7 items-center justify-center rounded-full bg-blue-100 text-blue-600"><CheckCircle2 class="h-4 w-4" /></span>{{ t('chat.shippingProcessing.candidateFiles', { count: candidateFileCount }) }}</span>
|
||||
<ChevronDown class="h-5 w-5 transition-transform" :class="completedExpanded ? 'rotate-180' : ''" />
|
||||
</button>
|
||||
<div v-if="completedExpanded && candidateFileCount" class="space-y-2 rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<div v-for="group in candidateEmailGroups" :key="`candidate-email-${group.parent.unitId}`" class="rounded-md border border-blue-100 bg-blue-50/50 px-3 py-2 dark:border-blue-900 dark:bg-blue-950/20">
|
||||
<div class="flex items-center gap-2 font-medium text-slate-700 dark:text-slate-200"><Mail class="h-4 w-4 text-blue-600" />{{ t('chat.shippingProcessing.emailPrefix') }}{{ group.parent.fileName }}<span class="ml-auto text-emerald-500">{{ t('chat.shippingProcessing.batchExtracted') }}</span></div>
|
||||
<div class="mt-1 space-y-1 border-l-2 border-blue-200 pl-3 dark:border-blue-800">
|
||||
<div v-for="row in group.children" :key="`candidate-child-${row.unitId}`" class="flex items-center gap-2 py-1 text-slate-600 dark:text-slate-300"><CheckCircle2 class="h-4 w-4 text-blue-500" />{{ row.fileName }}<span class="ml-auto text-blue-500">{{ rowStatusLabel(row) }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-for="row in candidateStandaloneRows" :key="`candidate-${row.unitId}`" class="flex items-center gap-2 py-1 text-slate-600 dark:text-slate-300"><CheckCircle2 class="h-4 w-4 text-blue-500" />{{ row.fileName }}<span class="ml-auto text-blue-500">{{ rowStatusLabel(row) }}</span></div>
|
||||
</div>
|
||||
<div v-for="row in activeEmailRows" :key="row.unitId" class="overflow-hidden rounded-lg border border-slate-300 bg-white shadow-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<div class="flex items-start gap-3 border-b border-slate-200 bg-blue-50/50 p-3 dark:border-slate-700 dark:bg-blue-950/20"><Mail class="mt-0.5 h-5 w-5 text-blue-600" /><div class="min-w-0 flex-1"><div class="flex items-center justify-between gap-3"><span class="font-medium">{{ t('chat.shippingProcessing.emailPrefix') }}{{ row.fileName }}</span><span class="rounded border px-2 py-0.5 text-xs" :class="isFailedParseRow(row) || emailHasFailedChild(row) ? 'border-rose-200 bg-rose-100/70 text-rose-600' : emailIsCompleted(row) ? 'border-emerald-200 bg-emerald-100/70 text-emerald-600' : 'border-blue-200 bg-blue-100/70 text-blue-600'">{{ isFailedParseRow(row) || emailHasFailedChild(row) ? t('chat.shippingProcessing.batchException') : emailIsCompleted(row) ? t('chat.shippingProcessing.batchExtracted') : t('chat.shippingProcessing.parsingAttachments') }}</span></div><span class="mt-1 block font-mono text-xs text-slate-500">{{ t('chat.shippingProcessing.emailMeta') }}</span></div></div>
|
||||
<div class="mx-4 my-2 flex flex-col gap-2 border-l-2 border-blue-200 bg-slate-50 p-3 pl-4 dark:border-blue-800 dark:bg-blue-950/30"><div v-for="child in childRows(row)" :key="`child-${child.unitId}`" class="flex items-center justify-between gap-3 text-sm"><span class="flex min-w-0 items-center gap-2"><CheckCircle2 v-if="child.status === 'candidate_ready'" class="h-4 w-4 text-emerald-500" /><LoaderCircle v-else-if="!isFailedParseRow(child)" class="h-4 w-4 animate-spin text-blue-500" /><AlertCircle v-else class="h-4 w-4 text-rose-500" /><span class="truncate">{{ child.fileName }}</span></span><span :class="rowStatusClass(child)">{{ rowStatusLabel(child) }}</span></div></div>
|
||||
|
||||
@@ -43,6 +43,12 @@ vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
vi.mock('@/shared/composables/useMessage', () => ({
|
||||
useMessage: () => ({ success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() }),
|
||||
}));
|
||||
const gateRecovery = vi.hoisted(() => ({
|
||||
submitPrimaryAction: vi.fn(async () => ({ outcome: 'submitted' })),
|
||||
}));
|
||||
vi.mock('@/features/shipping-process-gates/composables/useShippingProcessGateRecovery', () => ({
|
||||
useShippingProcessGateRecovery: () => gateRecovery,
|
||||
}));
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
@@ -114,6 +120,8 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
api.reparseCase.mockClear();
|
||||
api.reparseRun.mockClear();
|
||||
api.reparseBatch.mockClear();
|
||||
api.retryRun.mockClear();
|
||||
gateRecovery.submitPrimaryAction.mockClear();
|
||||
});
|
||||
|
||||
it('prefers backend five-stage lifecycle nodes and shows the authorized download toolbar in freight upload', async () => {
|
||||
@@ -125,8 +133,6 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
{ code: 'freight_upload', status: 'running', summary: { total: 1, completed: 0, needs_action: 1, processing: 0, failed: 0, blocking_reason: { code: 'manual_upload_pending' } } },
|
||||
{ code: 'upload_complete', status: 'pending', summary: { total: 1, completed: 0, needs_action: 0, processing: 0, failed: 0, blocking_reason: null } },
|
||||
],
|
||||
// 新字段存在时必须优先使用,不能显示兼容字段的旧/冲突结果。
|
||||
four_stage_nodes: [{ code: 'upload_complete', status: 'passed', summary: { total: 9, completed: 9, needs_action: 0, processing: 0, failed: 0, blocking_reason: null } }],
|
||||
output_artifacts: [{ order_task_no: 'OT-1', filename: 'notice.xlsx', type: 'xlsx', status: 'ready', action: { code: 'download_excel', enabled: true } }],
|
||||
} as Partial<ConversationProcessingProjection>);
|
||||
const wrapper = mountTimeline(processing, [fileProjection()]);
|
||||
@@ -292,7 +298,7 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
|
||||
await wrapper.findComponent({ name: 'ShippingConversationProcessingCard' }).vm.$emit('projection-action', {
|
||||
projection: file,
|
||||
item: { intent: 'retry', actionCode: 'reparse', labelKey: 'chat.shippingProcessing.action.retry_parse' },
|
||||
item: { intent: 'reparse', actionCode: 'reparse', labelKey: 'chat.shippingProcessing.action.retry_parse' },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
@@ -323,7 +329,7 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
|
||||
await wrapper.findComponent({ name: 'ShippingConversationProcessingCard' }).vm.$emit('projection-action', {
|
||||
projection: file,
|
||||
item: { intent: 'retry', actionCode: 'reparse', labelKey: 'chat.shippingProcessing.action.retry_parse' },
|
||||
item: { intent: 'reparse', actionCode: 'reparse', labelKey: 'chat.shippingProcessing.action.retry_parse' },
|
||||
});
|
||||
await flushPromises();
|
||||
const input = document.querySelector<HTMLTextAreaElement>('[data-testid="shipping-workflow-reason-input"]');
|
||||
@@ -431,7 +437,7 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-processing-batch-reparse"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('retries a file generic-retry action by its backend run instead of silently treating it as intake retry', async () => {
|
||||
it('rejects a legacy generic-retry action instead of treating it as a Run retry', async () => {
|
||||
const file = fileProjection({
|
||||
uiState: {
|
||||
status: 'failed', stage: 'document_parsing', lifecycleStage: 'intake_parse',
|
||||
@@ -444,12 +450,40 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
|
||||
await wrapper.findComponent({ name: 'ShippingConversationProcessingCard' }).vm.$emit('projection-action', {
|
||||
projection: file,
|
||||
item: { intent: 'retry', actionCode: 'retry', labelKey: 'chat.shippingProcessing.action.retry_parse' },
|
||||
item: { intent: 'retry_parse', actionCode: 'retry', labelKey: 'chat.shippingProcessing.action.retry_parse' },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// 后端只授予了 retry;附件层使用自己的 Run 执行,不能因 DOCUMENT 编号而吞掉操作。
|
||||
expect(api.retryRun).toHaveBeenCalledWith('RUN-1');
|
||||
// 泛化 retry 已退出契约;前端不得据 Run 编号擅自选择重试 API。
|
||||
expect(api.retryRun).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('submits an authorized freight-upload retry through its Gate instead of re-running extraction', async () => {
|
||||
const processGate = {
|
||||
execution_no: 'SPE-1',
|
||||
allowed_actions: ['retry_freight_upload_rpa'],
|
||||
recovery_targets: [],
|
||||
current_blocking_gate: {
|
||||
gate_code: 'freight_upload', evaluation_version: 1,
|
||||
},
|
||||
};
|
||||
const file = fileProjection({ processGate } as Partial<ShippingProcessingProjection>);
|
||||
const wrapper = mountTimeline(processingProjection(), [file]);
|
||||
await flushPromises();
|
||||
|
||||
await wrapper.findComponent({ name: 'ShippingConversationProcessingCard' }).vm.$emit('projection-action', {
|
||||
projection: file,
|
||||
item: {
|
||||
intent: 'retry_freight_upload_rpa', actionCode: 'retry_freight_upload_rpa',
|
||||
labelKey: 'chat.shippingProcessing.action.retry',
|
||||
},
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(gateRecovery.submitPrimaryAction).toHaveBeenCalledWith(processGate, expect.objectContaining({
|
||||
actionCode: 'retry_freight_upload_rpa',
|
||||
}));
|
||||
expect(api.retryRun).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('opens manual upload with the backend root task number for a document file action', async () => {
|
||||
@@ -469,23 +503,6 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
it('falls back to the compatibility lifecycle field and shows only title and total', async () => {
|
||||
const processing = processingProjection({
|
||||
four_stage_nodes: [{
|
||||
code: 'order_review', status: 'blocked',
|
||||
summary: { total: 2, completed: 0, needs_action: 2, processing: 0, failed: 0, blocking_reason: { code: 'field_conflict' } },
|
||||
}],
|
||||
} as Partial<ConversationProcessingProjection>);
|
||||
const wrapper = mountTimeline(processing, [fileProjection()]);
|
||||
await flushPromises();
|
||||
|
||||
const card = wrapper.get('[data-testid="shipping-workflow-stage-filter-order_review"]');
|
||||
expect(card.text()).toContain('订单复核');
|
||||
expect(card.text()).toContain('2');
|
||||
expect(card.text()).not.toContain('待处理');
|
||||
expect(card.text()).not.toContain('field_conflict');
|
||||
});
|
||||
|
||||
it('does not navigate when a lifecycle entry has an unknown backend state', async () => {
|
||||
routerPush.mockClear();
|
||||
const wrapper = mountTimeline(processingProjection(), [fileProjection()]);
|
||||
|
||||
@@ -115,12 +115,16 @@ const processing = computed(() => ctl.value.processing?.value ?? null);
|
||||
/** 展示投影:统一 ShippingProcessing / conversation_processing。 */
|
||||
const displayProcessing = computed(() => processing.value);
|
||||
const batchArtifacts = computed(() => displayProcessing.value?.output_artifacts || []);
|
||||
const batchLifecycleNodes = computed(() => (
|
||||
displayProcessing.value?.lifecycle_nodes || displayProcessing.value?.four_stage_nodes || []
|
||||
));
|
||||
const batchLifecycleNodes = computed(() => displayProcessing.value?.lifecycle_nodes || []);
|
||||
const lifecycleFilter = ref<'all' | 'intake_parse' | 'order_review' | 'fulfillment_prep' | 'freight_upload' | 'upload_complete'>('all');
|
||||
const fileSearchQuery = ref('');
|
||||
const selectedDownloadTaskNos = ref<string[]>([]);
|
||||
type ConversationStatusGroup = 'failed' | 'waiting_human' | 'processing' | 'completed' | 'cancelled' | 'archived';
|
||||
function statusGroupTasks(...groups: ConversationStatusGroup[]): ConversationProcessingUserTask[] {
|
||||
const statusGroups = displayProcessing.value?.status_groups;
|
||||
if (!statusGroups) return [];
|
||||
return groups.flatMap((group) => statusGroups[group] || []);
|
||||
}
|
||||
/** 五阶段后端编码为 snake_case,语言资源键沿用 camelCase;映射仅做展示翻译,不参与状态裁决。 */
|
||||
const BATCH_LIFECYCLE_I18N_KEYS: Record<string, string> = {
|
||||
intake_parse: 'intakeParse',
|
||||
@@ -193,87 +197,17 @@ async function downloadBatchArchive(taskNos: string[]) {
|
||||
msg.error(err instanceof Error ? err.message : t('chat.shippingProcessing.batchWorkbench.artifacts.downloadFailed', { count: taskNos.length }));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 批次总览一律按文件计数。会话 summary 中 processing/needs_action 是任务数,
|
||||
* 不能直接填入原型的“处理中/需处理”文件统计卡。
|
||||
*/
|
||||
function taskFileKeys(task: ConversationProcessingUserTask): string[] {
|
||||
const keys = new Set<string>();
|
||||
const collect = (children: ShippingProcessingProjection[]) => {
|
||||
for (const child of children) {
|
||||
const nested = child.aggregateChildren || [];
|
||||
if (nested.length) collect(nested);
|
||||
const filename = String(child.sourceSummary?.filename || '').trim();
|
||||
// 聚合父项/邮件容器只提供来源信息,叶子附件才计入业务文件。
|
||||
if (nested.length || filename.toLowerCase().endsWith('.eml')) continue;
|
||||
const id = Number(child.sourceSummary?.documentId || 0);
|
||||
const key = id > 0 ? `document:${id}` : filename ? `filename:${filename}` : '';
|
||||
if (key) keys.add(key);
|
||||
}
|
||||
};
|
||||
const children = task.aggregateChildren || [];
|
||||
if (children.length) {
|
||||
collect(children);
|
||||
return [...keys];
|
||||
}
|
||||
for (const object of task.objects || []) {
|
||||
if (object.kind !== 'document') continue;
|
||||
const id = Number(object.document_id || 0);
|
||||
const filename = String(object.filename || object.label || '').trim();
|
||||
if (filename.toLowerCase().endsWith('.eml')) continue;
|
||||
const key = id > 0
|
||||
? `document:${id}`
|
||||
: String(object.filename || object.object_key || '').trim();
|
||||
if (key) keys.add(key);
|
||||
}
|
||||
if (keys.size) return [...keys];
|
||||
// 无 EML 子附件明细时,直接文件可按自身 file_count 回退;EML 不允许伪造附件数。
|
||||
const taskName = String(task.title || '').trim().toLowerCase();
|
||||
if (taskName.endsWith('.eml') || task.aggregateSummary?.intakeNo) return [];
|
||||
const fallback = Math.max(0, Number(task.file_count || 0));
|
||||
return Array.from({ length: fallback }, (_, index) => `${task.user_task_no}:file:${index}`);
|
||||
}
|
||||
const batchOverview = computed(() => {
|
||||
const summary = displayProcessing.value?.summary;
|
||||
// [AUTHORITY] status_groups 表示新版批次投影。其 summary 是后端对完整批次
|
||||
// 一次裁决的文件事实,即使当前值为 0 也不得从局部展开行重算。
|
||||
if (displayProcessing.value?.status_groups && summary) {
|
||||
return {
|
||||
total: Number(summary.total_files || 0),
|
||||
processing: Number(summary.processing_files || 0),
|
||||
completed: Number(summary.completed_files || 0),
|
||||
needsAction: Number(summary.failed_files || 0) + Number(summary.waiting_human_files || 0),
|
||||
};
|
||||
}
|
||||
const groups = displayProcessing.value?.status_groups;
|
||||
const failed = groups?.failed || [];
|
||||
const waiting = groups?.waiting_human || [];
|
||||
const processingTasks = groups?.processing || displayProcessing.value?.processing || [];
|
||||
const completed = groups?.completed || displayProcessing.value?.completed || [];
|
||||
const seen = new Set<string>();
|
||||
const count = (tasks: ConversationProcessingUserTask[]) => tasks.reduce((total, task) => {
|
||||
let count = 0;
|
||||
for (const key of taskFileKeys(task)) {
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
count += 1;
|
||||
}
|
||||
return total + count;
|
||||
}, 0);
|
||||
const needsAction = count([...failed, ...waiting]);
|
||||
const processingCount = count(processingTasks);
|
||||
const completedCount = count(completed);
|
||||
const computedTotal = needsAction + processingCount + completedCount;
|
||||
const summaryTotal = Number(displayProcessing.value?.summary?.total_files || 0);
|
||||
// [AUTHORITY] 摘要投影的统计与状态组同由服务端一次裁决;不能从展开行重算,
|
||||
// 否则 EML 聚合、历史版本去重与五阶段筛选会再次发生口径漂移。
|
||||
return {
|
||||
// status_groups 的去重文件集合优先;旧 summary.total_files 只在没有可枚举文件时回退。
|
||||
total: computedTotal > 0 ? computedTotal : summaryTotal,
|
||||
processing: processingCount,
|
||||
completed: completedCount,
|
||||
needsAction,
|
||||
total: Number(summary?.total_files || 0),
|
||||
processing: Number(summary?.processing_files || 0),
|
||||
completed: Number(summary?.completed_files || 0),
|
||||
needsAction: Number(summary?.failed_files || 0) + Number(summary?.waiting_human_files || 0),
|
||||
};
|
||||
});
|
||||
const loading = computed(() => ctl.value.loading.value);
|
||||
/** 初始加载:首次打开投影仍为空时显示摘要占位。 */
|
||||
const initialLoading = computed(() => Boolean(ctl.value.initialLoading?.value));
|
||||
/** 用户主动刷新(刷新按钮 / 重试 / 重解析等):驱动顶部刷新图标旋转。 */
|
||||
@@ -287,11 +221,7 @@ const error = computed(() => ctl.value.error.value);
|
||||
const hasPinnedProcessingTasks = computed(() => {
|
||||
const projection = displayProcessing.value;
|
||||
if (!projection) return false;
|
||||
return Boolean(
|
||||
projection.needs_action?.length
|
||||
|| projection.processing?.length
|
||||
|| projection.completed?.length,
|
||||
);
|
||||
return statusGroupTasks('failed', 'waiting_human', 'processing', 'completed').length > 0;
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -492,7 +422,7 @@ async function onProcessingTaskAction(payload: {
|
||||
openReparseBatchDialog(runNo);
|
||||
return;
|
||||
}
|
||||
if (action === 'retry_parse' || action === 'retry') {
|
||||
if (action === 'retry_parse') {
|
||||
const intakeNo = String(task.user_task_no || '').replace(/^INTAKE:/i, '').trim();
|
||||
if (intakeNo.startsWith('SNI-')) {
|
||||
if (actionBusyItemNo.value) return;
|
||||
@@ -744,10 +674,8 @@ async function onTaskProjectionAction(payload: {
|
||||
return;
|
||||
}
|
||||
if (code === 'reparse') {
|
||||
const task = [
|
||||
...(displayProcessing.value?.needs_action || []),
|
||||
...(displayProcessing.value?.processing || []),
|
||||
].find((row) => String(row.user_task_no || '').trim() === taskNo);
|
||||
const task = statusGroupTasks('failed', 'waiting_human', 'processing')
|
||||
.find((row) => String(row.user_task_no || '').trim() === taskNo);
|
||||
if (task) {
|
||||
void onProcessingTaskAction({ task, action: 'reparse' });
|
||||
return;
|
||||
@@ -776,13 +704,16 @@ async function onTaskProjectionAction(payload: {
|
||||
openReparseBatchDialog(runNo);
|
||||
return;
|
||||
}
|
||||
if (code === 'retry_inventory_preparation') {
|
||||
const gateSummary = projection.processGate;
|
||||
if (!gateSummary) {
|
||||
msg.warning(t('workspace.shippingNotice.processGate.noAction'));
|
||||
return;
|
||||
}
|
||||
// Gate 执行器统一处理 execution_no、乐观锁与幂等键;批次卡不自行组装写请求。
|
||||
const gateSummary = projection.processGate;
|
||||
const gateAuthorized = Boolean(gateSummary && code && (
|
||||
(gateSummary.allowed_actions || []).some((action) => String(action).trim() === code)
|
||||
|| (gateSummary.recovery_targets || []).some((target) => (
|
||||
String(target.action_code || '').trim() === code
|
||||
))
|
||||
));
|
||||
if (gateAuthorized && gateSummary) {
|
||||
// Gate 执行器统一处理 execution_no、乐观锁与幂等键;不能因展示 intent=retry
|
||||
// 误将货代上传等 Gate 恢复动作路由为重新解析。
|
||||
const result = await submitGatePrimaryAction(gateSummary, {
|
||||
actionCode: code,
|
||||
navigationContext: gateNavigationContext.value,
|
||||
@@ -796,34 +727,13 @@ async function onTaskProjectionAction(payload: {
|
||||
void onProcessingIntakeAction({ item: projection, action: code });
|
||||
return;
|
||||
}
|
||||
if (code === 'retry' || item.intent === 'retry') {
|
||||
const runNo = String(projection.runNo || '').trim();
|
||||
if (!runNo) {
|
||||
msg.warning(t('chat.shippingProcessing.retryTaskMissingRun'));
|
||||
return;
|
||||
}
|
||||
if (actionBusyItemNo.value) return;
|
||||
actionBusyItemNo.value = runNo;
|
||||
try {
|
||||
await retryWorkspaceShippingOrderExtractionRun(runNo);
|
||||
await ctl.value.refresh();
|
||||
} catch (err) {
|
||||
msg.error(reparseErrorMessage(err));
|
||||
} finally {
|
||||
actionBusyItemNo.value = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (item.intent === 'refresh') {
|
||||
void onRefresh();
|
||||
return;
|
||||
}
|
||||
if (item.intent === 'open_order_review' || code === 'open_order_review') {
|
||||
const task = [
|
||||
...(displayProcessing.value?.needs_action || []),
|
||||
...(displayProcessing.value?.processing || []),
|
||||
...(displayProcessing.value?.completed || []),
|
||||
].find((row) => String(row.user_task_no || '').trim() === taskNo);
|
||||
const task = statusGroupTasks('failed', 'waiting_human', 'processing', 'completed')
|
||||
.find((row) => String(row.user_task_no || '').trim() === taskNo);
|
||||
if (task) {
|
||||
void onProcessingTaskAction({ task, action: code || 'open_review' });
|
||||
return;
|
||||
@@ -844,11 +754,8 @@ async function onTaskProjectionAction(payload: {
|
||||
return;
|
||||
}
|
||||
if (item.intent === 'view_result' || code === 'focus_task') {
|
||||
const task = [
|
||||
...(displayProcessing.value?.needs_action || []),
|
||||
...(displayProcessing.value?.processing || []),
|
||||
...(displayProcessing.value?.completed || []),
|
||||
].find((row) => String(row.user_task_no || '').trim() === taskNo);
|
||||
const task = statusGroupTasks('failed', 'waiting_human', 'processing', 'completed')
|
||||
.find((row) => String(row.user_task_no || '').trim() === taskNo);
|
||||
if (task) {
|
||||
await onProcessingFocus(taskNo);
|
||||
return;
|
||||
@@ -882,12 +789,9 @@ watch(
|
||||
const focusedTaskExists = computed(() => {
|
||||
const taskNo = String(route.query.focus_task_no || '').trim();
|
||||
if (!taskNo || !displayProcessing.value) return false;
|
||||
const groups = [
|
||||
...(displayProcessing.value.needs_action || []),
|
||||
...(displayProcessing.value.processing || []),
|
||||
...(displayProcessing.value.completed || []),
|
||||
...(displayProcessing.value.history || []),
|
||||
];
|
||||
const groups = statusGroupTasks(
|
||||
'failed', 'waiting_human', 'processing', 'completed', 'cancelled', 'archived',
|
||||
);
|
||||
return groups.some((task) => String(task.user_task_no || '').trim() === taskNo);
|
||||
});
|
||||
|
||||
@@ -959,7 +863,7 @@ watch(
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-0.5 space-y-0.5 text-xs text-secondary" data-testid="shipping-workflow-panel-summary">
|
||||
<template v-if="loading && !displayProcessing">
|
||||
<template v-if="initialLoading && !displayProcessing">
|
||||
{{ t('chat.shippingProcessing.loading') }}
|
||||
</template>
|
||||
<template v-else-if="displayProcessing">
|
||||
@@ -971,11 +875,11 @@ watch(
|
||||
{{ t('chat.shippingProcessing.summaryTruncatedHint') }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="error">
|
||||
{{ resolveShippingProcessingMessage('networkRecoverable', te, t) }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ t('chat.shippingProcessing.compactSummary', {
|
||||
active: 0,
|
||||
total: 0,
|
||||
}) }}
|
||||
{{ t('chat.shippingProcessing.loading') }}
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1001,6 +905,26 @@ watch(
|
||||
</div>
|
||||
|
||||
<div v-if="!collapsed" class="min-h-0 flex-1 overflow-y-auto p-5">
|
||||
<div
|
||||
v-if="initialLoading && !displayProcessing"
|
||||
class="mb-4 space-y-3"
|
||||
data-testid="shipping-workflow-loading"
|
||||
>
|
||||
<div class="grid grid-cols-2 gap-3 xl:grid-cols-4">
|
||||
<div v-for="index in 4" :key="index" class="h-24 animate-pulse rounded-xl border border-default bg-surface-muted" />
|
||||
</div>
|
||||
<div class="h-32 animate-pulse rounded-xl border border-default bg-surface-muted" />
|
||||
</div>
|
||||
<div
|
||||
v-else-if="error && !displayProcessing"
|
||||
class="mb-4 rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900"
|
||||
data-testid="shipping-workflow-load-error"
|
||||
>
|
||||
<p>{{ resolveShippingProcessingMessage('networkRecoverable', te, t) }}</p>
|
||||
<button type="button" class="mt-2 rounded-md border border-amber-300 px-2.5 py-1 text-xs font-medium" @click="onRefresh">
|
||||
{{ t('chat.shippingProcessing.actions.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="displayProcessing"
|
||||
class="mb-4 grid grid-cols-2 gap-3 xl:grid-cols-4"
|
||||
|
||||
Reference in new issue
Block a user