feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程

清理废弃的shipping xfa ocr automark相关代码和job配置
新增收料报表管理的前端页面、路由和侧边栏入口
新增后端收料报表配置接口、数据库模型和RPA脚本
优化发货通知流程的重试策略,将shipping相关job默认不自动重试
移除废弃的库存源确认相关逻辑,更新流程门禁规则
重构订单模板的值适配器模块,新增坐标OCR值适配器
清理前端shipping菜单和action的废弃选项
更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
hugo committed 2026-08-20 20:23:10 +08:00
1 parent 260465b72d
commit 1b6483a4ea
466 files changed
+32115 -33796

No files matched your search

@@ -1,6 +1,6 @@
<!--
features/chat/components/shipping-review/ReviewActionConfirmDialog.vue
用途:复核页破坏性/不可逆操作的二次确认弹窗(确认建单、重识别、非订单、质量异常、替代 PDF)。
用途:复核页破坏性/不可逆操作的二次确认弹窗(确认建单、重识别、非订单、质量异常)。
依赖:vue-i18n、dialog-overlay / dialog-panel 设计系统样式。
逻辑:ShippingOrderReviewView 以 v-model 控制显隐;质量异常须选原因码,other 时备注必填;
非订单/重识别将说明写入 comment,并附带稳定 reasonCode。
@@ -9,7 +9,7 @@
import { computed, onBeforeUnmount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
export type ReviewConfirmAction = 'confirm' | 'reparse' | 'non_order' | 'replace' | 'quality_issue';
export type ReviewConfirmAction = 'confirm' | 'reparse' | 'non_order' | 'quality_issue';
/** 确认弹窗提交载荷:稳定原因码 + 自由说明,供后端审计复盘。 */
export type ReviewConfirmPayload = {
@@ -1,87 +0,0 @@
<!--
features/chat/components/shipping-review/ReviewConversationRetryDrawer.vue
用途:按需展示本次对话级自动推进重试的逐项结果,不占用订单复核主内容。
依赖:vue-i18n、对话级重试 API 返回的摘要和对象结果。
逻辑:仅用户主动从顶栏打开;按结果分类展示,关闭不改变任务真实状态。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { RefreshCw } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
type RetryItem = {
object_type: string;
object_ref: string;
action?: string | null;
outcome: string;
reason_code?: string | null;
};
const props = defineProps<{
open: boolean;
result: {
summary: { total: number; retried: number; skipped: number; failed: number; blocked?: number };
items: RetryItem[];
} | null;
}>();
const emit = defineEmits<{ close: [] }>();
const { t, te } = useI18n();
const items = computed(() => props.result?.items || []);
function itemLabel(item: RetryItem): string {
const code = String(item.reason_code || '').trim();
const key = `chat.shippingOrderReview.conversationRetry.reason.${code}`;
return code && te(key) ? t(key) : outcomeLabel(item.outcome);
}
function outcomeLabel(outcome: string): string {
const key = `chat.shippingOrderReview.conversationRetry.outcome.${String(outcome || '').trim()}`;
return te(key) ? t(key) : t('chat.shippingOrderReview.conversationRetry.outcome.unknown');
}
</script>
<template>
<div
v-if="open && result"
class="fixed inset-0 z-40 flex justify-end bg-slate-900/10"
data-testid="review-conversation-retry-drawer"
@click.self="emit('close')"
>
<aside class="flex h-full w-full max-w-[360px] flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-slate-800 dark:bg-slate-900">
<header class="flex items-center justify-between gap-3 border-b border-slate-200 px-3 py-2.5 dark:border-slate-800">
<div class="flex min-w-0 items-center gap-2">
<span class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/60 dark:text-amber-200">
<RefreshCw class="h-3.5 w-3.5" />
</span>
<div class="min-w-0">
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.conversationRetry.title') }}</h2>
<p class="truncate text-[11px] text-muted">{{ t('chat.shippingOrderReview.conversationRetry.subtitle') }}</p>
</div>
</div>
<button type="button" class="rounded border border-slate-300 px-2 py-1 text-xs hover:bg-slate-50 dark:border-slate-600 dark:hover:bg-slate-800" data-testid="review-conversation-retry-drawer-close" @click="emit('close')">
{{ t('chat.shippingOrderReview.workbench.close') }}
</button>
</header>
<div class="flex flex-wrap gap-1.5 border-b border-slate-200 px-3 py-2 dark:border-slate-800">
<p class="rounded-full bg-emerald-50 px-2 py-1 text-[11px] text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300" data-testid="review-conversation-retry-retried">{{ t('chat.shippingOrderReview.conversationRetry.retried') }} <strong>{{ result.summary.retried }}</strong></p>
<p class="rounded-full bg-slate-100 px-2 py-1 text-[11px] text-slate-600 dark:bg-slate-800 dark:text-slate-300" data-testid="review-conversation-retry-skipped">{{ t('chat.shippingOrderReview.conversationRetry.skipped') }} <strong>{{ result.summary.skipped }}</strong></p>
<p class="rounded-full bg-rose-50 px-2 py-1 text-[11px] text-rose-700 dark:bg-rose-950/40 dark:text-rose-300" data-testid="review-conversation-retry-failed">{{ t('chat.shippingOrderReview.conversationRetry.failed') }} <strong>{{ result.summary.failed }}</strong></p>
<p class="rounded-full bg-violet-50 px-2 py-1 text-[11px] text-violet-700 dark:bg-violet-950/40 dark:text-violet-300" data-testid="review-conversation-retry-blocked">{{ t('chat.shippingOrderReview.conversationRetry.blocked') }} <strong>{{ result.summary.blocked || 0 }}</strong></p>
</div>
<ul class="min-h-0 flex-1 divide-y divide-slate-100 overflow-y-auto dark:divide-slate-800" data-testid="review-conversation-retry-item-list">
<li v-for="item in items" :key="`${item.object_type}:${item.object_ref}`" class="px-3 py-2.5 text-xs">
<div class="flex items-center justify-between gap-2">
<p class="min-w-0 truncate font-medium text-slate-800 dark:text-slate-100">{{ item.object_ref }}</p>
<span
class="shrink-0 rounded-full px-1.5 py-0.5 text-[10px]"
:class="item.outcome === 'queued' ? 'bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300' : item.outcome === 'needs_human' ? 'bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300' : 'bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-300'"
>{{ outcomeLabel(item.outcome) }}</span>
</div>
<p class="mt-0.5 text-[11px] text-muted">{{ itemLabel(item) }}</p>
</li>
</ul>
</aside>
</div>
</template>
@@ -18,6 +18,13 @@ const i18n = createI18n({
workspace: {
shippingNotice: {
processGate: {
actionCodes: {
retry_inventory_preparation: '重新获取库存',
},
inventoryActions: {
retryInventoryMatching: '重新库存匹配',
retryInventoryPreparation: '重新获取库存',
},
reasons: {
inventory_shortage_review_required: '存在库存缺口,需要人工处理',
},
@@ -171,7 +178,7 @@ describe('ReviewCurrentProcessingCard', () => {
expect(nextStep).not.toContain('inventory_shortage_review_required');
});
it('renders server-provided recovery actions without duplicating the primary action', async () => {
it('hides internal inventory recovery targets while retaining the stable primary action', async () => {
const wrapper = mount(ReviewCurrentProcessingCard, {
props: {
stageCode: 'inventory_matching',
@@ -185,7 +192,28 @@ describe('ReviewCurrentProcessingCard', () => {
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="review-current-task-recovery-retry_inventory_from_preparation"]').exists()).toBe(true);
expect(wrapper.findAll('button').length).toBe(2);
expect(wrapper.find('[data-testid="review-current-task-recovery-retry_inventory_from_preparation"]').exists()).toBe(false);
expect(wrapper.findAll('button').length).toBe(1);
});
it('emits rematch and RPA refresh as distinct actions for a shortage with an active inventory file', async () => {
const wrapper = mount(ReviewCurrentProcessingCard, {
props: {
stageCode: 'fulfillment_prep',
userStatus: 'waiting_human',
primaryAction: { code: 'retry_inventory_matching' },
recoveryActions: [{ code: 'retry_inventory_preparation' }],
},
global: { plugins: [i18n] },
});
await wrapper.get('[data-testid="review-current-task-primary-action"]').trigger('click');
await wrapper.get('[data-testid="review-current-task-recovery-retry_inventory_preparation"]').trigger('click');
// 两个稳定 action 码分别进入 Gate API:重匹配不可误触 RPA,重新获取库存才会触发 RPA。
expect(wrapper.emitted('action')).toEqual([
['retry_inventory_matching', {}],
['retry_inventory_preparation', {}],
]);
});
});
@@ -8,7 +8,7 @@
-->
<script setup lang="ts">
import { computed } from 'vue';
import { RefreshCw, Crosshair } from 'lucide-vue-next';
import { Bot, RefreshCw, Crosshair } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import type {
ShippingProcessingBlockingReason,
@@ -17,6 +17,7 @@ import type {
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
import { resolveGateReasonLabel } from '@/features/shipping-progress/gateReasonLabel';
import { lookupWorkbenchAction, shouldRenderWorkbenchAction } from '@/features/shipping-progress/workbenchActionRegistry';
import { inventoryActionLabelKey, isInternalInventoryAction } from '@/features/shipping-progress/actionPresentation';
const props = defineProps<{
stageCode?: string | null;
@@ -51,8 +52,6 @@ const props = defineProps<{
showAdminDiagnosis?: boolean;
retrying?: boolean;
locating?: boolean;
/** 题7A:自动次数已耗尽但允许人工继续的源;不为空时按钮语义提示「人工继续」+ tooltip 列名。 */
retryExhaustedSources?: string[] | null;
/** 仅 UI 展示的 running 文案(如 inventory_preparation 正在跑时主卡按钮 loading 附加信息)。 */
automation?: {
status?: string | null;
@@ -231,6 +230,7 @@ const showBusinessAction = computed(() => {
if (props.userStatus === 'running') return false;
if (props.retryable) return true;
const code = String(props.primaryAction?.code || '').trim();
if (isInternalInventoryAction(code)) return false;
if (!code) return false;
if (isNonTaskCapabilityAction(code)) return false;
if (isHiddenWorkbenchNavigationAction(code)) return false;
@@ -240,12 +240,10 @@ const showBusinessAction = computed(() => {
});
const businessActionLabel = computed(() => {
if (props.retryable) {
if ((props.retryExhaustedSources || []).length > 0) {
return t('chat.shippingOrderReview.currentTask.actionRetryWithExhausted');
}
return t('chat.shippingOrderReview.currentTask.actionRetry');
}
const code = String(props.primaryAction?.code || '').trim();
const inventoryKey = inventoryActionLabelKey(code);
if (inventoryKey && te(inventoryKey)) return t(inventoryKey);
if (props.retryable) return t('chat.shippingOrderReview.currentTask.actionRetry');
const pa = props.primaryAction;
if (!pa) return '';
if (isNonTaskCapabilityAction(String(pa.code || ''))) return '';
@@ -268,14 +266,7 @@ const businessActionLabel = computed(() => {
return '';
});
/** 题7A:按钮 tooltip(exhausted_sources 列表与文案)。 */
const businessActionTitle = computed(() => {
const exhausted = Array.isArray(props.retryExhaustedSources) ? props.retryExhaustedSources.filter(Boolean) : [];
if (exhausted.length > 0) {
return t('chat.shippingOrderReview.currentTask.actionRetryExhaustedTooltip', {
sources: exhausted.join(', '),
});
}
const retryingFlag = Boolean(props.retrying);
if (retryingFlag) {
return t('chat.shippingOrderReview.currentTask.actionRetryRunningTooltip');
@@ -284,9 +275,10 @@ const businessActionTitle = computed(() => {
});
const actionIsRetry = computed(() => Boolean(props.retryable) || String(props.primaryAction?.code || '') === 'retry');
const actionIsInventoryRpa = computed(() => String(props.primaryAction?.code || '').trim() === 'retry_inventory_preparation');
const recoveryActions = computed(() => (props.recoveryActions || []).filter((action) => {
const code = String(action.code || '').trim();
if (!code || isNonTaskCapabilityAction(code)) return false;
if (!code || isNonTaskCapabilityAction(code) || isInternalInventoryAction(code)) return false;
if (code === String(props.primaryAction?.code || '').trim()) return false;
const key = String(
action.i18nKey
@@ -297,6 +289,8 @@ const recoveryActions = computed(() => (props.recoveryActions || []).filter((act
}));
function recoveryActionLabel(action: (typeof recoveryActions.value)[number]): string {
const inventoryKey = inventoryActionLabelKey(action.code);
if (inventoryKey && te(inventoryKey)) return t(inventoryKey);
const key = String(
action.i18nKey
|| action.label_key
@@ -445,8 +439,9 @@ type ReviewCurrentUserStatus =
:title="businessActionTitle"
@click="handleBusinessActionClick"
>
<Bot v-if="actionIsInventoryRpa" class="h-3.5 w-3.5" />
<RefreshCw
v-if="actionIsRetry"
v-else-if="actionIsRetry"
class="h-3.5 w-3.5"
:class="{ 'animate-spin': Boolean(retrying) }"
/>
@@ -246,6 +246,21 @@ describe('ReviewDocumentEvidenceDrawer', () => {
expect(wrapper.find('[data-testid="review-evidence-no-bbox"]').text()).toContain('10 EA');
});
it('renders email evidence through the safe HTML preview URL', () => {
const wrapper = mountDrawer({
emailPreview: {
document_id: 9,
filename: 'source.eml',
text: 'fallback text',
render_kind: 'safe_html',
preview_url: '/email-preview?token=one-shot',
},
});
expect(wrapper.find('[data-testid="review-email-evidence-html"]').attributes('src'))
.toBe('/email-preview?token=one-shot');
expect(wrapper.find('[data-testid="review-email-evidence-preview"]').exists()).toBe(false);
});
it('does not render when closed', () => {
const wrapper = mountDrawer({ open: false });
expect(wrapper.find('[data-testid="review-document-evidence-drawer"]').exists()).toBe(false);
@@ -44,7 +44,7 @@ const props = defineProps<{
docked: boolean;
floatSide: 'right' | 'left';
src: string;
emailPreview?: { document_id: number; filename: string; text: string } | null;
emailPreview?: { document_id: number; filename: string; text: string; render_kind: 'safe_html' | 'text'; preview_url?: string } | null;
evidence: ShippingOrderReviewEvidence | null;
evidenceList: ShippingOrderReviewEvidence[];
fieldLabel?: string;
@@ -730,7 +730,16 @@ onBeforeUnmount(() => {
</div>
<div class="grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)_auto]">
<div v-if="emailPreview" class="min-h-0 overflow-auto whitespace-pre-wrap p-4 font-mono text-xs leading-6 text-slate-700 dark:text-slate-200" data-testid="review-email-evidence-preview">
<iframe
v-if="emailPreview?.render_kind === 'safe_html' && emailPreview.preview_url"
:src="emailPreview.preview_url"
sandbox=""
referrerpolicy="no-referrer"
:title="fieldLabel || t('chat.shippingOrderReview.evidenceDrawer.title')"
class="min-h-0 h-full w-full border-0 bg-white"
data-testid="review-email-evidence-html"
/>
<div v-else-if="emailPreview" class="min-h-0 overflow-auto whitespace-pre-wrap p-4 font-mono text-xs leading-6 text-slate-700 dark:text-slate-200" data-testid="review-email-evidence-preview">
{{ emailPreview.text }}
</div>
<ReviewDocumentPreview
@@ -104,11 +104,12 @@ describe('ReviewDocumentNavigation', () => {
global: { plugins: [i18n] },
});
// 关键断言:生命周期四阶段兼容不能改变既有的强制侧栏与编号折叠轨交互。
// 关键断言:收起后仍保留文件身份摘要,不能退化成无法识别的纯编号轨。
expect(wrapper.attributes('data-nav-mode')).toBe('sidebar');
expect(wrapper.get('[data-testid="review-doc-nav-C-2"]').text()).toContain('2');
expect(wrapper.get('[data-testid="review-doc-nav-C-2"]').text()).toContain('f2');
await wrapper.get('[data-testid="review-doc-nav-collapse"]').trigger('click');
expect(wrapper.get('[data-testid="review-doc-nav-C-2"]').text()).toContain('f2.pdf');
expect(wrapper.get('[data-testid="review-doc-nav-list"]').attributes('data-collapsed')).toBe('false');
});
it('keeps the file name as the queue row title while projecting PO, lifecycle stage and status', () => {
@@ -48,6 +48,7 @@ const props = defineProps<{
const emit = defineEmits<{
select: [caseNo: string];
'mode-change': [mode: ReviewDocumentNavMode];
'collapse-change': [collapsed: boolean];
}>();
const { t, te } = useI18n();
@@ -93,6 +94,7 @@ const mode = computed<ReviewDocumentNavMode>(() => {
});
watch(mode, (value) => emit('mode-change', value), { immediate: true });
watch(collapsed, (value) => emit('collapse-change', value), { immediate: true });
const activeIndex = computed(() => {
const idx = props.items.findIndex((item) => item.case_no === props.activeCaseNo);
@@ -181,7 +183,7 @@ function onSelect(caseNo: string) {
? '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'"
: ['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 transition-[width] duration-200 dark:border-slate-800 dark:bg-slate-900', collapsed ? 'lg:w-20' : 'lg:w-64']"
>
<!-- 2–4:顶部标签 -->
<div
@@ -244,6 +246,7 @@ function onSelect(caseNo: string) {
type="button"
class="rounded p-1 text-muted hover:bg-slate-100 dark:hover:bg-slate-800"
data-testid="review-doc-nav-collapse"
:aria-label="collapsed ? t('chat.shippingOrderReview.documentNavigation') : t('chat.shippingOrderReview.documentNavigation')"
@click="collapsed = !collapsed"
>
<ChevronLeft
@@ -287,6 +290,7 @@ function onSelect(caseNo: string) {
<div
class="min-h-0 flex-1 overflow-y-auto p-1.5"
data-testid="review-doc-nav-list"
:data-collapsed="collapsed"
>
<button
v-for="(item, index) in (collapsed ? items : filteredItems)"
@@ -304,9 +308,13 @@ function onSelect(caseNo: string) {
>
<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"
class="flex h-12 w-full min-w-0 flex-col items-center justify-center rounded-md bg-slate-100 px-1 text-[10px] dark:bg-slate-800"
:title="`${index + 1}. ${item.file_name || item.case_no}`"
>
{{ index + 1 }}
<span class="font-semibold">{{ index + 1 }}</span>
<span class="mt-0.5 w-full truncate text-center text-[9px] font-medium text-slate-600 dark:text-slate-300">
{{ (item.file_name || item.case_no).replace(/\.[^.]+$/, '').slice(0, 7) }}
</span>
</span>
<template v-else>
<TriangleAlert
@@ -26,6 +26,8 @@ const i18n = createI18n({
chat: { shippingOrderReview: {
fieldConflict: {
title: '字段冲突 {count} 项', subtitle: '请选择值', focusEvidence: '定位证据',
evidenceIssueTitle: '证据待确认({count})', evidenceIssueSubtitle: '请核对证据',
scope: { header: '订单头', line: '订单明细' },
customValue: '手工值', customPlaceholder: '请输入', submitCustom: '确认手工值',
resolveReason: '人工裁决', resolveFailed: '提交失败', resolveSuccess: '已处理',
fields: { part_number: '料号' }, reasons: { field_conflict: '字段冲突' },
@@ -38,6 +40,23 @@ const i18n = createI18n({
});
describe('ReviewFieldConflictPanel', () => {
it('separates evidence gaps from value conflicts and does not offer a duplicate value decision', () => {
const wrapper = mount(ReviewFieldConflictPanel, {
props: {
caseNo: 'SORC-1', draftVersion: 1, editable: true,
conflicts: [],
evidenceIssues: [{
conflict_key: '-1:reservation_id', field_code: 'reservation_id', line_index: null, scope: 'header',
reason: 'evidence_missing', options: [],
}],
},
global: { plugins: [i18n] },
});
expect(wrapper.get('[data-testid="review-evidence-issue-panel"]').text()).toContain('订单头 · reservation_id');
expect(wrapper.find('[data-testid="review-field-conflict-custom-toggle"]').exists()).toBe(false);
});
it('refreshes the case when confirming a stale manual value returns conflict-not-found', async () => {
resolveFieldConflict.mockRejectedValueOnce(new BusinessError({
message: 'Field conflict not found',
@@ -18,6 +18,7 @@ const props = defineProps<{
caseNo: string;
draftVersion: number | null | undefined;
conflicts: ShippingOrderReviewFieldConflict[] | null | undefined;
evidenceIssues?: ShippingOrderReviewFieldConflict[] | null | undefined;
editable: boolean;
}>();
@@ -33,6 +34,7 @@ const customOpenKey = ref<string | null>(null);
const customValue = ref('');
const openConflicts = computed(() => props.conflicts || []);
const openEvidenceIssues = computed(() => props.evidenceIssues || []);
/**
* 字段编码本地化标签(无文案时回退 field_code)。
@@ -50,6 +52,17 @@ function reasonLabel(reason: string): string {
return te(key) ? t(key) : reason;
}
/**
* 区分订单头与明细字段;同名字段不能被误读成同一份业务值。
*/
function scopeLabel(scope: string | null | undefined): string {
const code = ['header', 'line', 'line_unassigned', 'unscoped'].includes(String(scope || ''))
? String(scope)
: 'unscoped';
const key = `chat.shippingOrderReview.fieldConflict.scope.${code}`;
return t(key);
}
/**
* 证据角色本地化(主 PDF / 辅助 / 邮件正文)。
*/
@@ -170,11 +183,11 @@ async function submitCustom(conflict: ShippingOrderReviewFieldConflict) {
<template>
<section
v-if="openConflicts.length"
v-if="openConflicts.length || openEvidenceIssues.length"
class="rounded-xl border border-rose-200 bg-rose-50/70 p-3 shadow-sm dark:border-rose-900 dark:bg-rose-950/40"
data-testid="review-field-conflict-panel"
>
<header class="flex flex-wrap items-start justify-between gap-2">
<header v-if="openConflicts.length" class="flex flex-wrap items-start justify-between gap-2">
<div>
<h2 class="text-sm font-semibold text-rose-950 dark:text-rose-50">
{{ t('chat.shippingOrderReview.fieldConflict.title', { count: openConflicts.length }) }}
@@ -276,5 +289,38 @@ async function submitCustom(conflict: ShippingOrderReviewFieldConflict) {
</div>
</li>
</ul>
<div
v-if="openEvidenceIssues.length"
class="mt-3 rounded-lg border border-amber-200 bg-amber-50/80 p-2.5 dark:border-amber-900 dark:bg-amber-950/30"
data-testid="review-evidence-issue-panel"
>
<h2 class="text-sm font-semibold text-amber-950 dark:text-amber-50">
{{ t('chat.shippingOrderReview.fieldConflict.evidenceIssueTitle', { count: openEvidenceIssues.length }) }}
</h2>
<p class="mt-0.5 text-xs text-amber-800 dark:text-amber-200">
{{ t('chat.shippingOrderReview.fieldConflict.evidenceIssueSubtitle') }}
</p>
<ul class="mt-2 space-y-1.5">
<li
v-for="issue in openEvidenceIssues"
:key="`${issue.conflict_key}-${issue.reason}`"
class="flex flex-wrap items-center justify-between gap-2 rounded border border-amber-200 bg-white/95 px-2.5 py-2 text-xs dark:border-amber-900 dark:bg-slate-900"
>
<span class="text-amber-950 dark:text-amber-50">
<span class="text-muted">{{ scopeLabel(issue.scope) }} · </span>
<span class="font-mono">{{ fieldLabel(issue.field_code) }}</span>
</span>
<button
type="button"
class="text-[11px] text-primary underline-offset-2 hover:underline"
data-testid="review-evidence-issue-focus"
@click="onFocus(issue)"
>
{{ t('chat.shippingOrderReview.fieldConflict.focusEvidence') }}
</button>
</li>
</ul>
</div>
</section>
</template>
@@ -36,7 +36,6 @@ const i18n = createI18n({
markNonOrder: '标记为非订单',
markQualityIssue: '文件质量异常',
reparse: '重新识别此 PDF',
uploadReplacement: '上传替代 PDF',
},
},
},
@@ -54,6 +53,7 @@ const emailPdfContext: ShippingOrderReviewIntakeParseContext = {
email: {
document_id: 7,
filename: 'source.eml',
render_kind: 'text',
text: 'approved body text',
},
};
@@ -76,11 +76,6 @@ function mountPanel(props: Record<string, unknown>) {
loadFailed: false,
previewUrl: null,
previewLoading: false,
saving: false,
canMarkNonOrder: false,
canMarkQualityIssue: false,
canReparse: false,
canUploadReplacement: false,
...props,
},
global: { plugins: [i18n] },
@@ -96,6 +91,35 @@ describe('ReviewIntakeParsePanel', () => {
expect(wrapper.get('[data-testid="intake-parse-attachment-preview"] iframe').attributes('src')).toBe('blob:pdf');
});
it('uses a compact attachment heading without duplicate metadata', () => {
const wrapper = mountPanel({ context: emailPdfContext, previewUrl: 'blob:pdf' });
// 关键断言:文件名与当前附件合并展示,MIME 类型不再占用预览空间。
expect(wrapper.get('[data-testid="intake-parse-attachment-heading"]').text()).toContain('当前附件');
expect(wrapper.get('[data-testid="intake-parse-attachment-heading"]').text()).toContain('current.pdf');
expect(wrapper.text()).not.toContain('文件类型');
});
it('loads isolated EML HTML from the backend preview URL inside a sandboxed iframe', () => {
const wrapper = mountPanel({
context: {
...emailPdfContext,
email: {
...emailPdfContext.email!,
render_kind: 'safe_html',
preview_url: '/api/workspace/shipping-notice/order-review-cases/CASE-1/email-preview?preview_token=single-use',
},
},
});
// 关键断言:HTML 不得通过 srcdoc 注入工作台 DOM,必须由受控 URL 在无脚本 iframe 中读取。
const frame = wrapper.get('[data-testid="intake-parse-email-html"]');
expect(frame.attributes('sandbox')).toBeDefined();
expect(frame.attributes('src')).toContain('preview_token=single-use');
expect(frame.attributes('srcdoc')).toBeUndefined();
expect(wrapper.find('[data-testid="intake-parse-email-body"]').exists()).toBe(false);
});
it('does not render a PDF frame for an unsupported attachment', () => {
const wrapper = mountPanel({ context: unsupportedContext });
@@ -105,35 +129,22 @@ describe('ReviewIntakeParsePanel', () => {
expect(wrapper.get('[data-testid="intake-parse-no-email"]').text()).toContain('无邮件上下文');
});
it('emits parse disposition intent without executing Case commands', async () => {
it('does not render parse disposition controls inside the scrolling intake panel', () => {
const wrapper = mountPanel({
context: emailPdfContext,
canMarkNonOrder: true,
canMarkQualityIssue: true,
canReparse: true,
canUploadReplacement: true,
});
await wrapper.get('[data-testid="intake-parse-mark-non-order"]').trigger('click');
await wrapper.get('[data-testid="intake-parse-mark-quality-issue"]').trigger('click');
await wrapper.get('[data-testid="intake-parse-reparse"]').trigger('click');
await wrapper.get('[data-testid="intake-parse-upload-replacement"] input').trigger('change');
expect(wrapper.emitted('mark-non-order')).toHaveLength(1);
expect(wrapper.emitted('mark-quality-issue')).toHaveLength(1);
expect(wrapper.emitted('reparse')).toHaveLength(1);
expect(wrapper.emitted('upload-replacement')).toHaveLength(1);
// 关键断言:按钮由父级固定底栏统一承载,面板滚动时不得随内容离开视口。
expect(wrapper.find('[data-testid="intake-parse-disposition-actions"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="intake-parse-mark-non-order"]').exists()).toBe(false);
});
it('does not infer replacement permission from another disposition permission', () => {
it('does not render deprecated parse disposition controls inside the scrolling panel', () => {
const wrapper = mountPanel({
context: emailPdfContext,
canMarkQualityIssue: true,
canUploadReplacement: false,
});
// 关键断言:父级必须显式授予替代上传,不能因质量异常动作可用而显示上传入口。
expect(wrapper.get('[data-testid="intake-parse-mark-quality-issue"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="intake-parse-upload-replacement"]').exists()).toBe(false);
// 关键断言:处置由固定底栏承载,滚动内容区不得遗留重复入口。
expect(wrapper.find('[data-testid="intake-parse-reparse"]').exists()).toBe(false);
});
});
@@ -16,20 +16,11 @@ const props = defineProps<{
loadFailed: boolean;
previewUrl: string | null;
previewLoading: boolean;
saving: boolean;
canMarkNonOrder: boolean;
canMarkQualityIssue: boolean;
canReparse: boolean;
canUploadReplacement: boolean;
}>();
const emit = defineEmits<{
'retry-context': [];
'load-preview': [];
'mark-non-order': [];
'mark-quality-issue': [];
reparse: [];
'upload-replacement': [event: Event];
}>();
const { t } = useI18n();
@@ -83,7 +74,17 @@ watch(
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.lifecycle.intakeParse.email') }}</h2>
<template v-if="context.email">
<p class="mt-1 text-xs text-slate-500">{{ context.email.filename }}</p>
<iframe
v-if="context.email.render_kind === 'safe_html' && context.email.preview_url"
:src="context.email.preview_url"
sandbox=""
referrerpolicy="no-referrer"
:title="t('chat.shippingOrderReview.lifecycle.intakeParse.emailPreviewTitle')"
class="mt-3 h-72 w-full rounded border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-950"
data-testid="intake-parse-email-html"
/>
<pre
v-else
class="mt-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-slate-50 p-3 text-xs text-slate-700 dark:bg-slate-950/50 dark:text-slate-200"
data-testid="intake-parse-email-body"
>{{ context.email.text }}</pre>
@@ -98,24 +99,16 @@ watch(
</section>
<section class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900">
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.lifecycle.intakeParse.attachment') }}</h2>
<dl class="mt-3 grid gap-2 text-sm sm:grid-cols-2">
<div>
<dt class="text-xs text-slate-500">{{ t('chat.shippingOrderReview.lifecycle.intakeParse.fileName') }}</dt>
<dd class="mt-0.5 break-all">{{ context.attachment.filename }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500">{{ t('chat.shippingOrderReview.lifecycle.intakeParse.fileType') }}</dt>
<dd class="mt-0.5 break-all">{{ context.attachment.mime_type || '-' }}</dd>
</div>
</dl>
<h2 class="text-sm font-semibold" data-testid="intake-parse-attachment-heading">
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.attachment') }} ·
<span class="font-normal text-slate-500 dark:text-slate-400">{{ context.attachment.filename }}</span>
</h2>
<div
v-if="context.attachment.preview_kind === 'pdf'"
class="mt-4"
class="mt-3"
data-testid="intake-parse-attachment-preview"
>
<h3 class="text-xs font-medium text-slate-600 dark:text-slate-300">{{ t('chat.shippingOrderReview.lifecycle.intakeParse.preview') }}</h3>
<p
v-if="previewLoading"
class="mt-2 text-sm text-slate-500"
@@ -148,53 +141,6 @@ watch(
</p>
</section>
<div class="flex flex-wrap gap-2" data-testid="intake-parse-disposition-actions">
<button
v-if="canMarkNonOrder"
type="button"
:disabled="saving"
class="rounded border border-rose-200 px-3 py-2 text-sm text-rose-700 disabled:opacity-50 dark:border-rose-900 dark:text-rose-300"
data-testid="intake-parse-mark-non-order"
@click="emit('mark-non-order')"
>
{{ t('chat.shippingOrderReview.markNonOrder') }}
</button>
<button
v-if="canMarkQualityIssue"
type="button"
:disabled="saving"
class="rounded border border-amber-200 px-3 py-2 text-sm text-amber-800 disabled:opacity-50 dark:border-amber-900 dark:text-amber-200"
data-testid="intake-parse-mark-quality-issue"
@click="emit('mark-quality-issue')"
>
{{ t('chat.shippingOrderReview.markQualityIssue') }}
</button>
<button
v-if="canReparse"
type="button"
:disabled="saving"
class="rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 disabled:opacity-50 dark:border-slate-700 dark:text-slate-300"
data-testid="intake-parse-reparse"
@click="emit('reparse')"
>
{{ t('chat.shippingOrderReview.reparse') }}
</button>
<label
v-if="canUploadReplacement"
class="cursor-pointer rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 dark:border-slate-700 dark:text-slate-300"
:class="saving ? 'pointer-events-none opacity-50' : ''"
data-testid="intake-parse-upload-replacement"
>
<input
class="sr-only"
type="file"
accept="application/pdf,.pdf"
:disabled="saving"
@change="emit('upload-replacement', $event)"
>
{{ t('chat.shippingOrderReview.uploadReplacement') }}
</label>
</div>
</template>
</section>
</template>
@@ -1,9 +1,9 @@
/**
* features/chat/components/shipping-review/ReviewInventoryCandidatesPanel.spec.ts
* 用途:验证库存路由面板在服务端刷新后重置本地表单,并展示规则码/源编码以满足可追溯。
* 用途:验证库存路由面板展示服务端规则结果、规则码与源编码以满足可追溯。
* 依赖:Vitest、Vue Test Utils、vue-i18n、chat 文案。
* 逻辑:构造带技术编码的行投影;断言显示名+编码与命中规则;两列标签卡可扫描;
* 变更候选后本地勾选被重置。
* 自动重算意图只透传 line_key,不允许出现人工候选表单。
*/
import { flushPromises, mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
@@ -31,7 +31,6 @@ function line(
rule_suggestion_source_codes: ['DSV360_AWSDU'],
matched_rules: [{ rule_code: 'ROUTE_HINT_AWSSG', version: 1 }],
rule_versions: [{ rule_code: 'INVENTORY_RULE_18', version: 18 }],
manual_reason: 'initial reason',
...overrides,
};
}
@@ -82,24 +81,19 @@ describe('ReviewInventoryCandidatesPanel', () => {
expect(wrapper.text()).toContain('新加坡仓');
});
it('resets local form when server candidates change for the same line_key', async () => {
it('renders refreshed rule candidates without exposing manual selection inputs', async () => {
const wrapper = mount(ReviewInventoryCandidatesPanel, {
props: {
lines: [line({ candidate_inventory_source_codes: ['DSV360_AWSDU'], manual_reason: 'old' })],
lines: [line({ candidate_inventory_source_codes: ['DSV360_AWSDU'] })],
sourceLabels: { DSV360_AWSDU: '杜塞尔多夫仓', DSV360_AWSBI: '伯明翰仓' },
editable: true,
},
global: { plugins: [i18n] },
});
const textarea = wrapper.get('textarea');
await textarea.setValue('user typed reason');
expect((textarea.element as HTMLTextAreaElement).value).toBe('user typed reason');
await wrapper.setProps({
lines: [line({
candidate_inventory_source_codes: ['DSV360_AWSBI'],
manual_reason: 'server refreshed',
raw_rule_source_codes: ['DSV360_AWSBI'],
unavailable_source_codes: [],
rule_suggestion_source_codes: ['DSV360_AWSBI'],
@@ -107,11 +101,10 @@ describe('ReviewInventoryCandidatesPanel', () => {
})],
});
await flushPromises();
const refreshed = wrapper.get('textarea');
expect((refreshed.element as HTMLTextAreaElement).value).toBe('server refreshed');
expect(wrapper.text()).toContain('伯明翰仓');
expect(wrapper.text()).toContain('DSV360_AWSBI');
expect(wrapper.text()).toContain('ROUTE_HINT_AWSBI');
expect(wrapper.find('textarea').exists()).toBe(false);
expect(wrapper.find('input[type="checkbox"]').exists()).toBe(false);
});
});
@@ -1,20 +1,16 @@
<!--
features/chat/components/shipping-review/ReviewInventoryCandidatesPanel.vue
用途:库存路由恢复面板——展示规则建议/不可用源,支持 reroute、采纳建议、保留人工与多选提交。
用途:库存路由恢复面板——展示发布规则结果、不可用源并支持自动重算。
依赖:vue-i18n、ShippingOrderReviewBuildEligibilityLineProjection 类型。
逻辑:接收 recovery / suggestion_pending 行;规则候选优先,零候选回退已启用源;
服务端行指纹变化时重置本地表单;业务名与等宽 source_code 始终可见;
原始/不可用/建议候选用两列标签卡降低密度;emit 由 composable 写 API。
逻辑:只展示服务端规则裁决;服务端行指纹变化时刷新显示;业务名与等宽 source_code 始终可见;
原始/不可用/有效候选用两列标签卡降低密度;仅 emit 自动重算意图。
-->
<script setup lang="ts">
import { reactive, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingOrderReviewBuildEligibilityLineProjection } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
lines: ShippingOrderReviewBuildEligibilityLineProjection[];
/** 已启用库存源;规则零候选时作为可选列表 */
enabledSourceCodes?: string[];
/** 库存源编码 → 业务显示名;提交仍使用编码 */
sourceLabels?: Record<string, string>;
editable?: boolean;
@@ -22,30 +18,11 @@ const props = defineProps<{
}>();
const emit = defineEmits<{
(e: 'submit', payload: { lineKey: string; sourceCodes: string[]; reason: string }): void;
(e: 'reroute', lineKey?: string): void;
(e: 'adopt', payload: { lineKey: string; reason?: string }): void;
(e: 'keep', payload: { lineKey: string; reason?: string }): void;
}>();
const { t, te } = useI18n();
/** 每行本地表单状态:已选候选与原因。 */
const formState = reactive<Record<string, { selected: string[]; reason: string }>>({});
/**
* 行级可选源:规则候选优先,否则回退已启用库存源。
*/
function selectableCodes(line: ShippingOrderReviewBuildEligibilityLineProjection): string[] {
const candidates = (line.candidate_inventory_source_codes || [])
.map((code) => String(code || '').trim().toUpperCase())
.filter(Boolean);
if (candidates.length) return candidates;
return (props.enabledSourceCodes || [])
.map((code) => String(code || '').trim().toUpperCase())
.filter(Boolean);
}
/**
* 规则建议可用源编码。
*/
@@ -56,63 +33,6 @@ function ruleSuggestionCodes(line: ShippingOrderReviewBuildEligibilityLineProjec
|| [];
}
/**
* 服务端行投影指纹;变化时用于重置本地表单,避免提交过期候选/原因。
*/
function lineServerFingerprint(line: ShippingOrderReviewBuildEligibilityLineProjection): string {
return JSON.stringify({
line_key: String(line.line_key || line.line_index || ''),
candidates: (line.candidate_inventory_source_codes || []).map(String),
reason: String(line.manual_reason || ''),
suggestion_pending: Boolean(line.suggestion_pending),
rule: ruleSuggestionCodes(line).map(String),
unavailable: (line.unavailable_source_codes || []).map(String),
raw: (line.raw_rule_source_codes || []).map(String),
block_reason: String(line.block_reason || ''),
});
}
/**
* 清空本地表单缓存(下次 getForm 按服务端投影重新初始化)。
*/
function resetFormState() {
for (const key of Object.keys(formState)) {
delete formState[key];
}
}
watch(
() => (props.lines || []).map(lineServerFingerprint).join('\n'),
() => {
resetFormState();
},
);
/**
* 获取或初始化某行的表单状态。
*/
function getForm(line: ShippingOrderReviewBuildEligibilityLineProjection) {
const key = String(line.line_key || (line.line_index ?? ''));
if (!formState[key]) {
const ruleCandidates = (line.candidate_inventory_source_codes || []).map(String);
formState[key] = {
selected: [...ruleCandidates],
reason: String(line.manual_reason || ''),
};
}
return formState[key];
}
/**
* 切换候选编码勾选状态。
*/
function toggleCode(line: ShippingOrderReviewBuildEligibilityLineProjection, code: string) {
const form = getForm(line);
const index = form.selected.indexOf(code);
if (index >= 0) form.selected.splice(index, 1);
else form.selected.push(code);
}
/**
* 解析阻断原因展示文案。
*/
@@ -160,20 +80,6 @@ function unavailableReasonLabel(line: ShippingOrderReviewBuildEligibilityLinePro
return te(key) ? t(key) : t('chat.shippingOrderReview.inventoryRouting.unavailableReasonUnknown');
}
/**
* 校验并提交指定行的人工候选选择。
*/
function submitLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
const lineKey = String(line.line_key || '').trim();
if (!lineKey) return;
const form = getForm(line);
emit('submit', {
lineKey,
sourceCodes: [...form.selected],
reason: form.reason.trim(),
});
}
/**
* 触发行级重新匹配路由。
*/
@@ -182,25 +88,6 @@ function rerouteLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
emit('reroute', lineKey || undefined);
}
/**
* 采纳待决规则建议。
*/
function adoptLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
const lineKey = String(line.line_key || '').trim();
if (!lineKey) return;
const reason = getForm(line).reason.trim();
emit('adopt', { lineKey, ...(reason ? { reason } : {}) });
}
/**
* 保留当前人工路由结果。
*/
function keepLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
const lineKey = String(line.line_key || '').trim();
if (!lineKey) return;
const reason = getForm(line).reason.trim();
emit('keep', { lineKey, ...(reason ? { reason } : {}) });
}
</script>
<template>
@@ -313,55 +200,6 @@ function keepLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
</div>
</div>
<p
v-if="line.suggestion_pending"
class="mt-2 rounded border border-amber-200 bg-amber-50 px-2 py-1 text-xs text-amber-900 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-100"
data-testid="review-inventory-suggestion-pending"
>
{{ t('chat.shippingOrderReview.inventoryRouting.suggestionPending') }}
</p>
<div v-if="selectableCodes(line).length" class="mt-3">
<div class="text-xs font-medium text-slate-600 dark:text-slate-300">
{{
(line.candidate_inventory_source_codes || []).length
? t('chat.shippingOrderReview.inventoryCandidates.selectSources')
: t('chat.shippingOrderReview.inventoryCandidates.selectEnabledSources')
}}
</div>
<div class="mt-2 flex flex-wrap gap-2">
<label
v-for="code in selectableCodes(line)"
:key="code"
class="inline-flex cursor-pointer items-center gap-1.5 rounded border border-slate-200 px-2 py-1 text-xs dark:border-slate-600"
>
<input
type="checkbox"
:checked="getForm(line).selected.includes(code)"
:disabled="!editable || saving"
@change="toggleCode(line, code)"
>
<span>{{ sourceBusinessName(code) }}</span>
<span class="font-mono text-[11px] text-slate-500">{{ sourceCodeLabel(code) }}</span>
</label>
</div>
</div>
<p v-else class="mt-2 text-xs text-rose-600 dark:text-rose-300">
{{ t('chat.shippingOrderReview.inventoryCandidates.noEnabledSources') }}
</p>
<label class="mt-3 block text-xs font-medium text-slate-600 dark:text-slate-300">
{{ t('chat.shippingOrderReview.inventoryCandidates.reasonLabel') }}
<textarea
:value="getForm(line).reason"
:disabled="!editable || saving"
rows="2"
class="mt-1 w-full rounded-md border border-slate-300 bg-white px-2 py-1.5 text-xs dark:border-slate-600 dark:bg-slate-950"
:placeholder="t('chat.shippingOrderReview.inventoryCandidates.reasonPlaceholder')"
@input="getForm(line).reason = ($event.target as HTMLTextAreaElement).value"
/>
</label>
<div class="mt-3 flex flex-wrap items-center justify-end gap-2">
<button
type="button"
@@ -372,35 +210,6 @@ function keepLine(line: ShippingOrderReviewBuildEligibilityLineProjection) {
>
{{ t('chat.shippingOrderReview.inventoryRouting.reroute') }}
</button>
<template v-if="line.suggestion_pending">
<button
type="button"
class="rounded border border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 disabled:opacity-50 dark:border-amber-800 dark:bg-amber-950/50 dark:text-amber-100"
data-testid="review-inventory-routing-adopt"
:disabled="!editable || saving"
@click="adoptLine(line)"
>
{{ t('chat.shippingOrderReview.inventoryRouting.adoptSuggestion') }}
</button>
<button
type="button"
class="rounded border border-slate-300 bg-white px-3 py-1.5 text-xs text-slate-700 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-950 dark:text-slate-200"
data-testid="review-inventory-routing-keep"
:disabled="!editable || saving"
@click="keepLine(line)"
>
{{ t('chat.shippingOrderReview.inventoryRouting.keepManual') }}
</button>
</template>
<button
type="button"
class="rounded bg-sky-600 px-3 py-1.5 text-xs text-white disabled:opacity-50"
data-testid="review-inventory-candidates-submit"
:disabled="!editable || saving || !getForm(line).selected.length || !getForm(line).reason.trim()"
@click="submitLine(line)"
>
{{ t('chat.shippingOrderReview.inventoryCandidates.submit') }}
</button>
</div>
</article>
</section>
@@ -8,6 +8,7 @@
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { inventoryActionLabelKey } from '@/features/shipping-progress/actionPresentation';
export interface InventoryIssueFallback {
kind?: string | null;
@@ -70,7 +71,7 @@ const reasonLabel = computed(() => {
:disabled="busy"
@click="emit('retry-preparation')"
>
{{ t('chat.shippingOrderReview.lineOps.retryPreparation') }}
{{ t(inventoryActionLabelKey('retry_inventory_preparation')!) }}
</button>
</section>
</template>
@@ -34,8 +34,8 @@ function mountPanel(needsReview = false) {
needs_review: needsReview,
selected_profile: { profile_code: 'ODP-A', display_name: '客户订单模板', version: 1 },
candidates: [
{ profile_code: 'ODP-A', score: 0.99 },
{ profile_code: 'ODP-B', score: 0.98 },
{ profile_code: 'ODP-A', display_name: '客户订单模板', score: 0.99 },
{ profile_code: 'ODP-B', display_name: '客户订单模板(旧版)', score: 0.98 },
],
fallback_reason_codes: [],
},
@@ -59,4 +59,14 @@ describe('ReviewProfileMatchPanel', () => {
await wrapper.get('[data-testid="review-profile-match-candidates-toggle"]').trigger('click');
expect(wrapper.find('[data-testid="review-profile-match-candidates"]').exists()).toBe(false);
});
it('候选模板优先展示模板名称,不把内部编号作为主文案', async () => {
const wrapper = mountPanel(true);
await wrapper.get('[data-testid="review-profile-match-candidates-toggle"]').trigger('click');
// 关键断言:业务用户辨认模板依赖 display_name,ODP 编号不应出现在候选列表主展示中。
expect(wrapper.get('[data-testid="review-profile-match-candidates"]').text()).toContain('客户订单模板');
expect(wrapper.get('[data-testid="review-profile-match-candidates"]').text()).not.toContain('ODP-A');
});
});
@@ -57,7 +57,7 @@ const selectedLabel = computed(() => {
if (!selected) {
return t('chat.shippingOrderReview.profileMatch.noSelected');
}
const name = String(selected.display_name || selected.profile_code || '').trim();
const name = String(selected.display_name || '').trim();
if (!name) return t('chat.shippingOrderReview.profileMatch.noSelected');
if (!isAdminView.value) return name;
const version = selected.version != null ? ` v${selected.version}` : '';
@@ -128,7 +128,7 @@ const selectedLabel = computed(() => {
:key="`${item.profile_code}-${item.version}-${idx}`"
class="rounded-lg border border-default bg-surface-soft px-2.5 py-1.5 text-[11px] text-secondary"
>
<span class="font-mono">{{ item.profile_code }}</span>
<span>{{ item.display_name || t('chat.shippingOrderReview.profileMatch.noSelected') }}</span>
<span v-if="item.score != null" class="ml-2 text-muted">{{ item.score }}</span>
</li>
</ul>
@@ -24,6 +24,24 @@ const i18n = createI18n({
});
describe('ReviewWorkbenchFooter', () => {
it('keeps intake parse dispositions in the sticky footer without replacement upload', () => {
const wrapper = mount(ReviewWorkbenchFooter, {
props: {
availableActions: ['mark_non_order', 'mark_quality_issue', 'reparse', 'validate'],
canConfirmBuild: false, saving: false, isReadOnly: false, hasDraft: true,
showParseDispositions: true, showValidate: false,
},
global: { plugins: [i18n] },
});
// 关键断言:接收解析动作与订单复核使用同一 sticky 底栏;业务不支持替代 PDF 上传。
expect(wrapper.get('[data-testid="review-footer-actions"]').classes()).toEqual(expect.arrayContaining(['sticky', 'bottom-0']));
expect(wrapper.text()).toContain('chat.shippingOrderReview.markNonOrder');
expect(wrapper.text()).toContain('chat.shippingOrderReview.markQualityIssue');
expect(wrapper.text()).toContain('chat.shippingOrderReview.reparse');
expect(wrapper.text()).not.toContain('chat.shippingOrderReview.saveOrderAndValidate');
});
it('does not duplicate current-case flow actions in the order-review footer', () => {
const wrapper = mount(ReviewWorkbenchFooter, {
props: {
@@ -38,6 +38,8 @@ const props = withDefaults(defineProps<{
flowBusy?: boolean;
/** 解析处置入口由接收解析工作面承载时,订单复核底栏隐藏四项解析操作。 */
showParseDispositions?: boolean;
/** 保存并校验只属于订单复核表单,接收解析阶段必须隐藏。 */
showValidate?: boolean;
}>(), {
unsavedCount: 0,
flowPresentation: null,
@@ -49,13 +51,13 @@ const props = withDefaults(defineProps<{
actionsExecutable: true,
flowBusy: false,
showParseDispositions: true,
showValidate: true,
});
const emit = defineEmits<{
'mark-non-order': [];
'mark-quality-issue': [];
reparse: [];
'upload-replacement': [event: Event];
validate: [];
confirm: [];
'retry-stp': [];
@@ -130,20 +132,6 @@ const canWriteCaseActions = computed(() => props.actionsExecutable && !props.isR
>
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.reparse') }}
</button>
<label
v-if="showParseDispositions && hasAction('mark_quality_issue')"
class="cursor-pointer rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
:class="controlsBusy ? 'pointer-events-none opacity-50' : ''"
>
<input
class="sr-only"
type="file"
accept="application/pdf,.pdf"
:disabled="controlsBusy"
@change="emit('upload-replacement', $event)"
>
{{ t('chat.shippingOrderReview.uploadReplacement') }}
</label>
</template>
<button
@@ -184,7 +172,7 @@ const canWriteCaseActions = computed(() => props.actionsExecutable && !props.isR
</p>
<template v-if="!automating && canWriteCaseActions">
<button
v-if="hasAction('validate')"
v-if="showValidate && hasAction('validate')"
type="button"
:disabled="controlsBusy"
class="inline-flex items-center gap-1 rounded bg-sky-600 px-3 py-2 text-sm text-white disabled:opacity-50"
@@ -1,13 +1,11 @@
<!--
features/chat/components/shipping-review/ReviewWorkbenchHeader.vue
用途:订单复核工作台顶栏——对话级动作、审计/版本入口与保存状态。
用途:订单复核工作台顶栏——审计/版本入口与保存状态。
依赖:vue-i18n、lucide-vue-next。
逻辑:仅当后端 conversation_allowed_actions 含 retry_auto_progress 时渲染对话级按钮;
审计/版本为查看入口;「已保存」为状态文本;不含单个任务单写操作。
逻辑:审计/版本为查看入口;「已保存」为状态文本;不含单个任务单写操作。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { ArrowLeft, RefreshCw } from 'lucide-vue-next';
import { ArrowLeft } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
const props = defineProps<{
@@ -21,28 +19,15 @@ const props = defineProps<{
isReadOnly: boolean;
showVersionHistory?: boolean;
showAuditTrail?: boolean;
/** 对话级「重试自动推进」;仅 eligible_count>0 时由父级置 true */
showConversationRetry?: boolean;
conversationRetryEligibleCount?: number;
conversationRetrying?: boolean;
conversationRetryDisabled?: boolean;
hasConversationRetryResult?: boolean;
}>();
const emit = defineEmits<{
back: [];
'open-version-history': [];
'open-audit-trail': [];
'retry-conversation-auto-progress': [];
'open-conversation-retry-result': [];
}>();
const { t } = useI18n();
const showRetry = computed(() => (
Boolean(props.showConversationRetry)
&& Number(props.conversationRetryEligibleCount || 0) > 0
));
</script>
<template>
@@ -63,34 +48,6 @@ const showRetry = computed(() => (
data-testid="review-selected-order-summary"
>{{ selectedOrderSummary }}</p>
</div>
<button
v-if="showRetry"
type="button"
class="inline-flex items-center gap-1 rounded border border-amber-400 bg-amber-50 px-2.5 py-1.5 text-xs font-medium text-amber-950 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
data-testid="review-conversation-retry-auto-progress"
:disabled="conversationRetrying || conversationRetryDisabled || isReadOnly"
@click="emit('retry-conversation-auto-progress')"
>
<RefreshCw
class="h-3.5 w-3.5"
:class="conversationRetrying ? 'animate-spin' : ''"
/>
{{ conversationRetrying ? t('chat.shippingOrderReview.conversationRetry.retrying') : t('chat.shippingOrderReview.autoProgress.retry') }}
<span
v-if="conversationRetryEligibleCount"
class="rounded bg-amber-200/80 px-1 text-[10px] dark:bg-amber-900/60"
>{{ conversationRetryEligibleCount }}</span>
</button>
<button
v-if="hasConversationRetryResult"
type="button"
class="relative rounded border border-slate-200 px-2.5 py-1.5 text-xs hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800"
data-testid="review-open-conversation-retry-result"
@click="emit('open-conversation-retry-result')"
>
{{ t('chat.shippingOrderReview.conversationRetry.viewResult') }}
<span class="absolute -right-1 -top-1 h-2 w-2 rounded-full bg-rose-500" />
</button>
<button
v-if="showAuditTrail"
type="button"