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
@@ -195,23 +195,52 @@ export const createWorkspaceOrderExtractionSubmission = (
|
||||
* 核心逻辑:内嵌 conversation_processing 可选;缺省时前端由 work_items 合成分组;
|
||||
* 旧 conversation processing GET 已移除(无历史兼容)。
|
||||
*/
|
||||
type WorkspaceShippingProcessingResponse = {
|
||||
conversation_id: string;
|
||||
work_items: ReturnType<typeof normalizeShippingProcessingWorkItems>;
|
||||
conversation_processing: ConversationProcessingProjection | null;
|
||||
};
|
||||
|
||||
/** 同一会话跨组件实例共享在途请求,避免历史路由恢复重挂载造成重复慢查询。 */
|
||||
const shippingProcessingRequests = new Map<string, Promise<WorkspaceShippingProcessingResponse>>();
|
||||
const SHIPPING_PROCESSING_REQUEST_TIMEOUT_MS = 10_000;
|
||||
|
||||
export const getWorkspaceShippingProcessing = async (
|
||||
conversationId: string,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
const raw = await requestJson<{
|
||||
conversation_id?: string;
|
||||
work_items?: unknown[];
|
||||
conversation_processing?: ConversationProcessingProjection | null;
|
||||
}>(
|
||||
`/api/workspace/shipping-processing/conversations/${encodeURIComponent(conversationId)}`,
|
||||
{ signal },
|
||||
const normalized = String(conversationId || '').trim();
|
||||
const existing = shippingProcessingRequests.get(normalized);
|
||||
if (existing) return existing;
|
||||
|
||||
// 不把单个组件的 AbortSignal 传给共享网络请求:卸载旧实例不能取消新实例仍需的首屏数据。
|
||||
if (signal?.aborted) throw new DOMException('Aborted', 'AbortError');
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(
|
||||
() => controller.abort(),
|
||||
SHIPPING_PROCESSING_REQUEST_TIMEOUT_MS,
|
||||
);
|
||||
return {
|
||||
conversation_id: String(raw?.conversation_id || conversationId),
|
||||
work_items: normalizeShippingProcessingWorkItems(raw?.work_items),
|
||||
conversation_processing: raw?.conversation_processing ?? null,
|
||||
};
|
||||
const request = requestJson<{
|
||||
conversation_id?: string;
|
||||
work_items?: unknown[];
|
||||
conversation_processing?: ConversationProcessingProjection | null;
|
||||
}>(
|
||||
`/api/workspace/shipping-processing/conversations/${encodeURIComponent(normalized)}`,
|
||||
{ signal: controller.signal },
|
||||
)
|
||||
.then((raw): WorkspaceShippingProcessingResponse => ({
|
||||
conversation_id: String(raw?.conversation_id || normalized),
|
||||
work_items: normalizeShippingProcessingWorkItems(raw?.work_items),
|
||||
conversation_processing: raw?.conversation_processing ?? null,
|
||||
}))
|
||||
.finally(() => {
|
||||
clearTimeout(timeout);
|
||||
if (shippingProcessingRequests.get(normalized) === request) {
|
||||
shippingProcessingRequests.delete(normalized);
|
||||
}
|
||||
});
|
||||
shippingProcessingRequests.set(normalized, request);
|
||||
return request;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,15 +84,15 @@ type MaintenanceRecordPanelCommand = {
|
||||
|
||||
const page = useChatPageContext();
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const shippingProcessing = useShippingNoticeWorkflow({
|
||||
conversationId: () => page.conversationId,
|
||||
// 历史会话首屏直接使用路由 ID,与聊天消息并行拉取统一进度。
|
||||
conversationId: () => page.conversationId || String(route.query.conversation_id || ''),
|
||||
refreshTrigger: () => page.workflowRefreshTrigger,
|
||||
});
|
||||
provide(SHIPPING_WORKFLOW_KEY, shippingProcessing);
|
||||
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
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));
|
||||
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewDocumentNavigation.spec.ts
|
||||
* 用途:验收 OT 导航数量阈值与模式切换。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import ReviewDocumentNavigation, {
|
||||
type ReviewDocumentNavItem,
|
||||
} from './ReviewDocumentNavigation.vue';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
unnamedDocument: '未命名 PDF',
|
||||
documentNavigation: '导航',
|
||||
caseStatuses: { draft: '草稿', unknown: '未知' },
|
||||
otNav: {
|
||||
listTitle: '订单列表 · {count}',
|
||||
searchPlaceholder: '搜索',
|
||||
filterAll: '全部',
|
||||
filterNeedsAction: '待人工',
|
||||
filterProcessing: '处理中',
|
||||
filterDone: '完成',
|
||||
filterFailed: '失败',
|
||||
narrowTrigger: '订单 {current}/{total}',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* 生成 n 个导航项。
|
||||
*/
|
||||
function items(count: number): ReviewDocumentNavItem[] {
|
||||
return Array.from({ length: count }, (_, i) => ({
|
||||
case_no: `C-${i + 1}`,
|
||||
file_name: `f${i + 1}.pdf`,
|
||||
status: 'draft',
|
||||
issue_count: i === 0 ? 1 : 0,
|
||||
}));
|
||||
}
|
||||
|
||||
type NavForceMode = 'hidden' | 'tabs' | 'sidebar' | 'sidebar_search' | 'narrow';
|
||||
|
||||
/**
|
||||
* 挂载导航。
|
||||
*/
|
||||
function mountNav(count: number, forceMode?: NavForceMode) {
|
||||
return mount(ReviewDocumentNavigation, {
|
||||
props: {
|
||||
items: items(count),
|
||||
activeCaseNo: 'C-1',
|
||||
navAriaLabel: 'nav',
|
||||
forceMode: forceMode ?? null,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('ReviewDocumentNavigation', () => {
|
||||
it('hides navigation for a single OT', () => {
|
||||
const wrapper = mountNav(1, 'hidden');
|
||||
expect(wrapper.find('[data-testid="review-document-navigation"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('uses top tabs for 2–4 OTs', () => {
|
||||
const wrapper = mountNav(3, 'tabs');
|
||||
expect(wrapper.find('[data-testid="review-doc-nav-tabs"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-doc-nav-list"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('uses sidebar list for 5–20 OTs', () => {
|
||||
const wrapper = mountNav(8, 'sidebar');
|
||||
expect(wrapper.find('[data-testid="review-doc-nav-list"]').exists()).toBe(true);
|
||||
expect(wrapper.attributes('data-nav-mode')).toBe('sidebar');
|
||||
});
|
||||
|
||||
it('shows search for 20+ OTs', () => {
|
||||
const wrapper = mountNav(25, 'sidebar_search');
|
||||
expect(wrapper.find('[data-testid="review-doc-nav-search"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-doc-nav-filter"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('emits select when a tab is clicked', async () => {
|
||||
const wrapper = mountNav(2, 'tabs');
|
||||
await wrapper.get('[data-testid="review-doc-nav-C-2"]').trigger('click');
|
||||
expect(wrapper.emitted('select')?.[0]).toEqual(['C-2']);
|
||||
});
|
||||
});
|
||||
+325
-19
@@ -1,72 +1,378 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewDocumentNavigation.vue
|
||||
用途:复核工作台顶部横向 PDF 文件导航(紧凑标签样式)。
|
||||
用途:订单处理工作台 OT/PDF 导航(按数量响应式:隐藏 / 顶栏标签 / 左侧列表 / 窄屏抽屉)。
|
||||
依赖:vue-i18n、lucide-vue-next。
|
||||
逻辑:ShippingOrderReviewView 传入 Run 内 Case 摘要;emit select 切换当前 PDF Case。
|
||||
逻辑:1 份隐藏;2–4 顶栏;≥5 左侧列表(可收起);20+ 搜索过滤;窄屏「订单 i/n」抽屉。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { TriangleAlert } from 'lucide-vue-next';
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import {
|
||||
Check,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
Circle,
|
||||
Search,
|
||||
TriangleAlert,
|
||||
X,
|
||||
} from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
/** 导航项:一 PDF / 一 OT。 */
|
||||
export type ReviewDocumentNavItem = {
|
||||
case_no: string;
|
||||
file_name?: string | null;
|
||||
status: string;
|
||||
issue_count?: number;
|
||||
po_number?: string | null;
|
||||
customer_name?: string | null;
|
||||
stage_label?: string | null;
|
||||
};
|
||||
|
||||
export type ReviewDocumentNavMode = 'hidden' | 'tabs' | 'sidebar' | 'sidebar_search' | 'narrow';
|
||||
|
||||
const props = defineProps<{
|
||||
items: ReviewDocumentNavItem[];
|
||||
activeCaseNo?: string | null;
|
||||
/** 导航区域无障碍标签(避免与原生 aria-label 属性在 vue-tsc 中冲突) */
|
||||
navAriaLabel: string;
|
||||
/** 外部强制模式(测试用);默认按数量 + 窄屏自动推导 */
|
||||
forceMode?: ReviewDocumentNavMode | null;
|
||||
/** 侧栏是否默认收起为编号轨 */
|
||||
initiallyCollapsed?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
select: [caseNo: string];
|
||||
'mode-change': [mode: ReviewDocumentNavMode];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const isNarrow = ref(false);
|
||||
const collapsed = ref(Boolean(props.initiallyCollapsed));
|
||||
const drawerOpen = ref(false);
|
||||
const searchQuery = ref('');
|
||||
const statusFilter = ref<'all' | 'needs_action' | 'processing' | 'done' | 'failed'>('all');
|
||||
|
||||
let mediaQuery: MediaQueryList | null = null;
|
||||
|
||||
/**
|
||||
* 将 Case 状态码映射为本地化文案,供导航标签展示。
|
||||
* @param status - Case 状态码
|
||||
* @returns 本地化文案;未知状态回落 unknown
|
||||
* 同步窄屏断点(lg 以下走抽屉入口)。
|
||||
*/
|
||||
function syncNarrow(event?: MediaQueryListEvent) {
|
||||
isNarrow.value = event ? event.matches : Boolean(mediaQuery?.matches);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (typeof window === 'undefined' || !window.matchMedia) return;
|
||||
mediaQuery = window.matchMedia('(max-width: 1023px)');
|
||||
syncNarrow();
|
||||
mediaQuery.addEventListener('change', syncNarrow);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
mediaQuery?.removeEventListener('change', syncNarrow);
|
||||
});
|
||||
|
||||
/**
|
||||
* 推导导航呈现模式。
|
||||
*/
|
||||
const mode = computed<ReviewDocumentNavMode>(() => {
|
||||
if (props.forceMode) return props.forceMode;
|
||||
const count = props.items.length;
|
||||
if (count <= 1) return 'hidden';
|
||||
if (isNarrow.value) return 'narrow';
|
||||
if (count <= 4) return 'tabs';
|
||||
if (count <= 20) return 'sidebar';
|
||||
return 'sidebar_search';
|
||||
});
|
||||
|
||||
watch(mode, (value) => emit('mode-change', value), { immediate: true });
|
||||
|
||||
const activeIndex = computed(() => {
|
||||
const idx = props.items.findIndex((item) => item.case_no === props.activeCaseNo);
|
||||
return idx >= 0 ? idx + 1 : 1;
|
||||
});
|
||||
|
||||
/**
|
||||
* 将 Case 状态码映射为本地化文案。
|
||||
*/
|
||||
function caseStatusLabel(status: string): string {
|
||||
const key = `chat.shippingOrderReview.caseStatuses.${status}`;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.caseStatuses.unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航状态图标语义。
|
||||
*/
|
||||
function navIconKind(item: ReviewDocumentNavItem): 'active' | 'alert' | 'processing' | 'done' | 'failed' | 'idle' {
|
||||
if (props.activeCaseNo === item.case_no) return 'active';
|
||||
const status = String(item.status || '').toLowerCase();
|
||||
if (item.issue_count && item.issue_count > 0) return 'alert';
|
||||
if (status === 'failed' || status === 'error') return 'failed';
|
||||
if (status === 'confirmed' || status === 'completed' || status === 'ready' || status === 'closed') return 'done';
|
||||
if (status === 'processing' || status === 'reparse_pending' || status === 'queued') return 'processing';
|
||||
if (status === 'non_order' || status === 'cancelled' || status === 'superseded') return 'idle';
|
||||
if (status === 'draft' || status === 'pending_review' || status === 'waiting_review') return 'alert';
|
||||
return 'processing';
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否匹配状态分段过滤。
|
||||
*/
|
||||
function matchesStatusFilter(item: ReviewDocumentNavItem): boolean {
|
||||
if (statusFilter.value === 'all') return true;
|
||||
const kind = navIconKind(item);
|
||||
if (statusFilter.value === 'needs_action') return kind === 'alert';
|
||||
if (statusFilter.value === 'processing') return kind === 'processing' || kind === 'active';
|
||||
if (statusFilter.value === 'done') return kind === 'done';
|
||||
if (statusFilter.value === 'failed') return kind === 'failed';
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索 + 过滤后的列表。
|
||||
*/
|
||||
const filteredItems = computed(() => {
|
||||
const q = searchQuery.value.trim().toLowerCase();
|
||||
return props.items.filter((item) => {
|
||||
if (!matchesStatusFilter(item)) return false;
|
||||
if (!q) return true;
|
||||
const hay = [
|
||||
item.file_name,
|
||||
item.case_no,
|
||||
item.po_number,
|
||||
item.customer_name,
|
||||
item.stage_label,
|
||||
].map((v) => String(v || '').toLowerCase()).join(' ');
|
||||
return hay.includes(q);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 选择 OT;窄屏抽屉内选择后关闭。
|
||||
*/
|
||||
function onSelect(caseNo: string) {
|
||||
emit('select', caseNo);
|
||||
drawerOpen.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<nav
|
||||
class="rounded-xl border border-slate-200 bg-white p-2 shadow-sm dark:border-slate-800 dark:bg-slate-900"
|
||||
v-if="mode !== 'hidden'"
|
||||
:aria-label="navAriaLabel"
|
||||
data-testid="review-document-navigation"
|
||||
:data-nav-mode="mode"
|
||||
:class="mode === 'tabs'
|
||||
? 'rounded-xl border border-slate-200 bg-white p-2 shadow-sm dark:border-slate-800 dark:bg-slate-900'
|
||||
: mode === 'narrow'
|
||||
? ''
|
||||
: 'sticky top-3 flex max-h-[calc(100vh-6rem)] w-full shrink-0 flex-col rounded-xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900 lg:w-64'"
|
||||
>
|
||||
<div class="flex gap-1.5 overflow-x-auto">
|
||||
<!-- 2–4:顶部标签 -->
|
||||
<div
|
||||
v-if="mode === 'tabs'"
|
||||
class="flex gap-1.5 overflow-x-auto"
|
||||
data-testid="review-doc-nav-tabs"
|
||||
>
|
||||
<button
|
||||
v-for="item in items"
|
||||
:key="item.case_no"
|
||||
type="button"
|
||||
class="inline-flex max-w-[220px] shrink-0 items-center gap-1.5 rounded-lg border px-2.5 py-1.5 text-left text-xs transition-colors"
|
||||
class="inline-flex min-w-[9rem] max-w-[240px] shrink-0 flex-col gap-0.5 rounded-lg border px-2.5 py-1.5 text-left text-xs transition-colors"
|
||||
:class="activeCaseNo === item.case_no
|
||||
? 'border-sky-500 bg-sky-50 text-sky-950 dark:border-sky-700 dark:bg-sky-950/40 dark:text-sky-100'
|
||||
? 'border-sky-500 bg-sky-50 text-sky-950 ring-1 ring-sky-400 dark:border-sky-700 dark:bg-sky-950/40 dark:text-sky-100'
|
||||
: 'border-slate-200 text-slate-700 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800'"
|
||||
:data-testid="`review-doc-nav-${item.case_no}`"
|
||||
@click="emit('select', item.case_no)"
|
||||
@click="onSelect(item.case_no)"
|
||||
>
|
||||
<TriangleAlert
|
||||
v-if="item.issue_count"
|
||||
class="h-3.5 w-3.5 shrink-0 text-amber-500"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span class="truncate font-medium">{{ item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}</span>
|
||||
<span class="shrink-0 text-[10px] text-slate-500 dark:text-slate-400">
|
||||
{{ caseStatusLabel(item.status) }}
|
||||
<span class="flex items-center gap-1 truncate font-medium">
|
||||
<TriangleAlert
|
||||
v-if="navIconKind(item) === 'alert'"
|
||||
class="h-3.5 w-3.5 shrink-0 text-amber-500"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<Check
|
||||
v-else-if="navIconKind(item) === 'done'"
|
||||
class="h-3.5 w-3.5 shrink-0 text-emerald-500"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<X
|
||||
v-else-if="navIconKind(item) === 'failed'"
|
||||
class="h-3.5 w-3.5 shrink-0 text-rose-500"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<Circle
|
||||
v-else
|
||||
class="h-3 w-3 shrink-0 text-slate-400"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span class="truncate">{{ item.po_number || item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}</span>
|
||||
</span>
|
||||
<span class="truncate text-[10px] text-slate-500 dark:text-slate-400">
|
||||
{{ item.customer_name || caseStatusLabel(item.status) }}
|
||||
<template v-if="item.stage_label"> · {{ item.stage_label }}</template>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ≥5:左侧列表 -->
|
||||
<template v-else-if="mode === 'sidebar' || mode === 'sidebar_search'">
|
||||
<div class="flex items-center justify-between gap-2 border-b border-slate-100 px-2 py-2 dark:border-slate-800">
|
||||
<span class="text-xs font-semibold text-primary">
|
||||
{{ t('chat.shippingOrderReview.otNav.listTitle', { count: items.length }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded p-1 text-muted hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
data-testid="review-doc-nav-collapse"
|
||||
@click="collapsed = !collapsed"
|
||||
>
|
||||
<ChevronLeft
|
||||
v-if="!collapsed"
|
||||
class="h-4 w-4"
|
||||
/>
|
||||
<ChevronRight
|
||||
v-else
|
||||
class="h-4 w-4"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="!collapsed && mode === 'sidebar_search'"
|
||||
class="space-y-2 border-b border-slate-100 px-2 py-2 dark:border-slate-800"
|
||||
>
|
||||
<label class="relative block">
|
||||
<Search class="pointer-events-none absolute left-2 top-1.5 h-3.5 w-3.5 text-muted" />
|
||||
<input
|
||||
v-model="searchQuery"
|
||||
type="search"
|
||||
class="w-full rounded-md border border-slate-200 bg-white py-1 pl-7 pr-2 text-[11px] dark:border-slate-700 dark:bg-slate-950"
|
||||
:placeholder="t('chat.shippingOrderReview.otNav.searchPlaceholder')"
|
||||
data-testid="review-doc-nav-search"
|
||||
>
|
||||
</label>
|
||||
<select
|
||||
v-model="statusFilter"
|
||||
class="w-full rounded-md border border-slate-200 bg-white px-2 py-1 text-[11px] dark:border-slate-700 dark:bg-slate-950"
|
||||
data-testid="review-doc-nav-filter"
|
||||
>
|
||||
<option value="all">{{ t('chat.shippingOrderReview.otNav.filterAll') }}</option>
|
||||
<option value="needs_action">{{ t('chat.shippingOrderReview.otNav.filterNeedsAction') }}</option>
|
||||
<option value="processing">{{ t('chat.shippingOrderReview.otNav.filterProcessing') }}</option>
|
||||
<option value="done">{{ t('chat.shippingOrderReview.otNav.filterDone') }}</option>
|
||||
<option value="failed">{{ t('chat.shippingOrderReview.otNav.filterFailed') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="min-h-0 flex-1 overflow-y-auto p-1.5"
|
||||
data-testid="review-doc-nav-list"
|
||||
>
|
||||
<button
|
||||
v-for="(item, index) in (collapsed ? items : filteredItems)"
|
||||
:key="item.case_no"
|
||||
type="button"
|
||||
class="mb-1 flex w-full items-start gap-2 rounded-lg border px-2 py-1.5 text-left text-xs transition-colors"
|
||||
:class="activeCaseNo === item.case_no
|
||||
? 'border-sky-500 bg-sky-50 dark:border-sky-700 dark:bg-sky-950/40'
|
||||
: 'border-transparent hover:bg-slate-50 dark:hover:bg-slate-800'"
|
||||
:title="collapsed
|
||||
? `${item.file_name || item.case_no} · ${caseStatusLabel(item.status)}`
|
||||
: undefined"
|
||||
:data-testid="`review-doc-nav-${item.case_no}`"
|
||||
@click="onSelect(item.case_no)"
|
||||
>
|
||||
<span
|
||||
v-if="collapsed"
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-slate-100 text-[10px] font-semibold dark:bg-slate-800"
|
||||
>
|
||||
{{ index + 1 }}
|
||||
</span>
|
||||
<template v-else>
|
||||
<TriangleAlert
|
||||
v-if="navIconKind(item) === 'alert'"
|
||||
class="mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500"
|
||||
/>
|
||||
<Check
|
||||
v-else-if="navIconKind(item) === 'done'"
|
||||
class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500"
|
||||
/>
|
||||
<X
|
||||
v-else-if="navIconKind(item) === 'failed'"
|
||||
class="mt-0.5 h-3.5 w-3.5 shrink-0 text-rose-500"
|
||||
/>
|
||||
<Circle
|
||||
v-else
|
||||
class="mt-0.5 h-3 w-3 shrink-0 text-slate-400"
|
||||
/>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block truncate font-medium text-primary">
|
||||
{{ item.po_number || item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}
|
||||
</span>
|
||||
<span class="block truncate text-[10px] text-muted">
|
||||
{{ item.customer_name || caseStatusLabel(item.status) }}
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 窄屏:入口 + 抽屉 -->
|
||||
<template v-else-if="mode === 'narrow'">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-3 py-2 text-xs font-medium shadow-sm dark:border-slate-800 dark:bg-slate-900"
|
||||
data-testid="review-doc-nav-narrow-trigger"
|
||||
@click="drawerOpen = true"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.otNav.narrowTrigger', { current: activeIndex, total: items.length }) }}
|
||||
</button>
|
||||
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="drawerOpen"
|
||||
class="fixed inset-0 z-50 flex justify-end"
|
||||
data-testid="review-doc-nav-narrow-drawer"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-0 bg-slate-900/40"
|
||||
@click="drawerOpen = false"
|
||||
/>
|
||||
<aside class="relative z-10 flex h-full w-full max-w-sm flex-col border-l border-default bg-surface p-3 shadow-xl">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.otNav.listTitle', { count: items.length }) }}</h2>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded p-1 hover:bg-surface-muted"
|
||||
@click="drawerOpen = false"
|
||||
>
|
||||
<X class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 space-y-1 overflow-y-auto">
|
||||
<button
|
||||
v-for="item in items"
|
||||
:key="item.case_no"
|
||||
type="button"
|
||||
class="flex w-full flex-col rounded-lg border px-3 py-2 text-left text-xs"
|
||||
:class="activeCaseNo === item.case_no
|
||||
? 'border-sky-500 bg-sky-50'
|
||||
: 'border-slate-200'"
|
||||
:data-testid="`review-doc-nav-${item.case_no}`"
|
||||
@click="onSelect(item.case_no)"
|
||||
>
|
||||
<span class="font-medium">{{ item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}</span>
|
||||
<span class="text-[10px] text-muted">{{ caseStatusLabel(item.status) }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
</nav>
|
||||
</template>
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewUnsavedSwitchDialog.spec.ts
|
||||
* 用途:验收切换 OT 未保存硬拦截三按钮。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import ReviewUnsavedSwitchDialog from './ReviewUnsavedSwitchDialog.vue';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
unsavedSwitch: {
|
||||
title: '有未保存的修改',
|
||||
message: '当前订单有 {count} 项修改尚未保存。',
|
||||
cancel: '取消',
|
||||
discard: '放弃修改',
|
||||
saveAndSwitch: '保存后切换',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
describe('ReviewUnsavedSwitchDialog', () => {
|
||||
it('emits cancel / discard / save-and-switch', async () => {
|
||||
const wrapper = mount(ReviewUnsavedSwitchDialog, {
|
||||
props: { open: true, unsavedCount: 2 },
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
stubs: { Teleport: { template: '<div><slot /></div>' } },
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-unsaved-switch-dialog"]').exists()).toBe(true);
|
||||
await wrapper.get('[data-testid="review-unsaved-cancel"]').trigger('click');
|
||||
expect(wrapper.emitted('cancel')).toBeTruthy();
|
||||
await wrapper.get('[data-testid="review-unsaved-discard"]').trigger('click');
|
||||
expect(wrapper.emitted('discard')).toBeTruthy();
|
||||
await wrapper.get('[data-testid="review-unsaved-save-switch"]').trigger('click');
|
||||
expect(wrapper.emitted('save-and-switch')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewUnsavedSwitchDialog.vue
|
||||
用途:切换 OT/PDF 时未保存硬拦截确认框。
|
||||
依赖:vue-i18n。
|
||||
逻辑:由 ShippingOrderReviewView 在 select 前打开;三选一:取消 / 放弃修改 / 保存后切换。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
defineProps<{
|
||||
open: boolean;
|
||||
unsavedCount: number;
|
||||
saving?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
cancel: [];
|
||||
discard: [];
|
||||
'save-and-switch': [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-[60] flex items-center justify-center p-4"
|
||||
data-testid="review-unsaved-switch-dialog"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-0 bg-slate-900/40"
|
||||
:aria-label="t('chat.shippingOrderReview.unsavedSwitch.cancel')"
|
||||
@click="emit('cancel')"
|
||||
/>
|
||||
<div
|
||||
class="relative z-10 w-full max-w-md rounded-xl border border-default bg-surface p-4 shadow-xl"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
>
|
||||
<h2 class="text-sm font-semibold text-primary">
|
||||
{{ t('chat.shippingOrderReview.unsavedSwitch.title') }}
|
||||
</h2>
|
||||
<p class="mt-2 text-xs text-secondary">
|
||||
{{ t('chat.shippingOrderReview.unsavedSwitch.message', { count: unsavedCount }) }}
|
||||
</p>
|
||||
<div class="mt-4 flex flex-wrap justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1.5 text-xs font-medium"
|
||||
data-testid="review-unsaved-cancel"
|
||||
:disabled="saving"
|
||||
@click="emit('cancel')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.unsavedSwitch.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-rose-200 px-3 py-1.5 text-xs font-medium text-rose-700 dark:border-rose-900 dark:text-rose-300"
|
||||
data-testid="review-unsaved-discard"
|
||||
:disabled="saving"
|
||||
@click="emit('discard')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.unsavedSwitch.discard') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-sky-600 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50"
|
||||
data-testid="review-unsaved-save-switch"
|
||||
:disabled="saving"
|
||||
@click="emit('save-and-switch')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.unsavedSwitch.saveAndSwitch') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -1,14 +1,17 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewWorkbenchFooter.vue
|
||||
用途:订单复核工作台底部固定操作栏。
|
||||
依赖:vue-i18n、lucide-vue-next。
|
||||
逻辑:ShippingOrderReviewView 传入 available_actions 与门禁状态;sticky bottom 保证在主滚动区内常驻可见。
|
||||
用途:订单处理工作台底部唯一写操作栏(处置 / 保存 / 流程恢复动作)。
|
||||
依赖:vue-i18n、lucide-vue-next、ActionPresentation。
|
||||
逻辑:ShippingOrderReviewView 传入 available_actions 与流程动作投影;sticky bottom;
|
||||
系统自动推进中隐藏无效主写按钮;流程写操作经 flow-action emit。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { RefreshCw, Save } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ActionPresentation, ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
|
||||
const props = defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
availableActions: string[];
|
||||
canConfirmBuild: boolean;
|
||||
saving: boolean;
|
||||
@@ -16,7 +19,18 @@ const props = defineProps<{
|
||||
hasDraft: boolean;
|
||||
/** can_build && can_auto_create 时隐藏确认按钮并展示自动推进提示 */
|
||||
hideConfirmBecauseAutoGate?: boolean;
|
||||
}>();
|
||||
/** 未保存本地修改计数(硬拦截与底栏提示同源) */
|
||||
unsavedCount?: number;
|
||||
/** 统一流程动作(原进度条 ActionBar);surface=review */
|
||||
flowPresentation?: ActionPresentation | null;
|
||||
/** 系统自动推进中:隐藏主写按钮 */
|
||||
automating?: boolean;
|
||||
}>(), {
|
||||
unsavedCount: 0,
|
||||
flowPresentation: null,
|
||||
automating: false,
|
||||
hideConfirmBecauseAutoGate: false,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
'mark-non-order': [];
|
||||
@@ -25,9 +39,10 @@ const emit = defineEmits<{
|
||||
'upload-replacement': [event: Event];
|
||||
validate: [];
|
||||
confirm: [];
|
||||
'flow-action': [item: ActionPresentationItem];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t, te } = useI18n();
|
||||
|
||||
/**
|
||||
* 判断某 action 是否在当前 Case 可用。
|
||||
@@ -35,84 +50,140 @@ const { t } = useI18n();
|
||||
function hasAction(action: string): boolean {
|
||||
return props.availableActions.includes(action);
|
||||
}
|
||||
|
||||
const showFooter = computed(() => props.hasDraft && !props.isReadOnly);
|
||||
|
||||
const flowItems = computed((): ActionPresentationItem[] => {
|
||||
const presentation = props.flowPresentation;
|
||||
if (!presentation) return [];
|
||||
const items: ActionPresentationItem[] = [];
|
||||
if (presentation.primary) items.push(presentation.primary);
|
||||
if (presentation.secondary) items.push(presentation.secondary);
|
||||
items.push(...presentation.overflow);
|
||||
// 刷新留给顶部只读区;底栏不重复。
|
||||
return items.filter((item) => item.intent !== 'refresh');
|
||||
});
|
||||
|
||||
/**
|
||||
* 流程动作文案。
|
||||
*/
|
||||
function flowLabel(item: ActionPresentationItem): string {
|
||||
if (te(item.labelKey)) return t(item.labelKey);
|
||||
const gateKey = `workspace.shippingNotice.processGate.actions.${item.actionCode}`;
|
||||
if (te(gateKey)) return t(gateKey);
|
||||
return item.actionCode;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<footer
|
||||
v-if="hasDraft && !isReadOnly"
|
||||
v-if="showFooter"
|
||||
class="sticky bottom-0 z-20 flex shrink-0 flex-col gap-3 border-t border-slate-200 bg-white/95 p-3 shadow-[0_-4px_12px_rgba(15,23,42,0.06)] backdrop-blur sm:flex-row sm:items-center sm:justify-between dark:border-slate-800 dark:bg-slate-900/95"
|
||||
data-testid="review-footer-actions"
|
||||
:data-automating="automating ? '1' : '0'"
|
||||
>
|
||||
<div class="order-1 flex flex-wrap items-center gap-2 sm:order-1">
|
||||
<button
|
||||
v-if="hasAction('mark_non_order')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="rounded border border-rose-200 px-3 py-2 text-sm text-rose-700 hover:bg-rose-50 disabled:opacity-50 dark:border-rose-900 dark:text-rose-300 dark:hover:bg-rose-950/40"
|
||||
@click="emit('mark-non-order')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.markNonOrder') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('mark_quality_issue')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="rounded border border-amber-200 px-3 py-2 text-sm text-amber-800 hover:bg-amber-50 disabled:opacity-50 dark:border-amber-900 dark:text-amber-200 dark:hover:bg-amber-950/40"
|
||||
@click="emit('mark-quality-issue')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.markQualityIssue') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('reparse')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center gap-1 rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
@click="emit('reparse')"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.reparse') }}
|
||||
</button>
|
||||
<label
|
||||
v-if="hasAction('mark_quality_issue')"
|
||||
class="cursor-pointer rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
>
|
||||
<input
|
||||
class="sr-only"
|
||||
type="file"
|
||||
accept="application/pdf,.pdf"
|
||||
<template v-if="!automating">
|
||||
<button
|
||||
v-if="hasAction('mark_non_order')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
@change="emit('upload-replacement', $event)"
|
||||
class="rounded border border-rose-200 px-3 py-2 text-sm text-rose-700 hover:bg-rose-50 disabled:opacity-50 dark:border-rose-900 dark:text-rose-300 dark:hover:bg-rose-950/40"
|
||||
@click="emit('mark-non-order')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.uploadReplacement') }}
|
||||
</label>
|
||||
{{ t('chat.shippingOrderReview.markNonOrder') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('mark_quality_issue')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="rounded border border-amber-200 px-3 py-2 text-sm text-amber-800 hover:bg-amber-50 disabled:opacity-50 dark:border-amber-900 dark:text-amber-200 dark:hover:bg-amber-950/40"
|
||||
@click="emit('mark-quality-issue')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.markQualityIssue') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('reparse')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center gap-1 rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
@click="emit('reparse')"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.reparse') }}
|
||||
</button>
|
||||
<label
|
||||
v-if="hasAction('mark_quality_issue')"
|
||||
class="cursor-pointer rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
>
|
||||
<input
|
||||
class="sr-only"
|
||||
type="file"
|
||||
accept="application/pdf,.pdf"
|
||||
:disabled="saving"
|
||||
@change="emit('upload-replacement', $event)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.uploadReplacement') }}
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<button
|
||||
v-for="item in flowItems"
|
||||
:key="`${item.intent}-${item.actionCode}`"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="rounded border border-slate-300 px-3 py-2 text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
||||
:data-testid="`review-footer-flow-${item.intent}`"
|
||||
:data-intent="item.intent"
|
||||
@click="emit('flow-action', item)"
|
||||
>
|
||||
{{ flowLabel(item) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="order-2 flex flex-wrap items-center justify-end gap-2 sm:order-2">
|
||||
<p
|
||||
v-if="hideConfirmBecauseAutoGate"
|
||||
v-if="unsavedCount > 0"
|
||||
class="text-xs text-amber-700 dark:text-amber-300"
|
||||
data-testid="review-footer-unsaved"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.unsavedSwitch.unsavedCount', { count: unsavedCount }) }}
|
||||
</p>
|
||||
<p
|
||||
v-if="automating"
|
||||
class="text-xs text-muted"
|
||||
data-testid="review-footer-automating-hint"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.workflowProgress.automatingFooterHint') }}
|
||||
</p>
|
||||
<p
|
||||
v-else-if="hideConfirmBecauseAutoGate"
|
||||
class="text-xs text-muted"
|
||||
data-testid="review-auto-gate-hint"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.buildEligibility.autoGateProgressHint') }}
|
||||
</p>
|
||||
<button
|
||||
v-if="hasAction('validate')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center gap-1 rounded bg-sky-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
@click="emit('validate')"
|
||||
>
|
||||
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveNow') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('confirm') && !hideConfirmBecauseAutoGate"
|
||||
type="button"
|
||||
:disabled="saving || !canConfirmBuild"
|
||||
class="rounded bg-emerald-600 px-3 py-2 text-sm font-medium text-white disabled:opacity-50"
|
||||
data-testid="review-confirm-create"
|
||||
:title="!canConfirmBuild ? t('chat.shippingOrderReview.buildEligibility.confirmBlocked') : undefined"
|
||||
@click="emit('confirm')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.confirmCreate') }}
|
||||
</button>
|
||||
<template v-if="!automating">
|
||||
<button
|
||||
v-if="hasAction('validate')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center gap-1 rounded bg-sky-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
@click="emit('validate')"
|
||||
>
|
||||
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveNow') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('confirm') && !hideConfirmBecauseAutoGate"
|
||||
type="button"
|
||||
:disabled="saving || !canConfirmBuild"
|
||||
class="rounded bg-emerald-600 px-3 py-2 text-sm font-medium text-white disabled:opacity-50"
|
||||
data-testid="review-confirm-create"
|
||||
:title="!canConfirmBuild ? t('chat.shippingOrderReview.buildEligibility.confirmBlocked') : undefined"
|
||||
@click="emit('confirm')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.confirmCreate') }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</footer>
|
||||
</template>
|
||||
+43
-15
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewWorkflowProgressPanel.spec.ts
|
||||
* 用途:复核统一进度面板——UnifiedProgressTrack 挂载;人工入口仅 Gate 动作。
|
||||
* 用途:订单处理台进度面板——紧凑五域条;人工入口仅 Gate 动作。
|
||||
* 依赖:vitest、@vue/test-utils、vue-i18n stub、RouterLink stub。
|
||||
* 逻辑:有 processingProjection 才渲染轨道节点;manual upload 入口需 nextActionCode;RPA 不展示人工 CTA。
|
||||
* 逻辑:有 processingProjection 才渲染 ReviewProgressStrip;无页内 15 阶展开;manual upload 入口需 nextActionCode。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
@@ -22,7 +22,7 @@ const messages = {
|
||||
subtitle: 'Advances through freight upload',
|
||||
polling: 'Refreshing…',
|
||||
progressUnavailable: 'Progress unavailable — refresh the page.',
|
||||
openTaskWorkbench: 'Open task workbench to register',
|
||||
openTaskWorkbench: 'Open Task Center to register',
|
||||
nextStepsManualUpload:
|
||||
'Next: download Excel → upload on freight platform → submit evidence and receipt',
|
||||
nextStepsGeneric: 'Manual action required — follow the system prompt.',
|
||||
@@ -30,6 +30,22 @@ const messages = {
|
||||
},
|
||||
shippingProcessing: {
|
||||
panelTitle: 'Shipping processing',
|
||||
expandHistory: 'Show full track',
|
||||
collapseHistory: 'Hide full track',
|
||||
progress: {
|
||||
completedOfTotal: '{done} of {total} done',
|
||||
remainingHint: '{count} remaining',
|
||||
positionOfTotal: '{current} / {total}',
|
||||
domainReceiveParse: 'Receive',
|
||||
domainCandidateIdentity: 'Candidate',
|
||||
domainOrderConfirm: 'Confirm',
|
||||
domainInventoryHandle: 'Inventory',
|
||||
domainFulfillmentShip: 'Ship',
|
||||
currentNeedLabel: 'Need: ',
|
||||
systemProcessingNeed: 'System processing',
|
||||
viewProcessDetails: 'View process details',
|
||||
},
|
||||
gateReasons: { generic: 'Needs action' },
|
||||
status: {
|
||||
automating: 'Automating',
|
||||
blocked: 'Blocked',
|
||||
@@ -39,6 +55,18 @@ const messages = {
|
||||
freight_uploading: 'Uploading to freight',
|
||||
excel_generating: 'Generating Excel',
|
||||
},
|
||||
action: {
|
||||
refresh: 'Refresh',
|
||||
},
|
||||
},
|
||||
},
|
||||
workspace: {
|
||||
shippingNotice: {
|
||||
processGate: {
|
||||
actions: {
|
||||
wait_manual_upload: 'Wait for manual upload',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -76,11 +104,12 @@ describe('ReviewWorkflowProgressPanel', () => {
|
||||
it('shows unavailable state without projection', () => {
|
||||
const wrapper = mountPanel({ polling: false, processingProjection: null });
|
||||
expect(wrapper.find('[data-testid="review-progress-unavailable"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="unified-progress-track"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-progress-strip"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="unified-progress-track"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-open-task-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders unified track nodes from projection stage', () => {
|
||||
it('renders compact domain strip without inline 15-node expand', () => {
|
||||
const wrapper = mountPanel({
|
||||
polling: false,
|
||||
processingProjection: {
|
||||
@@ -90,13 +119,14 @@ describe('ReviewWorkflowProgressPanel', () => {
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-progress-unavailable"]').exists()).toBe(false);
|
||||
const current = wrapper.findAll('[data-testid="unified-progress-node"]')
|
||||
.find((node) => node.attributes('data-stage') === 'excel_generating');
|
||||
expect(current?.attributes('data-current')).toBe('true');
|
||||
expect(current?.attributes('data-state')).toBe('running');
|
||||
expect(wrapper.find('[data-testid="review-progress-strip"]').exists()).toBe(true);
|
||||
expect(wrapper.findAll('[data-testid="review-progress-domains"] [data-domain]').length).toBe(5);
|
||||
expect(wrapper.find('[data-testid="review-progress-expand-full"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="unified-action-bar"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-progress-open-details"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('lights freight_uploading and hides manual CTA while automating', () => {
|
||||
it('hides manual CTA while automating freight upload', () => {
|
||||
const wrapper = mountPanel({
|
||||
polling: false,
|
||||
processingProjection: {
|
||||
@@ -105,14 +135,12 @@ describe('ReviewWorkflowProgressPanel', () => {
|
||||
sourceType: 'eml',
|
||||
},
|
||||
});
|
||||
const freight = wrapper.findAll('[data-testid="unified-progress-node"]')
|
||||
.find((node) => node.attributes('data-stage') === 'freight_uploading');
|
||||
expect(freight?.attributes('data-current')).toBe('true');
|
||||
expect(wrapper.find('[data-testid="review-progress-strip"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-open-task-workbench"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-manual-upload-next-steps"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('shows task workbench link when gate next_action is manual upload', () => {
|
||||
it('shows Task Center link when gate next_action is manual upload', () => {
|
||||
const wrapper = mountPanel({
|
||||
polling: false,
|
||||
processingProjection: {
|
||||
@@ -129,7 +157,7 @@ describe('ReviewWorkflowProgressPanel', () => {
|
||||
});
|
||||
expect(wrapper.get('[data-testid="review-manual-upload-next-steps"]').text()).toContain('download Excel');
|
||||
const link = wrapper.get('[data-testid="review-open-task-workbench"]');
|
||||
expect(link.text()).toContain('Open task workbench to register');
|
||||
expect(link.text()).toContain('Open Task Center to register');
|
||||
expect(link.attributes('href')).toContain('workspace-shipping-my-tasks');
|
||||
expect(link.attributes('href')).toContain('SN-1');
|
||||
});
|
||||
|
||||
+17
-7
@@ -1,8 +1,8 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewWorkflowProgressPanel.vue
|
||||
用途:复核工作台统一进度轨道(完整 15 阶密度窗口)+ Gate 下一步提示。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、UnifiedProgressTrack、shippingProcessingFulfillment。
|
||||
逻辑:节点高亮仅读统一投影;任务台入口仅当 currentGate.nextActionCode 指人工上传。
|
||||
用途:订单处理工作台只读进度区(ReviewProgressStrip)+ Gate / 人工上传下一步提示。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、ReviewProgressStrip。
|
||||
逻辑:节点高亮只读统一投影;打开流程详情 / 刷新 emit 给宿主;写操作不在本面板。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
resolveShippingProcessingStatusLabel,
|
||||
shippingProcessingStageKey,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import UnifiedProgressTrack from '@/features/shipping-progress/components/UnifiedProgressTrack.vue';
|
||||
import ReviewProgressStrip from '@/features/shipping-progress/components/ReviewProgressStrip.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
item: ShippingReviewProgressContext | null;
|
||||
@@ -29,6 +29,11 @@ const props = defineProps<{
|
||||
processingProjection?: ShippingProcessingProjection | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'open-process-details': [];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const hasProjection = computed(() => Boolean(props.processingProjection));
|
||||
@@ -115,10 +120,15 @@ const genericNextStepMessage = computed(() => {
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3" data-testid="review-progress-nodes">
|
||||
<UnifiedProgressTrack
|
||||
<div
|
||||
v-if="processingProjection"
|
||||
class="mt-3"
|
||||
data-testid="review-progress-nodes"
|
||||
>
|
||||
<ReviewProgressStrip
|
||||
:projection="processingProjection"
|
||||
density="review"
|
||||
@open-process-details="emit('open-process-details')"
|
||||
@refresh="emit('refresh')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
+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
|
||||
|
||||
@@ -13,23 +13,15 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
|
||||
import {
|
||||
|
||||
isBuildConfirmBlocked,
|
||||
|
||||
isDraftVersionMismatchError,
|
||||
|
||||
isReviewCaseHistorical,
|
||||
|
||||
isReviewReadOnly,
|
||||
|
||||
isReviewWorkItemClosed,
|
||||
|
||||
lineNeedsManualInventorySelection,
|
||||
|
||||
lineHasPendingRoutingSuggestion,
|
||||
|
||||
lineNeedsInventoryRoutingRecovery,
|
||||
|
||||
mapReviewContextLifecycleStatus,
|
||||
REVIEW_BUILD_ELIGIBILITY_BLOCKED,
|
||||
|
||||
REVIEW_DRAFT_VERSION_MISMATCH,
|
||||
@@ -231,6 +223,14 @@ describe('useShippingOrderReview historical readonly', () => {
|
||||
)).toBe(true);
|
||||
});
|
||||
|
||||
it('maps confirmed case to non-closed lifecycle for post-confirm automation', () => {
|
||||
// 关键断言:confirmed 不得映射 closed,否则统一进度轨道会被误判为终态。
|
||||
expect(mapReviewContextLifecycleStatus('confirmed', null)).toBe('building_order');
|
||||
expect(mapReviewContextLifecycleStatus('confirmed', 'inventory_matching')).toBe('inventory_matching');
|
||||
expect(mapReviewContextLifecycleStatus('closed', null)).toBe('closed');
|
||||
expect(mapReviewContextLifecycleStatus('quality_issue', null)).toBe('closed');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
/**
|
||||
* features/chat/shipping-review/useShippingOrderReview.ts
|
||||
* ?????????? Run??? PDF Case ?????????ShippingReviewProgressContext??
|
||||
* ???shipping API review / extraction-run?useShippingProcessingWorkItem?Vue ????BusinessError?
|
||||
* ????????? runNo ????????????????? Workflow ????
|
||||
* Case.order_task_no / Candidate ??? OT ?????????? Run ? OT ? Notice ???
|
||||
* ?? REVIEW_DRAFT_VERSION_MISMATCH ???????????????
|
||||
* build_eligibility ???????????????????????reroute / adopt / keep??
|
||||
* ????? ShippingProcessing ???????? OT ??? extraction-run ???
|
||||
* ???? extraction-run ??????????? Review Run/Case?
|
||||
* ???????? Workflow ?????????????????????
|
||||
* ?????????/?/?/evidence_id?????? evidence ??????????????
|
||||
* PDF Blob ?? ensurePreviewLoaded ??????load/selectCase ??????
|
||||
* ????????? composable??Run/Case/PDF ??????????
|
||||
* ???shipping API review/extraction-run?useShippingProcessingWorkItem?Vue ref/computed?BusinessError?
|
||||
* ???? runNo ?? Review Run/Case??? ShippingReviewProgressContext?
|
||||
* ?? OT ?? Case.order_task_no / Candidate ????? ShippingProcessing ???
|
||||
* 409 REVIEW_DRAFT_VERSION_MISMATCH ???????build_eligibility ???? reroute/adopt/keep?
|
||||
* ???? extraction-run?draft_ready ? reload?PDF Blob ? ensurePreviewLoaded ????
|
||||
*/
|
||||
import { computed, getCurrentInstance, onBeforeUnmount, ref } from 'vue';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
@@ -69,13 +64,13 @@ export type ReviewStatusMessage =
|
||||
| 'draft_version_conflict'
|
||||
| null;
|
||||
|
||||
/** ???????????????? ConflictError.code ???? */
|
||||
/** ????????? ConflictError.code???????? */
|
||||
export const REVIEW_DRAFT_VERSION_MISMATCH = 'SHIPPING.REVIEW_DRAFT_VERSION_MISMATCH';
|
||||
|
||||
/** ???????? confirm ?????? */
|
||||
/** ?????????? confirm ????? */
|
||||
export const REVIEW_BUILD_ELIGIBILITY_BLOCKED = 'SHIPPING.REVIEW_BUILD_ELIGIBILITY_BLOCKED';
|
||||
|
||||
/** ???????????????????????? */
|
||||
/** ????????????????????????? */
|
||||
const INVENTORY_BLOCK_REASONS = new Set([
|
||||
'require_manual_review',
|
||||
'no_inventory_source_candidates',
|
||||
@@ -84,7 +79,7 @@ const INVENTORY_BLOCK_REASONS = new Set([
|
||||
'inventory_source_unresolved',
|
||||
]);
|
||||
|
||||
/** ???????????????????????????? Case??????? */
|
||||
/** ????????????/??????????? Case ??? */
|
||||
export type DraftVersionConflict = {
|
||||
localVersion: number;
|
||||
serverVersion: number | null;
|
||||
@@ -93,7 +88,7 @@ export type DraftVersionConflict = {
|
||||
};
|
||||
|
||||
/**
|
||||
* ??????????????????
|
||||
* ??????????????409 REVIEW_DRAFT_VERSION_MISMATCH??
|
||||
* @param error - ???????
|
||||
*/
|
||||
export function isDraftVersionMismatchError(error: unknown): boolean {
|
||||
@@ -143,7 +138,7 @@ type WorkItemRef = {
|
||||
} | null | undefined;
|
||||
|
||||
/**
|
||||
* ???? Case ?????/????????????
|
||||
* ???? Case ????????superseded ?? WorkItem ?? Case ?????
|
||||
*/
|
||||
export function isReviewCaseHistorical(activeCase: ReviewCaseRef, workItem: WorkItemRef): boolean {
|
||||
const caseNo = String(activeCase?.case_no || '');
|
||||
@@ -154,8 +149,8 @@ export function isReviewCaseHistorical(activeCase: ReviewCaseRef, workItem: Work
|
||||
}
|
||||
|
||||
/**
|
||||
* ???????????????/??????
|
||||
* ?????manual_upload_pending / upload_rpa_* ???????????????
|
||||
* ?? WorkItem ??????? closed/cancelled??
|
||||
* ?????confirmed / building_order ???? lifecycle ???????
|
||||
*/
|
||||
export function isReviewWorkItemClosed(workItem: WorkItemRef): boolean {
|
||||
const status = String(workItem?.lifecycle_status || '').trim();
|
||||
@@ -163,7 +158,7 @@ export function isReviewWorkItemClosed(workItem: WorkItemRef): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* ???????????????????????
|
||||
* ?????????? Case ? WorkItem ????
|
||||
*/
|
||||
export function isReviewReadOnly(activeCase: ReviewCaseRef, workItem: WorkItemRef): boolean {
|
||||
return isReviewCaseHistorical(activeCase, workItem) || isReviewWorkItemClosed(workItem);
|
||||
@@ -214,14 +209,16 @@ export function lineNeedsInventoryRoutingRecovery(
|
||||
}
|
||||
|
||||
/**
|
||||
* ? Case / Extraction Run ??????? WorkflowItem ? lifecycle_status?
|
||||
* ?????draft/ready ? pending_review?non_order ? cancelled???? Run ??????? lifecycle?
|
||||
* ? Case / Extraction Run ????? WorkflowItem lifecycle_status?
|
||||
* ?????draft/ready ? pending_review?non_order ? cancelled?
|
||||
* confirmed ???? closed?????? building_order ???
|
||||
* ??? closed / quality_issue ? closed?Extraction Run ????? Case ????
|
||||
*
|
||||
* @param caseStatus - Review Case ??
|
||||
* @param runStatus - Extraction Run ??????
|
||||
* @returns ?? WorkflowItem ?????????
|
||||
* @returns ??????? lifecycle ???
|
||||
*/
|
||||
function mapReviewContextLifecycleStatus(
|
||||
export function mapReviewContextLifecycleStatus(
|
||||
caseStatus?: string | null,
|
||||
runStatus?: string | null,
|
||||
): ShippingWorkflowItemLifecycleStatus {
|
||||
@@ -230,7 +227,13 @@ function mapReviewContextLifecycleStatus(
|
||||
|
||||
if (cs === 'non_order') return 'cancelled';
|
||||
if (cs === 'quality_issue') return 'closed';
|
||||
if (['confirmed', 'closed'].includes(cs)) return 'closed';
|
||||
if (cs === 'closed') return 'closed';
|
||||
// [UI-05] confirmed ? closed????????????????????
|
||||
if (cs === 'confirmed') {
|
||||
if (['building_order', 'inventory_matching', 'generating_excel'].includes(rs)) return rs;
|
||||
if (['manual_upload_pending', 'upload_rpa_pending', 'upload_rpa_running'].includes(rs)) return rs;
|
||||
return 'building_order';
|
||||
}
|
||||
if (cs === 'reparse_pending') return 'extracting';
|
||||
if (['failed', 'cancelled'].includes(rs)) return rs;
|
||||
if (rs === 'reparse_failed') return 'reparse_failed';
|
||||
|
||||
@@ -481,6 +481,8 @@ describe('conversationProcessingProjection', () => {
|
||||
sourceType: 'eml',
|
||||
rootOrderTaskNo: 'OT-WAIT',
|
||||
shippingNoticeNo: null,
|
||||
runNo: 'RUN-WAIT',
|
||||
caseNo: 'CASE-WAIT',
|
||||
conversationId: 'conv-1',
|
||||
submissionNo: 'SOS-1',
|
||||
intakeNo: 'SNI-2',
|
||||
@@ -545,6 +547,53 @@ describe('conversationProcessingProjection', () => {
|
||||
expect(projection!.processing.map((t) => t.user_task_no)).toEqual(['OT-RUN']);
|
||||
expect(projection!.needs_action[0]?.file_count).toBe(2);
|
||||
expect(projection!.needs_action[0]?.display_kind).toBe('multi_document_task');
|
||||
// [P0] 合成任务必须透传 run_no,禁止写死 null。
|
||||
expect(projection!.needs_action[0]?.run_no).toBe('RUN-WAIT');
|
||||
});
|
||||
|
||||
it('deduplicates conversation total_files by authoritative PDF id', () => {
|
||||
const base = {
|
||||
sourceType: 'direct_pdf' as const,
|
||||
shippingNoticeNo: null,
|
||||
conversationId: 'conv-1',
|
||||
submissionNo: 'SOS-1',
|
||||
intakeNo: 'SNI-1',
|
||||
status: 'waiting_review' as const,
|
||||
stage: 'waiting_review' as const,
|
||||
progressVersion: 1,
|
||||
lastActivityAt: '2026-08-06T00:00:00Z',
|
||||
currentGate: null,
|
||||
availableActions: ['open_order_review'],
|
||||
childOrderTasks: [],
|
||||
};
|
||||
const workItems: ShippingProcessingProjection[] = [
|
||||
{
|
||||
...base,
|
||||
workItemType: 'order_task',
|
||||
workItemNo: 'OT-A',
|
||||
rootOrderTaskNo: 'OT-A',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'a.pdf', documentId: 17,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-A',
|
||||
},
|
||||
},
|
||||
{
|
||||
...base,
|
||||
workItemType: 'order_task',
|
||||
workItemNo: 'OT-B',
|
||||
rootOrderTaskNo: 'OT-A',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'a.pdf', documentId: 17,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-B',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const projection = projectConversationProcessingFromWorkItems(workItems);
|
||||
// 异常重复绑定同一主 PDF 时,顶部必须仍显示 1 个文件。
|
||||
expect(projection?.summary.total_files).toBe(1);
|
||||
});
|
||||
|
||||
it('prefers work_items task lists over embedded conversation_processing when both exist', () => {
|
||||
|
||||
@@ -529,10 +529,9 @@ export function groupConversationProcessingTasks(
|
||||
const completed = tasks.filter((t) => t.group === 'completed');
|
||||
const history = tasks.filter((t) => t.group === 'history');
|
||||
const active = [...needs_action, ...processing, ...completed];
|
||||
const totalFiles = active.reduce((sum, task) => sum + Number(task.file_count || 0), 0);
|
||||
const summary: ConversationProcessingSummary = {
|
||||
total_tasks: needs_action.length + processing.length + completed.length,
|
||||
total_files: totalFiles,
|
||||
total_files: active.reduce((sum, task) => sum + Number(task.file_count || 0), 0),
|
||||
processing: processing.length,
|
||||
needs_action: needs_action.length,
|
||||
completed: completed.length,
|
||||
@@ -661,7 +660,8 @@ export function projectConversationProcessingFromWorkItems(
|
||||
group,
|
||||
status_label: String(item.status || '') || null,
|
||||
file_count: docCount > 0 ? docCount : (filename ? 1 : 0),
|
||||
run_no: null,
|
||||
// [P0] 消费后端投影 run_no,禁止写死 null 导致「进入订单处理」静默失败。
|
||||
run_no: String(item.runNo || '').trim() || null,
|
||||
can_append: false,
|
||||
last_activity_at: item.lastActivityAt || null,
|
||||
available_actions: Array.isArray(item.availableActions) ? [...item.availableActions] : [],
|
||||
@@ -675,7 +675,15 @@ export function projectConversationProcessingFromWorkItems(
|
||||
|
||||
const active = [...needs_action, ...processing, ...completed];
|
||||
if (!active.length && !history.length) return null;
|
||||
const totalFiles = active.reduce((sum, task) => sum + Number(task.file_count || 0), 0);
|
||||
// 后端未返回 embedded 汇总时,仍按 OT 主 PDF ID 去重,禁止兄弟 OT 重复累计。
|
||||
const documentIds = new Set(
|
||||
orderTasks
|
||||
.map((item) => Number(item.sourceSummary?.documentId || 0))
|
||||
.filter((id) => id > 0),
|
||||
);
|
||||
const totalFiles = documentIds.size > 0
|
||||
? documentIds.size
|
||||
: active.reduce((sum, task) => sum + Number(task.file_count || 0), 0);
|
||||
return {
|
||||
summary: {
|
||||
total_tasks: active.length,
|
||||
|
||||
@@ -35,6 +35,7 @@ describe('normalizeShippingProcessingProjection', () => {
|
||||
source_summary: {
|
||||
email_subject: null,
|
||||
filename: 'a.pdf',
|
||||
document_id: 17,
|
||||
document_count: 1,
|
||||
parsed_document_count: 1,
|
||||
candidate_count: 1,
|
||||
@@ -53,10 +54,27 @@ describe('normalizeShippingProcessingProjection', () => {
|
||||
expect(normalized!.currentGate?.gateCode).toBe('field_conflict_resolution');
|
||||
expect(normalized!.currentGate?.attemptNo).toBe(1);
|
||||
expect(normalized!.sourceSummary.filename).toBe('a.pdf');
|
||||
expect(normalized!.sourceSummary.documentId).toBe(17);
|
||||
expect(normalized!.sourceSummary.assetStatus).toBe('ready');
|
||||
expect(normalized!.availableActions).toEqual(['open_review']);
|
||||
});
|
||||
|
||||
it('normalizes stage_nodes from backend', () => {
|
||||
const normalized = normalizeShippingProcessingProjection({
|
||||
work_item_no: 'OT-2',
|
||||
work_item_type: 'order_task',
|
||||
status: 'processing',
|
||||
stage: 'document_parsing',
|
||||
stage_nodes: [
|
||||
{ stage: 'upload_received', absolute_index: 0, status: 'passed' },
|
||||
{ stage: 'document_parsing', absolute_index: 2, status: 'running' },
|
||||
],
|
||||
});
|
||||
expect(normalized?.stageNodes).toHaveLength(2);
|
||||
expect(normalized?.stageNodes?.[1]?.status).toBe('running');
|
||||
expect(normalized?.stageNodes?.[1]?.absoluteIndex).toBe(2);
|
||||
});
|
||||
|
||||
it('returns null when work_item_no missing', () => {
|
||||
expect(normalizeShippingProcessingProjection({ status: 'processing' })).toBeNull();
|
||||
});
|
||||
|
||||
@@ -11,6 +11,8 @@ import type {
|
||||
ShippingOrderTaskSummary,
|
||||
ShippingProcessingProjection,
|
||||
ShippingProcessingStage,
|
||||
ShippingProcessingStageNode,
|
||||
ShippingProcessingStageNodeStatus,
|
||||
ShippingProcessingStatus,
|
||||
ShippingProcessingWorkItemType,
|
||||
} from '../types/shipping.api.types';
|
||||
@@ -76,6 +78,26 @@ function normalizeGate(raw: unknown): ProcessGateSummary | null {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 规范单个 stage_node(兼容 snake / camel)。
|
||||
*/
|
||||
function normalizeStageNode(raw: unknown): ShippingProcessingStageNode | null {
|
||||
if (!raw || typeof raw !== 'object') return null;
|
||||
const item = raw as Record<string, unknown>;
|
||||
const stage = readString(item, 'stage', 'stage') as ShippingProcessingStage;
|
||||
if (!stage) return null;
|
||||
const absoluteIndexRaw = item.absolute_index ?? item.absoluteIndex;
|
||||
const absoluteIndex = Number.isFinite(Number(absoluteIndexRaw))
|
||||
? Number(absoluteIndexRaw)
|
||||
: 0;
|
||||
const status = readString(item, 'status', 'status') as ShippingProcessingStageNodeStatus;
|
||||
return {
|
||||
stage,
|
||||
absoluteIndex,
|
||||
status: status || 'pending',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将后端 / 混合字段投影规范为 ShippingProcessingProjection。
|
||||
* 核心逻辑:缺字段给安全默认值,保证四页面可渲染;非法输入返回 null。
|
||||
@@ -100,6 +122,10 @@ export function normalizeShippingProcessingProjection(
|
||||
const availableActions = Array.isArray(actionsRaw)
|
||||
? actionsRaw.map((action) => String(action || '').trim()).filter(Boolean)
|
||||
: [];
|
||||
const stageNodesRaw = item.stage_nodes ?? item.stageNodes;
|
||||
const stageNodes = Array.isArray(stageNodesRaw)
|
||||
? stageNodesRaw.map(normalizeStageNode).filter((row): row is ShippingProcessingStageNode => Boolean(row))
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
workItemType: (readString(item, 'work_item_type', 'workItemType') || 'order_task') as ShippingProcessingWorkItemType,
|
||||
@@ -107,6 +133,8 @@ export function normalizeShippingProcessingProjection(
|
||||
sourceType: (readNullableString(item, 'source_type', 'sourceType') || 'eml') as OrderIntakeSourceType,
|
||||
rootOrderTaskNo: readNullableString(item, 'root_order_task_no', 'rootOrderTaskNo'),
|
||||
shippingNoticeNo: readNullableString(item, 'shipping_notice_no', 'shippingNoticeNo'),
|
||||
runNo: readNullableString(item, 'run_no', 'runNo'),
|
||||
caseNo: readNullableString(item, 'case_no', 'caseNo'),
|
||||
conversationId: readNullableString(item, 'conversation_id', 'conversationId'),
|
||||
submissionNo: readString(item, 'submission_no', 'submissionNo'),
|
||||
intakeNo: readString(item, 'intake_no', 'intakeNo'),
|
||||
@@ -114,11 +142,13 @@ export function normalizeShippingProcessingProjection(
|
||||
stage: (readString(item, 'stage', 'stage') || 'upload_received') as ShippingProcessingStage,
|
||||
progressVersion: Number(item.progress_version ?? item.progressVersion ?? 0) || 0,
|
||||
lastActivityAt: readString(item, 'last_activity_at', 'lastActivityAt'),
|
||||
stageNodes: stageNodes?.length ? stageNodes : undefined,
|
||||
currentGate: normalizeGate(item.current_gate ?? item.currentGate),
|
||||
availableActions,
|
||||
sourceSummary: {
|
||||
emailSubject: readNullableString(summaryRaw, 'email_subject', 'emailSubject'),
|
||||
filename: readNullableString(summaryRaw, 'filename', 'filename'),
|
||||
documentId: Number(summaryRaw.document_id ?? summaryRaw.documentId ?? 0) || null,
|
||||
documentCount: Number(summaryRaw.document_count ?? summaryRaw.documentCount ?? 0) || 0,
|
||||
parsedDocumentCount: Number(summaryRaw.parsed_document_count ?? summaryRaw.parsedDocumentCount ?? 0) || 0,
|
||||
candidateCount: Number(summaryRaw.candidate_count ?? summaryRaw.candidateCount ?? 0) || 0,
|
||||
|
||||
@@ -17,6 +17,7 @@ const LEGACY_STATUS_TO_PROCESSING: Record<string, string> = {
|
||||
cancelling: 'processing',
|
||||
blocked: 'blocked',
|
||||
automating: 'automating',
|
||||
review_case_draft: 'waiting_review',
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -139,6 +139,22 @@ describe('useShippingNoticeWorkflow', () => {
|
||||
ctl.stop();
|
||||
});
|
||||
|
||||
it('coalesces concurrent refreshes for the same conversation', async () => {
|
||||
const pending = deferred<ReturnType<typeof buildUnifiedProcessing>>();
|
||||
api.getShippingProcessing.mockImplementation(() => pending.promise);
|
||||
|
||||
const ctl = useShippingNoticeWorkflow({ conversationId: ref('conv-1') });
|
||||
const manualRefresh = ctl.refresh();
|
||||
await nextTick();
|
||||
|
||||
// 首轮恢复、页面刷新和可见性触发命中同一会话时只能产生一个网络请求。
|
||||
expect(api.getShippingProcessing).toHaveBeenCalledTimes(1);
|
||||
pending.resolve(buildUnifiedProcessing());
|
||||
await manualRefresh;
|
||||
expect(ctl.processing.value?.summary.needs_action).toBe(1);
|
||||
ctl.stop();
|
||||
});
|
||||
|
||||
it('records recoverable error without throwing', async () => {
|
||||
const conversationId = ref('conv-1');
|
||||
const ctl = useShippingNoticeWorkflow({ conversationId });
|
||||
|
||||
@@ -116,6 +116,7 @@ export function useShippingNoticeWorkflow(
|
||||
let pollGeneration = 0;
|
||||
let requestController: AbortController | null = null;
|
||||
let requestGeneration = 0;
|
||||
let inFlightRefresh: { conversationId: string; promise: Promise<void> } | null = null;
|
||||
let failureCount = 0;
|
||||
let pollingStopped = false;
|
||||
|
||||
@@ -151,17 +152,10 @@ export function useShippingNoticeWorkflow(
|
||||
/**
|
||||
* 仅拉取统一 shipping-processing 投影。
|
||||
* 核心逻辑:work_items 非空时始终由 order_task 合成任务列表;embedded 仅补焦点元数据;
|
||||
* 新请求会中止旧请求,且只有最新一代请求可回写 loading / error / 会话数据。
|
||||
* 同会话在途请求合并;跨会话请求中止,且只有最新一代可回写页面数据。
|
||||
* @returns Promise<void>;可恢复网络失败写入 error,不向页面抛出。
|
||||
*/
|
||||
async function refresh(): Promise<void> {
|
||||
const conversationId = normalizedConversationId.value;
|
||||
if (!conversationId) {
|
||||
processing.value = null;
|
||||
processingWorkItems.value = [];
|
||||
error.value = null;
|
||||
return;
|
||||
}
|
||||
async function executeRefresh(conversationId: string): Promise<void> {
|
||||
const generation = ++requestGeneration;
|
||||
loading.value = true;
|
||||
const controller = createRequestController();
|
||||
@@ -196,6 +190,27 @@ export function useShippingNoticeWorkflow(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取统一进度;同一会话已有请求时复用该 Promise,避免首屏触发源互相取消重发。
|
||||
*/
|
||||
function refresh(): Promise<void> {
|
||||
const conversationId = normalizedConversationId.value;
|
||||
if (!conversationId) {
|
||||
processing.value = null;
|
||||
processingWorkItems.value = [];
|
||||
error.value = null;
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (inFlightRefresh?.conversationId === conversationId) {
|
||||
return inFlightRefresh.promise;
|
||||
}
|
||||
const promise = executeRefresh(conversationId).finally(() => {
|
||||
if (inFlightRefresh?.promise === promise) inFlightRefresh = null;
|
||||
});
|
||||
inFlightRefresh = { conversationId, promise };
|
||||
return promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 focus/viewed/submit 写路径响应应用到本地 processing 与 work_items。
|
||||
* 核心逻辑:有 work_items 时用统一合成;否则仅回写 processing 兼容块。
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/chat/shipping/useShippingOrderExtractionRuns.spec.ts
|
||||
* 用途:验证订单抽取 Run 的状态映射、消息幂等持久化与轮询生命周期。
|
||||
* 用途:验证订单抽取 Run 的状态映射、单状态卡消息持久化与轮询生命周期。
|
||||
* 依赖:Vitest、Vue refs、shipping.api mock、useShippingOrderExtractionRuns。
|
||||
* 逻辑:覆盖状态契约、新会话启动、无变化轮询、恢复失败及切会话迟到响应。
|
||||
* 逻辑:覆盖新建/追加提交不生成重复反馈气泡、状态契约、无变化轮询及恢复隔离。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
@@ -98,7 +98,7 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('persists stable user and assistant formIds and does not write unchanged polling state again', async () => {
|
||||
it('persists one user message and one Run state card without duplicate submission feedback', async () => {
|
||||
const queued = run({
|
||||
run_no: 'SNER-START',
|
||||
conversation_id: 'conv-created',
|
||||
@@ -126,14 +126,41 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
expect(harness.options.onConversationResolved).toHaveBeenCalledWith('conv-created');
|
||||
expect(harness.messages.value.map((item) => item.payload?.formId)).toEqual([
|
||||
'shipping-order-extraction-user:SNER-START',
|
||||
'shipping-submission-decision:op-1',
|
||||
'shipping-order-extraction-run:SNER-START',
|
||||
]);
|
||||
expect(harness.options.saveLocalMessageToBackend).toHaveBeenCalledTimes(3);
|
||||
expect(harness.options.saveLocalMessageToBackend).toHaveBeenCalledTimes(2);
|
||||
|
||||
await vi.advanceTimersByTimeAsync(1000);
|
||||
expect(api.getRun).toHaveBeenCalledWith('SNER-START', expect.any(AbortSignal));
|
||||
expect(harness.options.saveLocalMessageToBackend).toHaveBeenCalledTimes(3);
|
||||
expect(harness.options.saveLocalMessageToBackend).toHaveBeenCalledTimes(2);
|
||||
harness.runs.stopPolling();
|
||||
});
|
||||
|
||||
it('keeps an appended submission in the user message and the existing Run state card only', async () => {
|
||||
const queued = run({
|
||||
run_no: 'SNER-APPENDED',
|
||||
conversation_id: 'conv-existing',
|
||||
user_task_no: 'OT-EXISTING',
|
||||
});
|
||||
api.createSubmission.mockResolvedValue({
|
||||
decision: 'appended',
|
||||
user_task_no: 'OT-EXISTING',
|
||||
run_no: 'SNER-APPENDED',
|
||||
created_new: false,
|
||||
operation_id: 'op-appended',
|
||||
});
|
||||
api.getRun.mockResolvedValue(queued);
|
||||
const harness = createHarness();
|
||||
harness.conversationId.value = 'conv-existing';
|
||||
|
||||
await harness.runs.startRun('追加附件', ['SNI-1'], []);
|
||||
|
||||
expect(harness.messages.value.map((item) => item.payload?.formId)).toEqual([
|
||||
'shipping-order-extraction-user:SNER-APPENDED',
|
||||
'shipping-order-extraction-run:SNER-APPENDED',
|
||||
]);
|
||||
expect(harness.messages.value[0]?.payload?.submission_decision).toBe('appended');
|
||||
expect(harness.options.saveLocalMessageToBackend).toHaveBeenCalledTimes(2);
|
||||
harness.runs.stopPolling();
|
||||
});
|
||||
|
||||
@@ -177,6 +204,7 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
expect.objectContaining({ content: '' }),
|
||||
undefined,
|
||||
);
|
||||
expect(harness.messages.value).toHaveLength(2);
|
||||
harness.runs.stopPolling();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* features/chat/shipping/useShippingOrderExtractionRuns.ts
|
||||
* 用途:把货代订单抽取作为独立 Run 启动、轮询并投影到聊天状态消息。
|
||||
* 依赖:shipping.api 统一提交/Run 接口、shippingSubmissionFeedback、chat.types、Vue refs。
|
||||
* 依赖:shipping.api 统一提交/Run 接口、shippingSubmissionFeedback 标识生成器、chat.types、Vue refs。
|
||||
* 逻辑:发送处理器调用 startRun → createWorkspaceOrderExtractionSubmission(后端裁决 append/create);
|
||||
* 写入用户消息 + 非阻塞决策系统消息后轮询 Run;终态后仍保留 run_no 供状态卡展示。
|
||||
* 写入用户消息 + 唯一 Run 状态卡后轮询;终态后仍保留 run_no 供状态卡展示。
|
||||
* 右侧「本次处理」由 processing / Workflow 投影驱动,本模块在终态/重识别后触发刷新回调。
|
||||
* 轮询前台 2s / 后台 5–10s;取消走请求语义 API,刷新为只读 GET。
|
||||
* 持久化去重签名必须包含 handling_items / primary_notice,避免处理说明变化后历史会话仍读到旧卡。
|
||||
@@ -23,7 +23,6 @@ import type { ChatMessage, ChatMessageAttachment, ShippingOrderExtractionReviewA
|
||||
import type { ShippingOrderExtractionRun } from '../types/shipping.api.types';
|
||||
import type { ShippingNoticeCandidate } from '../types/shipping.types';
|
||||
import {
|
||||
buildShippingSubmissionFeedback,
|
||||
createComposerContextId,
|
||||
createShippingSubmissionId,
|
||||
} from './shippingSubmissionFeedback';
|
||||
@@ -430,7 +429,7 @@ export function useShippingOrderExtractionRuns(options: UseShippingOrderExtracti
|
||||
};
|
||||
|
||||
/**
|
||||
* 启动订单抽取统一提交:后端裁决 append/create,并把用户操作与状态卡持久化到本地会话。
|
||||
* 启动订单抽取统一提交:后端裁决 append/create,并只持久化用户操作与唯一 Run 状态卡。
|
||||
* @param query - 用户本次备注;允许为空,不发送给 Dify Chatflow。
|
||||
* @param intakeNos - 本次冻结的 Intake 编号。
|
||||
* @param attachments - 用户消息中的安全附件快照。
|
||||
@@ -463,11 +462,6 @@ export function useShippingOrderExtractionRuns(options: UseShippingOrderExtracti
|
||||
composerBoundConversationId = run.conversation_id;
|
||||
}
|
||||
|
||||
const feedback = buildShippingSubmissionFeedback(submission, attachments.length);
|
||||
const decisionKey = feedback.decision === 'appended'
|
||||
? 'chat.shippingSubmission.appended'
|
||||
: 'chat.shippingSubmission.created';
|
||||
|
||||
const userMessage: ChatMessage = {
|
||||
role: 'user',
|
||||
type: 'text',
|
||||
@@ -479,29 +473,12 @@ export function useShippingOrderExtractionRuns(options: UseShippingOrderExtracti
|
||||
formId: `shipping-order-extraction-user:${run.run_no}`,
|
||||
order_extraction_run_no: run.run_no,
|
||||
user_task_no: submission.user_task_no,
|
||||
submission_decision: feedback.decision,
|
||||
submission_decision: submission.decision,
|
||||
},
|
||||
};
|
||||
options.messages.value.push(userMessage);
|
||||
await options.saveLocalMessageToBackend(userMessage, query || undefined);
|
||||
|
||||
// 非阻塞系统反馈:可回看,不弹窗。
|
||||
const systemMessage: ChatMessage = {
|
||||
role: 'assistant',
|
||||
type: 'text',
|
||||
content: options.t(decisionKey, { count: feedback.fileCount }),
|
||||
local_id: options.newLocalMessageId('shipping-submission-decision'),
|
||||
local_only: true,
|
||||
payload: {
|
||||
formId: `shipping-submission-decision:${submission.operation_id || submissionId}`,
|
||||
submission_decision: feedback.decision,
|
||||
user_task_no: submission.user_task_no,
|
||||
run_no: submission.run_no,
|
||||
},
|
||||
};
|
||||
options.messages.value.push(systemMessage);
|
||||
await options.saveLocalMessageToBackend(systemMessage);
|
||||
|
||||
// 新建任务自动聚焦;追加则保持/回写当前 OT。
|
||||
options.setFocusedUserTaskNo?.(submission.user_task_no || null);
|
||||
|
||||
|
||||
@@ -68,6 +68,13 @@ export type ShippingProcessingStageNodeStatus =
|
||||
| 'blocked'
|
||||
| 'failed';
|
||||
|
||||
/** 后端 stage_nodes 单节点(BE-02 权威态;优先于前端 index 启发式)。 */
|
||||
export interface ShippingProcessingStageNode {
|
||||
stage: ShippingProcessingStage;
|
||||
absoluteIndex: number;
|
||||
status: ShippingProcessingStageNodeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一动作意图(四页面只能消费 ActionPresentation)。
|
||||
* 权威:progress_audit_contract.SHIPPING_PROCESSING_ACTION_INTENTS
|
||||
@@ -139,6 +146,10 @@ export interface ShippingProcessingProjection {
|
||||
sourceType: OrderIntakeSourceType;
|
||||
rootOrderTaskNo: string | null;
|
||||
shippingNoticeNo: string | null;
|
||||
/** 关联 Extraction Run 编号;进入订单处理工作台深链必填。 */
|
||||
runNo?: string | null;
|
||||
/** 开放 Review Case 编号(若有)。 */
|
||||
caseNo?: string | null;
|
||||
conversationId: string | null;
|
||||
submissionNo: string;
|
||||
intakeNo: string;
|
||||
@@ -146,11 +157,15 @@ export interface ShippingProcessingProjection {
|
||||
stage: ShippingProcessingStage;
|
||||
progressVersion: number;
|
||||
lastActivityAt: string;
|
||||
/** 后端 15 阶节点态;存在时 UI 优先消费,禁止页面自行推导。 */
|
||||
stageNodes?: ShippingProcessingStageNode[];
|
||||
currentGate: ProcessGateSummary | null;
|
||||
availableActions: string[];
|
||||
sourceSummary: {
|
||||
emailSubject: string | null;
|
||||
filename: string | null;
|
||||
/** 当前 OT 主 PDF;会话汇总按此字段去重。 */
|
||||
documentId?: number | null;
|
||||
documentCount: number;
|
||||
parsedDocumentCount: number;
|
||||
candidateCount: number;
|
||||
@@ -472,6 +487,7 @@ export interface ShippingTaskSummary {
|
||||
customer_resolution_method?: string | null;
|
||||
customer_name_snapshot?: string | null;
|
||||
customer_short_code_snapshot?: string | null;
|
||||
po_number?: string | null;
|
||||
current_step?: string | null;
|
||||
process_status: string;
|
||||
review_status?: string | null;
|
||||
@@ -536,6 +552,8 @@ export interface ShippingTaskSummary {
|
||||
can_handle?: boolean;
|
||||
/** 统一 ShippingProcessing status(列表轮询优先读此字段)。 */
|
||||
shipping_processing_status?: string | null;
|
||||
/** 统一 ShippingProcessing stage(任务中心紧凑进度)。 */
|
||||
shipping_processing_stage?: string | null;
|
||||
/** 统一进度版本(与 shipping_processing_status 配套)。 */
|
||||
progress_version?: number | null;
|
||||
/** 关联的真实 OT 编号(Candidate 形成后);工作台拉取统一投影用。 */
|
||||
|
||||
@@ -61,6 +61,7 @@ const reviewRun = ref({
|
||||
],
|
||||
});
|
||||
const workItem = ref<Record<string, any> | null>(null);
|
||||
const reviewProgressContext = ref<Record<string, any> | null>(null);
|
||||
|
||||
const activeCase = ref({
|
||||
case_no: 'CASE-1',
|
||||
@@ -121,7 +122,13 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
|
||||
useShippingOrderReview: () => ({
|
||||
reviewRun,
|
||||
activeCase,
|
||||
reviewProgressContext,
|
||||
workItem,
|
||||
authoritativeOrderTaskNo: computed(() => {
|
||||
const no = String(reviewProgressContext.value?.user_task_no || '').trim();
|
||||
if (!no || reviewProgressContext.value?.user_task_authoritative === false) return null;
|
||||
return no;
|
||||
}),
|
||||
versions: ref([]),
|
||||
statusMessage: ref(null),
|
||||
draftConflict: ref(null),
|
||||
@@ -180,6 +187,10 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
|
||||
requestSuggestion: vi.fn(),
|
||||
decideSuggestion: vi.fn(),
|
||||
editable: computed(() => true),
|
||||
formalEditable: computed(() => false),
|
||||
canEditFormalFields: computed(() => false),
|
||||
isFieldEditable: () => true,
|
||||
isWorkItemClosed: computed(() => false),
|
||||
showWorkflowProgress: computed(() => false),
|
||||
workflowProgressPolling: computed(() => false),
|
||||
shippingProcessingProjection: ref(null),
|
||||
@@ -488,10 +499,11 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
vi.clearAllMocks();
|
||||
resetActiveCaseFixture();
|
||||
workItem.value = null;
|
||||
reviewProgressContext.value = null;
|
||||
});
|
||||
|
||||
it('shows restored version as current and latest version only as failed attempt', async () => {
|
||||
workItem.value = {
|
||||
reviewProgressContext.value = {
|
||||
item_no: 'WFI-1',
|
||||
current_version_no: 4,
|
||||
lifecycle_status: 'reparse_failed',
|
||||
@@ -516,7 +528,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
});
|
||||
|
||||
it('does not show reparse-failure version notice for normal review', async () => {
|
||||
workItem.value = {
|
||||
reviewProgressContext.value = {
|
||||
item_no: 'WFI-1', current_version_no: 3, lifecycle_status: 'pending_review',
|
||||
};
|
||||
const wrapper = await mountView();
|
||||
@@ -634,6 +646,7 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
resetActiveCaseFixture();
|
||||
reviewProgressContext.value = null;
|
||||
vi.mocked(auditWorkspaceShippingOrderReviewVersionHistory).mockResolvedValue({
|
||||
audited: true,
|
||||
case_no: 'CASE-1',
|
||||
|
||||
@@ -1,29 +1,21 @@
|
||||
<!--
|
||||
features/chat/views/ShippingOrderReviewView.vue
|
||||
用途:建单前订单人工复核工作台(主编辑区 + 摘要侧栏 + workbenchMode 状态机)。
|
||||
用途:建单前/正式任务「订单处理工作台」(主编辑区 + 摘要侧栏 + workbenchMode 状态机)。
|
||||
依赖:路由参数、useShippingOrderReview、ReviewWorkbenchHeader/Footer、ReviewDocumentNavigation、
|
||||
ReviewWorkflowProgressPanel、ReviewProcessDetailDrawer、ReviewUnsavedSwitchDialog、
|
||||
ReviewWorkbenchModeToggle、ReviewDocumentEvidenceDrawer、ReviewVersionHistoryDrawer、
|
||||
ReviewLlmSuggestionDrawer、ReviewActionConfirmDialog、ReviewLineNoOverrideDialog、
|
||||
ReviewCustomerResolutionPanel / ReviewFieldConflictPanel / ReviewDuplicatePanel /
|
||||
ReviewAutomationStatusPanel、
|
||||
ReviewBuildEligibilitySummary、ReviewInventoryIssueList、ReviewInventoryCandidatesPanel、
|
||||
ProcessGateRecoveryCard;确认后进度回到对话侧,不重复挂载完整进度面板。
|
||||
逻辑:顶部横向 PDF 导航 + 模式切换;主编辑区始终保持订单字段/明细宽度;
|
||||
证据默认右下角浮动面板(不进网格);用户主动「固定为侧栏」才双栏;
|
||||
非宽屏将当前业务阻断(Gate/未确认客户/建单资格)置于长表格之前;
|
||||
客户已确认后缩为摘要并放入「更多状态」;
|
||||
定位图标按 highlight_quality 绿/橙/红着色;无可靠坐标用 CircleAlert(仅诊断);
|
||||
双击字段可定位 PDF;证据联动字段高亮;Alt+[ / Alt+] 切换异常字段;
|
||||
明细单元格纵向排布输入与来源/定位,窄屏靠横向滚动;
|
||||
库存模式仅异常行处理;完整检查/AI/版本历史按需抽屉并写访问审计(失败告警且不打开);
|
||||
页面仅保留单一主纵向滚动,底栏 sticky;build_eligibility 驱动建单门禁;
|
||||
确认响应读 confirm_outcome/auto_progress;刷新时由 post_confirm_auto_progress 恢复重试条;
|
||||
重识别/确认进度模式自动切换 workbenchMode;不含对话上下文渲染。
|
||||
ReviewAutomationStatusPanel、ReviewBuildEligibilitySummary、ReviewInventory*、
|
||||
ProcessGateRecoveryCard;formal_task 挂载 TaskTodoPanel(仅表单,主写按钮在 Footer)。
|
||||
逻辑:只读五域进度 + 流程详情抽屉;OT 导航按数量响应式;写操作仅底栏;
|
||||
切换 OT 未保存硬拦截;证据浮窗/侧栏不与流程详情抢位;
|
||||
页面单一主纵向滚动,底栏 sticky;build_eligibility 驱动建单门禁。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { ArrowLeft, Check, CircleX, Crosshair, Plus, RefreshCw, Undo2, Copy, Trash2 } from 'lucide-vue-next';
|
||||
import { Check, CircleX, Crosshair, Plus, RefreshCw, Undo2, Copy, Trash2 } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
@@ -38,6 +30,7 @@ import {
|
||||
autoProgressWorkspaceShippingTask,
|
||||
attemptWorkspaceShippingOrderReviewFieldLocate,
|
||||
getWorkspaceShippingOrderReviewEvidenceItem,
|
||||
getWorkspaceShippingTask,
|
||||
viewWorkspaceShippingOrderReviewHighlightDiagnostic,
|
||||
} from '../api/shipping.api';
|
||||
import ReviewActionConfirmDialog, {
|
||||
@@ -55,27 +48,36 @@ import ReviewFulfillmentSummaryCard from '../components/shipping-review/ReviewFu
|
||||
import ReviewCloseFulfillmentDialog from '../components/shipping-review/ReviewCloseFulfillmentDialog.vue';
|
||||
import ReviewAuditTrailDrawer from '../components/shipping-review/ReviewAuditTrailDrawer.vue';
|
||||
import ReviewAutomationStatusPanel from '../components/shipping-review/ReviewAutomationStatusPanel.vue';
|
||||
import ReviewDocumentNavigation from '../components/shipping-review/ReviewDocumentNavigation.vue';
|
||||
import ReviewDocumentNavigation, {
|
||||
type ReviewDocumentNavMode,
|
||||
} from '../components/shipping-review/ReviewDocumentNavigation.vue';
|
||||
import ReviewWorkflowProgressPanel from '../components/shipping-review/ReviewWorkflowProgressPanel.vue';
|
||||
import ReviewInventoryCandidatesPanel from '../components/shipping-review/ReviewInventoryCandidatesPanel.vue';
|
||||
import ReviewInventoryIssueList from '../components/shipping-review/ReviewInventoryIssueList.vue';
|
||||
import ReviewWorkbenchFooter from '../components/shipping-review/ReviewWorkbenchFooter.vue';
|
||||
import ReviewWorkbenchHeader from '../components/shipping-review/ReviewWorkbenchHeader.vue';
|
||||
import ReviewWorkbenchModeToggle from '../components/shipping-review/ReviewWorkbenchModeToggle.vue';
|
||||
import ReviewUnsavedSwitchDialog from '../components/shipping-review/ReviewUnsavedSwitchDialog.vue';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import TaskTodoPanel from '@/features/workspace/shipping-task-center/TaskTodoPanel.vue';
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
|
||||
import ReviewLineNoOverrideDialog, {
|
||||
type LineNoOverridePayload,
|
||||
} from '../components/shipping-review/ReviewLineNoOverrideDialog.vue';
|
||||
import ReviewLlmSuggestionDrawer from '../components/shipping-review/ReviewLlmSuggestionDrawer.vue';
|
||||
import ReviewVersionHistoryDrawer from '../components/shipping-review/ReviewVersionHistoryDrawer.vue';
|
||||
import ReviewProcessDetailDrawer from '@/features/shipping-progress/components/ReviewProcessDetailDrawer.vue';
|
||||
import { useProcessingActionPresentation } from '@/features/shipping-progress/composables/useProcessingActionPresentation';
|
||||
import { parseOrderReviewConfirmResponse } from '../shipping-review/parseOrderReviewConfirmResponse';
|
||||
import { REVIEW_BUILD_ELIGIBILITY_BLOCKED, useShippingOrderReview } from '../shipping-review/useShippingOrderReview';
|
||||
import type { ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
import type {
|
||||
ReviewWorkbenchMode,
|
||||
ReviewWorkbenchPanelState,
|
||||
ShippingOrderReviewDraftFieldMeta,
|
||||
ShippingOrderReviewEvidence,
|
||||
ShippingOrderReviewValueSource,
|
||||
ShippingTaskDetail,
|
||||
} from '../types/shipping.api.types';
|
||||
|
||||
/** 证据模式才加载,避免标准复核首屏拉入 pdfjs 预览组件。 */
|
||||
@@ -93,6 +95,7 @@ const {
|
||||
reviewProgressContext,
|
||||
shippingProcessingProjection,
|
||||
authoritativeOrderTaskNo,
|
||||
refreshShippingProcessing,
|
||||
workflowProgressPolling,
|
||||
versions,
|
||||
statusMessage,
|
||||
@@ -170,10 +173,12 @@ const shippingProcessingSummaryLabel = computed(() => {
|
||||
return [status, stage].filter(Boolean).join(' · ');
|
||||
});
|
||||
|
||||
/** 复核页始终可见的统一进度条:有投影或权威 OT 号即展示。 */
|
||||
/** 复核页始终可见的统一进度条:有投影、权威 OT 或确认成功即展示。 */
|
||||
const showUnifiedProcessingStrip = computed(() => (
|
||||
Boolean(shippingProcessingProjection.value)
|
||||
|| Boolean(shippingProcessingSummaryLabel.value)
|
||||
|| Boolean(authoritativeOrderTaskNo.value)
|
||||
|| Boolean(confirmSuccess.value)
|
||||
));
|
||||
|
||||
const runNo = computed(() => String(route.query.run_no || route.params.runNo || ''));
|
||||
@@ -201,6 +206,10 @@ const panelState = ref<ReviewWorkbenchPanelState>({
|
||||
scrollRestoreKey: null,
|
||||
});
|
||||
const auditTrailOpen = ref(false);
|
||||
const processDetailOpen = ref(false);
|
||||
const unsavedSwitchOpen = ref(false);
|
||||
const pendingSwitchCaseNo = ref<string | null>(null);
|
||||
const otNavMode = ref<ReviewDocumentNavMode>('hidden');
|
||||
const closeFulfillmentOpen = ref(false);
|
||||
const closeFulfillmentLineKeys = ref<string[]>([]);
|
||||
|
||||
@@ -872,6 +881,50 @@ const canEnterInventory = computed(() => (
|
||||
|| Number(activeCase.value?.line_fulfillment?.open_count || 0) > 0
|
||||
));
|
||||
const availableActions = computed(() => activeCase.value?.available_actions || []);
|
||||
|
||||
/** 底栏流程写操作:与原进度条 ActionBar 同源,surface=review。 */
|
||||
const flowProjectionRef = computed(() => shippingProcessingProjection.value);
|
||||
const flowPresentation = useProcessingActionPresentation(flowProjectionRef, { surface: 'review' });
|
||||
|
||||
/** 系统自动推进中:底栏隐藏无效主写按钮。 */
|
||||
const isProcessingAutomating = computed(() => {
|
||||
const status = String(shippingProcessingProjection.value?.status || '').trim().toLowerCase();
|
||||
return ['processing', 'automating', 'queued'].includes(status)
|
||||
&& !shippingProcessingProjection.value?.currentGate?.nextActionCode;
|
||||
});
|
||||
|
||||
/** OT 导航侧栏模式(≥5)时主区并排。 */
|
||||
const otNavUsesSidebar = computed(() => (
|
||||
otNavMode.value === 'sidebar' || otNavMode.value === 'sidebar_search'
|
||||
));
|
||||
|
||||
/**
|
||||
* 导航项:一 PDF 一 Case;当前 Case 附带 PO/客户/阶段(摘要列表无跨 Case 草稿字段)。
|
||||
*/
|
||||
const documentNavItems = computed(() => {
|
||||
const items = reviewRun.value?.items || [];
|
||||
const header = activeCase.value?.draft?.header_values as Record<string, unknown> | undefined;
|
||||
const activeNo = activeCase.value?.case_no;
|
||||
const stage = shippingProcessingProjection.value?.stage;
|
||||
const stageKey = stage ? shippingProcessingStageKey(stage) : '';
|
||||
const stageLabel = stageKey && te(stageKey) ? t(stageKey) : null;
|
||||
return items.map((item) => {
|
||||
const isActive = item.case_no === activeNo;
|
||||
return {
|
||||
...item,
|
||||
po_number: isActive ? (String(header?.po_number || '').trim() || null) : null,
|
||||
customer_name: isActive ? (String(header?.customer_name || '').trim() || null) : null,
|
||||
stage_label: isActive ? stageLabel : null,
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/** 流程详情标题用 PO。 */
|
||||
const processDetailPoNumber = computed(() => {
|
||||
const header = activeCase.value?.draft?.header_values as Record<string, unknown> | undefined;
|
||||
return String(header?.po_number || shippingProcessingProjection.value?.sourceSummary?.poNumber || '').trim() || null;
|
||||
});
|
||||
|
||||
const isReparsePrimary = computed(() => workbenchMode.value === 'reparse' && reparseProgressActive.value);
|
||||
/** 重识别任务存在时常驻展示轨道;轮询结束后保留最终状态,避免用户失去进度上下文。 */
|
||||
const hasReparseProgressContext = computed(() => Boolean(
|
||||
@@ -903,6 +956,52 @@ const hasCreatedShippingTask = computed(() => Boolean(
|
||||
|| String(reviewProgressContext.value?.current_task_no || '').trim(),
|
||||
));
|
||||
|
||||
/** 正式 Notice 编号(SN),供履约写 API / TaskTodoPanel。 */
|
||||
const confirmedNoticeTaskNo = computed(() => String(
|
||||
activeCase.value?.confirmed_task_no
|
||||
|| reviewProgressContext.value?.current_task_no
|
||||
|| '',
|
||||
).trim());
|
||||
|
||||
/** 确认后履约待办详情;任务中心不再挂工作台,由本工作台承接。 */
|
||||
const formalTaskDetail = ref<ShippingTaskDetail | null>(null);
|
||||
const formalTaskDetailLoading = ref(false);
|
||||
const formalTodoPanelRef = ref<{
|
||||
invokeActionByCode: (actionId: string) => Promise<void>;
|
||||
openCustomerDialog: () => Promise<void>;
|
||||
} | null>(null);
|
||||
|
||||
/**
|
||||
* 拉取确认后的 Notice 履约详情,供 TaskTodoPanel 使用。
|
||||
*/
|
||||
async function loadFormalTaskDetail() {
|
||||
const taskNo = confirmedNoticeTaskNo.value;
|
||||
if (!taskNo) {
|
||||
formalTaskDetail.value = null;
|
||||
return;
|
||||
}
|
||||
formalTaskDetailLoading.value = true;
|
||||
try {
|
||||
formalTaskDetail.value = await getWorkspaceShippingTask(taskNo);
|
||||
} catch {
|
||||
formalTaskDetail.value = null;
|
||||
} finally {
|
||||
formalTaskDetailLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
[confirmedNoticeTaskNo, workbenchMode, hasCreatedShippingTask],
|
||||
([taskNo, mode, created]) => {
|
||||
if (taskNo && created && (mode === 'formal_task' || mode === 'confirm_progress')) {
|
||||
void loadFormalTaskDetail();
|
||||
return;
|
||||
}
|
||||
if (!taskNo) formalTaskDetail.value = null;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/** Schema 字段显示名同时按 field_code / field_id 建索引,避免阻断只显示内部标识。 */
|
||||
const reviewFieldLabels = computed(() => Object.fromEntries(
|
||||
(activeCase.value?.schema.fields || []).flatMap((field) => [
|
||||
@@ -1196,7 +1295,7 @@ const autoProgressStatusLabel = (status: string) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 确认后主路径:返回对话并以 order_task_no 聚焦 OT 卡;Notice 编号仅用于文案辅助。
|
||||
* 确认后主路径留在复核页:统一动作栏驱动重试/刷新/任务台;返回对话仅作次要链接。
|
||||
*/
|
||||
const openTaskProgress = (orderTaskNo: string, noticeNo?: string) => {
|
||||
const focusNo = String(orderTaskNo || '').trim();
|
||||
@@ -1250,6 +1349,60 @@ const retryAutoProgressAfterConfirm = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 统一动作栏点击:优先复用已有写路径;履约业务动作委托 TaskTodoPanel。
|
||||
*/
|
||||
const onUnifiedProcessingAction = (item: ActionPresentationItem) => {
|
||||
const intent = item.intent;
|
||||
if (intent === 'retry') {
|
||||
void retryAutoProgressAfterConfirm();
|
||||
return;
|
||||
}
|
||||
if (intent === 'refresh') {
|
||||
void refreshShippingProcessing();
|
||||
void loadFormalTaskDetail();
|
||||
return;
|
||||
}
|
||||
if (intent === 'download_excel' && confirmedNoticeTaskNo.value) {
|
||||
void (async () => {
|
||||
try {
|
||||
await downloadWorkspaceShippingExcelFile(confirmedNoticeTaskNo.value);
|
||||
await loadFormalTaskDetail();
|
||||
} catch (error: unknown) {
|
||||
msg.warning(error instanceof Error ? error.message : t('errors.generic'));
|
||||
}
|
||||
})();
|
||||
return;
|
||||
}
|
||||
if (
|
||||
intent === 'open_manual_upload'
|
||||
|| intent === 'open_inventory_source_review'
|
||||
|| intent === 'open_inventory_match_review'
|
||||
|| intent === 'open_shortage_review'
|
||||
|| intent === 'upload_inventory_file'
|
||||
|| intent === 'regenerate_excel'
|
||||
) {
|
||||
// [UI-01] 履约动作统一由 ActionBar 触发,表单/弹窗仍由 TaskTodoPanel 承接。
|
||||
if (!formalTaskDetail.value && confirmedNoticeTaskNo.value) {
|
||||
void loadFormalTaskDetail().then(() => {
|
||||
void formalTodoPanelRef.value?.invokeActionByCode(item.actionCode);
|
||||
});
|
||||
} else {
|
||||
void formalTodoPanelRef.value?.invokeActionByCode(item.actionCode);
|
||||
}
|
||||
void nextTick(() => {
|
||||
document
|
||||
.querySelector('[data-testid="review-formal-task-todo-panel"]')
|
||||
?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (intent === 'open_order_review' || intent === 'edit_formal_task') {
|
||||
// 已在订单处理工作台,无需跳转。
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const reportSave = async (action: () => Promise<unknown> | null) => {
|
||||
try { await action(); }
|
||||
catch (error) {
|
||||
@@ -1481,12 +1634,55 @@ const selectReplacement = (event: Event) => {
|
||||
(event.target as HTMLInputElement).value = '';
|
||||
};
|
||||
|
||||
/**
|
||||
* 实际切换 Case(无未保存拦截)。
|
||||
*/
|
||||
const select = async (caseNo: string) => {
|
||||
focusedEvidenceRef.value = null;
|
||||
await selectCase(caseNo);
|
||||
await router.replace({ query: { ...route.query, case: caseNo } });
|
||||
};
|
||||
|
||||
/** 未保存本地修改数(与底栏提示、切换拦截同源)。 */
|
||||
const unsavedEditCount = computed(() => (pendingLineNoEdit.value ? 1 : 0));
|
||||
const hasUnsavedEdits = computed(() => unsavedEditCount.value > 0);
|
||||
|
||||
/**
|
||||
* 请求切换 OT:有未保存修改时硬拦截。
|
||||
*/
|
||||
const requestSelectCase = async (caseNo: string) => {
|
||||
if (caseNo === activeCase.value?.case_no) return;
|
||||
if (hasUnsavedEdits.value) {
|
||||
pendingSwitchCaseNo.value = caseNo;
|
||||
unsavedSwitchOpen.value = true;
|
||||
return;
|
||||
}
|
||||
await select(caseNo);
|
||||
};
|
||||
|
||||
/**
|
||||
* 放弃本地未保存修改并切换。
|
||||
*/
|
||||
const discardAndSwitchCase = async () => {
|
||||
const target = pendingSwitchCaseNo.value;
|
||||
pendingLineNoEdit.value = null;
|
||||
unsavedSwitchOpen.value = false;
|
||||
pendingSwitchCaseNo.value = null;
|
||||
if (target) await select(target);
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存校验后切换(丢弃无法单独落库的行号 pending,再走 validate)。
|
||||
*/
|
||||
const saveAndSwitchCase = async () => {
|
||||
const target = pendingSwitchCaseNo.value;
|
||||
pendingLineNoEdit.value = null;
|
||||
await reportSave(() => validate());
|
||||
unsavedSwitchOpen.value = false;
|
||||
pendingSwitchCaseNo.value = null;
|
||||
if (target) await select(target);
|
||||
};
|
||||
|
||||
/**
|
||||
* 版本历史面板选择:历史版本只读打开,当前版本正常编辑。
|
||||
*/
|
||||
@@ -1768,7 +1964,7 @@ watch(
|
||||
<button
|
||||
v-if="confirmSuccess.progressFailed"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded border border-amber-500 px-2.5 py-1.5 text-xs font-medium hover:bg-amber-100 disabled:opacity-50 dark:hover:bg-amber-900"
|
||||
class="inline-flex items-center gap-1 rounded border border-amber-500 bg-amber-100/80 px-2.5 py-1.5 text-xs font-medium hover:bg-amber-100 disabled:opacity-50 dark:bg-amber-900/40 dark:hover:bg-amber-900"
|
||||
:disabled="progressRetrying"
|
||||
data-testid="retry-auto-progress-after-confirm"
|
||||
@click="retryAutoProgressAfterConfirm"
|
||||
@@ -1776,21 +1972,19 @@ watch(
|
||||
<RefreshCw class="h-3.5 w-3.5" />{{ t('chat.shippingOrderReview.autoProgress.retry') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="confirmSuccess.orderTaskNo"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded border px-2.5 py-1.5 text-xs font-medium"
|
||||
:class="confirmSuccess.progressFailed
|
||||
? 'border-amber-500 hover:bg-amber-100 dark:hover:bg-amber-900'
|
||||
: 'border-emerald-400 hover:bg-emerald-100 dark:hover:bg-emerald-900'"
|
||||
data-testid="open-confirmed-task-progress"
|
||||
class="text-xs font-medium text-emerald-800 underline hover:text-emerald-950 dark:text-emerald-200 dark:hover:text-emerald-50"
|
||||
data-testid="open-confirmed-task-progress-link"
|
||||
@click="openTaskProgress(confirmSuccess.orderTaskNo, confirmSuccess.taskNo)"
|
||||
>
|
||||
<ArrowLeft class="h-3.5 w-3.5" />{{ t('chat.shippingOrderReview.autoProgress.returnToChat') }}
|
||||
{{ t('chat.shippingOrderReview.autoProgress.returnToChat') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 确认后进度主路径回到对话「本次处理中」;复核页仅保留结果摘要与返回入口。 -->
|
||||
<!-- 确认后统一进度主路径留在本页;返回对话仅作次要聚焦链接。 -->
|
||||
|
||||
<div v-if="loading" class="p-8 text-sm text-slate-600 dark:text-slate-300">{{ t('chat.shippingOrderReview.loading') }}</div>
|
||||
<div
|
||||
@@ -1819,12 +2013,14 @@ watch(
|
||||
>
|
||||
<ReviewWorkflowProgressPanel
|
||||
v-if="showUnifiedProcessingStrip"
|
||||
:item="null"
|
||||
:item="reviewProgressContext"
|
||||
:task-no="authoritativeOrderTaskNo"
|
||||
:polling="workflowProgressPolling"
|
||||
:processing-projection="shippingProcessingProjection"
|
||||
class="mb-1"
|
||||
data-testid="review-shipping-processing-strip"
|
||||
@open-process-details="processDetailOpen = true"
|
||||
@refresh="() => { void refreshShippingProcessing(); }"
|
||||
/>
|
||||
<p
|
||||
v-if="workbenchMode === 'formal_task'"
|
||||
@@ -1838,14 +2034,23 @@ watch(
|
||||
class="ml-1.5 text-muted"
|
||||
>{{ authoritativeOrderTaskNo }}</span>
|
||||
</p>
|
||||
<template v-if="showWorkbenchGrid">
|
||||
<ReviewDocumentNavigation
|
||||
:items="reviewRun?.items || []"
|
||||
:active-case-no="activeCase?.case_no"
|
||||
:nav-aria-label="t('chat.shippingOrderReview.documentNavigation')"
|
||||
@select="select"
|
||||
<section
|
||||
v-if="hasCreatedShippingTask && (workbenchMode === 'formal_task' || workbenchMode === 'confirm_progress')"
|
||||
class="rounded-xl border border-default bg-surface p-3"
|
||||
data-testid="review-formal-task-todo-panel"
|
||||
>
|
||||
<div v-if="formalTaskDetailLoading" class="py-4 text-center text-xs text-muted">
|
||||
{{ t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<TaskTodoPanel
|
||||
v-else-if="formalTaskDetail"
|
||||
ref="formalTodoPanelRef"
|
||||
:detail="formalTaskDetail"
|
||||
:can-handle="!isReadOnly"
|
||||
:hide-primary-actions="true"
|
||||
@refreshed="() => { void loadFormalTaskDetail(); void refreshShippingProcessing(); }"
|
||||
/>
|
||||
</template>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="hasReparseProgressContext"
|
||||
@@ -1983,6 +2188,22 @@ watch(
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="showWorkbenchGrid"
|
||||
:class="otNavUsesSidebar ? 'lg:flex lg:items-start lg:gap-4' : 'contents'"
|
||||
data-testid="review-workbench-ot-shell"
|
||||
>
|
||||
<ReviewDocumentNavigation
|
||||
:items="documentNavItems"
|
||||
:active-case-no="activeCase?.case_no"
|
||||
:nav-aria-label="t('chat.shippingOrderReview.documentNavigation')"
|
||||
@mode-change="(mode) => { otNavMode = mode; }"
|
||||
@select="(caseNo) => { void requestSelectCase(caseNo); }"
|
||||
/>
|
||||
<div
|
||||
class="min-w-0 flex-1 space-y-4"
|
||||
:class="otNavUsesSidebar ? '' : 'contents'"
|
||||
>
|
||||
<template v-if="showWorkbenchGrid">
|
||||
<ReviewWorkbenchModeToggle
|
||||
v-if="workbenchMode !== 'standard' && workbenchMode !== 'reparse'"
|
||||
@@ -2483,6 +2704,8 @@ watch(
|
||||
</aside>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -2571,12 +2794,35 @@ watch(
|
||||
:saving="saving"
|
||||
:is-read-only="isReadOnly"
|
||||
:has-draft="Boolean(activeCase?.draft)"
|
||||
:unsaved-count="unsavedEditCount"
|
||||
:flow-presentation="flowPresentation"
|
||||
:automating="isProcessingAutomating"
|
||||
@mark-non-order="openActionDialog('non_order')"
|
||||
@mark-quality-issue="openActionDialog('quality_issue')"
|
||||
@reparse="openActionDialog('reparse')"
|
||||
@upload-replacement="selectReplacement"
|
||||
@validate="reportSave(() => validate())"
|
||||
@confirm="openActionDialog('confirm')"
|
||||
@flow-action="onUnifiedProcessingAction"
|
||||
/>
|
||||
|
||||
<ReviewProcessDetailDrawer
|
||||
:open="processDetailOpen"
|
||||
:projection="shippingProcessingProjection"
|
||||
:po-number="processDetailPoNumber"
|
||||
:order-task-no="authoritativeOrderTaskNo"
|
||||
:audit-available="Boolean(activeCase?.case_no)"
|
||||
@close="processDetailOpen = false"
|
||||
@open-audit="() => { processDetailOpen = false; auditTrailOpen = true; }"
|
||||
/>
|
||||
|
||||
<ReviewUnsavedSwitchDialog
|
||||
:open="unsavedSwitchOpen"
|
||||
:unsaved-count="unsavedEditCount"
|
||||
:saving="saving"
|
||||
@cancel="() => { unsavedSwitchOpen = false; pendingSwitchCaseNo = null; }"
|
||||
@discard="() => { void discardAndSwitchCase(); }"
|
||||
@save-and-switch="() => { void saveAndSwitchCase(); }"
|
||||
/>
|
||||
|
||||
<ReviewActionConfirmDialog
|
||||
|
||||
Reference in new issue
Block a user