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>