feat(shipping-notice): 落地 XFA 统一视觉拆分确认门禁与处理投影收敛
闭合拆分预览令牌单次消费、样本 checksum 绑定与确认审计;正式提取改为 bindings-only。 同步统一标注工作台交互,并补齐进度投影/任务中心与迁移文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d2b3d74def
commit
84a881b554
195 files changed
+20269
-3463
No files matched your search
+87
-1
@@ -8,7 +8,10 @@ import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import chatZhCn from '@/locales/zh-CN/chat.json';
|
||||
import type { ConversationProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import type {
|
||||
ConversationProcessingProjection,
|
||||
ShippingProcessingProjection,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import ShippingConversationProcessingCard from './ShippingConversationProcessingCard.vue';
|
||||
|
||||
const i18n = createI18n({
|
||||
@@ -64,6 +67,41 @@ function buildProjection(): ConversationProcessingProjection {
|
||||
};
|
||||
}
|
||||
|
||||
/** 构造任务卡使用的权威统一进度。 */
|
||||
function buildWorkItem(
|
||||
taskNo: string,
|
||||
patch: Partial<ShippingProcessingProjection> = {},
|
||||
): ShippingProcessingProjection {
|
||||
return {
|
||||
workItemType: 'order_task',
|
||||
workItemNo: taskNo,
|
||||
sourceType: 'direct_pdf',
|
||||
rootOrderTaskNo: taskNo,
|
||||
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: `${taskNo}.pdf`,
|
||||
documentId: taskNo === 'OT-NEED' ? 1 : 2,
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
...patch,
|
||||
};
|
||||
}
|
||||
|
||||
describe('ShippingConversationProcessingCard', () => {
|
||||
it('renders needs_action / processing / completed groups, hides history on the right panel', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
@@ -315,4 +353,52 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
item: { workItemNo: 'SNI-1' },
|
||||
});
|
||||
});
|
||||
|
||||
it('renders each PDF task with its own compact projection, including completed tasks', async () => {
|
||||
const projection = buildProjection();
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection,
|
||||
workItems: [
|
||||
buildWorkItem('OT-NEED', {
|
||||
status: 'waiting_review',
|
||||
stage: 'waiting_review',
|
||||
}),
|
||||
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);
|
||||
});
|
||||
|
||||
it('maps internal review_case_draft status to a user-facing review label', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.needs_action = [{
|
||||
...projection.needs_action[0],
|
||||
status_label: 'review_case_draft',
|
||||
}];
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.text()).toContain('待复核');
|
||||
expect(wrapper.text()).not.toContain('review_case_draft');
|
||||
});
|
||||
});
|
||||
+67
-5
@@ -2,10 +2,11 @@
|
||||
* features/chat/components/shipping/ShippingConversationProcessingCard.vue
|
||||
* 用途:右侧「本次处理中」顶层任务卡——按 needs_action / processing / completed 展示。
|
||||
* 依赖:vue-i18n、ConversationProcessingProjection、conversationProcessingState、
|
||||
* shippingProcessingLabels。
|
||||
* shippingProcessingLabels、SidebarProgressInline。
|
||||
* 逻辑:由 ShippingWorkflowTimeline 嵌入;只消费统一 projection / workItems,禁止 Workflow fallback;
|
||||
* 单 PDF 主标题用文件名,多 PDF 用「订单识别任务」;右侧不渲染 history;
|
||||
* 任务级操作只消费后端 available_actions;另渲染尚未建 OT 的 order_intake 材料卡。
|
||||
* 仅聚焦卡展开完整 SidebarProgressInline,未聚焦显示紧凑单行,已完成默认收起(UI-05);
|
||||
* 单 PDF 不展示「展开文件详情」。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, watch } from 'vue';
|
||||
@@ -31,6 +32,8 @@ import {
|
||||
shippingProcessingSourceTypeKey,
|
||||
shippingProcessingStageKey,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import SidebarProgressInline from '@/features/shipping-progress/components/SidebarProgressInline.vue';
|
||||
import type { ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
|
||||
const props = defineProps<{
|
||||
projection: ConversationProcessingProjection | null;
|
||||
@@ -51,6 +54,8 @@ const emit = defineEmits<{
|
||||
taskAction: [payload: { task: ConversationProcessingUserTask; action: string }];
|
||||
/** Intake 级统一投影动作(如 retry_parse) */
|
||||
intakeAction: [payload: { item: ShippingProcessingProjection; action: string }];
|
||||
/** OT 卡内统一进度动作。 */
|
||||
projectionAction: [payload: { projection: ShippingProcessingProjection; item: ActionPresentationItem }];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -82,6 +87,17 @@ const focusedTaskNo = computed(() => resolveFocusedTask(uiState, {
|
||||
recentTaskNo: activeProjection.value?.recent_task_no,
|
||||
}));
|
||||
|
||||
/** 按权威 OT 编号取得卡片自己的统一进度投影。 */
|
||||
function projectionForTask(task: ConversationProcessingUserTask): ShippingProcessingProjection | null {
|
||||
const taskNo = String(task.user_task_no || '').trim();
|
||||
if (!taskNo) return null;
|
||||
const items = Array.isArray(props.workItems) ? props.workItems : [];
|
||||
return items.find((item) => (
|
||||
item.workItemType === 'order_task'
|
||||
&& String(item.workItemNo || '').trim() === taskNo
|
||||
)) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切会话时重置本地焦点/展开,避免跨会话残留。
|
||||
*/
|
||||
@@ -129,6 +145,28 @@ function isMultiDocumentTask(task: ConversationProcessingUserTask): boolean {
|
||||
return Array.isArray(task.document_names) && task.document_names.length > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否展示「展开文件详情」:单 PDF/单对象时隐藏,避免空抽屉。
|
||||
*/
|
||||
function canExpandFileDetails(task: ConversationProcessingUserTask): boolean {
|
||||
if (isMultiDocumentTask(task)) return true;
|
||||
const objects = Array.isArray(task.objects) ? task.objects : [];
|
||||
return objects.length > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* UI-05:仅聚焦且非已完成卡展开完整进度;未聚焦显示紧凑单行;已完成默认不展进度。
|
||||
*/
|
||||
function progressModeForTask(task: ConversationProcessingUserTask): 'full' | 'compact' | 'hidden' {
|
||||
if (!projectionForTask(task)) 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 编号。
|
||||
*/
|
||||
@@ -500,8 +538,15 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
|
||||
</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"
|
||||
v-if="visibleTaskActions(task).length && !projectionForTask(task)"
|
||||
class="mt-1.5 flex flex-wrap gap-1.5"
|
||||
data-testid="shipping-processing-task-actions"
|
||||
>
|
||||
@@ -517,6 +562,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</button>
|
||||
</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)"
|
||||
@@ -582,8 +628,15 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
|
||||
</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"
|
||||
v-if="visibleTaskActions(task).length && !projectionForTask(task)"
|
||||
class="mt-1.5 flex flex-wrap gap-1.5"
|
||||
data-testid="shipping-processing-task-actions"
|
||||
>
|
||||
@@ -599,6 +652,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</button>
|
||||
</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)"
|
||||
@@ -652,8 +706,15 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
{{ 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"
|
||||
v-if="visibleTaskActions(task).length && !projectionForTask(task)"
|
||||
class="mt-1.5 flex flex-wrap gap-1.5"
|
||||
data-testid="shipping-processing-task-actions"
|
||||
>
|
||||
@@ -669,6 +730,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
</button>
|
||||
</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)"
|
||||
|
||||
+148
-1
@@ -6,10 +6,13 @@
|
||||
*/
|
||||
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,
|
||||
@@ -52,6 +55,7 @@ const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): Shipping
|
||||
|
||||
describe('ShippingOrderExtractionCard', () => {
|
||||
it('renders batch summary, current stage, health tip and action buttons', () => {
|
||||
// 冷启动 transform 较慢时放宽超时,避免首测误伤。
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-1' },
|
||||
global: { plugins: [i18n] },
|
||||
@@ -62,7 +66,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).toContain('刷新状态');
|
||||
expect(wrapper.text()).toContain('取消本次识别');
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-document-result"]').length).toBe(0);
|
||||
});
|
||||
}, 30_000);
|
||||
|
||||
it('renders duplicate-linked notice when only open_existing results remain', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
@@ -185,6 +189,149 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
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);
|
||||
});
|
||||
|
||||
it('hides handling primary actions when unified processing projection is present (UI-01)', () => {
|
||||
const projection = {
|
||||
workItemType: 'order_task' as const,
|
||||
workItemNo: 'OT-UI01',
|
||||
sourceType: 'direct_pdf' as const,
|
||||
rootOrderTaskNo: 'OT-UI01',
|
||||
shippingNoticeNo: null,
|
||||
conversationId: null,
|
||||
submissionNo: 'SUB-1',
|
||||
intakeNo: 'INT-1',
|
||||
status: 'waiting_review' as const,
|
||||
stage: 'waiting_review' as const,
|
||||
progressVersion: 1,
|
||||
lastActivityAt: '2026-08-05T00:00:00Z',
|
||||
stageNodes: [],
|
||||
currentGate: null,
|
||||
availableActions: ['open_order_review'],
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'PO.pdf',
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
};
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
status: 'review_required',
|
||||
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',
|
||||
},
|
||||
],
|
||||
healthTips: [],
|
||||
currentActivity: null,
|
||||
}),
|
||||
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 () => {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingOrderExtractionCard.vue
|
||||
* 用途:聊天主区批次进度卡——摘要计数、Run 级处理事项、当前文件阶段、健康提醒与动作。
|
||||
* 用途:聊天主区批次进度卡——摘要计数、Run 级诊断事项、当前文件阶段、健康提醒与动作。
|
||||
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、
|
||||
* orderExtractionProgressDisplay、vue-router、vue-i18n、ProcessGateRecoveryCard。
|
||||
* 逻辑:回退 handling_items / primary_notice / Run summary;
|
||||
* Run 失败优先展示 errorExplainability.message;详情抽屉证据入口携带 focus+document_id;
|
||||
* Gate confirm_customer 经 ChatPage 打开客户选择弹窗;不再读取 Workflow 空壳 counts。
|
||||
* orderExtractionProgressDisplay、vue-router、vue-i18n、ChatProgressSummary;
|
||||
* ProcessGateRecoveryCard 仅兼容保留(runLevelProcessGate 当前恒为空)。
|
||||
* 逻辑:有统一投影时按当前 Run 根 OT 展示全部 PDF/OT 紧凑进度,主操作仅来自投影;
|
||||
* handlingItems 保留诊断信息,不再渲染与投影平级的 primaryAction 主按钮;
|
||||
* Run 失败优先展示 errorExplainability.message;详情抽屉证据入口携带 focus+document_id。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, ref } from 'vue';
|
||||
@@ -23,6 +24,12 @@ import type {
|
||||
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,
|
||||
@@ -47,6 +54,8 @@ const props = defineProps<{
|
||||
/** 新版 Run 已替代旧版时,历史卡仅允许查看详情。 */
|
||||
readonly?: boolean;
|
||||
readonlyReason?: string | null;
|
||||
/** 可选统一投影;缺省时从 SHIPPING_WORKFLOW_KEY 解析。 */
|
||||
processingProjection?: ShippingProcessingProjection | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -59,6 +68,54 @@ 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('');
|
||||
|
||||
@@ -92,7 +149,21 @@ const displaySummary = computed(() => props.state.summary);
|
||||
const workflowStageLabel = computed(() => '');
|
||||
const workflowLastActivityLabel = computed(() => '');
|
||||
|
||||
const handlingItems = computed(() => props.state.handlingItems || []);
|
||||
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()));
|
||||
});
|
||||
|
||||
/**
|
||||
* 是否为「仅重复关联已有任务、无需人工复核」终态通知。
|
||||
@@ -528,7 +599,7 @@ function openCancelConfirm() {
|
||||
</div>
|
||||
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="runLevelProcessGate?.current_blocking_gate"
|
||||
v-if="runLevelProcessGate?.current_blocking_gate && !hasProcessingProjection"
|
||||
class="mt-2"
|
||||
:summary="runLevelProcessGate"
|
||||
:can-handle="!readonly"
|
||||
@@ -538,6 +609,25 @@ function openCancelConfirm() {
|
||||
@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"
|
||||
@@ -558,9 +648,10 @@ function openCancelConfirm() {
|
||||
<span class="ml-1 opacity-80">{{ t('chat.shippingOrderExtractionHandling.count', { count: item.count }) }}</span>
|
||||
</div>
|
||||
<button
|
||||
v-if="item.primaryAction && !readonly && (item.primaryAction !== 'review_candidate' || !handlingItems.some((other) => other.primaryAction === 'enter_manual_review'))"
|
||||
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')
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 用途:聊天页右侧「本次处理中」面板——OT 任务卡 + 按需展开的文件明细。
|
||||
* 依赖:vue-i18n、useMessage、useShippingNoticeWorkflow、ShippingConversationProcessingCard、
|
||||
* conversationProcessingProjection、DetailDrawer、ReasonDialog、ProcessGateRecoveryCard。
|
||||
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;展开任务后由
|
||||
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;每张 OT 卡内展示自己的紧凑进度与动作;
|
||||
* mapUserTaskObjectsToFileRows 合成文件行;取消/重识别走 Run API;
|
||||
* 路由 focus_task_no / 服务端 focused_task_no 驱动选中卡与当前阶段摘要;
|
||||
* 详情抽屉仅用列表投影,不再请求 WorkflowItem 详情 API。
|
||||
@@ -43,6 +43,7 @@ import ShippingWorkflowItemDetailDrawer from './ShippingWorkflowItemDetailDrawer
|
||||
import ShippingWorkflowReasonDialog, {
|
||||
type ShippingWorkflowReasonAction,
|
||||
} from './ShippingWorkflowReasonDialog.vue';
|
||||
import type { ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
|
||||
const props = defineProps<{
|
||||
conversationId?: string | null;
|
||||
@@ -261,12 +262,15 @@ function itemActivityLabel(item: ShippingWorkflowItem | null): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开当前 PDF 对应的人工复核工作台(fileItems 行)。
|
||||
* 打开当前 PDF 对应的订单处理工作台(fileItems 行)。
|
||||
* 核心逻辑:复用 Run/Case/文档上下文,避免用户重新寻找待处理文件。
|
||||
*/
|
||||
async function openReview(item: ShippingWorkflowItem) {
|
||||
const runNo = String(item.current_run_no || '').trim();
|
||||
if (!runNo) return;
|
||||
if (!runNo) {
|
||||
msg.warning(t('chat.shippingOrderReview.caseRequired'));
|
||||
return;
|
||||
}
|
||||
await pushOrderReviewQuery({
|
||||
runNo,
|
||||
documentId: item.current_document_id,
|
||||
@@ -276,11 +280,15 @@ async function openReview(item: ShippingWorkflowItem) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 OT 任务投影打开复核(无 fileItems 时的生产路径)。
|
||||
* 从 OT 任务投影打开订单处理工作台(无 fileItems 时的生产路径)。
|
||||
* 核心逻辑:必须有 run_no;缺失时 toast 提示,禁止静默 return。
|
||||
*/
|
||||
async function openReviewFromTask(task: ConversationProcessingUserTask) {
|
||||
const runNo = String(task.run_no || '').trim();
|
||||
if (!runNo) return;
|
||||
if (!runNo) {
|
||||
msg.warning(t('chat.shippingOrderReview.caseRequired'));
|
||||
return;
|
||||
}
|
||||
const doc = (task.objects || []).find((row) => row.kind === 'document');
|
||||
const caseObj = (task.objects || []).find((row) => String(row.case_no || '').trim());
|
||||
await pushOrderReviewQuery({
|
||||
@@ -745,6 +753,46 @@ async function onReasonConfirm(payload: { reason: string; comment?: string }) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个 OT 卡的统一动作点击:复用 Timeline 已有任务处理器。
|
||||
* @param payload.projection - 当前卡片自己的权威投影
|
||||
* @param payload.item - 动作展示项
|
||||
*/
|
||||
function onTaskProjectionAction(payload: {
|
||||
projection: ShippingProcessingProjection;
|
||||
item: ActionPresentationItem;
|
||||
}) {
|
||||
const { projection, item } = payload;
|
||||
const taskNo = String(projection.workItemNo || '').trim();
|
||||
const code = String(item.actionCode || '').trim();
|
||||
if (code === 'retry_parse' || item.intent === 'retry') {
|
||||
void onProcessingIntakeAction({ item: projection, action: code || 'retry_parse' });
|
||||
return;
|
||||
}
|
||||
if (item.intent === 'refresh') {
|
||||
void onRefresh();
|
||||
return;
|
||||
}
|
||||
if (item.intent === 'open_order_review') {
|
||||
const task = [
|
||||
...(displayProcessing.value?.needs_action || []),
|
||||
...(displayProcessing.value?.processing || []),
|
||||
...(displayProcessing.value?.completed || []),
|
||||
].find((row) => String(row.user_task_no || '').trim() === taskNo);
|
||||
if (task) {
|
||||
void onProcessingTaskAction({ task, action: 'open_review' });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (item.intent === 'open_manual_upload' && taskNo) {
|
||||
void router.push({
|
||||
name: 'workspace-shipping-my-tasks',
|
||||
query: { task_no: taskNo },
|
||||
});
|
||||
}
|
||||
// 其余 intent 由任务卡/ Gate 卡片承载,此处安全 no-op。
|
||||
}
|
||||
|
||||
watch(
|
||||
() => error.value,
|
||||
() => {
|
||||
@@ -812,7 +860,10 @@ watch(
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-0.5 text-xs text-secondary" data-testid="shipping-workflow-panel-summary">
|
||||
<template v-if="displayProcessing">
|
||||
<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,
|
||||
@@ -867,6 +918,7 @@ watch(
|
||||
@collapse-files="onCollapseTaskFiles"
|
||||
@task-action="(payload) => void onProcessingTaskAction(payload)"
|
||||
@intake-action="(payload) => void onProcessingIntakeAction(payload)"
|
||||
@projection-action="onTaskProjectionAction"
|
||||
/>
|
||||
|
||||
<section
|
||||
|
||||
Reference in new issue
Block a user