feat(shipping-notice): 支持已确认订单改绑客户并重冻结快照

- 客户识别面板两态化:已识别折叠为摘要条 +「修改客户」入口,前端管控复用编辑窗头级谓词
- 新增 rebind_confirmed_customer 链路:守卫→更新 resolution 行→审计→手动重冻结,改后重新生成 Excel
- 守卫保证仅在无发货通知/Excel 产物时可改,匹配与门禁零触碰、无失效连锁
- 路由引擎/建单资格/编辑窗服务同步适配,errors 补充改绑错误码四语言
- 同步客户面板测试、确认对话框与四语言文案,落设计与实施计划文档
This commit is contained in:
hugo committed 2026-10-13 21:13:58 +08:00
1 parent 4a726fe8b2
commit 6ac2effac3
30 files changed
+1913 -93

No files matched your search

@@ -25,17 +25,20 @@ watch(() => props.open, (open) => {
</script>
<template>
<div v-if="open" class="admin-modal-overlay animate-fade-in items-center z-[170]">
<div class="admin-modal-panel max-w-xl max-h-[90vh] scale-100">
<div class="px-6 py-5 border-b border-subtle"><h3 class="section-title">{{ t('chat.shippingCustomer.title') }}</h3><p class="section-desc mt-1">{{ t('chat.shippingCustomer.subtitle') }}</p></div>
<div class="px-6 py-5 space-y-4 overflow-y-auto">
<div class="flex gap-2"><input v-model="query" class="input-field text-sm" :placeholder="t('chat.shippingCustomer.searchPlaceholder')" @keyup.enter="emit('search', query)" /><button type="button" class="btn-ghost" @click="emit('search', query)">{{ t('chat.shippingCustomer.search') }}</button></div>
<div class="space-y-2 max-h-80 overflow-y-auto">
<label v-for="customer in options" :key="customer.id" class="flex items-center gap-3 rounded-xl border border-default p-3 cursor-pointer hover:border-brand-300"><input v-model="selectedId" type="radio" :value="customer.id" /><span class="flex-1"><span class="font-medium text-primary">{{ customer.standard_name }}</span><span class="ml-2 font-mono text-xs text-muted">{{ customer.short_code }}</span></span></label>
<div v-if="!loading && !options.length" class="text-sm text-muted py-8 text-center">{{ t('chat.shippingCustomer.empty') }}</div>
<!-- Teleport 到 body:面板/工作区子树的层叠上下文会让页内 fixed 遮罩被粘性列表穿透。 -->
<Teleport to="body">
<div v-if="open" class="admin-modal-overlay animate-fade-in items-center z-[170]">
<div class="admin-modal-panel max-w-xl max-h-[90vh] scale-100">
<div class="px-6 py-5 border-b border-subtle"><h3 class="section-title">{{ t('chat.shippingCustomer.title') }}</h3><p class="section-desc mt-1">{{ t('chat.shippingCustomer.subtitle') }}</p></div>
<div class="px-6 py-5 space-y-4 overflow-y-auto">
<div class="flex min-w-0 gap-2"><input v-model="query" class="input-field min-w-0 flex-1 text-sm" :placeholder="t('chat.shippingCustomer.searchPlaceholder')" @keyup.enter="emit('search', query)" /><button type="button" class="btn-ghost shrink-0 whitespace-nowrap" @click="emit('search', query)">{{ t('chat.shippingCustomer.search') }}</button></div>
<div class="space-y-2 max-h-80 overflow-y-auto">
<label v-for="customer in options" :key="customer.id" class="flex cursor-pointer items-center gap-3 rounded-xl border p-3" :class="selectedId === customer.id ? 'border-brand-500 bg-brand-50' : 'border-default hover:border-brand-300'"><input v-model="selectedId" type="radio" :value="customer.id" class="accent-brand-600" /><span class="flex-1"><span class="font-medium text-primary">{{ customer.standard_name }}</span><span class="ml-2 font-mono text-xs text-muted">{{ customer.short_code }}</span></span></label>
<div v-if="!loading && !options.length" class="text-sm text-muted py-8 text-center">{{ t('chat.shippingCustomer.empty') }}</div>
</div>
</div>
<div class="admin-modal-footer"><button type="button" class="btn-ghost" @click="emit('close')">{{ t('common.cancel') }}</button><button type="button" class="btn-primary" :disabled="!selectedId || loading" @click="selectedId && emit('confirm', selectedId)">{{ t('chat.shippingCustomer.confirm') }}</button></div>
</div>
<div class="admin-modal-footer"><button type="button" class="btn-ghost" @click="emit('close')">{{ t('common.cancel') }}</button><button type="button" class="btn-primary" :disabled="!selectedId || loading" @click="selectedId && emit('confirm', selectedId)">{{ t('chat.shippingCustomer.confirm') }}</button></div>
</div>
</div>
</Teleport>
</template>
@@ -1,21 +1,52 @@
/**
* features/chat/components/shipping-review/ReviewCustomerResolutionPanel.spec.ts
* 用途:锁定唯一标准客户候选的工作台提示,避免将可自动确认状态误报为未识别。
* 依赖:vitest、@vue/test-utils、vue-i18n、ReviewCustomerResolutionPanel。
* 逻辑:unique_candidate 显示自动确认说明和明确按钮;其他未确认状态维持人工选择入口。
* 用途:锁定客户识别面板两态行为——未确认态保留候选确认流程;已确认态折叠为摘要条并提供「修改客户」改绑入口。
* 依赖:vitest、@vue/test-utils、vue-i18n、ReviewCustomerResolutionPanel、shipping.api(mock)。
* 逻辑:已确认摘要条默认折叠(已确认徽标 + 标准客户名 + chevron),展开仅显示既有识别详情;
* rebindAllowed=false 时改绑按钮禁用并展示原因;选定新客户经影响确认弹窗提交改绑 API 并 emit refreshed。
* 改绑 i18n 键由 Task 3 落 chat.json,这里在 vue-i18n mock 中前置补齐同路径键。
*/
import { describe, expect, it } from 'vitest';
import { mount } from '@vue/test-utils';
import { flushPromises, mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import ReviewCustomerResolutionPanel from './ReviewCustomerResolutionPanel.vue';
import ShippingCustomerConfirmDialog from '@/features/chat/components/ShippingCustomerConfirmDialog.vue';
import {
listWorkspaceShippingCustomerOptions,
rebindWorkspaceShippingOrderReviewCustomer,
} from '@/features/chat/api/shipping.api';
import { useMessage } from '@/shared/composables/useMessage';
const messageSpies = vi.hoisted(() => ({
success: vi.fn(),
warning: vi.fn(),
error: vi.fn(),
info: vi.fn(),
}));
vi.mock('@/features/chat/api/shipping.api', () => ({
confirmWorkspaceShippingOrderReviewCustomer: vi.fn(),
listWorkspaceShippingCustomerOptions: vi.fn(),
retryWorkspaceShippingOrderReviewCustomerResolution: vi.fn(),
rebindWorkspaceShippingOrderReviewCustomer: vi.fn(),
}));
vi.mock('@/shared/composables/useMessage', () => ({
useMessage: () => messageSpies,
}));
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
common: { cancel: '取消' },
chat: {
shippingCustomer: { loadFailed: '加载失败', confirmFailed: '确认失败' },
shippingCustomer: {
loadFailed: '加载失败',
confirmFailed: '确认失败',
confirm: '确认',
},
shippingOrderReview: {
customerResolution: {
title: '客户确认', subtitle: '请选择标准客户', uniqueCandidateHint: '已找到唯一标准客户候选;保存校验时系统会自动确认,也可手动确认。',
@@ -24,6 +55,13 @@ const i18n = createI18n({
standardCustomer: '标准客户', customerCode: '客户编码', matchedInputs: '匹配输入', candidates: '候选客户', pdfReparseHint: '请重新识别 PDF',
inputLabels: { customerCode: '客户编码', customerName: '客户名称', address: '地址', email: '邮箱', domain: '域名', other: '其他' },
status: { unique_candidate: '唯一候选', unmatched: '未匹配', confirmed: '已确认' },
// 改绑键:与 Task 3 将落入 locales/*/chat.json 的键路径保持一致
rebindButton: '修改客户',
rebindDisabledExcelExists: '已产生发货通知/Excel,请先走撤销流程',
rebindConfirmTitle: '确认修改客户',
rebindConfirmImpact: '将更新订单客户并重新冻结订单快照;已生成的发货通知/Excel 需重新生成',
rebindSuccessToast: '客户已更新,可回通知准备重新生成 Excel',
rebindFailedToast: '修改客户失败,请稍后重试',
},
resume: { autoCreated: '已自动建单', waitingManualConfirm: '等待人工确认' },
},
@@ -32,32 +70,110 @@ const i18n = createI18n({
},
});
function mountPanel(status: string) {
const resolvedResolution = {
resolved: true,
status: 'confirmed',
rebind_allowed: true,
customer_id: 11,
raw_name: 'acme',
standard_name: 'ACME 标准客户',
short_code: 'ACME',
input_values: [
{ definition_code: 'customer_code', definition_label: null, raw_value: 'ACME', normalized_value: 'ACME' },
],
};
function mountPanel(resolution: Record<string, unknown>, extraProps: Record<string, unknown> = {}) {
return mount(ReviewCustomerResolutionPanel, {
props: {
caseNo: 'CASE-CUSTOMER-1',
editable: true,
resolution: { resolved: false, status, raw_name: 'ACME' },
orderDataVersion: 4,
resolution,
...extraProps,
},
global: {
plugins: [i18n],
stubs: { ShippingCustomerConfirmDialog: true },
// teleport 就地渲染:改绑影响确认弹窗 Teleport 到 body,stub 后断言仍在 wrapper 内可达。
stubs: { ShippingCustomerConfirmDialog: true, teleport: true },
},
});
}
describe('ReviewCustomerResolutionPanel', () => {
beforeEach(() => {
vi.clearAllMocks();
vi.mocked(listWorkspaceShippingCustomerOptions).mockResolvedValue([]);
});
it('唯一候选展示自动确认说明和明确确认入口', () => {
const wrapper = mountPanel('unique_candidate');
const wrapper = mountPanel({ resolved: false, status: 'unique_candidate', raw_name: 'ACME' });
expect(wrapper.text()).toContain('保存校验时系统会自动确认');
expect(wrapper.get('[data-testid="review-select-customer"]').text()).toContain('确认唯一候选');
});
it('非唯一未确认状态维持人工选择客户入口', () => {
const wrapper = mountPanel('unmatched');
const wrapper = mountPanel({ resolved: false, status: 'unmatched', raw_name: 'ACME' });
expect(wrapper.text()).not.toContain('保存校验时系统会自动确认');
expect(wrapper.get('[data-testid="review-select-customer"]').text()).toContain('选择标准客户');
});
it('已确认态默认折叠为摘要条,展开仅显示既有识别详情', async () => {
const wrapper = mountPanel(resolvedResolution);
// 断言意图:摘要条可见(已确认徽标 + 标准客户名),识别详情默认不展开
expect(wrapper.get('[data-testid="review-customer-resolution-badge"]').text()).toContain('已确认');
expect(wrapper.text()).toContain('ACME 标准客户');
expect(wrapper.find('[data-testid="review-customer-resolution-details"]').exists()).toBe(false);
// 断言意图:改绑入口在摘要条上存在
expect(wrapper.get('[data-testid="review-rebind-customer"]').exists()).toBe(true);
// 断言意图:chevron 展开后显示既有识别详情(命中输入),不再是整块识别面板
await wrapper.get('[data-testid="review-customer-resolution-toggle"]').trigger('click');
expect(wrapper.get('[data-testid="review-customer-resolution-details"]').exists()).toBe(true);
expect(wrapper.text()).toContain('匹配输入');
});
it('rebindAllowed=false 时改绑按钮禁用并以 tooltip 说明原因', () => {
const wrapper = mountPanel({ ...resolvedResolution, rebind_allowed: false });
const rebindButton = wrapper.get('[data-testid="review-rebind-customer"]');
// 断言意图:edit_window.header=false(Excel 已产生/活动 Attempt)时按钮禁用
expect(rebindButton.attributes('disabled')).toBeDefined();
// 断言意图:禁用原因经 tooltip 透出,而非静默置灰
expect(rebindButton.attributes('title')).toContain('撤销');
});
it('选定新客户并确认影响后提交改绑 API 且 emit refreshed', async () => {
vi.mocked(rebindWorkspaceShippingOrderReviewCustomer).mockResolvedValue({
case: null,
customer_resolution: null,
rebind: { previous_customer_id: 11, customer_id: 42, snapshot_id: 9 },
});
const wrapper = mountPanel(resolvedResolution);
// [STEP 1] 打开复用的客户搜索选择弹窗并选定目标客户
await wrapper.get('[data-testid="review-rebind-customer"]').trigger('click');
await flushPromises();
const selectDialog = wrapper.findComponent(ShippingCustomerConfirmDialog);
expect(selectDialog.exists()).toBe(true);
selectDialog.vm.$emit('confirm', 42);
await flushPromises();
// [STEP 2] 影响确认弹窗出现后提交
await wrapper.get('[data-testid="review-rebind-confirm-submit"]').trigger('click');
await flushPromises();
// 断言意图:携带乐观锁版本调用改绑 API
expect(rebindWorkspaceShippingOrderReviewCustomer).toHaveBeenCalledTimes(1);
expect(rebindWorkspaceShippingOrderReviewCustomer).toHaveBeenCalledWith(
'CASE-CUSTOMER-1',
{ customer_id: 42, expected_order_data_version: 4 },
);
// 断言意图:成功 toast + 复用 refreshed 事件走既有刷新链
expect(messageSpies.success).toHaveBeenCalled();
expect(wrapper.emitted('refreshed')).toHaveLength(1);
});
});
@@ -1,9 +1,11 @@
<!--
features/chat/components/shipping-review/ReviewCustomerResolutionPanel.vue
用途:复核工作台固定「建单前客户确认」区域(与重新识别 PDF 分层)。
依赖:vue-i18n、ShippingCustomerConfirmDialog、shipping.api 客户确认/重识别接口。
逻辑:未解决时完整展开置顶;已解决且 compact 时缩为一行摘要;
选择标准客户 / 重新识别客户;成功后 emit refreshed 刷新建单资格。
用途:复核工作台固定「建单前客户确认」区域,两态渲染:未确认走识别候选确认流程;已确认折叠为一行摘要条并提供「修改客户」改绑入口。
依赖:vue-i18n、ShippingCustomerConfirmDialog、shipping.api 客户确认/重识别/改绑接口。
逻辑:resolved=false 时完整展开置顶(现状不动);resolved=true 时默认折叠摘要条(已确认徽标+标准客户名+chevron+修改客户按钮),
chevron 展开既有识别详情(不含 ODM 范围);改绑走「复用客户搜索选定 → 影响确认弹窗 → rebind API → 成功 toast → emit refreshed」。
resolution.rebind_allowed=false(Excel 已产生/活动 Attempt,后端投影下发)时按钮禁用并以 tooltip 说明;
后端 fail-closed 兜底,409 的 BusinessError localized message 直接经 toast 展示。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
@@ -14,6 +16,7 @@ import ShippingCustomerConfirmDialog from '@/features/chat/components/ShippingCu
import {
confirmWorkspaceShippingOrderReviewCustomer,
listWorkspaceShippingCustomerOptions,
rebindWorkspaceShippingOrderReviewCustomer,
retryWorkspaceShippingOrderReviewCustomerResolution,
} from '@/features/chat/api/shipping.api';
import type {
@@ -25,7 +28,10 @@ const props = defineProps<{
caseNo: string;
resolution: ShippingOrderReviewCustomerResolution | null | undefined;
editable: boolean;
/** 已解决时缩为一行摘要(放入「更多状态」) */
/** 已确认改绑入口可用性:edit_window.header 明确 false 时禁用;缺失/undefined 视为可用(后端权威守卫兜底) */
/** 改绑乐观锁版本:case 投影的 order_data_version(正式任务当前版本),缺省时后端按版本冲突拒绝 */
orderDataVersion?: number | null;
/** 已解决时缩为一行摘要(历史兼容属性;已确认态现在恒为折叠摘要条) */
compact?: boolean;
}>();
@@ -39,8 +45,15 @@ const busy = ref(false);
const dialogOpen = ref(false);
const options = ref<ShippingCustomerOption[]>([]);
const loadingOptions = ref(false);
/** 已确认态识别详情是否展开(默认折叠为一行摘要条) */
const confirmedDetailsExpanded = ref(false);
/** 改绑影响确认弹窗显隐与待提交的新客户 */
const rebindConfirmOpen = ref(false);
const pendingRebindCustomerId = ref<number | null>(null);
const resolved = computed(() => Boolean(props.resolution?.resolved));
/** 改绑可用性:prop 缺省视为可用,与 formalHeaderEditable 的 fail-open 语义对齐(后端 409 兜底) */
const rebindAllowed = computed(() => props.resolution?.rebind_allowed === true);
const hasUniqueCandidate = computed(() => (
!resolved.value
&& String(props.resolution?.status || '').trim() === 'unique_candidate'
@@ -66,6 +79,15 @@ const displayName = computed(() => {
const inputValues = computed(() => props.resolution?.input_values || []);
const candidateRows = computed(() => props.resolution?.candidates || []);
/** 改绑影响确认弹窗中展示的待提交客户名;选项已卸载时回落展示 ID。 */
const pendingRebindCustomerLabel = computed(() => {
const customerId = pendingRebindCustomerId.value;
if (customerId == null) return '—';
const match = options.value.find((item) => item.id === customerId);
if (match) return `${match.standard_name} (${match.short_code})`;
return `#${customerId}`;
});
function inputLabel(definitionCode: string | null | undefined): string {
const code = String(definitionCode || '').trim().toLowerCase();
if (code.includes('customer') && code.includes('code')) return t('chat.shippingOrderReview.customerResolution.inputLabels.customerCode');
@@ -84,8 +106,13 @@ function candidateValue(candidate: unknown, key: string): string {
return String(row[key] ?? '').trim() || '—';
}
/** 切换已确认摘要条的识别详情展开/折叠。 */
function toggleConfirmedDetails() {
confirmedDetailsExpanded.value = !confirmedDetailsExpanded.value;
}
/**
* 打开标准客户选择弹窗并加载选项。
* 打开标准客户选择弹窗并加载选项(未确认确认流程入口,also 供父级经 ref 外部触发)。
*/
async function openSelectDialog() {
if (!props.editable || busy.value) return;
@@ -106,7 +133,25 @@ defineExpose({
});
/**
* 按关键词搜索标准客户。
* 打开改绑客户选择弹窗(已确认态「修改客户」入口;复用同一搜索选择弹窗)。
* AI 触发时机:用户在已确认摘要条点击「修改客户」时进入;rebindAllowed=false 时按钮已禁用,这里仅兜底防抖。
*/
async function openRebindDialog() {
if (!rebindAllowed.value || busy.value) return;
dialogOpen.value = true;
loadingOptions.value = true;
try {
options.value = await listWorkspaceShippingCustomerOptions();
} catch (error: unknown) {
options.value = [];
msg.warning(error instanceof Error ? error.message : t('chat.shippingCustomer.loadFailed'));
} finally {
loadingOptions.value = false;
}
}
/**
* 按关键词搜索标准客户(客户选择弹窗复用入口)。
*/
async function searchCustomers(query: string) {
loadingOptions.value = true;
@@ -120,7 +165,20 @@ async function searchCustomers(query: string) {
}
/**
* 确认标准客户并通知父级刷新 Case / 建单资格。
* 客户选择弹窗确认分发:已确认态进入改绑影响确认(不重走识别确认);未确认态走既有确认建单链路。
*/
function onCustomerDialogConfirm(customerId: number) {
if (resolved.value) {
pendingRebindCustomerId.value = customerId;
dialogOpen.value = false;
rebindConfirmOpen.value = true;
return;
}
void onConfirm(customerId);
}
/**
* 确认标准客户并通知父级刷新 Case / 建单资格(仅未确认态)。
*/
async function onConfirm(customerId: number) {
if (!props.caseNo || busy.value) return;
@@ -152,6 +210,34 @@ async function onConfirm(customerId: number) {
}
}
/**
* 提交改绑:携带 case 投影的 order_data_version 乐观锁调用 rebind API;成功后 toast 并 emit refreshed 走既有刷新链。
* 失败:BusinessError(含 409 守卫/版本冲突)展示后端 localized message;其余错误回落 rebindFailedToast。
*/
async function onRebindConfirmSubmit() {
const customerId = pendingRebindCustomerId.value;
if (!props.caseNo || customerId == null || busy.value) return;
busy.value = true;
try {
await rebindWorkspaceShippingOrderReviewCustomer(props.caseNo, {
customer_id: customerId,
expected_order_data_version: Number(props.orderDataVersion ?? 0),
});
rebindConfirmOpen.value = false;
pendingRebindCustomerId.value = null;
confirmedDetailsExpanded.value = false;
msg.success(t('chat.shippingOrderReview.customerResolution.rebindSuccessToast'));
emit('refreshed');
} catch (error: unknown) {
const message = error instanceof BusinessError
? resolveLocalizedErrorMessage(error.code, error.message)
: t('chat.shippingOrderReview.customerResolution.rebindFailedToast');
msg.warning(message);
} finally {
busy.value = false;
}
}
/**
* 重新识别客户(不触发 PDF 重识别)。
*/
@@ -178,26 +264,74 @@ async function onRetry() {
class="rounded-xl border border-default bg-surface p-3 shadow-sm"
data-testid="review-customer-resolution-panel"
:data-compact="compact && resolved ? 'true' : 'false'"
:data-state="resolved ? 'resolved' : 'pending'"
>
<!-- 已解决摘要:一行展示客户与状态,避免占满侧栏首位 -->
<!-- 已确认态:折叠摘要条(已确认徽标 + 标准客户名 + chevron + 修改客户入口),不整体占位 -->
<template v-if="resolved">
<div
v-if="compact && resolved"
class="flex flex-wrap items-center justify-between gap-2"
data-testid="review-customer-resolution-compact"
>
<p class="text-xs text-secondary">
<span class="font-medium text-primary">{{ t('chat.shippingOrderReview.customerResolution.title') }}</span>
<span class="mx-1 text-muted">·</span>
<span>{{ displayName }}</span>
</p>
<span
class="rounded-full bg-emerald-100 px-2 py-0.5 text-[11px] font-medium text-emerald-800 dark:bg-emerald-950 dark:text-emerald-100"
data-testid="review-customer-resolution-badge"
<button
type="button"
class="flex min-w-0 flex-1 items-center gap-2 text-left"
data-testid="review-customer-resolution-toggle"
:aria-expanded="confirmedDetailsExpanded"
@click="toggleConfirmedDetails"
>
{{ statusLabel }}
</span>
<span
class="shrink-0 rounded-full bg-emerald-100 px-2 py-0.5 text-[11px] font-medium text-emerald-800 dark:bg-emerald-950 dark:text-emerald-100"
data-testid="review-customer-resolution-badge"
>
{{ statusLabel }}
</span>
<span class="truncate text-xs font-medium text-primary">{{ displayName }}</span>
<span class="shrink-0 text-[10px] text-muted" aria-hidden="true">{{ confirmedDetailsExpanded ? '▲' : '▼' }}</span>
</button>
<button
type="button"
class="shrink-0 rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-secondary hover:bg-surface-soft disabled:opacity-60"
data-testid="review-rebind-customer"
:disabled="!rebindAllowed || busy"
:title="rebindAllowed ? undefined : t('chat.shippingOrderReview.customerResolution.rebindDisabledExcelExists')"
@click="openRebindDialog"
>
{{ t('chat.shippingOrderReview.customerResolution.rebindButton') }}
</button>
</div>
<!-- 已确认展开区:既有识别详情(标准客户/编码/命中输入/候选),不含 ODM 范围 -->
<dl
v-if="confirmedDetailsExpanded"
class="mt-2 space-y-1 text-xs text-secondary"
data-testid="review-customer-resolution-details"
>
<div class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.customerResolution.standardCustomer') }}</dt>
<dd class="font-medium text-primary">{{ displayName }}</dd>
</div>
<div v-if="resolution?.short_code" class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.customerResolution.customerCode') }}</dt>
<dd class="font-mono font-medium text-primary">{{ resolution.short_code }}</dd>
</div>
<div v-if="inputValues.length" class="mt-2 border-t border-default pt-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.customerResolution.matchedInputs') }}</dt>
<dd v-for="item in inputValues" :key="`${item.definition_code}:${item.normalized_value}`" class="mt-1 flex flex-wrap gap-x-2">
<span class="text-muted">{{ inputLabel(item.definition_label || item.definition_code) }}</span>
<span class="font-mono text-primary">{{ item.raw_value || item.normalized_value || '—' }}</span>
</dd>
</div>
<div v-if="candidateRows.length > 1" class="mt-2 border-t border-default pt-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.customerResolution.candidates') }}</dt>
<dd v-for="candidate in candidateRows" :key="String(candidate.customer_id)" class="mt-1 flex flex-wrap gap-x-2">
<span class="text-primary">{{ candidateValue(candidate, 'standard_name') }}</span>
<span class="font-mono text-muted">{{ candidateValue(candidate, 'short_code') }}</span>
</dd>
</div>
</dl>
</template>
<!-- 未确认态:既有识别候选确认流程(现状不动) -->
<template v-else>
<header class="flex flex-wrap items-start justify-between gap-2">
<div>
@@ -209,10 +343,7 @@ async function onRetry() {
</p>
</div>
<span
class="rounded-full px-2.5 py-1 text-xs font-medium"
:class="resolved
? 'bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-100'
: 'bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-100'"
class="rounded-full px-2.5 py-1 text-xs font-medium bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-100"
data-testid="review-customer-resolution-badge"
>
{{ statusLabel }}
@@ -269,15 +400,57 @@ async function onRetry() {
<p class="mt-2 text-[11px] text-muted">
{{ t('chat.shippingOrderReview.customerResolution.pdfReparseHint') }}
</p>
</template>
<!-- 客户搜索选择弹窗:未确认态确认 / 已确认态改绑共用 -->
<ShippingCustomerConfirmDialog
:open="dialogOpen"
:options="options"
:loading="loadingOptions || busy"
@close="dialogOpen = false"
@search="searchCustomers"
@confirm="onConfirm"
@confirm="onCustomerDialogConfirm"
/>
</template>
<!-- 改绑影响确认弹窗:明示快照重冻结与通知/Excel 重生成影响后再提交。Teleport 到 body 避免粘性列穿透。 -->
<Teleport to="body">
<div
v-if="rebindConfirmOpen"
class="admin-modal-overlay animate-fade-in items-center z-[180]"
role="dialog"
aria-modal="true"
data-testid="review-rebind-confirm-dialog"
>
<div class="admin-modal-panel max-w-md scale-100">
<div class="px-6 py-5 border-b border-subtle">
<h3 class="section-title">{{ t('chat.shippingOrderReview.customerResolution.rebindConfirmTitle') }}</h3>
</div>
<div class="px-6 py-5 space-y-3 text-sm">
<p class="text-secondary">{{ t('chat.shippingOrderReview.customerResolution.rebindConfirmImpact') }}</p>
<p class="font-medium text-primary" data-testid="review-rebind-confirm-customer">{{ pendingRebindCustomerLabel }}</p>
</div>
<div class="admin-modal-footer">
<button
type="button"
class="btn-ghost"
data-testid="review-rebind-confirm-cancel"
:disabled="busy"
@click="rebindConfirmOpen = false"
>
{{ t('common.cancel') }}
</button>
<button
type="button"
class="btn-primary"
data-testid="review-rebind-confirm-submit"
:disabled="busy"
@click="onRebindConfirmSubmit"
>
{{ t('chat.shippingCustomer.confirm') }}
</button>
</div>
</div>
</div>
</Teleport>
</section>
</template>