feat(in-transit-transfer): inbound/outbound 幂等重命名与解析用途分层

- receipt→inbound 三件套改名(回调桥/文件门禁/触发服务),回调链幂等去重,迁移 tt14 同步台账键与测试基建
- 库存解析用途分层 onhand/inbound/outbound(迁移 tt15):解析档案、文件存储与下载名按用途隔离,管理端表单同步
- 「成熟」概念退役(迁移 tt16):数据无成熟属性,日期边界由调用方入参严格判定
- backlog 新增重解析服务,在途重识别投影 processing,EML 父项不再停留处理中
- 收料 RPA 回调/归档/排程链路同步改名挂点,运维脚本复位假完成状态
- 文档随批:ADR 0003 模块边界决策、10-15/10-16 计划与设计、调拨文档族与 demand/tec/funclist
- 同步 chat/errors 文案四语言、调拨前端卡片与 e2e、测试全家
This commit is contained in:
hugo committed 2026-10-16 19:43:49 +08:00
1 parent 43dceaf027
commit 8102a1fe44
151 files changed
+8057 -2382

No files matched your search

@@ -2,23 +2,37 @@
features/chat/components/messages/TransferBacklogSummaryCard.vue
用途:待处理异常卡(可恢复/已关闭/结果未知三组)——列与匹配窗口一致,
支持关键字/结果筛选、多选批量操作(重查/恢复/关闭)与行级快捷操作。
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo、transferFormat.formatQuantity。
逻辑:仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
依赖:Element Plus ElTable/ElTableColumn/ElSelect/ElOption/ElPagination、
props.items(服务端返回的当前页切片)+ props.total(筛选后全量计数)、
i18n chat.transfer.*、transferBatch.deriveBatchNo、transferFormat.formatQuantity。
逻辑:2026-10-16 服务端分页 + 筛选下推(后端 GET /backlog page/page_size/
keyword/result_filter)——本组件只持有筛选 UI 态并向父级上抛 query-change,
由宿主经 useChatTransfer.loadBacklog 拉取当前页;行渲染/勾选/批量语义:
仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
可恢复行按 result_code 细分徽标(blocked_file_removed=文件已移除);
blocked_file_removed 行行内仅留「关闭」(重查不可恢复——消失证据
无法由重查翻回,唯一出口=人工关闭或等文件重新同步);
批量按钮与行内按钮同用短文案键(重查/恢复/关闭,2026-10-12 文案一致化,
完整语义经 title 悬浮),勾选计数保留;
勾选集合为卡片本地态,操作经 emit 交父组件调用批量端点并刷新。
完整语义经 title 悬浮)。
勾选集合跨页保留(翻页/筛选不清空;批量计数=勾选总数,后端逐行校验兜底);
关键字 300ms 防抖后上抛,筛选/翻页变更即上抛,首挂载上抛初始切片查询
(首页计数卡进入时 initialFilter 直接生效)。
行定位:el-table 行不支持逐行 attr,行 testid 改经 row-class-name 注入
(transfer-backlog-row-<invoice_no>,spec/e2e 用类选择器等价定位)。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { ElPagination, ElTable, ElTableColumn, ElSelect, ElOption } from 'element-plus';
import { TRANSFER_PAGE_SIZE } from '../../composables/useChatTransfer';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import type { TransferBacklogItem } from '../../types/transfer.types';
const props = defineProps<{
/** 当前页行切片(服务端分页返回;筛选在服务端执行)。 */
items: TransferBacklogItem[];
/** 筛选后全量计数(分页器数据源;不传视为 0=隐藏分页条)。 */
total?: number;
busy?: boolean;
/** 初始结果筛选(首页计数卡切片进入:closed 卡落「已关闭」切片等)。 */
initialFilter?: 'all' | 'recoverable' | 'closed' | 'unknown';
@@ -31,12 +45,19 @@ const emit = defineEmits<{
requery: [itemIds: number[]];
close: [item: TransferBacklogItem];
batchClose: [itemIds: number[]];
/** 查询变更(翻页/筛选/首挂载):宿主据此调用 loadBacklog 拉取对应页。 */
'query-change': [query: { page: number; keyword: string; resultFilter: 'all' | 'recoverable' | 'closed' | 'unknown' }];
}>();
/** 勾选集合(本地视图态;仅可恢复行可勾选)。 */
/** 每页行数(与组合式函数 loadBacklog 默认 pageSize 同源:TRANSFER_PAGE_SIZE)。 */
const PAGE_SIZE = TRANSFER_PAGE_SIZE;
/** 勾选集合(本地视图态;仅可恢复行可勾选;跨页保留——批量计数=勾选总数,
* 行状态变化由后端批量端点逐行校验兜底)。 */
const selectedIds = ref<Set<number>>(new Set());
const keyword = ref('');
const resultFilter = ref<'all' | 'recoverable' | 'closed' | 'unknown'>(props.initialFilter ?? 'all');
const currentPage = ref(1);
function isActionable(item: TransferBacklogItem): boolean {
return item.status === 'blocked_recoverable';
@@ -50,27 +71,10 @@ function isFileRemoved(item: TransferBacklogItem): boolean {
return item.result_code === 'blocked_file_removed';
}
const filtered = computed(() =>
props.items.filter((item) => {
const kw = keyword.value.trim().toLowerCase();
if (kw) {
const haystack = [item.invoice_no, item.material_no, item.material_name, item.source_code]
.map((value) => String(value ?? '').toLowerCase());
if (!haystack.some((value) => value.includes(kw))) return false;
}
if (resultFilter.value === 'recoverable' && item.status !== 'blocked_recoverable') return false;
if (resultFilter.value === 'closed' && item.status !== 'manually_closed') return false;
if (resultFilter.value === 'unknown' && item.status !== 'result_unknown') return false;
return true;
}),
);
const selectedActionableIds = computed(() =>
filtered.value.filter((item) => isActionable(item) && selectedIds.value.has(item.item_id)).map((item) => item.item_id),
);
const selectedActionableIds = computed(() => [...selectedIds.value]);
const allFilteredSelected = computed(() => {
const actionable = filtered.value.filter(isActionable);
const actionable = props.items.filter(isActionable);
return actionable.length > 0 && actionable.every((item) => selectedIds.value.has(item.item_id));
});
@@ -83,7 +87,7 @@ function toggleRow(item: TransferBacklogItem, checked: boolean) {
function toggleAll(checked: boolean) {
const next = new Set(selectedIds.value);
for (const item of filtered.value.filter(isActionable)) {
for (const item of props.items.filter(isActionable)) {
if (checked) next.add(item.item_id);
else next.delete(item.item_id);
}
@@ -94,12 +98,39 @@ function clearSelection() {
selectedIds.value = new Set();
}
/** 行操作后/刷新后清理已消失行的勾选残留。 */
function pruneSelection() {
const alive = new Set(props.items.map((item) => item.item_id));
selectedIds.value = new Set([...selectedIds.value].filter((id) => alive.has(id)));
// [STEP 1] 查询上抛:翻页/筛选立即上抛,关键字 300ms 防抖(服务端逐次查询防抖动);
// 首挂载即上抛初始切片查询(宿主不再兜底首拉,避免双请求)。
function emitQuery() {
emit('query-change', { page: currentPage.value, keyword: keyword.value.trim(), resultFilter: resultFilter.value });
}
defineExpose({ pruneSelection });
watch(currentPage, () => emitQuery());
watch(resultFilter, () => {
if (currentPage.value !== 1) currentPage.value = 1; // 翻页 watch 负责上抛
else emitQuery();
});
let keywordTimer: ReturnType<typeof setTimeout> | undefined;
watch(keyword, () => {
clearTimeout(keywordTimer);
keywordTimer = setTimeout(() => {
if (currentPage.value !== 1) currentPage.value = 1;
else emitQuery();
}, 300);
});
onBeforeUnmount(() => clearTimeout(keywordTimer));
onMounted(() => emitQuery());
// [STEP 2] 行操作/刷新后总行数变小:收拢当前页防空白页(越界时回落末页并重查)。
watch(() => props.total, (total = 0) => {
const maxPage = Math.max(1, Math.ceil(total / PAGE_SIZE));
if (currentPage.value > maxPage) {
currentPage.value = maxPage; // 翻页 watch 负责上抛
}
});
function agingLabel(level: string): string {
const map: Record<string, string> = {
@@ -116,6 +147,16 @@ function rowKey(item: TransferBacklogItem): string {
return `${item.item_id}|${item.invoice_no}`;
}
/**
* el-table 行类:注入行定位类(替代旧行 testid)+ 不可操作行置灰(同旧行样式)。
*/
function rowClassName({ row }: { row: TransferBacklogItem }): string {
return [
`transfer-backlog-row-${row.invoice_no}`,
isActionable(row) ? '' : 'bg-surface-soft text-muted',
].filter(Boolean).join(' ');
}
/** 结果徽标文案键:可恢复行按 result_code 细分(blocked_file_removed=文件已移除),其余按状态。 */
function resultLabelKey(item: TransferBacklogItem): string {
if (item.status === 'result_unknown') return 'chat.transfer.resultUnknown';
@@ -140,7 +181,7 @@ function resultLabelKey(item: TransferBacklogItem): string {
</button>
</div>
<!-- 批量操作条:勾选 ≥1 行时原位替换筛选区 -->
<!-- 批量操作条:勾选 ≥1 行时原位替换筛选区(跨页勾选同样计入) -->
<div v-if="selectedActionableIds.length" class="mb-2 flex flex-wrap items-center gap-2">
<span class="text-xs font-bold text-secondary" data-testid="transfer-backlog-selected-count">
{{ $t('chat.transfer.selectedRows', { count: selectedActionableIds.length }) }}
@@ -193,138 +234,156 @@ function resultLabelKey(item: TransferBacklogItem): string {
:placeholder="$t('chat.transfer.filterPlaceholder')"
data-testid="transfer-backlog-filter"
/>
<select
v-model="resultFilter"
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
data-testid="transfer-backlog-result-filter"
>
<option value="all">{{ $t('chat.transfer.filterAll') }}</option>
<option value="recoverable">{{ $t('chat.transfer.homeRecoverable') }}</option>
<option value="closed">{{ $t('chat.transfer.homeClosed') }}</option>
<option value="unknown">{{ $t('chat.transfer.homeUnknown') }}</option>
</select>
<!-- el-select 默认 width:100%(EP 样式会覆盖工具类),外包定宽容器锁定紧凑尺寸,
与关键字输入并排一行,避免筛选区独占两行 -->
<div class="w-32 shrink-0">
<el-select
v-model="resultFilter"
size="small"
data-testid="transfer-backlog-result-filter"
:aria-label="$t('chat.transfer.colResult')"
>
<el-option value="all" :label="$t('chat.transfer.filterAll')" />
<el-option value="recoverable" :label="$t('chat.transfer.homeRecoverable')" />
<el-option value="closed" :label="$t('chat.transfer.homeClosed')" />
<el-option value="unknown" :label="$t('chat.transfer.homeUnknown')" />
</el-select>
</div>
</div>
<div v-if="filtered.length" class="overflow-x-auto">
<table class="w-full min-w-[1360px] text-xs" data-testid="transfer-backlog-table">
<thead>
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
<th class="p-2">
<input
type="checkbox"
:checked="allFilteredSelected"
data-testid="transfer-backlog-select-all"
@change="toggleAll(($event.target as HTMLInputElement).checked)"
/>
</th>
<!-- 表头全列 nowrap:防「拨出仓库/匹配结果」等折行;品名列吃剩余宽度 -->
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromQty') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToQty') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colResult') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAging') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAction') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="item in filtered"
:key="rowKey(item)"
class="border-b border-subtle"
:class="{ 'bg-surface-soft text-muted': !isActionable(item) }"
:data-testid="`transfer-backlog-${item.invoice_no}`"
<!-- EP 表格壳:数据=服务端返回的当前页切片;横向滚动由 el-table 内建(列 min-width 撑开) -->
<el-table
v-if="items.length"
:data="items"
:row-key="rowKey"
:row-class-name="rowClassName"
size="small"
class="text-xs"
data-testid="transfer-backlog-table"
>
<el-table-column width="36" class-name="whitespace-nowrap">
<template #header>
<input
type="checkbox"
:checked="allFilteredSelected"
data-testid="transfer-backlog-select-all"
@change="toggleAll(($event.target as HTMLInputElement).checked)"
/>
</template>
<template #default="{ row }">
<input
type="checkbox"
:checked="selectedIds.has(row.item_id)"
:disabled="!isActionable(row as TransferBacklogItem) || busy"
:data-testid="`transfer-backlog-check-${row.invoice_no}`"
@change="toggleRow(row as TransferBacklogItem, ($event.target as HTMLInputElement).checked)"
/>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.colInvoice')" prop="invoice_no" min-width="130" class-name="whitespace-nowrap">
<template #default="{ row }">
<span class="font-semibold">{{ row.invoice_no }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="100" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.colName')" min-width="140">
<template #default="{ row }">{{ row.material_name || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" min-width="110" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.from_warehouse || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="110" class-name="whitespace-nowrap">
<template #default="{ row }">{{ deriveBatchNo(row.lot_no ?? '') || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="90" class-name="whitespace-nowrap">
<template #default="{ row }">{{ formatQuantity(row.external_quantity) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colToWarehouse')" min-width="110" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.to_warehouse || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" class-name="whitespace-nowrap">
<template #default="{ row }">{{ formatQuantity(row.movement_quantity) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colResult')" min-width="110">
<template #default="{ row }">
<span
class="whitespace-nowrap rounded-full px-2 py-0.5 font-bold"
:class="{
'bg-red-50 text-red-700': row.status === 'blocked_recoverable',
'bg-amber-50 text-amber-700': row.status === 'result_unknown',
'bg-surface-soft text-muted': row.status === 'manually_closed',
}"
:title="row.reason || undefined"
data-testid="transfer-backlog-result"
>
<td class="p-2">
<input
type="checkbox"
:checked="selectedIds.has(item.item_id)"
:disabled="!isActionable(item) || busy"
:data-testid="`transfer-backlog-check-${item.invoice_no}`"
@change="toggleRow(item, ($event.target as HTMLInputElement).checked)"
/>
</td>
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行;
操作列三按钮保持一行 -->
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ item.material_no }}</td>
<td class="p-2">{{ item.material_name || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ item.from_warehouse || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ deriveBatchNo(item.lot_no ?? '') || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.external_quantity) }}</td>
<td class="whitespace-nowrap p-2">{{ item.to_warehouse || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.receipt_quantity) }}</td>
<td class="p-2">
<span
class="whitespace-nowrap rounded-full px-2 py-0.5 font-bold"
:class="{
'bg-red-50 text-red-700': item.status === 'blocked_recoverable',
'bg-amber-50 text-amber-700': item.status === 'result_unknown',
'bg-surface-soft text-muted': item.status === 'manually_closed',
}"
:title="item.reason || undefined"
data-testid="transfer-backlog-result"
>
{{
$t(resultLabelKey(item))
}}
</span>
</td>
<td class="whitespace-nowrap p-2">{{ $t(agingLabel(item.aging_level)) }}</td>
<td class="whitespace-nowrap p-2">
<template v-if="isActionable(item)">
<!-- 失效行(文件已移除)隐藏重查/恢复处理:重查会被后端拒绝
(TRANSFER.RETRY_NOT_ALLOWED),恢复处理也无济于事,只留关闭出口 -->
<button
v-if="!isFileRemoved(item)"
type="button"
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
:data-testid="`transfer-backlog-requery-${item.invoice_no}`"
:disabled="busy"
@click="emit('retry', item.item_id)"
>
{{ $t('chat.transfer.requeryRow') }}
</button>
<button
v-if="!isFileRemoved(item)"
type="button"
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
:title="$t('chat.transfer.resumeAction')"
:data-testid="`transfer-backlog-resume-${item.invoice_no}`"
:disabled="busy"
@click="emit('resume', [item.item_id])"
>
{{ $t('chat.transfer.resumeActionShort') }}
</button>
<button
type="button"
class="rounded border border-red-200 px-1 py-0.5 text-[10px] font-bold text-red-600 transition hover:bg-red-50 disabled:opacity-40"
:title="$t('chat.transfer.manualClose')"
:data-testid="`transfer-backlog-close-${item.invoice_no}`"
:disabled="busy"
@click="emit('close', item)"
>
{{ $t('chat.transfer.manualCloseShort') }}
</button>
</template>
<span v-else-if="item.status === 'result_unknown'" class="text-[11px] text-muted">
{{ $t('chat.transfer.resultUnknownReadonly') }}
</span>
</td>
</tr>
</tbody>
</table>
</div>
{{ $t(resultLabelKey(row as TransferBacklogItem)) }}
</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colAging')" min-width="90" class-name="whitespace-nowrap">
<template #default="{ row }">{{ $t(agingLabel(row.aging_level)) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colAction')" min-width="150" class-name="whitespace-nowrap">
<template #default="{ row }">
<template v-if="isActionable(row as TransferBacklogItem)">
<!-- 失效行(文件已移除)隐藏重查/恢复处理:重查会被后端拒绝
(TRANSFER.RETRY_NOT_ALLOWED),恢复处理也无济于事,只留关闭出口 -->
<button
v-if="!isFileRemoved(row as TransferBacklogItem)"
type="button"
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
:data-testid="`transfer-backlog-requery-${row.invoice_no}`"
:disabled="busy"
@click="emit('retry', row.item_id)"
>
{{ $t('chat.transfer.requeryRow') }}
</button>
<button
v-if="!isFileRemoved(row as TransferBacklogItem)"
type="button"
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
:title="$t('chat.transfer.resumeAction')"
:data-testid="`transfer-backlog-resume-${row.invoice_no}`"
:disabled="busy"
@click="emit('resume', [row.item_id])"
>
{{ $t('chat.transfer.resumeActionShort') }}
</button>
<button
type="button"
class="rounded border border-red-200 px-1 py-0.5 text-[10px] font-bold text-red-600 transition hover:bg-red-50 disabled:opacity-40"
:title="$t('chat.transfer.manualClose')"
:data-testid="`transfer-backlog-close-${row.invoice_no}`"
:disabled="busy"
@click="emit('close', row as TransferBacklogItem)"
>
{{ $t('chat.transfer.manualCloseShort') }}
</button>
</template>
<span v-else-if="row.status === 'result_unknown'" class="text-[11px] text-muted">
{{ $t('chat.transfer.resultUnknownReadonly') }}
</span>
</template>
</el-table-column>
</el-table>
<div v-else class="rounded-lg bg-surface-soft p-3 text-xs text-muted">
{{ $t('chat.transfer.noBacklog') }}
</div>
<!-- 服务端分页条(单页时隐藏):total=筛选后全量计数;文案走全局 ElConfigProvider 四语言 -->
<el-pagination
v-if="(total ?? 0) > PAGE_SIZE"
:current-page="currentPage"
:total="total ?? 0"
:page-size="PAGE_SIZE"
layout="total, prev, pager, next, jumper"
size="small"
class="mt-2 justify-end"
data-testid="transfer-backlog-pagination"
@current-change="(page: number) => { currentPage = page }"
/>
</div>
</template>
@@ -0,0 +1,58 @@
/**
* features/chat/components/messages/TransferExecutableCard.spec.ts
* 用途:验证可调拨明细卡的客户端分页——50/页切片渲染、翻页余量、
* 关键字筛选变更重置回第 1 页(防"停在末页筛选后空白")。
* 依赖:@vue/test-utils、i18n。纯组件 props 驱动,无需 mock API。
* 逻辑:分页为纯渲染切片,勾选/批量语义不在本套件(由 MessageView 接线覆盖)。
*/
import { mount, flushPromises } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import i18n from '@/i18n';
import TransferExecutableCard from './TransferExecutableCard.vue';
function makeItems(count: number) {
return Array.from({ length: count }, (_, i) => ({
item_id: i + 1,
source_code: 'DBS-AWSBI',
material_no: `MAT-${i + 1}`,
material_name: '物料',
specification: '',
invoice_no: `INV-${String(i + 1).padStart(3, '0')}`,
movement_date: '2026-09-01',
from_warehouse: 'DBS-TRANSIT',
from_quantity: '1',
to_warehouse: 'HUB-CN01',
to_quantity: '1',
result: 'executable',
lot_no: 'LOT-1',
}));
}
function mountCard(items: ReturnType<typeof makeItems>) {
return mount(TransferExecutableCard, {
props: { items },
global: { plugins: [i18n] },
});
}
describe('TransferExecutableCard 客户端分页', () => {
it('55 行只渲染首页 50 行,翻页渲染余量 5 行', async () => {
const wrapper = mountCard(makeItems(55));
// [断言意图] 首页切片=50 行(非全量 55),DOM 规模被页大小约束。
expect(wrapper.findAll('tbody tr')).toHaveLength(50);
await wrapper.find('.btn-next').trigger('click');
await flushPromises();
expect(wrapper.findAll('tbody tr')).toHaveLength(5);
});
it('关键字筛选变更重置回第 1 页(末页筛选不再空白)', async () => {
// [断言意图] 停在第 2 页(余量 5 行)时输入关键字:命中 11 行
// (MAT-1、MAT-10~19),若未重置页码则第 2 页切片为空——行数断言同时锁两件事。
const wrapper = mountCard(makeItems(55));
await wrapper.find('.btn-next').trigger('click');
expect(wrapper.findAll('tbody tr')).toHaveLength(5);
await wrapper.find('[data-testid="transfer-executable-filter"]').setValue('MAT-1');
await flushPromises();
expect(wrapper.findAll('tbody tr')).toHaveLength(11);
});
});
@@ -1,13 +1,17 @@
<!--
features/chat/components/messages/TransferExecutableCard.vue
用途:可调拨明细卡——全局可执行行队列(跨匹配范围):勾选明细行后按行生成调拨单。
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo。
逻辑:行由后端按业务稳定键排序(收料日期→Invoice→创建时间);勾选为卡片本地态;
依赖:Element Plus ElPagination(客户端分页,2026-10-16)、props.items、
i18n chat.transfer.*、transferBatch.deriveBatchNo。
逻辑:行由后端按业务稳定键排序(异动日期→Invoice→创建时间);勾选为卡片本地态;
stale/file_current 行置灰提示(执行门禁在后端,失败经 BusinessError 展示);
无 item_id 的历史回放行禁选。
客户端分页(2026-10-16):集合天然有界(仅当日成熟可执行行)但为防增长后
DOM 失控,50/页切片渲染;关键字筛选变更回第 1 页,勾选集合跨页保留。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { computed, ref, watch } from 'vue';
import { ElPagination } from 'element-plus';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import { parseApiUtcDate } from '@/shared/utils/dateTime';
@@ -24,10 +28,14 @@ const emit = defineEmits<{
requery: [itemIds: number[]];
}>();
/** 勾选集合(本地视图态,按明细行 item_id)。 */
/** 勾选集合(本地视图态,按明细行 item_id;跨页保留——批量计数按全量过滤行)。 */
const selectedIds = ref<Set<number>>(new Set());
const keyword = ref('');
/** 客户端分页(50/页):可执行池量级小但无硬上限,切片渲染防 DOM 失控。 */
const PAGE_SIZE = 50;
const currentPage = ref(1);
const filtered = computed(() =>
props.items.filter((item) => {
const kw = keyword.value.trim().toLowerCase();
@@ -38,6 +46,19 @@ const filtered = computed(() =>
}),
);
const pagedItems = computed(() =>
filtered.value.slice((currentPage.value - 1) * PAGE_SIZE, currentPage.value * PAGE_SIZE),
);
// 筛选变更回第 1 页;刷新后行数减少时收拢当前页防空白页
watch(keyword, () => {
currentPage.value = 1;
});
watch(() => filtered.value.length, (len) => {
const maxPage = Math.max(1, Math.ceil(len / PAGE_SIZE));
if (currentPage.value > maxPage) currentPage.value = maxPage;
});
const checked = computed(() =>
filtered.value.filter((item) => item.item_id != null && selectedIds.value.has(item.item_id)),
);
@@ -132,7 +153,7 @@ function checkedTime(item: TransferMatchingItem): string {
<!-- 表头全列 nowrap:防「拨出仓库/投入数量」等折行;品名列吃剩余宽度 -->
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMovementDate') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
@@ -146,7 +167,7 @@ function checkedTime(item: TransferMatchingItem): string {
</thead>
<tbody>
<tr
v-for="item in filtered"
v-for="item in pagedItems"
:key="rowKey(item)"
class="border-b border-subtle"
:class="{ 'bg-surface-soft text-muted': item.stale || item.file_current === false }"
@@ -164,7 +185,7 @@ function checkedTime(item: TransferMatchingItem): string {
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行 -->
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ item.movement_date || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ item.material_no }}</td>
<td class="p-2">{{ item.material_name }}</td>
<td class="whitespace-nowrap p-2">{{ item.from_warehouse }}</td>
@@ -197,7 +218,18 @@ function checkedTime(item: TransferMatchingItem): string {
</tbody>
</table>
</div>
<div v-else class="rounded-lg bg-surface-soft p-3 text-xs text-muted" data-testid="transfer-executable-empty">
<!-- 客户端分页(单页时隐藏):文案走全局 ElConfigProvider 四语言 locale -->
<el-pagination
v-if="filtered.length > PAGE_SIZE"
v-model:current-page="currentPage"
:total="filtered.length"
:page-size="PAGE_SIZE"
layout="total, prev, pager, next, jumper"
size="small"
class="mt-2 justify-end"
data-testid="transfer-executable-pagination"
/>
<div v-else-if="!filtered.length" class="rounded-lg bg-surface-soft p-3 text-xs text-muted" data-testid="transfer-executable-empty">
{{ $t('chat.transfer.executableEmpty') }}
</div>
@@ -29,7 +29,7 @@ const FAILED_TICKET = {
submit_timestamp: '2026-08-06 09:00:00',
status: 'business_failed',
status_group: 'failed',
receipt_date: '2026-08-05',
movement_date: '2026-08-05',
from_warehouse: 'DBS-TRANSIT',
to_warehouse: 'HUB-CN01',
erp_document_no: null,
@@ -47,7 +47,7 @@ const UNKNOWN_TICKET = {
submit_timestamp: '2026-08-06 10:00:00',
status: 'result_unknown',
status_group: 'result_unknown',
receipt_date: '2026-08-05',
movement_date: '2026-08-05',
from_warehouse: 'DBS-TRANSIT',
to_warehouse: 'HUB-CN02',
erp_document_no: null,
@@ -6,20 +6,25 @@
result_unknown 行仅 [重新触发],D11 无关闭入口;动作按钮与状态徽标
同簇靠右、紧跟状态展示,2026-09-29 布局调整)+ 上一页/下一页分页;
无自动轮询(进入拉一次 + 手动刷新)。
依赖:transfer.api(fetchExecutedOrders/closeTransferDocument/retriggerTransferDocument)、
依赖:Element Plus ElDialog/ElTable/ElTableColumn(2026-10-16 EP 组件化:
关闭单弹层壳与展开明细表格迁 EP,单列表卡片形态与交互不变)、
transfer.api(fetchExecutedOrders/closeTransferDocument/retriggerTransferDocument)、
transferBatch.deriveBatchNo(拨出批号展示侧 WTP→HOW 镜像)、
useMessage、i18n chat.transfer.homeExecuted.*。
逻辑:props.initialGroup(首页卡片点击带入的初始分组,''=全部)→ mounted→load;
[全部] 点击→清 statusGroup+page=1;日期范围变更→page=1+load(后端按收料
[全部] 点击→清 statusGroup+page=1;日期范围变更→page=1+load(后端按异动
日期过滤);[返回]→emit('back') 由首页面板切回卡片视图;关闭单走 D18
原因必填弹窗(同单行影响面 + 「关闭调拨单≠ERP 无单」红线)→close→load。
行为与融合卡(TransferResultCard)一致。列表排序(收料日期→数据源→库位
弹层壳禁 ESC/遮罩点击/X 关闭(仅收起/确认按钮可关,防误触关闭高危操作)。
行为与融合卡(TransferResultCard)一致。列表排序(异动日期→数据源→库位
升序)与分组计数恒全量由后端保证,本视图不消费计数
(计数展示在首页 TransferExecutedCards)。
-->
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { ElDialog, ElTable, ElTableColumn } from 'element-plus';
import { transferDialogShellAttrs } from './transferDialogShell';
import { useMessage } from '@/shared/composables/useMessage';
import {
closeTransferDocument,
@@ -256,7 +261,7 @@ onMounted(() => { void load(); });
>
<div class="flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-xs">
<span class="font-semibold text-secondary">
{{ order.receipt_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
{{ order.movement_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
· {{ $t('chat.transfer.materialCount', { count: order.items.length }) }}
</span>
<!-- 状态徽标与单据级行内动作(D11/D18)同簇靠右:处置动作紧跟状态,扫读动线「状态→处置」 -->
@@ -306,34 +311,25 @@ onMounted(() => { void load(); });
</div>
</div>
<!-- 展开明细(invoice 粒度行集) -->
<!-- 展开明细(invoice 粒度行集;EP 表格壳:空态/样式与业务表格一致) -->
<div
v-if="expandedDocNo === order.doc_no"
class="border-t border-subtle px-3 py-2"
:data-testid="`transfer-executed-items-${order.doc_no}`"
>
<table class="w-full text-xs">
<thead>
<tr class="text-left text-[11px] text-muted">
<th class="p-1">{{ $t('chat.transfer.colInvoice') }}</th>
<th class="p-1">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="p-1">{{ $t('chat.transfer.colName') }}</th>
<th class="p-1">{{ $t('chat.transfer.colFromBatch') }}</th>
<th class="p-1">{{ $t('chat.transfer.colToQty') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="item in order.items" :key="`${order.doc_no}|${item.invoice_no}|${item.material_no}`" class="border-t border-subtle">
<td class="p-1">{{ item.invoice_no }}</td>
<td class="p-1">{{ item.material_no }}</td>
<td class="p-1">{{ item.material_name }}</td>
<!-- 拨出批号展示外部形态(WTP→HOW 镜像转换,与匹配卡/可调拨明细/待办池同规则;
行上数据保持文件原形态,转换只发生在展示侧) -->
<td class="p-1">{{ deriveBatchNo(item.lot_no) || '—' }}</td>
<td class="p-1">{{ item.quantity }}<template v-if="item.unit"> {{ item.unit }}</template></td>
</tr>
</tbody>
</table>
<el-table :data="order.items" size="small" class="text-xs">
<el-table-column :label="$t('chat.transfer.colInvoice')" prop="invoice_no" min-width="120" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="140" />
<!-- 拨出批号展示外部形态(WTP→HOW 镜像转换,与匹配卡/可调拨明细/待办池同规则;
行上数据保持文件原形态,转换只发生在展示侧) -->
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" class-name="whitespace-nowrap">
<template #default="{ row }">{{ deriveBatchNo(row.lot_no) || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.quantity }}<template v-if="row.unit"> {{ row.unit }}</template></template>
</el-table-column>
</el-table>
</div>
</li>
</ul>
@@ -363,57 +359,63 @@ onMounted(() => { void load(); });
</button>
</div>
<!-- 关闭单确认弹层(D18:原因必填 + 同单行影响面 + 「关闭调拨单≠ERP 无单」红线) -->
<div
<!-- 关闭单确认弹层(D18:原因必填 + 同单行影响面 + 「关闭调拨单≠ERP 无单」红线)。
v-if + model-value=true:打开即渲染、关闭即卸载(无过渡等待,测试语义同旧行为) -->
<el-dialog
v-if="closeTarget"
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
data-testid="transfer-executed-close-dialog"
:model-value="true"
v-bind="transferDialogShellAttrs"
width="28rem"
class="rounded-2xl bg-surface"
>
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
<h3 class="text-base font-bold text-primary">
<template #header>
<h3
class="text-base font-bold text-primary"
data-testid="transfer-executed-close-dialog"
>
{{ $t('chat.transfer.homeExecuted.closeDialog.title', { docNo: closeTarget.doc_no }) }}
</h3>
<p class="mt-1 text-xs text-muted">
{{ $t('chat.transfer.homeExecuted.closeDialog.redlineReopen') }}
</p>
<ul class="mt-2 max-h-32 overflow-y-auto rounded-lg bg-surface-soft p-2 text-[11px] text-secondary">
<li v-for="item in closeTarget.items" :key="`${item.invoice_no}|${item.material_no}`">
{{ item.invoice_no }} · {{ item.material_no }} {{ item.material_name }} ·
{{ item.quantity }}<template v-if="item.unit"> {{ item.unit }}</template>
</li>
</ul>
<ul class="mt-2 list-disc pl-4 text-xs font-bold text-red-600">
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineWhole') }}</li>
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineResidue') }}</li>
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineErpCheck') }}</li>
</ul>
<textarea
v-model="closeDialog.reason"
rows="3"
class="mt-3 w-full rounded-lg border border-default p-2 text-sm"
:placeholder="$t('chat.transfer.homeExecuted.closeDialog.reasonRequired')"
data-testid="transfer-executed-close-reason"
/>
<div class="mt-4 flex justify-end gap-2">
<button
type="button"
class="rounded-lg border border-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
data-testid="transfer-executed-close-dismiss"
@click="closeDialog = { docNo: '', reason: '' }"
>
{{ $t('chat.transfer.orderClose.dismiss') }}
</button>
<button
type="button"
class="rounded-lg bg-red-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-40"
data-testid="transfer-executed-close-confirm"
:disabled="!closeDialog.reason.trim() || actionBusy"
@click="confirmCloseOrder"
>
{{ $t('chat.transfer.homeExecuted.closeDialog.confirm') }}
</button>
</div>
</template>
<p class="text-xs text-muted">
{{ $t('chat.transfer.homeExecuted.closeDialog.redlineReopen') }}
</p>
<ul class="mt-2 max-h-32 overflow-y-auto rounded-lg bg-surface-soft p-2 text-[11px] text-secondary">
<li v-for="item in closeTarget.items" :key="`${item.invoice_no}|${item.material_no}`">
{{ item.invoice_no }} · {{ item.material_no }} {{ item.material_name }} ·
{{ item.quantity }}<template v-if="item.unit"> {{ item.unit }}</template>
</li>
</ul>
<ul class="mt-2 list-disc pl-4 text-xs font-bold text-red-600">
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineWhole') }}</li>
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineResidue') }}</li>
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineErpCheck') }}</li>
</ul>
<textarea
v-model="closeDialog.reason"
rows="3"
class="mt-3 w-full rounded-lg border border-default p-2 text-sm"
:placeholder="$t('chat.transfer.homeExecuted.closeDialog.reasonRequired')"
data-testid="transfer-executed-close-reason"
/>
<div class="mt-4 flex justify-end gap-2">
<button
type="button"
class="rounded-lg border border-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
data-testid="transfer-executed-close-dismiss"
@click="closeDialog = { docNo: '', reason: '' }"
>
{{ $t('chat.transfer.orderClose.dismiss') }}
</button>
<button
type="button"
class="rounded-lg bg-red-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-40"
data-testid="transfer-executed-close-confirm"
:disabled="!closeDialog.reason.trim() || actionBusy"
@click="confirmCloseOrder"
>
{{ $t('chat.transfer.homeExecuted.closeDialog.confirm') }}
</button>
</div>
</div>
</el-dialog>
</section>
</template>
@@ -1,6 +1,6 @@
<!--
features/chat/components/messages/TransferFileProgressCard.vue
用途:来源实例级收料文件准备进度(决策 18:来源隔离展示,不伪造总百分比)。
用途:来源实例级入站文件准备进度(决策 18:来源隔离展示,不伪造总百分比)。
依赖:props.sources、i18n chat.transfer.*。
逻辑:按来源显示 file_ready / waiting_rpa_callback / failed 阶段与文件信息。
-->
@@ -18,21 +18,25 @@ const api = vi.hoisted(() => ({
getTransferRun: vi.fn(),
retryTransferItem: vi.fn(),
manualCloseTransferItem: vi.fn(),
downloadTransferReceiptFiles: vi.fn(),
downloadTransferInboundFiles: vi.fn(),
downloadTransferErpInventory: vi.fn(),
downloadTransferExceptions: vi.fn(),
listTransferBacklog: vi.fn(),
listTransferBacklogPage: vi.fn(),
getTransferBacklogSummary: vi.fn(),
listPendingMatchRecords: vi.fn(),
listPendingMatchRecordsPage: vi.fn(),
listTransferSources: vi.fn(),
fetchTransferTypes: vi.fn(),
listExecutableTransferItems: vi.fn(),
fetchExecutedOrders: vi.fn(),
// Task 8 维护链路端点(待匹配抽屉「清空重解析」;本套件不触发,仅补齐 mock 模块形状)
fetchPendingMatchReparsePreview: vi.fn(),
reparsePendingMatch: vi.fn(),
}));
vi.mock('@/features/chat/api/transfer.api', () => api);
import TransferHomePanel from './TransferHomePanel.vue';
import TransferBacklogSummaryCard from './TransferBacklogSummaryCard.vue';
function mountHome() {
return mount(TransferHomePanel, {
@@ -47,10 +51,10 @@ describe('TransferHomePanel chat home entry', () => {
api.getTransferBacklogSummary.mockResolvedValue({
recoverable: 6, closed: 2, unknown: 1, pending_match: 3, aging: { warn_3d: 3, escalate_5d: 2, critical_7d: 1 },
});
api.listTransferBacklog.mockResolvedValue([]);
api.listTransferBacklogPage.mockResolvedValue({ items: [], total: 0, page: 1, page_size: 20 });
api.listExecutableTransferItems.mockResolvedValue({ items: [], counts: { executable_count: 0 } });
// 「待匹配」桶只读清单(D16 第 4 卡抽屉数据源;默认空,专项用例自行覆盖)。
api.listPendingMatchRecords.mockResolvedValue([]);
api.listPendingMatchRecordsPage.mockResolvedValue({ records: [], total: 0, page: 1, page_size: 20 });
api.listExecutableTransferItems.mockResolvedValue({ items: [], counts: { executable_count: 0 } });
api.listTransferSources.mockResolvedValue([
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
@@ -79,21 +83,21 @@ describe('TransferHomePanel chat home entry', () => {
expect(api.getTransferBacklogSummary).toHaveBeenCalled();
// [断言意图] 首屏只取计数:计数卡不消费全量待办列表(68.5kB 级),
// /backlog 全量列表延迟到切片子视图(TransferMessageView backlog 挂载)自行加载。
expect(api.listTransferBacklog).not.toHaveBeenCalled();
expect(api.listTransferBacklogPage).not.toHaveBeenCalled();
});
it('点击“匹配可调拨库存”今日待办入口独立触发来源选择卡(复用 TransferMessageView)', async () => {
api.createTransferMatching.mockResolvedValue({
matching_id: 'MTG-1', status: 'ready_to_execute', business_date: '2026-08-06',
eligible_receipt_date_to: '2026-08-05', expires_at: '',
counts: { file_invoice_count: 1, not_matured_count: 0, matched_count: 1, executable_count: 1, blocked_count: 0 },
expires_at: '',
counts: { file_invoice_count: 1, matched_count: 1, executable_count: 1, blocked_count: 0 },
estimated_transfer_quantity: '1200', estimated_external_write_count: 1, matching_hash: 'sha256:x',
});
api.getTransferMatching.mockResolvedValue({
summary: {
matching_id: 'MTG-1', status: 'ready_to_execute', business_date: '2026-08-06',
eligible_receipt_date_to: '2026-08-05', expires_at: '',
counts: { file_invoice_count: 1, not_matured_count: 0, matched_count: 1, executable_count: 1, blocked_count: 0 },
expires_at: '',
counts: { file_invoice_count: 1, matched_count: 1, executable_count: 1, blocked_count: 0 },
estimated_transfer_quantity: '1200', estimated_external_write_count: 1, matching_hash: 'sha256:x',
},
items: [{
@@ -114,16 +118,27 @@ describe('TransferHomePanel chat home entry', () => {
it('点击历史待办计数卡独立触发 backlog 卡片,并按计数卡切片初始筛选', async () => {
// [断言意图] 两张计数卡不再落入同一份全量列表:可恢复/已关闭
// 各自带对应 resultFilter 打开待处理池(否则 0 行的已关闭被 50 行可恢复淹没);
// 各自携带对应 resultFilter 打开待处理池(否则 0 行的已关闭被 50 行可恢复淹没);
// 结果未知无首页卡(2026-09-29),unknown 切片仅池内筛选可达。
api.listTransferBacklog.mockResolvedValue([
// 2026-10-16 服务端分页+筛选下推:mock 按查询参数返回对应切片,
// 同时验证切片条件真实透传到 API(query-change 接线端到端)。
const poolItems = [
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1',
status: 'blocked_recoverable', reason: '收料 1200 / ERP 1000', age_days: 1, aging_level: 'normal' },
status: 'blocked_recoverable', reason: '异动 1200 / ERP 1000', age_days: 1, aging_level: 'normal' },
{ item_id: 8, source_code: 'DBS-AWSBI', invoice_no: 'INV-002', material_no: 'MAT-2',
status: 'manually_closed', reason: '线下处理', age_days: 2, aging_level: 'closed' },
{ item_id: 9, source_code: 'DBS-AWSBI', invoice_no: 'INV-003', material_no: 'MAT-3',
status: 'result_unknown', reason: '待人工核实', age_days: 3, aging_level: 'result_unknown' },
]);
];
const filterStatus: Record<string, string> = {
recoverable: 'blocked_recoverable', closed: 'manually_closed', unknown: 'result_unknown',
};
api.listTransferBacklogPage.mockImplementation((query: { resultFilter?: string }) => {
const items = query.resultFilter && query.resultFilter !== 'all'
? poolItems.filter((entry) => entry.status === filterStatus[query.resultFilter as string])
: poolItems;
return Promise.resolve({ items, total: items.length, page: 1, page_size: 20 });
});
const wrapper = mountHome();
await flushPromises();
@@ -131,8 +146,10 @@ describe('TransferHomePanel chat home entry', () => {
await wrapper.find('[data-testid="transfer-home-recoverable"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="transfer-backlog-card"]').exists()).toBe(true);
expect(api.listTransferBacklog).toHaveBeenCalled();
expect((wrapper.find('[data-testid="transfer-backlog-result-filter"]').element as HTMLSelectElement).value).toBe('recoverable');
expect(api.listTransferBacklogPage).toHaveBeenCalled();
// [断言意图] 结果筛选迁 EP el-select(非原生 select),初始切片断言改走组件 prop
// (等价语义:计数卡切片落入对应 resultFilter)。
expect(wrapper.findComponent(TransferBacklogSummaryCard).props('initialFilter')).toBe('recoverable');
// 切片后仅可见对应状态行。
expect(wrapper.text()).toContain('INV-001');
expect(wrapper.text()).not.toContain('INV-002');
@@ -141,7 +158,7 @@ describe('TransferHomePanel chat home entry', () => {
await flushPromises();
await wrapper.find('[data-testid="transfer-home-closed"]').trigger('click');
await flushPromises();
expect((wrapper.find('[data-testid="transfer-backlog-result-filter"]').element as HTMLSelectElement).value).toBe('closed');
expect(wrapper.findComponent(TransferBacklogSummaryCard).props('initialFilter')).toBe('closed');
expect(wrapper.text()).toContain('INV-002');
expect(wrapper.text()).not.toContain('INV-001');
});
@@ -153,23 +170,27 @@ describe('TransferHomePanel chat home entry', () => {
expect(wrapper.find('[data-testid="transfer-home-pending-match"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="transfer-home-pending-match"]').text()).toContain('3');
// 首屏只取计数:抽屉清单延迟到进入子视图才拉。
expect(api.listPendingMatchRecords).not.toHaveBeenCalled();
expect(api.listPendingMatchRecordsPage).not.toHaveBeenCalled();
});
it('点击「待匹配」卡进只读抽屉:清单渲染、无勾选/执行入口,「去匹配」切来源选择卡', async () => {
api.listPendingMatchRecords.mockResolvedValue([
{ ledger_record_id: 101, doc_no: 'HOM-901', material_code: 'MAT-9', material_name: '未匹配物料',
movement_date: '2026-08-04', source_code: 'DBS-AWSBI', quantity: '55' },
]);
api.listPendingMatchRecordsPage.mockResolvedValue({
records: [
{ ledger_record_id: 101, doc_no: 'HOM-901', material_code: 'MAT-9', material_name: '未匹配物料',
movement_date: '2026-08-04', source_code: 'DBS-AWSBI', quantity: '55' },
],
total: 1, page: 1, page_size: 20,
});
const wrapper = mountHome();
await flushPromises();
await wrapper.find('[data-testid="transfer-home-pending-match"]').trigger('click');
await flushPromises();
// [断言意图] 抽屉=只读清单:进入子视图才拉清单,行字段可见。
expect(api.listPendingMatchRecords).toHaveBeenCalled();
expect(api.listPendingMatchRecordsPage).toHaveBeenCalled();
expect(wrapper.find('[data-testid="transfer-pending-match-panel"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="transfer-pending-match-HOM-901"]').exists()).toBe(true);
// [断言意图] 行定位:el-table 行类 transfer-pending-match-row-<doc_no>(EP 化后行无逐行 attr)。
expect(wrapper.find('.transfer-pending-match-row-HOM-901').exists()).toBe(true);
expect(wrapper.text()).toContain('MAT-9');
// [断言意图] 不可勾选执行:抽屉内无任何复选框与「生成调拨单」按钮(记录尚未匹配/未库存核对)。
expect(wrapper.find('[data-testid="transfer-pending-match-panel"]').find('input[type="checkbox"]').exists()).toBe(false);
@@ -2,7 +2,7 @@
features/chat/components/messages/TransferHomePanel.vue
用途:在途仓自动调拨 Agent 的 Chat 首页入口区——上区「库存匹配」动作入口,
中区「待办看板」四队列(待匹配/可调拨明细/待恢复异常/已人工关闭;「待匹配」
为 2026-10-14 D16 新增第 4 卡:已落档尚未匹配的外部收料记录,只读抽屉清单
为 2026-10-14 D16 新增第 4 卡:已落档尚未匹配的外部入站记录,只读抽屉清单
+「去匹配」引导,不可勾选执行;结果未知行 2026-09-29 起不再设首页卡——行级
在待办池只读且无独立出口,统一走下方执行看板的结果未知单据 [重新触发],
池内仍可经结果筛选查看),
@@ -68,7 +68,8 @@ async function loadHomeSummary() {
]);
}
if (view.value === 'pending-match') {
await transfer.loadPendingMatchRecords().catch(() => undefined);
// 服务端分页(2026-10-16):每次进入抽屉回到第 1 页(D16 不做缓存,匹配后数据即变)
await transfer.loadPendingMatchRecords({ page: 1 }).catch(() => undefined);
}
}
@@ -192,7 +193,9 @@ function goBack() {
</button>
<TransferPendingMatchPanel
:records="transfer.pendingMatchRecords.value"
:total="transfer.pendingMatchTotal.value"
@go-match="view = 'source-select'"
@page-change="(query) => transfer.loadPendingMatchRecords(query)"
@refresh="() => transfer.loadPendingMatchRecords()"
/>
</div>
@@ -1,11 +1,17 @@
<!--
features/chat/components/messages/TransferManualCloseDialog.vue
用途:人工关闭弹窗(原因必填;关闭后永久排除,历史保留);count>1 时按批量文案展示。
依赖:props(open/invoiceNo/count)、i18n chat.transfer.*。
依赖:Element Plus ElDialog(弹层壳:焦点圈定/滚动锁定/aria 语义)、
props(open/invoiceNo/count)、i18n chat.transfer.*。
逻辑:原因为空时确认按钮禁用;确认时 emit confirm(reason)。
弹层壳 2026-10-16 由原生 fixed 遮罩迁 EP el-dialog(视觉与交互不变:
禁 ESC/遮罩点击关闭与右上角 X,仅取消/确认按钮可关,防止误触关闭危险操作);
v-if+model-value=true 挂载即渲染(EP onMounted 对初值 true 同步置 rendered)。
-->
<script setup lang="ts">
import { ref, watch } from 'vue';
import { ElDialog } from 'element-plus';
import { transferDialogShellAttrs } from './transferDialogShell';
const props = defineProps<{
open: boolean;
@@ -30,45 +36,50 @@ watch(
</script>
<template>
<div
<el-dialog
v-if="open"
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
data-testid="transfer-manual-close-dialog"
:model-value="true"
v-bind="transferDialogShellAttrs"
width="28rem"
class="rounded-2xl bg-surface"
>
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
<h3 class="text-base font-bold text-primary">
<template #header>
<h3
class="text-base font-bold text-primary"
data-testid="transfer-manual-close-dialog"
>
{{ $t(count && count > 1 ? 'chat.transfer.batchCloseTitle' : 'chat.transfer.manualCloseTitle', count && count > 1 ? { count } : {}) }}
</h3>
<p class="mt-1 text-xs text-muted">
<template v-if="count && count > 1">{{ $t('chat.transfer.manualCloseHint') }}</template>
<template v-else>{{ invoiceNo }} · {{ $t('chat.transfer.manualCloseHint') }}</template>
</p>
<textarea
v-model="reason"
rows="3"
class="mt-3 w-full rounded-lg border border-default p-2 text-sm"
:placeholder="$t('chat.transfer.closeReasonPlaceholder')"
data-testid="transfer-close-reason"
/>
<div class="mt-4 flex justify-end gap-2">
<button
type="button"
class="rounded-lg border border-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
data-testid="transfer-close-cancel"
@click="emit('cancel')"
>
{{ $t('chat.transfer.cancel') }}
</button>
<button
type="button"
class="rounded-lg bg-brand-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
:disabled="!reason.trim()"
data-testid="transfer-close-confirm"
@click="emit('confirm', reason.trim())"
>
{{ $t('chat.transfer.confirmClose') }}
</button>
</div>
</template>
<p class="text-xs text-muted">
<template v-if="count && count > 1">{{ $t('chat.transfer.manualCloseHint') }}</template>
<template v-else>{{ invoiceNo }} · {{ $t('chat.transfer.manualCloseHint') }}</template>
</p>
<textarea
v-model="reason"
rows="3"
class="mt-3 w-full rounded-lg border border-default p-2 text-sm"
:placeholder="$t('chat.transfer.closeReasonPlaceholder')"
data-testid="transfer-close-reason"
/>
<div class="mt-4 flex justify-end gap-2">
<button
type="button"
class="rounded-lg border border-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
data-testid="transfer-close-cancel"
@click="emit('cancel')"
>
{{ $t('chat.transfer.cancel') }}
</button>
<button
type="button"
class="rounded-lg bg-brand-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
:disabled="!reason.trim()"
data-testid="transfer-close-confirm"
@click="emit('confirm', reason.trim())"
>
{{ $t('chat.transfer.confirmClose') }}
</button>
</div>
</div>
</el-dialog>
</template>
@@ -18,11 +18,9 @@ function buildSummary(): TransferMatchingSummary {
matching_id: 'MTG-T',
status: 'completed',
business_date: '2026-08-06',
eligible_receipt_date_to: '2026-08-06',
expires_at: '2026-08-06T23:59:59',
counts: {
file_invoice_count: 0,
not_matured_count: 0,
matched_count: 0,
executable_count: 0,
blocked_count: 0,
@@ -72,7 +70,7 @@ describe('TransferMatchCard 来源失败顶栏', () => {
});
/** [2026-10-12 单据数口径修正] 预计 ERP 单据数按执行建单五元组去重。
* 行分组键 = (external_org, source_code, receipt_date, from_warehouse,
* 行分组键 = (external_org, source_code, movement_date, from_warehouse,
* to_warehouse),与后端 execution_service.prepare_execution 同口径:
* 同组多行执行期合并一张 ERP 单,预估数不得等于可执行行数。 */
function buildItem(overrides: Partial<TransferMatchingItem>): TransferMatchingItem {
@@ -83,7 +81,7 @@ function buildItem(overrides: Partial<TransferMatchingItem>): TransferMatchingIt
material_name: '连接器组件',
specification: 'A 型',
invoice_no: 'HOM-001',
receipt_date: '2026-08-05',
movement_date: '2026-08-05',
from_warehouse: 'DBS-TRANSIT',
from_quantity: '100',
to_warehouse: 'HUB-CN01',
@@ -94,19 +92,19 @@ function buildItem(overrides: Partial<TransferMatchingItem>): TransferMatchingIt
};
}
/** 计数卡第 5 格 = 预计 ERP 单据(可执行/未成熟/阻断/数量/单据/待查/失效)。 */
/** 计数卡第 4 格 = 预计 ERP 单据(可执行/阻断/数量/单据/待查/失效)。 */
function estimateCardText(wrapper: ReturnType<typeof mount>): string {
const cells = wrapper.find('[data-testid="transfer-match-counts"]').findAll('div.rounded-lg');
return cells[4]?.text() ?? '';
return cells[3]?.text() ?? '';
}
describe('TransferMatchCard 预计 ERP 单据数(五元组去重)', () => {
const sameGroupA = buildItem({ item_id: 1, invoice_no: 'HOM-001' });
const sameGroupB = buildItem({ item_id: 2, invoice_no: 'HOX-002' });
const crossDate = buildItem({ item_id: 3, invoice_no: 'HOM-003', receipt_date: '2026-08-04' });
const crossDate = buildItem({ item_id: 3, invoice_no: 'HOM-003', movement_date: '2026-08-04' });
it('计数卡:同组两行 + 跨日一行 → 预估 2(不等于可执行行数 3)', () => {
// [断言意图] 锁定五元组去重口径:receipt_date 入键,同组合并、跨组拆分,
// [断言意图] 锁定五元组去重口径:movement_date 入键,同组合并、跨组拆分,
// 历史快照旧口径(=行数)持久值不再上屏。
const wrapper = mount(TransferMatchCard, {
props: {
@@ -2,11 +2,11 @@
features/chat/components/messages/TransferMatchCard.vue
用途:匹配卡——计数 + 来源失败提示 + 调拨明细表(含筛选)+ 勾选 + “直接生成调拨单”按钮。
依赖:props(summary/items/sources/selected/busy)、i18n chat.transfer.*。
逻辑:明细表渲染 filtered(关键字/结果筛选生效);阻断/未成熟项 checkbox 禁用;
逻辑:明细表渲染 filtered(关键字/结果筛选生效);阻断项 checkbox 禁用;
勾选键 = 明细行 item_id(历史回放行无 item_id 禁用防误选);
库存数量下方小字透出查询时刻(checked_at);stale 行置灰 + 重查提示;
file_current=false 行提示文件已更新(自动对齐语义);blocked_file_removed
徽标独立文案;pending_stock_check 行徽标「待查库存」(amber 与未成熟同色系);
徽标独立文案;pending_stock_check 行徽标「待查库存」(amber 提示色);
计数卡透出待查库存(pending_stock_check_count)/已失效(invalid_count),
历史回放缺省按 0 展示;blocked_file_removed 行退出主视图(表格不渲染),
表格下方折叠提示去待处理异常池处理——重查救不了已消失的行,主清单只留
@@ -18,7 +18,7 @@
顶栏按 error_code 客户端排除,历史卡片回放同样生效;
[2026-10-12 单据数口径修正] 预计 ERP 单据数(计数卡=全部可执行行、
生成按钮旁=勾选可执行行)按执行建单五元组 (external_org, source_code,
receipt_date, from_warehouse, to_warehouse) 去重实时计算(与后端
movement_date, from_warehouse, to_warehouse) 去重实时计算(与后端
execution_service 同键),同组多行合并一张单——原「=可执行行数」口径
高估单据数误导用户。
-->
@@ -74,7 +74,7 @@ const failedSources = computed(() =>
/** 筛选与全选状态(表格交互本地态,勾选集合仍由父级持有)。 */
const keyword = ref('');
const resultFilter = ref<'all' | 'executable' | 'blocked' | 'not_matured'>('all');
const resultFilter = ref<'all' | 'executable' | 'blocked'>('all');
function isBlocked(item: TransferMatchingItem): boolean {
return String(item.result).startsWith('blocked_');
@@ -113,7 +113,6 @@ const filtered = computed(() =>
}
if (resultFilter.value === 'executable' && item.result !== 'executable') return false;
if (resultFilter.value === 'blocked' && !isBlocked(item)) return false;
if (resultFilter.value === 'not_matured' && item.result !== 'not_matured') return false;
return true;
}),
);
@@ -151,13 +150,13 @@ const executableCheckedItemIds = computed(() =>
/** [2026-10-12 单据数口径修正] 执行建单五元组键(与后端 execution_service.
* prepare_execution 分组建单同键同 .trim() 规范化):(external_org, source_code,
* receipt_date, from_warehouse, to_warehouse),同组多行执行期合并一张 ERP 单。
* movement_date, from_warehouse, to_warehouse),同组多行执行期合并一张 ERP 单。
* 老卡片行缺 external_org 按 '' 参与(分组退化为四元组,仅跨组织同仓库配置下有差异)。 */
function documentGroupKey(item: TransferMatchingItem): string {
return [
(item.external_org ?? '').trim(),
(item.source_code ?? '').trim(),
(item.receipt_date ?? '').trim(),
(item.movement_date ?? '').trim(),
(item.from_warehouse ?? '').trim(),
(item.to_warehouse ?? '').trim(),
].join('\u001f');
@@ -195,7 +194,6 @@ function checkedAtLabel(item: TransferMatchingItem): string | null {
function resultLabel(result: string): string {
const map: Record<string, string> = {
executable: 'chat.transfer.resultExecutable',
not_matured: 'chat.transfer.resultNotMatured',
pending_stock_check: 'chat.transfer.resultPendingStockCheck',
blocked_quantity_mismatch: 'chat.transfer.resultBlocked',
blocked_inventory_not_found: 'chat.transfer.resultBlocked',
@@ -235,15 +233,11 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
<span class="text-xs text-muted">{{ $t('chat.transfer.businessDate') }}:{{ summary.business_date }}</span>
</div>
<div class="mb-3 grid grid-cols-2 gap-2 sm:grid-cols-7" data-testid="transfer-match-counts">
<div class="mb-3 grid grid-cols-2 gap-2 sm:grid-cols-6" data-testid="transfer-match-counts">
<div class="rounded-lg bg-surface-soft p-2 text-center">
<div class="text-lg font-black text-brand-600">{{ summary.counts.executable_count }}</div>
<div class="text-[11px] text-muted">{{ $t('chat.transfer.executableCount') }}</div>
</div>
<div class="rounded-lg bg-surface-soft p-2 text-center">
<div class="text-lg font-black text-secondary">{{ summary.counts.not_matured_count }}</div>
<div class="text-[11px] text-muted">{{ $t('chat.transfer.notMaturedCount') }}</div>
</div>
<div class="rounded-lg bg-surface-soft p-2 text-center">
<div class="text-lg font-black text-secondary">{{ summary.counts.blocked_count }}</div>
<div class="text-[11px] text-muted">{{ $t('chat.transfer.blockedCount') }}</div>
@@ -293,7 +287,6 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
<option value="all">{{ $t('chat.transfer.filterAll') }}</option>
<option value="executable">{{ $t('chat.transfer.resultExecutable') }}</option>
<option value="blocked">{{ $t('chat.transfer.resultBlocked') }}</option>
<option value="not_matured">{{ $t('chat.transfer.resultNotMatured') }}</option>
</select>
<button
type="button"
@@ -320,7 +313,7 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
<!-- 表头全列 nowrap:防「拨出仓库/投入数量」等折行;品名列吃剩余宽度 -->
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMovementDate') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
@@ -334,7 +327,7 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
<tbody>
<tr
v-for="item in filtered"
:key="`${item.source_code}|${item.invoice_no}|${item.material_no}|${item.receipt_date ?? ''}`"
:key="`${item.source_code}|${item.invoice_no}|${item.material_no}|${item.movement_date ?? ''}`"
class="border-b border-subtle"
:class="{ 'bg-surface-soft text-muted': !isSelectable(item), 'opacity-60': item.stale === true }"
:data-testid="`transfer-item-${item.invoice_no}`"
@@ -351,7 +344,7 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行 -->
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ item.movement_date || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ item.material_no }}</td>
<td class="p-2">{{ item.material_name }}</td>
<td class="whitespace-nowrap p-2">{{ item.from_warehouse }}</td>
@@ -377,8 +370,8 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
class="whitespace-nowrap rounded-full px-2 py-0.5 font-bold"
:class="{
'bg-emerald-50 text-emerald-700': item.result === 'executable',
'bg-amber-50 text-amber-700': item.result === 'not_matured' || item.result === 'pending_stock_check',
'bg-red-50 text-red-700': !isSelectable(item) && item.result !== 'not_matured' && item.result !== 'pending_stock_check',
'bg-amber-50 text-amber-700': item.result === 'pending_stock_check',
'bg-red-50 text-red-700': !isSelectable(item) && item.result !== 'pending_stock_check',
}"
:title="reasonTitle(item)"
data-testid="transfer-item-result"
@@ -10,6 +10,9 @@ import { mount, flushPromises } from '@vue/test-utils';
import { describe, expect, it, vi, beforeEach } from 'vitest';
import i18n from '@/i18n';
// EP el-table 在 jsdom 挂载较重(整文件连跑时部分用例超默认 5s),本 spec 放宽到 30s。
vi.setConfig({ testTimeout: 30000 });
const api = vi.hoisted(() => ({
createTransferMatching: vi.fn(),
getTransferMatching: vi.fn(),
@@ -21,10 +24,10 @@ const api = vi.hoisted(() => ({
manualCloseTransferItem: vi.fn(),
batchRequeryTransferItems: vi.fn(),
batchManualCloseTransferItems: vi.fn(),
downloadTransferReceiptFiles: vi.fn(),
downloadTransferInboundFiles: vi.fn(),
downloadTransferErpInventory: vi.fn(),
downloadTransferExceptions: vi.fn(),
listTransferBacklog: vi.fn(),
listTransferBacklogPage: vi.fn(),
getTransferBacklogSummary: vi.fn(),
listTransferSources: vi.fn(),
fetchTransferTypes: vi.fn(),
@@ -46,7 +49,14 @@ vi.mock('@/shared/composables/useMessage', () => ({
}));
import TransferMessageView from './TransferMessageView.vue';
import { eligibleReceiptDateTo } from './transferDate';
import { defaultMovementDate } from './transferDate';
/**
* 待处理池服务端分页 envelope(2026-10-16):items=当前页切片,total=筛选后全量计数。
*/
function backlogPage(items: unknown[], total = items.length) {
return { items, total, page: 1, page_size: 20 };
}
const payload = {
kind: 'match',
@@ -54,9 +64,8 @@ const payload = {
matching_id: 'MTG-1',
status: 'ready_to_execute',
business_date: '2026-08-06',
eligible_receipt_date_to: '2026-08-05',
expires_at: '',
counts: { file_invoice_count: 1, not_matured_count: 0, matched_count: 1, executable_count: 1, blocked_count: 0 },
counts: { file_invoice_count: 1, matched_count: 1, executable_count: 1, blocked_count: 0 },
estimated_transfer_quantity: '1200',
estimated_external_write_count: 1,
matching_hash: 'sha256:x',
@@ -64,7 +73,7 @@ const payload = {
items: [{
item_id: 101,
source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: '连接器组件', specification: 'A',
invoice_no: 'INV-001', receipt_date: '2026-08-05', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200',
invoice_no: 'INV-001', movement_date: '2026-08-05', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200',
to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable',
}],
sources: [{ source_code: 'DBS-AWSBI', stage: 'file_ready', file_no: 'REC-1' }],
@@ -93,7 +102,7 @@ describe('TransferMessageView self-driving wiring', () => {
vi.clearAllMocks();
api.executeTransferItems.mockResolvedValue({ run_no: 'RUN-1', status: 'success' });
api.getTransferRun.mockResolvedValue(runPayload.run);
api.downloadTransferReceiptFiles.mockResolvedValue({ blob: new Blob(['z']), filename: 'r.zip' });
api.downloadTransferInboundFiles.mockResolvedValue({ blob: new Blob(['z']), filename: 'r.zip' });
api.downloadTransferErpInventory.mockResolvedValue({ blob: new Blob(['c']), filename: 'e.csv' });
});
@@ -117,15 +126,15 @@ describe('TransferMessageView self-driving wiring', () => {
expect(wrapper.find('[data-testid="transfer-result-card"]').exists()).toBe(true);
});
it('结果卡下载按钮调用下载 API(收料来源文件 + ERP 库存表)', async () => {
it('结果卡下载按钮调用下载 API(出入站来源文件 + ERP 库存表)', async () => {
const wrapper = mount(TransferMessageView, {
props: { payload: runPayload },
global: { plugins: [i18n] },
});
await wrapper.find('[data-testid="transfer-download-receipt"]').trigger('click');
await wrapper.find('[data-testid="transfer-download-inbound"]').trigger('click');
await wrapper.find('[data-testid="transfer-download-erp"]').trigger('click');
await flushPromises();
expect(api.downloadTransferReceiptFiles).toHaveBeenCalledWith('RUN-1');
expect(api.downloadTransferInboundFiles).toHaveBeenCalledWith('RUN-1');
expect(api.downloadTransferErpInventory).toHaveBeenCalledWith('RUN-1');
});
@@ -138,12 +147,12 @@ describe('TransferMessageView self-driving wiring', () => {
});
it('backlog 视图拉取待处理列表,行级重查/关闭调用对应 API', async () => {
api.listTransferBacklog.mockResolvedValue([{
api.listTransferBacklogPage.mockResolvedValue(backlogPage([{
item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1',
status: 'blocked_recoverable', reason: '收料 1200 / ERP 1000', age_days: 1, aging_level: 'normal',
receipt_date: '2026-08-05', material_name: '连接器组件', from_warehouse: 'DBS-TRANSIT',
to_warehouse: 'HUB-CN01', lot_no: 'LOT-10', receipt_quantity: '1200', external_quantity: '1000',
}]);
status: 'blocked_recoverable', reason: '异动 1200 / ERP 1000', age_days: 1, aging_level: 'normal',
movement_date: '2026-08-05', material_name: '连接器组件', from_warehouse: 'DBS-TRANSIT',
to_warehouse: 'HUB-CN01', lot_no: 'LOT-10', movement_quantity: '1200', external_quantity: '1000',
}]));
api.getTransferBacklogSummary.mockResolvedValue({
recoverable: 1, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
});
@@ -172,10 +181,10 @@ describe('TransferMessageView self-driving wiring', () => {
});
it('backlog 批量:勾选后操作条出现,重查/恢复/批量关闭调用对应端点', async () => {
api.listTransferBacklog.mockResolvedValue([
api.listTransferBacklogPage.mockResolvedValue(backlogPage([
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1', status: 'blocked_recoverable', reason: '', age_days: 0, aging_level: 'normal' },
{ item_id: 8, source_code: 'DBS-AWSBI', invoice_no: 'INV-002', material_no: 'MAT-2', status: 'result_unknown', reason: '', age_days: 2, aging_level: 'result_unknown' },
]);
]));
api.getTransferBacklogSummary.mockResolvedValue({
recoverable: 1, closed: 0, unknown: 1, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
});
@@ -216,11 +225,11 @@ describe('TransferMessageView self-driving wiring', () => {
it('backlog 结果徽标:blocked_file_removed 行显示「文件已移除」,普通阻断仍为「已阻断」', async () => {
// [断言意图] F1(2026-09-23 评审修复):backlog 行带 result_code 后,
// 收料行已从最新文件移除(blocked_file_removed)的行必须与普通数量阻断区分展示。
api.listTransferBacklog.mockResolvedValue([
{ item_id: 9, source_code: 'DBS-AWSBI', invoice_no: 'INV-009', material_no: 'MAT-9', status: 'blocked_recoverable', result_code: 'blocked_file_removed', reason: '收料行已从最新文件移除', age_days: 0, aging_level: 'normal' },
{ item_id: 10, source_code: 'DBS-AWSBI', invoice_no: 'INV-010', material_no: 'MAT-10', status: 'blocked_recoverable', result_code: 'blocked_quantity_mismatch', reason: '收料 300 / ERP 280', age_days: 0, aging_level: 'normal' },
]);
// 入站行已从最新文件移除(blocked_file_removed)的行必须与普通数量阻断区分展示。
api.listTransferBacklogPage.mockResolvedValue(backlogPage([
{ item_id: 9, source_code: 'DBS-AWSBI', invoice_no: 'INV-009', material_no: 'MAT-9', status: 'blocked_recoverable', result_code: 'blocked_file_removed', reason: '入站行已从最新文件移除', age_days: 0, aging_level: 'normal' },
{ item_id: 10, source_code: 'DBS-AWSBI', invoice_no: 'INV-010', material_no: 'MAT-10', status: 'blocked_recoverable', result_code: 'blocked_quantity_mismatch', reason: '异动 300 / ERP 280', age_days: 0, aging_level: 'normal' },
]));
api.getTransferBacklogSummary.mockResolvedValue({
recoverable: 2, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
});
@@ -230,13 +239,94 @@ describe('TransferMessageView self-driving wiring', () => {
global: { plugins: [i18n] },
});
await flushPromises();
const removedBadge = wrapper.find('[data-testid="transfer-backlog-INV-009"] [data-testid="transfer-backlog-result"]');
const normalBadge = wrapper.find('[data-testid="transfer-backlog-INV-010"] [data-testid="transfer-backlog-result"]');
// [断言意图] EP el-table 行不支持逐行 attr,行定位改经 row-class-name 注入的
// transfer-backlog-row-<invoice_no> 类(等价定位同一行),徽标 testid 不变。
const removedBadge = wrapper.find('.transfer-backlog-row-INV-009 [data-testid="transfer-backlog-result"]');
const normalBadge = wrapper.find('.transfer-backlog-row-INV-010 [data-testid="transfer-backlog-result"]');
expect(removedBadge.text()).toContain('文件已移除');
expect(normalBadge.text()).toContain('已阻断');
expect(normalBadge.text()).not.toContain('文件已移除');
});
it('backlog 服务端分页:翻页携带 page 参数重查,当前页渲染切片', async () => {
// [断言意图] 大池(现网 951/324 行级)走服务端分页(2026-10-16):待办卡
// 翻页上抛 query-change → loadBacklog 合并页码重查;首拉由卡片挂载
// query-change 触发且携带默认切片查询(page=1)。
api.listTransferBacklogPage
.mockResolvedValue(backlogPage(
Array.from({ length: 20 }, (_, i) => ({
item_id: 100 + i,
source_code: 'DBS-AWSBI',
invoice_no: `INV-${String(i + 1).padStart(3, '0')}`,
material_no: `MAT-${i + 1}`,
status: 'blocked_recoverable',
reason: '异动 300 / ERP 280',
age_days: 0,
aging_level: 'normal',
})),
25,
))
.mockResolvedValueOnce(backlogPage(
Array.from({ length: 20 }, (_, i) => ({
item_id: 100 + i,
source_code: 'DBS-AWSBI',
invoice_no: `INV-${String(i + 1).padStart(3, '0')}`,
material_no: `MAT-${i + 1}`,
status: 'blocked_recoverable',
reason: '异动 300 / ERP 280',
age_days: 0,
aging_level: 'normal',
})),
25,
))
.mockResolvedValueOnce(backlogPage(
[{
item_id: 120,
source_code: 'DBS-AWSBI',
invoice_no: 'INV-021',
material_no: 'MAT-21',
status: 'blocked_recoverable',
reason: '异动 300 / ERP 280',
age_days: 0,
aging_level: 'normal',
}],
25,
));
api.getTransferBacklogSummary.mockResolvedValue({
recoverable: 25, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
});
const wrapper = mount(TransferMessageView, {
props: { payload: { kind: 'backlog' } },
global: { plugins: [i18n] },
});
await flushPromises();
// [断言意图] 首拉=卡片挂载上抛的默认查询(page=1)。
expect(api.listTransferBacklogPage).toHaveBeenLastCalledWith(
expect.objectContaining({ page: 1, pageSize: 20, resultFilter: 'all' }),
);
expect(wrapper.findAll('tr.el-table__row')).toHaveLength(20);
// 翻页:query-change(page=2) → 服务端重查,渲染第 2 页切片。
await wrapper.find('.btn-next').trigger('click');
await flushPromises();
expect(api.listTransferBacklogPage).toHaveBeenLastCalledWith(
expect.objectContaining({ page: 2, pageSize: 20 }),
);
expect(wrapper.findAll('tr.el-table__row')).toHaveLength(1);
expect(wrapper.find('.transfer-backlog-row-INV-021').exists()).toBe(true);
// [断言意图] 勾选跨页保留:第 2 页勾选 INV-021,翻页/刷新后批量条计数不丢。
await wrapper.find('[data-testid="transfer-backlog-check-INV-021"]').setValue(true);
// [断言意图] 操作后无参重拉沿用最近查询(page=2,不跳回第 1 页)。
await wrapper.find('[data-testid="transfer-backlog-requery-INV-021"]').trigger('click');
await flushPromises();
expect(api.listTransferBacklogPage).toHaveBeenLastCalledWith(
expect.objectContaining({ page: 2, pageSize: 20 }),
);
await wrapper.find('.btn-prev').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="transfer-backlog-selected-count"]').text()).toContain('1');
});
it('可调拨明细视图:加载全局可执行行,勾选后按行生成调拨单', async () => {
// [断言意图] 行归属解耦后的执行入口:executable 视图聚合全部可执行行,
// 勾选(item_id)→ /items/execute → 结果卡,恢复后的行在此闭环。
@@ -268,10 +358,10 @@ describe('TransferMessageView self-driving wiring', () => {
// [断言意图] 行式执行重构(2026-09-23):恢复处理不再重建/打开匹配卡,
// 语义收敛为按明细 id 重查库存;结果按 status 统计(ready_to_execute=已恢复),
// 完成后留在待处理池(fail-closed),toast 汇总 recovered/blocked。
api.listTransferBacklog.mockResolvedValue([
api.listTransferBacklogPage.mockResolvedValue(backlogPage([
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1', status: 'blocked_recoverable', reason: '', age_days: 0, aging_level: 'normal' },
{ item_id: 8, source_code: 'DBS-AWSBI', invoice_no: 'INV-002', material_no: 'MAT-2', status: 'blocked_recoverable', reason: '', age_days: 1, aging_level: 'normal' },
]);
]));
api.getTransferBacklogSummary.mockResolvedValue({
recoverable: 2, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
});
@@ -302,7 +392,7 @@ describe('TransferMessageView self-driving wiring', () => {
expect(toastText).toContain('仍阻断');
});
it('来源实例选择:加载列表与类型配置 → 确认范围 → 创建匹配并切换匹配卡(默认携带 D+1 日期范围)', async () => {
it('来源实例选择:加载列表与类型配置 → 确认范围 → 创建匹配并切换匹配卡(默认携带 T−2 日期范围)', async () => {
// [断言意图] Task 7 接口化:挂载时并行拉取来源列表与调拨类型配置(fetchTransferTypes),
// 类型选项=接口数据渲染进来源卡;确认仍携带缺省(首项)类型 code。
api.listTransferSources.mockResolvedValue([
@@ -334,10 +424,10 @@ describe('TransferMessageView self-driving wiring', () => {
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
await flushPromises();
const cutoff = eligibleReceiptDateTo();
const defaultDate = defaultMovementDate();
expect(api.createTransferMatching).toHaveBeenCalledWith({
source_codes: ['DBS-AWSBI'], business_date: undefined,
receipt_date_from: cutoff, receipt_date_to: cutoff,
movement_date_from: defaultDate, movement_date_to: defaultDate,
transfer_type: 'in_transit_to_hub',
});
expect(wrapper.find('[data-testid="transfer-match-card"]').exists()).toBe(true);
@@ -367,12 +457,12 @@ function t13Run(status: string, orders: Array<Record<string, unknown>>) {
/** T0:提交后立即(单已建好,全部待处理)。 */
const t13Pending = t13Run('queued', [
{
doc_no: 'HTT-OR-1', receipt_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
doc_no: 'HTT-OR-1', movement_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
status: 'pending', erp_document_no: null, error_message: null,
lines: [t13Line('M001', '材料甲', 'V1', '100.000000'), t13Line('M002', '材料乙', 'V2', '500.000000')],
},
{
doc_no: 'HTT-OR-2', receipt_date: '2026-09-19', from_warehouse: 'B25', to_warehouse: 'B02',
doc_no: 'HTT-OR-2', movement_date: '2026-09-19', from_warehouse: 'B25', to_warehouse: 'B02',
status: 'pending', erp_document_no: null, error_message: null,
lines: [t13Line('M003', '材料丙', 'V3', '55.000000')],
},
@@ -381,16 +471,16 @@ const t13Pending = t13Run('queued', [
/** T1:执行中(轮询刷新,逐单亮结果)。 */
const t13Executing = t13Run('executing', [
{
doc_no: 'D-EXE', receipt_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
doc_no: 'D-EXE', movement_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
status: 'executing', erp_document_no: null, error_message: null,
lines: [t13Line('M001', '材料甲', 'V1', '100.000000')],
},
{
doc_no: 'D-OK', receipt_date: '2026-09-19', from_warehouse: 'B25', to_warehouse: 'B02',
doc_no: 'D-OK', movement_date: '2026-09-19', from_warehouse: 'B25', to_warehouse: 'B02',
status: 'success', erp_document_no: '1401-2609230008', error_message: null, lines: [],
},
{
doc_no: 'D-BUS', receipt_date: '2026-09-21', from_warehouse: 'B25', to_warehouse: 'B02',
doc_no: 'D-BUS', movement_date: '2026-09-21', from_warehouse: 'B25', to_warehouse: 'B02',
status: 'business_failed', erp_document_no: null, error_message: null,
lines: [t13Line('M003', '材料丙', 'V3', '55.000000')],
},
@@ -399,17 +489,17 @@ const t13Executing = t13Run('executing', [
/** T2:终态部分失败(成功 + 结果未知 + 业务失败)。 */
const t13Partial = t13Run('partial_failed', [
{
doc_no: 'D-OK', receipt_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
doc_no: 'D-OK', movement_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
status: 'success', erp_document_no: '1401-2609230007', error_message: null,
lines: [t13Line('M001', '材料甲', 'V1', '100.000000')],
},
{
doc_no: 'D-UNK', receipt_date: '2026-09-20', from_warehouse: 'B25', to_warehouse: 'B02',
doc_no: 'D-UNK', movement_date: '2026-09-20', from_warehouse: 'B25', to_warehouse: 'B02',
status: 'result_unknown', erp_document_no: null, error_message: null,
lines: [t13Line('M002', '材料乙', 'V2', '500.000000')],
},
{
doc_no: 'D-FAIL', receipt_date: '2026-09-21', from_warehouse: 'B25', to_warehouse: 'B02',
doc_no: 'D-FAIL', movement_date: '2026-09-21', from_warehouse: 'B25', to_warehouse: 'B02',
status: 'business_failed', erp_document_no: null, error_message: null,
lines: [t13Line('MAT-1', '连接器组件', 'LOT-10', '1200.000000', '料号无有效成本')],
},
@@ -433,7 +523,7 @@ describe('融合卡(Task 13):调拨单清单=进度=结果', () => {
});
});
it('T0 全待处理:卡顶「排队中」,单行=收料日期·仓库·物料数·合计+待处理徽标,行明细常驻展开,非终态无下载区', async () => {
it('T0 全待处理:卡顶「排队中」,单行=异动日期·仓库·物料数·合计+待处理徽标,行明细常驻展开,非终态无下载区', async () => {
api.getTransferRun.mockResolvedValue(t13Pending);
const wrapper = mountRunView();
await flushPromises();
@@ -550,7 +640,7 @@ describe('融合卡(Task 13):调拨单清单=进度=结果', () => {
// POST /documents/{doc_no}/retry(按单圈行重查+自动重跑)。
api.getTransferRun.mockResolvedValue(t13Run('failed', [
{
doc_no: 'D-FAIL', receipt_date: '2026-08-05', from_warehouse: 'DBS-TRANSIT', to_warehouse: 'HUB-CN01',
doc_no: 'D-FAIL', movement_date: '2026-08-05', from_warehouse: 'DBS-TRANSIT', to_warehouse: 'HUB-CN01',
status: 'business_failed', erp_document_no: null, error_message: null,
lines: [t13Line('MAT-1', '连接器组件', '', '1200.000000')],
},
@@ -5,7 +5,7 @@
依赖:Transfer*Card、useChatTransfer、i18n chat.transfer.*。
逻辑:payload 作为初始状态(ChatLog 回放;历史行无 item_id 仅展示不可选);仅携带
matching_id 时按 ID 恢复匹配卡(最近匹配入口);勾选/执行按明细 item_id;
来源选择卡重试收料 RPA 为 202 异步——存在抓取中来源时组合式函数自动轮询
来源选择卡重试入站 RPA 为 202 异步——存在抓取中来源时组合式函数自动轮询
GET /sources,RPA 回调收口后状态自动刷新,离开来源卡即停轮询;
来源选择卡挂载时并行拉取来源列表与调拨类型配置(Task 7 接口化,
类型选项=GET /transfer-types 接口下发);
@@ -70,18 +70,17 @@ const busy = ref(false);
const closeTarget = ref<TransferBacklogItem | null>(null);
/** 批量标记无需处理的明细 id 集合(与单行关闭共用同一弹窗)。 */
const batchCloseIds = ref<number[]>([]);
/** 正在重试收料 RPA 的来源编码集合(按来源独立展示重试中)。 */
/** 正在重试入站 RPA 的来源编码集合(按来源独立展示重试中)。 */
const retryingSource = ref<Set<string>>(new Set());
/** 上次提交执行的明细行快照(失败单「重查库存」按物料/收料日期关联 item_id 用)。 */
/** 上次提交执行的明细行快照(失败单「重查库存」按物料/异动日期关联 item_id 用)。 */
const lastExecutedItems = ref<TransferMatchingItem[]>([]);
const transfer = useChatTransfer();
/** 待处理异常视图:进入时拉取列表与汇总 */
/** 待处理异常视图:进入时拉取列表与汇总(2026-10-16 服务端分页:首拉由
* 待办卡挂载时上抛 query-change 触发(携带计数卡切片 initialFilter),
* 此处不再兜底首拉避免双请求)。 */
onMounted(() => {
if (kind.value === 'backlog') {
void transfer.loadBacklog();
}
if (kind.value === 'source-select') {
void transfer.loadSources();
// 调拨类型配置(Task 7 接口化):类型选项=接口下发,与来源列表并行拉取。
@@ -92,6 +91,11 @@ onMounted(() => {
}
});
/** 待办卡查询变更(翻页/筛选/首挂载):转调组合式函数按服务端分页拉取。 */
function onBacklogQueryChange(query: { page: number; keyword: string; resultFilter: 'all' | 'recoverable' | 'closed' | 'unknown' }) {
void transfer.loadBacklog(query);
}
/** payload 更新时重置本地状态(历史回放/刷新);初始化组合式函数上下文 */
function applyPayload(payload?: Record<string, unknown> | null) {
if (!payload) return;
@@ -125,13 +129,13 @@ watch(mode, (value) => {
if (value !== 'source-select') transfer.stopSourcePolling();
});
/** 打包下载选中来源的最新归档收料文件 */
/** 打包下载选中来源的最新归档入站文件 */
async function onDownloadSources(sourceCodes: string[]) {
if (!sourceCodes.length) return;
busy.value = true;
try {
const result = await downloadTransferSourceFiles(sourceCodes);
triggerBlobDownload(result.blob, result.filename ?? `receipt-files-${sourceCodes.length}.zip`);
triggerBlobDownload(result.blob, result.filename ?? `inbound-files-${sourceCodes.length}.zip`);
} catch (e) {
reportError(e);
} finally {
@@ -261,9 +265,9 @@ async function onOrderClosed() {
}
}
async function onDownloadReceipt() {
async function onDownloadInbound() {
try {
await transfer.downloadReceiptFiles();
await transfer.downloadInboundFiles();
} catch (e) {
reportError(e);
}
@@ -364,7 +368,7 @@ async function onCloseConfirm(reason: string) {
}
}
/** 来源实例选择确认 → 创建匹配并切换匹配卡(决策 4:两步第一步;收料日期范围为查询范围;调拨类型决定数据范围) */
/** 来源实例选择确认 → 创建匹配并切换匹配卡(决策 4:两步第一步;异动日期范围为查询范围;调拨类型决定数据范围) */
async function onSourceConfirm(
sourceCodes: string[],
dateRange?: { from?: string; to?: string },
@@ -384,7 +388,7 @@ async function onSourceConfirm(
}
}
/** 对来源(单个或批量)重新触发收料 RPA 抓取,重试期间标记该来源(busy 独立于 confirm busy)。 */
/** 对来源(单个或批量)重新触发入站 RPA 抓取,重试期间标记该来源(busy 独立于 confirm busy)。 */
async function onSourceRetry(sourceCodes: string[]) {
const codes = Array.isArray(sourceCodes) ? sourceCodes : [sourceCodes];
retryingSource.value = new Set([...retryingSource.value, ...codes]);
@@ -450,7 +454,7 @@ async function onSourceRetry(sourceCodes: string[]) {
v-else-if="(mode === 'run' || mode === 'result') && (runNo || run?.run_no)"
:run-no="runNo || String(run?.run_no ?? '')"
:initial-run="run"
@download-receipt="onDownloadReceipt"
@download-inbound="onDownloadInbound"
@download-erp="onDownloadErp"
@download-exceptions="onDownloadExceptions"
@retry="onOrderRetry"
@@ -459,8 +463,10 @@ async function onSourceRetry(sourceCodes: string[]) {
<TransferBacklogSummaryCard
v-else-if="mode === 'backlog'"
:items="transfer.backlog.value"
:total="transfer.backlogTotal.value"
:busy="busy"
:initial-filter="backlogInitialFilter"
@query-change="onBacklogQueryChange"
@retry="onBacklogRetry"
@requery="onBacklogRequery"
@resume="onBacklogResume"
@@ -0,0 +1,206 @@
/**
* features/chat/components/messages/TransferPendingMatchPanel.spec.ts
* 用途:验证「待匹配」抽屉的「清空并重新解析」维护链路(Task 8,后端 Task 7)——
* 来源行按钮渲染、点击先调预检(GET reparse-preview)、确认弹窗展示预检数据
* (文件份数/规则 code+version/将清除与证据缺失保留行数)、确认后调执行端点
* (POST reparse)、成功后 emit refresh 并展示结果摘要(清除 N/重落 M)、
* 失败在弹窗内展示后端中止原因(解析失败未删任何数据)。
* 依赖:vi.mock(transfer.api)、@vue/test-utils、i18n(真实实例,R4:键值纯文本无插值)。
* 逻辑:数值断言取自 mock 载荷(与文案键解耦,防 red 阶段误判);确认弹窗数据必须
* 来自预检接口而非本地猜测(断言 preview 调用先于弹窗内容)。
*/
import { mount, flushPromises } from '@vue/test-utils';
import { describe, expect, it, vi, beforeEach } from 'vitest';
import i18n from '@/i18n';
import { BusinessError } from '@/shared/api/client';
const api = vi.hoisted(() => ({
// useChatTransfer 全量依赖(vi.mock 工厂整模块替换,按 composable 导入面列出)
createTransferMatching: vi.fn(),
getTransferMatching: vi.fn(),
executeTransferItems: vi.fn(),
getTransferRun: vi.fn(),
cancelTransferRun: vi.fn(),
retryTransferItem: vi.fn(),
manualCloseTransferItem: vi.fn(),
batchRequeryTransferItems: vi.fn(),
downloadTransferInboundFiles: vi.fn(),
downloadTransferErpInventory: vi.fn(),
downloadTransferExceptions: vi.fn(),
listTransferSources: vi.fn(),
fetchTransferTypes: vi.fn(),
retryTransferSourceRpa: vi.fn(),
retryTransferSourcesRpaBatch: vi.fn(),
listTransferBacklogPage: vi.fn(),
getTransferBacklogSummary: vi.fn(),
listExecutableTransferItems: vi.fn(),
listPendingMatchRecordsPage: vi.fn(),
// Task 7 维护链路端点(本组件被测面)
fetchPendingMatchReparsePreview: vi.fn(),
reparsePendingMatch: vi.fn(),
}));
vi.mock('@/features/chat/api/transfer.api', () => api);
import TransferPendingMatchPanel from './TransferPendingMatchPanel.vue';
/** 两个来源的待匹配记录(同来源多行验证按钮行级渲染) */
const records = [
{ ledger_record_id: 101, doc_no: 'HOM-901', material_code: 'MAT-9', material_name: '未匹配物料',
movement_date: '2026-08-04', source_code: 'DBS-AWSBI', quantity: '55' },
{ ledger_record_id: 102, doc_no: 'HOM-902', material_code: 'MAT-8', material_name: '未匹配物料二',
movement_date: '2026-08-05', source_code: 'DBS-AWSBI', quantity: '12' },
{ ledger_record_id: 103, doc_no: 'HOM-903', material_code: 'MAT-7', material_name: '未匹配物料三',
movement_date: '2026-08-05', source_code: 'CRANE-FP', quantity: '3' },
];
/** 预检载荷(数值刻意互异:文件 2 份/规则 v3/清除 12/保留 4,供弹窗文案断言) */
const previewPayload = {
files: [
{ archived_at: '2026-08-03T10:00:00', sha256: 'sha-aaa', rows: 7 },
{ archived_at: '2026-08-04T10:00:00', sha256: 'sha-bbb', rows: 5 },
],
profile: { code: 'DBS-INV', version: 3 },
clearable_rows: 12,
kept_rows: 4,
};
/** 执行结果载荷(cleared/reinserted 与预检不同值,断言摘要来自执行端点而非预检) */
const reparsePayload = {
source_code: 'DBS-AWSBI',
cleared: 12,
reinserted: 10,
date_skipped: 0,
kept_unrebuildable: 4,
unlinked_items: 2,
files: [{ file_id: 5, sha256: 'sha-aaa', archived_at: '2026-08-03T10:00:00', inserted: 10 }],
};
function mountPanel() {
return mount(TransferPendingMatchPanel, {
props: { records },
global: { plugins: [i18n] },
});
}
/** el-table 行渲染晚于 mount 同步时刻(EP 表格数据经内部 store 下一 tick 上屏),统一先 flush。 */
async function mountFlushedPanel(customRecords: typeof records = records) {
const wrapper = mount(TransferPendingMatchPanel, {
props: { records: customRecords },
global: { plugins: [i18n] },
});
await flushPromises();
return wrapper;
}
/** 打开确认弹窗的公共前置:点击首行按钮并等待预检返回 */
async function openDialog(wrapper: ReturnType<typeof mountPanel>) {
await wrapper.find('[data-testid="transfer-pending-match-reparse"]').trigger('click');
await flushPromises();
}
describe('TransferPendingMatchPanel 清空重解析(Task 8)', () => {
beforeEach(() => {
vi.clearAllMocks();
api.listPendingMatchRecordsPage.mockResolvedValue({ records: [], total: 0, page: 1, page_size: 20 });
api.fetchPendingMatchReparsePreview.mockResolvedValue(previewPayload);
api.reparsePendingMatch.mockResolvedValue(reparsePayload);
});
it('来源行渲染「清空重解析」按钮:每行一个,携带行来源', async () => {
const wrapper = await mountFlushedPanel();
const buttons = wrapper.findAll('[data-testid="transfer-pending-match-reparse"]');
// [断言意图] 行级入口:按钮数=记录数(非按来源聚合条),首按钮指向首行来源。
expect(buttons).toHaveLength(records.length);
expect(buttons[0].attributes('data-source')).toBe('DBS-AWSBI');
expect(buttons[2].attributes('data-source')).toBe('CRANE-FP');
});
it('点击后先调预检并弹确认:展示文件份数/规则 code+version/清除与保留行数', async () => {
// [断言意图] 确认弹窗数据必须来自预检接口:点击即调 reparse-preview(带行来源),
// 弹窗内容展示预检四要素(份数 2 / DBS-INV v3 / 清除 12 / 保留 4)。
const wrapper = await mountFlushedPanel();
await openDialog(wrapper);
expect(api.fetchPendingMatchReparsePreview).toHaveBeenCalledWith('DBS-AWSBI');
const dialog = wrapper.find('[data-testid="transfer-pending-match-reparse-dialog"]');
expect(dialog.exists()).toBe(true);
expect(wrapper.find('[data-testid="transfer-pending-match-reparse-files"]').text()).toContain('2');
const profile = wrapper.find('[data-testid="transfer-pending-match-reparse-profile"]').text();
expect(profile).toContain('DBS-INV');
expect(profile).toContain('3');
const rows = wrapper.find('[data-testid="transfer-pending-match-reparse-rows"]').text();
expect(rows).toContain('12');
expect(rows).toContain('4');
});
it('来源未绑定解析规则时弹窗展示「未绑定规则」文案而非 code+version', async () => {
// [断言意图] profile=null(无已发布入站规则=无重建通道)必须显式披露,
// 不允许渲染成空串或 undefined。
api.fetchPendingMatchReparsePreview.mockResolvedValue({ ...previewPayload, profile: null });
const wrapper = await mountFlushedPanel();
await openDialog(wrapper);
expect(wrapper.find('[data-testid="transfer-pending-match-reparse-profile"]').text()).not.toContain('DBS-INV');
expect(wrapper.find('[data-testid="transfer-pending-match-reparse-profile-empty"]').exists()).toBe(true);
});
it('确认后调执行端点,成功后 emit refresh 并展示结果摘要(清除/重落)', async () => {
const wrapper = await mountFlushedPanel();
await openDialog(wrapper);
await wrapper.find('[data-testid="transfer-pending-match-reparse-confirm"]').trigger('click');
await flushPromises();
// [断言意图] 执行走 POST reparse(带来源);成功后向上冒泡 refresh 让宿主
// 重拉待匹配清单,并在弹窗内展示执行端点返回的计数摘要。
expect(api.reparsePendingMatch).toHaveBeenCalledWith('DBS-AWSBI');
expect(wrapper.emitted('refresh')).toBeTruthy();
const summary = wrapper.find('[data-testid="transfer-pending-match-reparse-result"]').text();
expect(summary).toContain('12');
expect(summary).toContain('10');
});
it('执行失败在弹窗内展示中止原因(解析失败一行未删),不 emit refresh', async () => {
// [断言意图] 后端整体中止(TRANSFER.REPARSE_PARSE_FAILED)→ 弹窗保持打开并
// 透出后端 reason(含「未删任何数据」语义);失败不得触发清单刷新。
api.reparsePendingMatch.mockRejectedValue(
new BusinessError({ message: '归档 1 份解析失败:b.xlsx', code: 'TRANSFER.REPARSE_PARSE_FAILED' }),
);
const wrapper = await mountFlushedPanel();
await openDialog(wrapper);
await wrapper.find('[data-testid="transfer-pending-match-reparse-confirm"]').trigger('click');
await flushPromises();
expect(wrapper.emitted('refresh')).toBeFalsy();
const error = wrapper.find('[data-testid="transfer-pending-match-reparse-error"]');
expect(error.exists()).toBe(true);
expect(error.text()).toContain('归档 1 份解析失败:b.xlsx');
});
it('待匹配清单服务端分页:翻页上抛 page-change 由宿主拉取对应页', async () => {
// [断言意图] 服务端分页契约(2026-10-16):组件只持页码 UI 态——
// 渲染 props.records(服务端当前页切片),DOM 随页大小有界。
// 翻页只上抛 page-change 由宿主拉取(服务端分页,2026-10-16)。
const pageRecords = Array.from({ length: 20 }, (_, i) => ({
ledger_record_id: 200 + i,
doc_no: `HOM-${900 + i}`,
material_code: `MAT-${i}`,
material_name: '未匹配物料',
movement_date: '2026-08-05',
source_code: 'DBS-AWSBI',
quantity: '1',
}));
const wrapper = await mountFlushedPanel(pageRecords);
// 注入 total=25(模拟服务端返回的桶全量计数)触发分页条渲染。
await wrapper.setProps({ total: 25 });
expect(wrapper.findAll('tr.el-table__row')).toHaveLength(20);
await wrapper.find('.btn-next').trigger('click');
// [断言意图] 组件不自行改数据:翻页仅上抛 page-change({page:2})。
expect(wrapper.emitted('page-change')?.[0][0]).toEqual({ page: 2 });
});
it('取消关闭弹窗且不发任何执行请求', async () => {
const wrapper = await mountFlushedPanel();
await openDialog(wrapper);
await wrapper.find('[data-testid="transfer-pending-match-reparse-cancel"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="transfer-pending-match-reparse-dialog"]').exists()).toBe(false);
expect(api.reparsePendingMatch).not.toHaveBeenCalled();
});
});
@@ -1,29 +1,167 @@
<!--
features/chat/components/messages/TransferPendingMatchPanel.vue
用途:「待匹配」桶只读清单(D16,规格 §10/§12.3)——已抓取尚未匹配的外部收料
记录(档记录尚无 items),首页待办看板第 4 张卡的抽屉数据源。
依赖:props.records(GET /backlog/pending-match 投影)、i18n chat.transfer.transferPendingMatch*。
逻辑:纯只读——无勾选列、无执行入口(记录尚未经匹配/库存核对,不可执行);
顶部「去匹配」按钮上抛 go-match,由父级切到库存匹配入口(来源选择卡);
清单按后端稳定排序(收料日期→来源→单号)渲染,数量为档原值文本。
用途:「待匹配」桶清单(D16,规格 §10/§12.3)+「清空并重新解析」维护入口(Task 8,
规格 §6,后端 Task 7)——已抓取尚未匹配的外部入站记录(档记录尚无 items),
首页待办看板第 4 张卡的抽屉数据源;解析规则修改后可按来源清空旧映射档行、
以当前绑定入站解析规则重建(确认弹窗数据来自预检接口,执行失败透出中止未删语义)。
依赖:Element Plus ElTable/ElTableColumn/ElDialog(2026-10-16 EP 组件化:表格与确认
弹层壳迁 EP,预检→确认→执行语义不变)、props.records(GET /backlog/pending-match
投影)、fetchPendingMatchReparsePreview(预检,只读)、
useChatTransfer().reparsePendingMatch(执行+刷新桶)、i18n chat.transfer.*。
逻辑:清单主体仍按后端稳定排序只读渲染(无勾选列,不可执行;「去匹配」上抛 go-match
由父级切库存匹配入口);行级「清空重解析」按钮点击先调预检(GET reparse-preview)
再弹确认——弹窗展示文件份数/规则 code+version(或「未绑定解析规则」)/将清除行数/
证据缺失保留行数,数据只来自预检响应、禁止本地估算;确认调执行端点(单事务在后端),
成功后 emit refresh 由宿主重拉清单并展示结果摘要(清除 N/重落 M),失败在弹窗内
透出后端 reason(解析失败一行未删)。行定位:el-table 行不支持逐行 attr,
行 testid 改经 row-class-name 注入(transfer-pending-match-row-<doc_no>)。
弹层壳禁 ESC/遮罩点击/X 关闭(仅取消/确认按钮可关,防误触关闭维护操作)。
服务端分页(2026-10-16):后端接口分页 envelope,本组件只持页码 UI 态,
翻页上抛 page-change 由宿主(TransferHomePanel)拉取当前页。
文案遵守 R4:chat.transfer 新键一律纯文本(无 {xxx} 插值,vue-i18n 11.4.7
深层嵌套键命名插值异常),动态数量由脚本拼接。
-->
<script setup lang="ts">
import type { TransferPendingMatchRecord } from '../../types/transfer.types';
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { ElDialog, ElPagination, ElTable, ElTableColumn } from 'element-plus';
import { TRANSFER_PAGE_SIZE } from '../../composables/useChatTransfer';
import { transferDialogShellAttrs } from './transferDialogShell';
import { fetchPendingMatchReparsePreview } from '../../api/transfer.api';
import { useChatTransfer } from '../../composables/useChatTransfer';
import type {
TransferPendingMatchRecord,
TransferPendingMatchReparsePreview,
TransferPendingMatchReparseResult,
} from '../../types/transfer.types';
defineProps<{
const props = defineProps<{
/** 当前页记录切片(服务端分页返回;父级经 loadPendingMatchRecords 拉取)。 */
records: TransferPendingMatchRecord[];
/** 桶全量计数(分页器数据源;不传视为 0=隐藏分页条)。 */
total?: number;
busy?: boolean;
}>();
const emit = defineEmits<{
/** 「去匹配」引导:切到现有库存匹配入口(来源选择卡),本桶不提供任何执行动作。 */
/** 「去匹配」引导:切到现有库存匹配入口(来源选择卡),清单本身不提供执行动作。 */
'go-match': [];
refresh: [];
/** 翻页:宿主据此调用 loadPendingMatchRecords({page}) 拉取对应页(服务端分页)。 */
'page-change': [query: { page: number }];
}>();
const { t } = useI18n();
// 维护链路专用实例(组件自驱动,模式同 TransferMessageView):仅消费 reparsePendingMatch
const transfer = useChatTransfer();
/** 分页页码(本地 UI 态;数据由父级按 page-change 拉取后经 props 回流)。
* 翻页/收拢统一经 watch(currentPage) 上抛(单一出口,收拢也通知宿主重拉)。 */
const PAGE_SIZE = TRANSFER_PAGE_SIZE;
const currentPage = ref(1);
watch(currentPage, (page) => emit('page-change', { page }));
// 桶变小(清空重解析/刷新)后收拢当前页防空白页:页码变化经上述 watch 上抛,
// 宿主重拉后 props.records/total 回流,避免停留在越界空页。
watch(() => props.total, (total = 0) => {
const maxPage = Math.max(1, Math.ceil(total / PAGE_SIZE));
if (currentPage.value > maxPage) currentPage.value = maxPage;
});
/**
* 确认弹窗状态:source=当前操作来源;preview=预检数据(弹窗内容唯一数据源);
* previewLoading=预检在途;confirming=执行在途(防重复点击);result=执行成功摘要;
* errorMessage=中止原因(预检失败或后端整体中止 TRANSFER.REPARSE_PARSE_FAILED 透传)。
*/
const dialogSource = ref<string | null>(null);
const preview = ref<TransferPendingMatchReparsePreview | null>(null);
const previewLoading = ref(false);
const confirming = ref(false);
const result = ref<TransferPendingMatchReparseResult | null>(null);
const errorMessage = ref('');
function rowKey(record: TransferPendingMatchRecord): string {
return `${record.ledger_record_id}|${record.doc_no}`;
}
/** el-table 行类:注入行定位类(替代旧行 testid)。 */
function rowClassName({ row }: { row: TransferPendingMatchRecord }): string {
return `transfer-pending-match-row-${row.doc_no}`;
}
/**
* 点击来源行「清空重解析」:先调预检(只读零副作用),成功才进入确认态。
* 【AI 触发时机】用户点击行级按钮时调用;禁止跳过预检直接执行
* (确认弹窗必须展示预检数据,让操作者在执行前看到重建范围)。
*
* @param sourceCode - 行来源实例编码(业务约束:来自待匹配记录,禁止传显示名)
*/
async function openReparseDialog(sourceCode: string) {
dialogSource.value = sourceCode;
preview.value = null;
result.value = null;
errorMessage.value = '';
previewLoading.value = true;
try {
preview.value = await fetchPendingMatchReparsePreview(sourceCode);
} catch (e) {
// 预检失败(网络/权限等):错误落弹窗内文案,不进入可确认态(confirm 由 !preview 拦截)
errorMessage.value = e instanceof Error ? e.message : String(e);
} finally {
previewLoading.value = false;
}
}
/** 关闭确认弹窗并清空全部弹窗态(取消/成功后关闭共用,幂等)。 */
function closeReparseDialog() {
dialogSource.value = null;
preview.value = null;
result.value = null;
errorMessage.value = '';
}
/**
* 确认执行清空重建:调 POST reparse(单事务在后端,先全量预解析、失败一行不删)。
* 成功 → 展示结果摘要(清除 N/重落 M)并 emit refresh 让宿主重拉待匹配清单;
* 失败 → 弹窗保持打开并透出后端 reason(含「中止未删」语义),不刷新清单。
*/
async function confirmReparse() {
if (!dialogSource.value || confirming.value) return;
confirming.value = true;
errorMessage.value = '';
try {
result.value = await transfer.reparsePendingMatch(dialogSource.value);
emit('refresh');
} catch (e) {
errorMessage.value = e instanceof Error ? e.message : String(e);
} finally {
confirming.value = false;
}
}
// —— R4 纯文本拼接文案:vue-i18n 11.4.7 深层嵌套键命名插值异常,禁 {xxx} 占位;
// 动态数量一律「纯文本键 + 脚本拼接」(先例 shippingOrderReview.releaseBar.missingPrefix/Suffix)。
const filesLine = computed(() =>
preview.value
? `${t('chat.transfer.reparseFilesPrefix')}${preview.value.files.length}${t('chat.transfer.reparseFilesSuffix')}`
: '',
);
const profileLine = computed(() => {
const profile = preview.value?.profile;
if (!profile) return '';
return `${t('chat.transfer.reparseProfilePrefix')}${profile.code}${t('chat.transfer.reparseProfileVersionPrefix')}${profile.version}`;
});
const rowsLine = computed(() =>
preview.value
? `${t('chat.transfer.reparseRowsClearPrefix')}${preview.value.clearable_rows}${t('chat.transfer.reparseRowsClearSuffix')}${t('chat.transfer.reparseRowsKeptPrefix')}${preview.value.kept_rows}${t('chat.transfer.reparseRowsKeptSuffix')}`
: '',
);
const successLine = computed(() =>
result.value
? `${t('chat.transfer.reparseSuccessPrefix')}${result.value.cleared}${t('chat.transfer.reparseSuccessReinsertPrefix')}${result.value.reinserted}${t('chat.transfer.reparseSuccessSuffix')}`
: '',
);
</script>
<template>
@@ -54,37 +192,132 @@ function rowKey(record: TransferPendingMatchRecord): string {
</div>
</div>
<div v-if="records.length" class="overflow-x-auto">
<table class="w-full min-w-[720px] text-xs" data-testid="transfer-pending-match-table">
<thead>
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.transferPendingMatchColSource') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.transferPendingMatchColDocNo') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.transferPendingMatchColMaterial') }}</th>
<th class="p-2">{{ $t('chat.transfer.transferPendingMatchColName') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.transferPendingMatchColDate') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.transferPendingMatchColQuantity') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="record in records"
:key="rowKey(record)"
class="border-b border-subtle"
:data-testid="`transfer-pending-match-${record.doc_no}`"
<!-- EP 表格壳:只读清单(数据=服务端当前页切片),横向滚动由 el-table 内建;行级维护入口语义不变 -->
<el-table
v-if="records.length"
:data="records"
:row-key="rowKey"
:row-class-name="rowClassName"
size="small"
class="text-xs"
data-testid="transfer-pending-match-table"
>
<el-table-column :label="$t('chat.transfer.transferPendingMatchColSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" prop="doc_no" min-width="120" class-name="whitespace-nowrap">
<template #default="{ row }">
<span class="font-semibold">{{ row.doc_no }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.transferPendingMatchColMaterial')" min-width="110" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.material_code || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.transferPendingMatchColName')" min-width="140">
<template #default="{ row }">{{ row.material_name || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDate')" min-width="100" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.transferPendingMatchColQuantity')" min-width="90" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.quantity ?? '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colAction')" min-width="120" class-name="whitespace-nowrap">
<template #default="{ row }">
<!-- 行级维护入口(Task 8):点击先调预检再弹确认,不在行上直接执行 -->
<button
type="button"
class="rounded-lg border border-indigo-200 px-2 py-0.5 text-[11px] font-bold text-indigo-600 hover:bg-indigo-50 disabled:cursor-not-allowed disabled:opacity-40"
:disabled="busy"
:data-source="row.source_code"
data-testid="transfer-pending-match-reparse"
@click="openReparseDialog(row.source_code)"
>
<td class="whitespace-nowrap p-2">{{ record.source_code }}</td>
<td class="whitespace-nowrap p-2 font-semibold">{{ record.doc_no }}</td>
<td class="whitespace-nowrap p-2">{{ record.material_code || '—' }}</td>
<td class="p-2">{{ record.material_name || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ record.movement_date || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ record.quantity ?? '—' }}</td>
</tr>
</tbody>
</table>
</div>
<div v-else class="rounded-lg bg-surface-soft p-3 text-xs text-muted" data-testid="transfer-pending-match-empty">
{{ $t('chat.transfer.reparseButton') }}
</button>
</template>
</el-table-column>
</el-table>
<!-- 服务端分页条(单页时隐藏):total=桶全量计数,页码变化统一经 watch 上抛;
文案走全局 ElConfigProvider 四语言 locale -->
<el-pagination
v-if="(total ?? 0) > PAGE_SIZE"
v-model:current-page="currentPage"
:total="total ?? 0"
:page-size="PAGE_SIZE"
layout="total, prev, pager, next, jumper"
size="small"
class="mt-2 justify-end"
data-testid="transfer-pending-match-pagination"
/>
<div v-else-if="!records.length" class="rounded-lg bg-surface-soft p-3 text-xs text-muted" data-testid="transfer-pending-match-empty">
{{ $t('chat.transfer.transferPendingMatchEmpty') }}
</div>
<!-- 「清空并重新解析」确认弹层(Task 8;内容唯一数据源=预检接口,禁止本地估算)。
v-if + model-value=true:打开即渲染、关闭即卸载(无过渡等待,测试语义同旧行为) -->
<el-dialog
v-if="dialogSource"
:model-value="true"
v-bind="transferDialogShellAttrs"
width="28rem"
class="rounded-2xl bg-surface"
>
<template #header>
<h3 class="text-base font-bold text-primary" data-testid="transfer-pending-match-reparse-dialog">
{{ $t('chat.transfer.reparseTitle') }}
</h3>
</template>
<p class="text-xs font-semibold text-secondary">{{ dialogSource }}</p>
<p v-if="previewLoading" class="mt-3 text-xs text-muted" data-testid="transfer-pending-match-reparse-loading">
…
</p>
<ul v-else-if="preview" class="mt-3 space-y-1 rounded-lg bg-surface-soft p-3 text-xs text-secondary">
<li data-testid="transfer-pending-match-reparse-files">{{ filesLine }}</li>
<li data-testid="transfer-pending-match-reparse-profile">
<template v-if="preview.profile">{{ profileLine }}</template>
<span v-else class="font-bold text-amber-600" data-testid="transfer-pending-match-reparse-profile-empty">
{{ $t('chat.transfer.reparseProfileEmpty') }}
</span>
</li>
<li data-testid="transfer-pending-match-reparse-rows">{{ rowsLine }}</li>
</ul>
<p
v-if="result"
class="mt-3 rounded-lg bg-emerald-50 px-3 py-2 text-xs font-bold text-emerald-700"
data-testid="transfer-pending-match-reparse-result"
>
{{ successLine }}
</p>
<p
v-if="errorMessage"
class="mt-3 rounded-lg bg-red-50 px-3 py-2 text-xs font-bold text-red-600"
data-testid="transfer-pending-match-reparse-error"
>
{{ $t('chat.transfer.reparseFailedPrefix') }}{{ errorMessage }}
</p>
<div class="mt-4 flex justify-end gap-2">
<button
type="button"
class="rounded-lg border border-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
data-testid="transfer-pending-match-reparse-cancel"
@click="closeReparseDialog"
>
{{ $t('chat.transfer.cancel') }}
</button>
<button
v-if="!result"
type="button"
class="rounded-lg bg-indigo-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-40"
:disabled="!preview || confirming"
data-testid="transfer-pending-match-reparse-confirm"
@click="confirmReparse"
>
{{ $t('chat.transfer.reparseButton') }}
</button>
</div>
</el-dialog>
</div>
</template>
@@ -1,7 +1,7 @@
<!--
features/chat/components/messages/TransferResultCard.vue
用途:融合卡(D9:调拨单清单=进度=结果)——props { run_no } 自驱动轮询 GET /runs/{run_no},
逐单展示「收料日期 · 拨出→拨入 · N 物料 · 合计」与状态徽标(待处理/执行中/ERP 单号/失败),
逐单展示「异动日期 · 拨出→拨入 · N 物料 · 合计」与状态徽标(待处理/执行中/ERP 单号/失败),
行明细常驻展开(Invoice | 料号 | 品名 | 拨出批号 | 投入数量,列序对齐可调拨明细);
单据级动作与状态徽标同排头部右侧(2026-09-29 方案A):result_unknown [重新触发]
(D11 唯一出口,幂等只触发末步);失败行 [重试](emit 上抛,复用既有 batch-requery)+
@@ -33,7 +33,7 @@ const props = defineProps<{
}>();
const emit = defineEmits<{
downloadReceipt: [];
downloadInbound: [];
downloadErp: [];
downloadExceptions: [];
/** 失败单 [重试]:上抛父级调 POST /documents/{doc_no}/retry(一键重查+自动重跑)。 */
@@ -67,7 +67,7 @@ const orders = computed<TransferOrder[]>(() => {
if (Array.isArray(data.orders) && data.orders.length) return data.orders;
return (data.result?.external_documents ?? []).map((doc) => ({
doc_no: doc.document_no,
receipt_date: '',
movement_date: '',
from_warehouse: doc.from_warehouse,
to_warehouse: doc.to_warehouse,
status: 'success' as const,
@@ -319,7 +319,7 @@ async function confirmCloseOrder() {
>
<div class="flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-xs">
<span class="font-semibold text-secondary" :data-testid="`transfer-order-summary-${order.doc_no}`">
{{ order.receipt_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
{{ order.movement_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
· {{ $t('chat.transfer.materialCount', { count: order.lines.length }) }}
<template v-if="order.lines.length"> · {{ orderTotalQuantity(order) }} {{ orderUnit(order) }}</template>
</span>
@@ -423,7 +423,7 @@ async function confirmCloseOrder() {
</ul>
</div>
<!-- 终态动作:下载异常清单 / 收料文件 / ERP 库存表(父级经 useChatTransfer 真实下载) -->
<!-- 终态动作:下载异常清单 / 入站文件 / ERP 库存表(父级经 useChatTransfer 真实下载) -->
<div v-if="terminal" class="mt-3 flex flex-wrap gap-2 border-t border-subtle pt-3" data-testid="transfer-result-downloads">
<button
type="button"
@@ -436,10 +436,10 @@ async function confirmCloseOrder() {
<button
type="button"
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50"
data-testid="transfer-download-receipt"
@click="emit('downloadReceipt')"
data-testid="transfer-download-inbound"
@click="emit('downloadInbound')"
>
{{ $t('chat.transfer.downloadReceiptFiles') }}
{{ $t('chat.transfer.downloadInboundFiles') }}
</button>
<button
type="button"
@@ -1,7 +1,7 @@
/**
* features/chat/components/messages/TransferSourceSelectCard.spec.ts
* 用途:来源实例选择卡——平台分组、全选已启用、清空、按收料文件状态门禁确认、
* 确认提交、重试收料 RPA;调拨类型选项=接口下发(Task 7 接口化):
* 用途:来源实例选择卡——平台分组、全选已启用、清空、按入站文件状态门禁确认、
* 确认提交、重试入站 RPA;调拨类型选项=接口下发(Task 7 接口化):
* 选项渲染/名称多语言回退/空配置空态/确认禁用,「即将上线」占位不再出现。
* 依赖:@vue/test-utils、i18n。
* 逻辑:平台 DBS/Crane 仅分组;实例为选择与执行边界(决策 2/3/4);
@@ -15,7 +15,7 @@ import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import i18n from '@/i18n';
import TransferSourceSelectCard from './TransferSourceSelectCard.vue';
import { eligibleReceiptDateTo } from './transferDate';
import { defaultMovementDate, shanghaiBusinessDate } from './transferDate';
import type { TransferTypeOption } from '../../types/transfer.types';
const readySources = [
@@ -156,8 +156,8 @@ describe('TransferSourceSelectCard', () => {
});
it('parse_failed 显示解析失败徽标且可重试', async () => {
// [断言意图] 当日收料文件解析失败(file_status=parse_failed)不得误报就绪;
// 与 none/failed/expired 一样允许重新触发收料 RPA。
// [断言意图] 当日入站文件解析失败(file_status=parse_failed)不得误报就绪;
// 与 none/failed/expired 一样允许重新触发入站 RPA。
const wrapper = mountCard({}, [
{ source_code: 'DSV-BAD', display_name: 'bad', platform: 'dbs', enabled: true, has_ready_file: false, file_status: 'parse_failed' as const },
]);
@@ -189,24 +189,28 @@ describe('TransferSourceSelectCard', () => {
expect(wrapper.emitted('confirm')).toBeUndefined();
});
it('D+1 规则提示收进 ⓘ 悬浮(title),不再平铺占宽', () => {
it('日期默认值提示收进 ⓘ 悬浮(title),不再平铺占宽', () => {
// [断言意图] 长规则文案通过原生 title 渐进披露,紧凑日期行不换行错位。
const wrapper = mountCard();
const title = wrapper.find('[data-testid="transfer-source-date-hint"]').attributes('title') ?? '';
expect(title).toContain('D+1 规则');
expect(title).toContain('业务日期前一天');
expect(title).toContain('T−2');
expect(title).toContain('业务日期');
});
it('收料日期默认为 D+1 规则日期(T-1)且上限锁定(输入期限制)', () => {
// [断言意图] 默认值与 max 均为上海口径 T-1,未来日期在选择器层面不可选。
it('异动日期默认 T−2、上限=业务日期当天(成熟规则退役后仅入参限界),movementDateLabel 文案渲染', () => {
// [断言意图] 默认值=T−2 产品默认作业点(非强制边界);max=上海口径业务日期
// 当天(更近日期允许显式选择,未来日期由后端 MOVEMENT_DATE_RANGE_INVALID 卡控);
// 日期标签 i18n 键 chat.transfer.movementDateLabel(Task 5,值=异动日期)。
const wrapper = mountCard();
const from = wrapper.find('[data-testid="transfer-source-date-from"]').element as HTMLInputElement;
const to = wrapper.find('[data-testid="transfer-source-date-to"]').element as HTMLInputElement;
const cutoff = eligibleReceiptDateTo();
expect(from.value).toBe(cutoff);
expect(to.value).toBe(cutoff);
expect(from.max).toBe(cutoff);
expect(to.max).toBe(cutoff);
const today = shanghaiBusinessDate();
expect(from.value).toBe(defaultMovementDate());
expect(to.value).toBe(defaultMovementDate());
expect(from.max).toBe(today);
expect(to.max).toBe(today);
// i18n 键更名后标签正常解析(深层嵌套纯文本键,不依赖命名插值)。
expect(wrapper.find('[data-testid="transfer-source-params"]').text()).toContain('异动日期');
});
it('起始晚于截止时行内提示并禁用确认(不等提交报错)', async () => {
@@ -258,19 +262,19 @@ describe('TransferSourceSelectCard', () => {
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSBI', 'DBS-AWSSG', 'CRANE-SZ']);
});
it('空数据来源显示「无收料数据」徽标而非抓取失败', async () => {
// [断言意图] 抓取成功但当日无收料记录(file_status=no_data)属业务结果,
// 必须如实展示"无收料数据",不得与"抓取失败"混淆(2026-10-08 PRD01 误标事故)。
it('空数据来源显示「无入站数据」徽标而非抓取失败', async () => {
// [断言意图] 抓取成功但当日无入站记录(file_status=no_data)属业务结果,
// 必须如实展示"无入站数据",不得与"抓取失败"混淆(2026-10-08 PRD01 误标事故)。
const wrapper = mountCard({}, [
{ source_code: 'CRANE-NODATA', display_name: '空数据在途仓', platform: 'crane', enabled: true, has_ready_file: false, file_status: 'no_data' },
]);
expect(wrapper.find('[data-testid="transfer-source-status-CRANE-NODATA"]').text()).toBe('无收料数据');
expect(wrapper.find('[data-testid="transfer-source-status-CRANE-NODATA"]').text()).toBe('无入站数据');
expect((wrapper.find('[data-testid="transfer-source-retry-CRANE-NODATA"]').element as HTMLButtonElement).disabled).toBe(false);
});
it('已过期来源显示「文件已过期」徽标且可重试', async () => {
// [断言意图] 保留期已到的来源不得误报就绪(has_ready_file=false);
// expired 状态与 none/failed 一样允许重新触发收料 RPA。
// expired 状态与 none/failed 一样允许重新触发入站 RPA。
const wrapper = mountCard({}, [
{ source_code: 'CRANE-EXP', display_name: '过期在途仓', platform: 'crane', enabled: true, has_ready_file: false, file_status: 'expired' },
]);
@@ -4,7 +4,7 @@
选择调拨类型后“确认范围并匹配”发起匹配。
依赖:props.sources、props.transferTypes(GET /transfer-types 接口下发,Task 7 接口化)、
i18n chat.transfer.*。
逻辑:匹配参数区(调拨类型 + 收料日期,确认时一并提交)→ 选择辅助/上下文操作条
逻辑:匹配参数区(调拨类型 + 异动日期,确认时一并提交)→ 选择辅助/上下文操作条
(有选中时原位替换辅助区,承载批量重试/下载/清空选择)→ 平台分组来源列表
(平台仅分组不可直接执行)→ 底部唯一实心主按钮「确认范围并匹配」(未选禁用);
确认只提交具备 ready 文件的来源:混合选择(含非就绪项)先披露范围再确认
@@ -19,7 +19,7 @@
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useMessage } from '@/shared/composables/useMessage';
import { eligibleReceiptDateTo } from './transferDate';
import { defaultMovementDate, shanghaiBusinessDate } from './transferDate';
import type { TransferSourceOption, TransferTypeOption } from '../../types/transfer.types';
const props = defineProps<{
@@ -27,13 +27,13 @@ const props = defineProps<{
/** 调拨类型选项(接口下发真相;空数组=无可用类型,渲染空态并禁用确认) */
transferTypes: TransferTypeOption[];
busy?: boolean;
/** 正在重试收料 RPA 的来源编码集合 */
/** 正在重试入站 RPA 的来源编码集合 */
retrying?: Set<string>;
}>();
const emit = defineEmits<{
confirm: [sourceCodes: string[], dateRange?: { from?: string; to?: string }, transferType?: string];
/** 批量重试收料 RPA:传来源编码列表 */
/** 批量重试入站 RPA:传来源编码列表 */
retry: [sourceCodes: string[]];
download: [sourceCodes: string[]];
}>();
@@ -42,11 +42,12 @@ const { warning: notifyWarning } = useMessage();
const { t, locale } = useI18n();
const selected = ref<Set<string>>(new Set());
/** 收料日期范围(匹配查询范围):默认 D+1 规则日期(T-1),上限同(输入期限制,
* 不等提交报错);后端 RECEIPT_DATE_RANGE_INVALID 卡控保留为双保险。 */
const maxReceiptDate = eligibleReceiptDateTo();
const dateFrom = ref(maxReceiptDate);
const dateTo = ref(maxReceiptDate);
/** 异动日期范围(匹配查询范围):默认 T−2 产品默认作业点;输入上限=业务日期
* 当天(成熟规则已退役,日期边界只由入参给定);未来日期由后端
* MOVEMENT_DATE_RANGE_INVALID 兜底卡控。 */
const maxMovementDate = shanghaiBusinessDate();
const dateFrom = ref(defaultMovementDate());
const dateTo = ref(defaultMovementDate());
/** 起始不得晚于截止(清空视为不限,提交 undefined)。 */
const dateRangeInvalid = computed(() => {
@@ -54,7 +55,7 @@ const dateRangeInvalid = computed(() => {
const to = dateTo.value || null;
return from !== null && to !== null && from > to;
});
/** 调拨业务类型 code(Task 7 接口化):决定本次匹配纳入哪些收料数据与转换规则;
/** 调拨业务类型 code(Task 7 接口化):决定本次匹配纳入哪些入站数据与转换规则;
* 空配置(无可选类型)时为 null,确认按钮禁用兜底。 */
const transferType = ref<string | null>(null);
@@ -164,7 +165,7 @@ function clearSelected() {
selected.value = new Set();
}
/** 批量重试收料 RPA:仅触发所选来源中可重试的那部分。 */
/** 批量重试入站 RPA:仅触发所选来源中可重试的那部分。 */
function batchRetry() {
const codes = [...selected.value].filter(
(code) => props.sources.some((s) => s.source_code === code && isRetryable(s)),
@@ -232,7 +233,7 @@ watch(selected, () => {
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-source-select-card">
<h3 class="mb-3 text-sm font-bold text-primary">{{ $t('chat.transfer.sourceSelectTitle') }}</h3>
<!-- [ZONE 1] 匹配参数区:调拨类型 + 收料日期同组(确认匹配时一并提交,参数先行定范围)。 -->
<!-- [ZONE 1] 匹配参数区:调拨类型 + 异动日期同组(确认匹配时一并提交,参数先行定范围)。 -->
<div class="mb-3 rounded-lg border border-subtle p-3" data-testid="transfer-source-params">
<p class="mb-2 text-[11px] font-bold text-muted">{{ $t('chat.transfer.matchParams') }}</p>
<div class="flex flex-wrap items-center gap-2">
@@ -260,11 +261,11 @@ watch(selected, () => {
</button>
</div>
<div class="mt-2 flex flex-wrap items-center gap-2">
<span class="text-xs font-bold text-secondary">{{ $t('chat.transfer.receiptDateLabel') }}</span>
<span class="text-xs font-bold text-secondary">{{ $t('chat.transfer.movementDateLabel') }}</span>
<input
v-model="dateFrom"
type="date"
:max="maxReceiptDate"
:max="maxMovementDate"
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
data-testid="transfer-source-date-from"
/>
@@ -272,7 +273,7 @@ watch(selected, () => {
<input
v-model="dateTo"
type="date"
:max="maxReceiptDate"
:max="maxMovementDate"
:min="dateFrom || undefined"
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
data-testid="transfer-source-date-to"
@@ -280,12 +281,12 @@ watch(selected, () => {
<!-- D+1 规则属低频说明:收进原生 title 悬浮(渐进披露),避免长文案挤压布局。 -->
<span
class="cursor-help text-xs text-muted"
:title="$t('chat.transfer.receiptDateHint')"
:title="$t('chat.transfer.movementDateHint')"
data-testid="transfer-source-date-hint"
>ⓘ</span>
<!-- 输入期校验:起始晚于截止时行内提示并禁用确认(不等提交报错)。 -->
<span v-if="dateRangeInvalid" class="text-xs font-bold text-red-600" data-testid="transfer-source-date-invalid">
{{ $t('chat.transfer.receiptDateInvalid') }}
{{ $t('chat.transfer.movementDateInvalid') }}
</span>
</div>
</div>
@@ -405,7 +406,7 @@ watch(selected, () => {
>
{{ t('chat.transfer.fileFailed') }}
</span>
<!-- 无收料数据(no_data):抓取成功但当日无收料记录,属业务结果而非故障;当日稍后到货可重抓补数 -->
<!-- 无入站数据(no_data):抓取成功但当日无入站记录,属业务结果而非故障;当日稍后到货可重抓补数 -->
<span
v-else-if="source.file_status === 'no_data'"
class="inline-flex items-center gap-1 rounded-full bg-sky-50 px-2 py-0.5 text-[10px] font-bold text-sky-700"
@@ -420,7 +421,7 @@ watch(selected, () => {
>
{{ t('chat.transfer.fileExpired') }}
</span>
<!-- 解析失败(parse_failed):当日收料文件解析失败;重试按状态分层——parse_failed=本地重解析,其余状态=重新触发收料 RPA 重抓 -->
<!-- 解析失败(parse_failed):当日入站文件解析失败;重试按状态分层——parse_failed=本地重解析,其余状态=重新触发入站 RPA 重抓 -->
<span
v-else-if="source.file_status === 'parse_failed'"
class="inline-flex items-center gap-1 rounded-full bg-red-50 px-2 py-0.5 text-[10px] font-bold text-red-700"
@@ -439,7 +440,7 @@ watch(selected, () => {
type="button"
class="ml-1 inline-flex h-6 w-6 items-center justify-center rounded-md border border-default text-sm text-muted hover:border-brand-200 hover:text-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
:disabled="busy || !isRetryable(source) || retrying?.has(source.source_code)"
:title="t('chat.transfer.retryReceipt')"
:title="t('chat.transfer.retryInbound')"
:data-testid="`transfer-source-retry-${source.source_code}`"
@click.stop="emit('retry', [source.source_code])"
>
@@ -8,7 +8,7 @@
* (evidence-sync,2026-09-25);匹配卡批号列 deriveBatchNo 旧路径兼容
* (Task 7 规则化后未传规则仍 WTP→HOW)。
*/
import { mount } from '@vue/test-utils';
import { mount, flushPromises } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import i18n from '@/i18n';
import TransferFileProgressCard from './TransferFileProgressCard.vue';
@@ -22,9 +22,8 @@ const summary = {
matching_id: 'MTG-1',
status: 'ready_to_execute',
business_date: '2026-08-06',
eligible_receipt_date_to: '2026-08-05',
expires_at: '',
counts: { file_invoice_count: 3, not_matured_count: 1, matched_count: 2, executable_count: 2, blocked_count: 0 },
counts: { file_invoice_count: 3, matched_count: 3, executable_count: 2, blocked_count: 1 },
estimated_transfer_quantity: '2400',
estimated_external_write_count: 2,
matching_hash: 'sha256:x',
@@ -32,7 +31,7 @@ const summary = {
const items = [
{ item_id: 101, source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: '连接器', specification: 'A', invoice_no: 'INV-001', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200', to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable', checked_at: '2026-09-23T09:05:00+08:00' },
{ item_id: 102, source_code: 'DBS-AWSBI', material_no: 'MAT-2', material_name: '控制器', specification: 'B', invoice_no: 'INV-041', from_warehouse: '', from_quantity: null, to_warehouse: '', to_quantity: '400', result: 'not_matured' },
{ item_id: 102, source_code: 'DBS-AWSBI', material_no: 'MAT-2', material_name: '控制器', specification: 'B', invoice_no: 'INV-041', from_warehouse: '', from_quantity: null, to_warehouse: '', to_quantity: '400', result: 'result_unknown' },
];
describe('TransferFileProgressCard', () => {
@@ -50,16 +49,17 @@ describe('TransferFileProgressCard', () => {
});
describe('TransferMatchCard', () => {
it('勾选键为明细行 item_id:阻断/未成熟项 checkbox 禁用,可执行项可选', () => {
it('勾选键为明细行 item_id:可执行项可选,终态行(result_unknown)checkbox 禁用', () => {
const wrapper = mount(TransferMatchCard, {
props: { summary, items, selected: new Set<number>([101]) },
...mountOptions,
});
const executableCheck = wrapper.find('[data-testid="transfer-check-INV-001"]');
const maturedCheck = wrapper.find('[data-testid="transfer-check-INV-041"]');
const terminalCheck = wrapper.find('[data-testid="transfer-check-INV-041"]');
expect((executableCheck.element as HTMLInputElement).disabled).toBe(false);
expect((executableCheck.element as HTMLInputElement).checked).toBe(true);
expect((maturedCheck.element as HTMLInputElement).disabled).toBe(true);
// [断言意图] blocked 行可勾(供重查),终态行(result_unknown,不可执行不可重查)禁用。
expect((terminalCheck.element as HTMLInputElement).disabled).toBe(true);
});
it('历史回放行(无 item_id)checkbox 禁用,防误选', () => {
@@ -157,7 +157,7 @@ describe('TransferMatchCard', () => {
expect(legacyWrapper.find('[data-testid="transfer-match-counts"]').text()).toContain('已失效 0 行');
});
it('pending_stock_check 行徽标展示「待查库存」(amber 同未成熟色系)', () => {
it('pending_stock_check 行徽标展示「待查库存」(amber 提示色)', () => {
// [断言意图] evidence-sync(2026-09-25):文件已落地未查 ERP 的行为
// pending_stock_check,徽标须用独立文案且为 amber 族(非阻断红)。
const pendingItems = [{ ...items[0], result: 'pending_stock_check' }];
@@ -205,15 +205,15 @@ describe('TransferMatchCard', () => {
expect(wrapper.find('[data-testid="transfer-file-removed-hint"]').exists()).toBe(true);
});
it('同 Invoice 跨收料日期拆单(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
it('同 Invoice 跨异动日期拆单(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
// [断言意图] 回归防线(2026-09-21):拆单设计下 invoice_no 不再唯一,
// 行 key 若仍用 invoice_no 会出现重复 key,Vue 列表 diff 错乱导致
// 筛选后不匹配行残留/克隆(用户输入 HOX 仍见 SLC2PHX 行)。
// 行身份 = (来源, Invoice, 料号, 收料日期),key 必须用同一粒度。
// 行身份 = (来源, Invoice, 料号, 异动日期),key 必须用同一粒度。
const dupItems = [
{ item_id: 201, source_code: 'CRANE', material_no: 'M-1', material_name: '机框', specification: '', invoice_no: 'HOX-1', receipt_date: '2026-09-11', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
{ item_id: 202, source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-03', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
{ item_id: 203, source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-04', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
{ item_id: 201, source_code: 'CRANE', material_no: 'M-1', material_name: '机框', specification: '', invoice_no: 'HOX-1', movement_date: '2026-09-11', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
{ item_id: 202, source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', movement_date: '2026-09-03', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
{ item_id: 203, source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', movement_date: '2026-09-04', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
];
const wrapper = mount(TransferMatchCard, {
props: { summary, items: dupItems, selected: new Set<number>() },
@@ -242,7 +242,7 @@ describe('TransferResultCard(Task 13 融合卡)', () => {
posting_status: 'posted',
lines: [{ material_no: 'MAT-1', material_name: '连接器', specification: 'A', invoice_no: 'INV-001', quantity: '1200' }],
}],
exceptions: [{ source_code: 'DBS-AWSBI', invoice_no: 'INV-999', material_no: 'MAT-9', reason: 'business_failed', facts: '收料 300 / ERP 280' }],
exceptions: [{ source_code: 'DBS-AWSBI', invoice_no: 'INV-999', material_no: 'MAT-9', reason: 'business_failed', facts: '异动 300 / ERP 280' }],
},
};
const mountCard = () => mount(TransferResultCard, { props: { runNo: 'RUN-1', initialRun: run }, ...mountOptions });
@@ -264,12 +264,12 @@ describe('TransferResultCard(Task 13 融合卡)', () => {
expect(wrapper.find('[data-testid="transfer-exceptions-area"]').text()).toContain('INV-999');
});
it('提供下载按钮(收料来源文件 + ERP 库存表 + 异常清单)', async () => {
it('提供下载按钮(出入站来源文件 + ERP 库存表 + 异常清单)', async () => {
const wrapper = mountCard();
await wrapper.find('[data-testid="transfer-download-receipt"]').trigger('click');
await wrapper.find('[data-testid="transfer-download-inbound"]').trigger('click');
await wrapper.find('[data-testid="transfer-download-erp"]').trigger('click');
await wrapper.find('[data-testid="transfer-download-exceptions"]').trigger('click');
expect(wrapper.emitted('downloadReceipt')).toBeTruthy();
expect(wrapper.emitted('downloadInbound')).toBeTruthy();
expect(wrapper.emitted('downloadErp')).toBeTruthy();
expect(wrapper.emitted('downloadExceptions')).toBeTruthy();
});
@@ -286,6 +286,8 @@ describe('TransferManualCloseDialog', () => {
props: { open: true, invoiceNo: 'INV-001' },
...mountOptions,
});
// [断言意图] EP el-dialog 挂载后下一 tick 才渲染弹层内容,先 flush 再断言。
await flushPromises();
const confirm = wrapper.find('[data-testid="transfer-close-confirm"]');
expect((confirm.element as HTMLButtonElement).disabled).toBe(true);
await wrapper.find('[data-testid="transfer-close-reason"]').setValue('线下已处理');
@@ -1,21 +1,24 @@
/**
* features/chat/components/messages/transferDate.spec.ts
* 用途:锁定 T+2 成熟口径的截止日计算(与后端 date_policy 同口径,默认 lag=2)。
* 用途:锁定匹配日期默认值(T−2 产品默认作业点)与上海业务日计算(与后端
* date_policy 同口径)。
* 依赖:被测纯函数 transferDate.ts。
* 逻辑:直接注入 UTC 时刻构造上海业务日,断言跨日/跨月边界不漂移。
* 【成熟规则已退役 2026-10-16】原「可匹配截止日」断言改为默认值语义
* (T−2 仅是选择器默认,非强制边界;输入上限=业务日期当天)。
*/
import { describe, expect, it } from 'vitest';
import { eligibleReceiptDateTo, shanghaiBusinessDate } from './transferDate';
import { defaultMovementDate, shanghaiBusinessDate } from './transferDate';
describe('eligibleReceiptDateTo(T+2 口径)', () => {
it('T=2026-09-28 → 截止 2026-09-26(T-2,海外时差)', () => {
describe('defaultMovementDate(T−2 默认作业点)', () => {
it('T=2026-09-28 → 默认 2026-09-26(T-2)', () => {
// 上海 9-28 13:00 = UTC 05:00。
expect(eligibleReceiptDateTo(new Date('2026-09-28T05:00:00Z'))).toBe('2026-09-26');
expect(defaultMovementDate(new Date('2026-09-28T05:00:00Z'))).toBe('2026-09-26');
});
it('UTC 月末跨界仍按上海业务日回退 2 天', () => {
// 上海 10-01 00:30 = UTC 9-30 16:30 → T=10-01,截止 09-29。
expect(eligibleReceiptDateTo(new Date('2026-09-30T16:30:00Z'))).toBe('2026-09-29');
// 上海 10-01 00:30 = UTC 9-30 16:30 → T=10-01,默认 09-29。
expect(defaultMovementDate(new Date('2026-09-30T16:30:00Z'))).toBe('2026-09-29');
});
it('shanghaiBusinessDate 返回上海业务日(UTC 17:00 = 上海次日)', () => {
@@ -1,15 +1,17 @@
/**
* features/chat/components/messages/transferDate.ts
* 用途:在途调拨业务日期工具——按 Asia/Shanghai 计算业务日期(T)与
* T+lag 成熟规则的可匹配截止日(T - lag,lag 默认 2 即 T+2),
* 与后端 date_policy 完全同口径。
* 用途:在途调拨业务日期工具——按 Asia/Shanghai 计算业务日期(T)、
* 匹配日期默认值(T−2 产品默认作业点)与输入上限(T 当天)。
* 依赖:无(纯函数,便于单测)。
* 逻辑:浏览器本地时区不可靠(部署/用户时区任意),必须固定上海时区口径,
* 否则前端日期上限与后端 TRANSFER.RECEIPT_DATE_RANGE_INVALID 卡控会漂移。
* 否则前端日期默认/上限与后端 TRANSFER.MOVEMENT_DATE_RANGE_INVALID
* 卡控会漂移。
* 【成熟规则已退役 2026-10-16】数据无成熟属性——T−2 只是日期选择器的
* 默认值(非强制边界),输入上限=业务日期当天;未来日期由后端卡控。
*/
/** 成熟滞后天数:与后端 IN_TRANSIT_TRANSFER_MATURITY_LAG_DAYS 默认值一致(T+2,海外时差余量)。 */
const MATURITY_LAG_DAYS = 2;
/** 匹配日期默认回看天数:T−2 为产品默认作业点(与排程任务常用 T−N 偏移一致)。 */
const DEFAULT_LOOKBACK_DAYS = 2;
/** Asia/Shanghai 当前业务日期(YYYY-MM-DD)。 */
export function shanghaiBusinessDate(now: Date = new Date()): string {
@@ -22,9 +24,9 @@ export function shanghaiBusinessDate(now: Date = new Date()): string {
}).format(now);
}
/** T+lag 规则可匹配截止日(业务日期 T - lag 天,默认 T-2,YYYY-MM-DD)。 */
export function eligibleReceiptDateTo(now: Date = new Date()): string {
/** 匹配日期默认值(业务日期 T − 2 天,YYYY-MM-DD):仅是选择器默认,非强制边界。 */
export function defaultMovementDate(now: Date = new Date()): string {
const business = new Date(`${shanghaiBusinessDate(now)}T00:00:00Z`);
business.setUTCDate(business.getUTCDate() - MATURITY_LAG_DAYS);
business.setUTCDate(business.getUTCDate() - DEFAULT_LOOKBACK_DAYS);
return business.toISOString().slice(0, 10);
}
@@ -0,0 +1,16 @@
/**
* features/chat/components/messages/transferDialogShell.ts
* 用途:在途调拨确认弹层壳(ElDialog)共享配置——人工关闭/清空重解析/关闭单
* 三处高危确认弹窗统一的防误触语义与居中形态。
* 依赖:无(纯常量,供组件模板 v-bind 展开)。
* 逻辑:禁 ESC / 遮罩点击 / 右上角 X 关闭——确认类危险操作仅经取消/确认按钮关闭,
* 与 EP 化前原生遮罩层行为一致;alignCenter 对齐原 fixed 居中布局。
*/
/** ElDialog 防误触共享配置:`v-bind="transferDialogShellAttrs"` 展开到组件标签。 */
export const transferDialogShellAttrs = {
alignCenter: true,
closeOnClickModal: false,
closeOnPressEscape: false,
showClose: false,
} as const;