feat(shipping-notice): 落地 XFA 统一视觉拆分确认门禁与处理投影收敛

闭合拆分预览令牌单次消费、样本 checksum 绑定与确认审计;正式提取改为 bindings-only。
同步统一标注工作台交互,并补齐进度投影/任务中心与迁移文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-06 10:21:25 +08:00
1 parent d2b3d74def
commit 84a881b554
195 files changed
+20269 -3463

No files matched your search

@@ -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']);
});
});
@@ -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>
@@ -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>
@@ -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');
});
@@ -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>