feat(in-transit-transfer): 实现匹配静默顶替并完善单号与明细表体验

This commit is contained in:
hugo committed 2026-10-27 16:35:56 +08:00
1 parent f5611d6783
commit 79050d02ba
25 files changed
+806 -178

No files matched your search

@@ -320,7 +320,7 @@ function resultLabelKey(item: TransferBacklogItem): string {
</div>
</div>
<!-- EP 表格壳:数据=服务端返回的当前页切片;横向滚动由 el-table 内建(列 min-width 撑开) -->
<!-- EP 表格:show-overflow-tooltip;左固定勾选,右固定结果+操作;单号/老化可滚 -->
<el-table
v-if="items.length"
:data="items"
@@ -330,7 +330,7 @@ function resultLabelKey(item: TransferBacklogItem): string {
class="text-xs"
data-testid="transfer-backlog-table"
>
<el-table-column width="48" class-name="whitespace-nowrap">
<el-table-column fixed width="48">
<template #header>
<el-checkbox
size="small"
@@ -349,40 +349,61 @@ function resultLabelKey(item: TransferBacklogItem): string {
/>
</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.transferTypeLabel')" min-width="140" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="120" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.transferTypeLabel')" min-width="140" show-overflow-tooltip>
<template #default="{ row }">
<span :data-testid="`transfer-backlog-type-${row.invoice_no}`">{{ typeLabel(row.transfer_type) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colInvoice')" prop="invoice_no" min-width="130" class-name="whitespace-nowrap">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColDocNo')"
prop="invoice_no"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span class="font-semibold">{{ row.invoice_no }}</span>
<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">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColExternalDoc')"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span data-testid="transfer-backlog-external-doc">{{ row.external_doc_no || '—' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="110" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="140" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="160" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" min-width="110" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="90" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colToWarehouse')" min-width="110" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" show-overflow-tooltip>
<template #default="{ row }">{{ formatQuantity(row.movement_quantity) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colResult')" min-width="110">
<el-table-column :label="$t('chat.transfer.colAging')" min-width="90" show-overflow-tooltip>
<template #default="{ row }">{{ $t(agingLabel(row.aging_level)) }}</template>
</el-table-column>
<el-table-column
fixed="right"
:label="$t('chat.transfer.colResult')"
width="100"
>
<template #default="{ row }">
<el-tag
size="small"
@@ -395,10 +416,11 @@ function resultLabelKey(item: TransferBacklogItem): string {
</el-tag>
</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">
<el-table-column
fixed="right"
:label="$t('chat.transfer.colAction')"
width="150"
>
<template #default="{ row }">
<template v-if="isActionable(row as TransferBacklogItem)">
<!-- 失效行(文件已移除)只留关闭:重查会被后端拒绝(TRANSFER.RETRY_NOT_ALLOWED)。 -->
@@ -2,20 +2,18 @@
features/chat/components/messages/TransferExecutableCard.vue
用途:可调拨明细卡——全局可执行行队列(跨匹配范围):勾选明细行后按行生成调拨单。
依赖:Element Plus ElTable/ElTableColumn/ElInput/ElButton/ElTag/ElPagination/
ElCheckbox(2026-10-20:勾选列一并 EP;testid 挂 el-checkbox,规格经内层
input 读写)、props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo。
逻辑:行由后端按业务稳定键排序(异动日期→Invoice→创建时间);勾选为卡片本地态;
stale/file_current 行置灰提示(执行门禁在后端,失败经 BusinessError 展示);
无 item_id 的历史回放行禁选。
客户端分页(2026-10-16):集合天然有界(仅当日成熟可执行行)但为防增长后
DOM 失控,50/页切片渲染;关键字筛选变更回第 1 页,勾选集合跨页保留。
行定位:el-table 经 row-class-name 注入 transfer-executable-<invoice_no>。
调拨类型列取行上 transfer_type,按启用类型配置显示当前语言名称。
ElCheckbox/ElAlert、props.items、i18n chat.transfer.*、transferBatch /
transferItemTable(明细表密度约定)。
逻辑:行由后端按业务稳定键排序;勾选本地态;无 item_id 历史行禁选;50/页分页。
表格遵循 transferItemTable:show-overflow-tooltip、左固定勾选、右固定结果+操作、
单号可滚、库存数量与查询时刻同行、过期用顶栏 el-alert 汇总批量重查。
行定位:row-class-name 注入 transfer-executable-<invoice_no>。
-->
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import {
ElAlert,
ElButton,
ElCheckbox,
ElInput,
@@ -27,8 +25,11 @@ import {
import type { CheckboxValueType } from 'element-plus';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import {
formatStockQuantityCell,
freshnessHint,
} from './transferItemTable';
import { transferTypeDisplay } from './transferTypeLabel';
import { parseApiUtcDate } from '@/shared/utils/dateTime';
import type { TransferMatchingItem, TransferTypeOption } from '../../types/transfer.types';
const props = withDefaults(defineProps<{
@@ -40,7 +41,7 @@ const props = withDefaults(defineProps<{
transferTypes: () => [],
});
const { locale } = useI18n();
const { locale, t } = useI18n();
/**
* 把可执行行的调拨类型 code 显示成名称。
@@ -70,7 +71,7 @@ const filtered = computed(() =>
props.items.filter((item) => {
const kw = keyword.value.trim().toLowerCase();
if (!kw) return true;
const haystack = [item.invoice_no, item.material_no, item.material_name, item.source_code, item.lot_no]
const haystack = [item.invoice_no, item.external_doc_no, item.material_no, item.material_name, item.source_code, item.lot_no]
.map((value) => String(value ?? '').toLowerCase());
return haystack.some((value) => value.includes(kw));
}),
@@ -80,7 +81,6 @@ const pagedItems = computed(() =>
filtered.value.slice((currentPage.value - 1) * PAGE_SIZE, currentPage.value * PAGE_SIZE),
);
// 筛选变更回第 1 页;刷新后行数减少时收拢当前页防空白页
watch(keyword, () => {
currentPage.value = 1;
});
@@ -97,6 +97,13 @@ const allFilteredSelected = computed(() =>
filtered.value.length > 0 && filtered.value.every((item) => item.item_id != null && selectedIds.value.has(item.item_id)),
);
/** 当前筛选下库存已过期且可重查的行 id。 */
const staleItemIds = computed(() =>
filtered.value
.filter((item) => item.stale === true && item.item_id != null)
.map((item) => item.item_id as number),
);
function toggleRow(item: TransferMatchingItem, checkedBox: boolean) {
if (item.item_id == null) return;
const next = new Set(selectedIds.value);
@@ -126,7 +133,7 @@ function rowKey(item: TransferMatchingItem): string {
/**
* el-table 行类:注入行定位类 + stale/文件过期置灰。
* @param row 可执行明细行
* @returns 空格分隔的 class 串(含 transfer-executable-<invoice_no>)
* @returns 空格分隔的 class 串
*/
function rowClassName({ row }: { row: TransferMatchingItem }): string {
return [
@@ -135,12 +142,21 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
].filter(Boolean).join(' ');
}
/** 查询时刻展示(HH:mm);后端 naive ISO 按 UTC 解析后转浏览器本地时区
* (仓库约定 parseApiUtcDate,2026-09-29 修复 UTC+8 展示异常);无 checked_at 不渲染。 */
function checkedTime(item: TransferMatchingItem): string {
if (!item.checked_at) return '';
const date = parseApiUtcDate(item.checked_at);
return Number.isNaN(date.getTime()) ? '' : date.toTimeString().slice(0, 5);
/**
* 库存数量单元格:数量与完整查询时刻同一行。
* @param item 可执行明细行
*/
function stockCell(item: TransferMatchingItem): string {
return formatStockQuantityCell(formatQuantity(item.from_quantity), item.checked_at);
}
/**
* 批量重查当前筛选下全部过期行。
* 核心逻辑:顶栏汇总入口,避免结果列刷长文案。
*/
function requeryStaleRows() {
if (!staleItemIds.value.length) return;
emit('requery', [...staleItemIds.value]);
}
</script>
@@ -157,6 +173,30 @@ function checkedTime(item: TransferMatchingItem): string {
</el-button>
</div>
<el-alert
v-if="staleItemIds.length"
type="warning"
:closable="false"
class="mb-2"
data-testid="transfer-executable-stale-banner"
>
<template #title>
<div class="flex flex-wrap items-center gap-2">
<span>{{ $t('chat.transfer.staleBanner', { count: staleItemIds.length }) }}</span>
<el-button
link
type="primary"
size="small"
:disabled="busy"
data-testid="transfer-executable-requery-stale"
@click="requeryStaleRows"
>
{{ $t('chat.transfer.staleBannerRequery') }}
</el-button>
</div>
</template>
</el-alert>
<div class="mb-2 flex flex-wrap items-center gap-2">
<div class="w-56 shrink-0">
<el-input
@@ -189,7 +229,7 @@ function checkedTime(item: TransferMatchingItem): string {
class="text-xs"
data-testid="transfer-executable-table"
>
<el-table-column width="48" class-name="whitespace-nowrap">
<el-table-column fixed width="48">
<template #header>
<el-checkbox
size="small"
@@ -208,52 +248,77 @@ function checkedTime(item: TransferMatchingItem): string {
/>
</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.transferTypeLabel')" min-width="140" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="120" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.transferTypeLabel')" min-width="140" show-overflow-tooltip>
<template #default="{ row }">
<span :data-testid="`transfer-executable-type-${row.invoice_no}`">{{ typeLabel(row.transfer_type) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colInvoice')" prop="invoice_no" min-width="130" class-name="whitespace-nowrap">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColDocNo')"
prop="invoice_no"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span class="font-semibold">{{ row.invoice_no }}</span>
<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">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColExternalDoc')"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span data-testid="transfer-executable-external-doc">{{ row.external_doc_no || '—' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="110" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="140" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="160" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" prop="from_warehouse" min-width="110" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="168" show-overflow-tooltip>
<template #default="{ row }">
{{ formatQuantity(row.from_quantity) }}
<div v-if="checkedTime(row as TransferMatchingItem)" class="text-[10px] text-muted">{{ checkedTime(row as TransferMatchingItem) }}</div>
<span
:class="row.stale ? 'text-amber-700' : undefined"
:title="freshnessHint(row as TransferMatchingItem, t) || undefined"
:data-testid="`transfer-executable-stock-${row.invoice_no}`"
>
{{ stockCell(row as TransferMatchingItem) }}
</span>
</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">
<el-table-column :label="$t('chat.transfer.colToWarehouse')" prop="to_warehouse" min-width="110" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" show-overflow-tooltip>
<template #default="{ row }">{{ formatQuantity(row.to_quantity) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colResult')" min-width="120">
<el-table-column
fixed="right"
:label="$t('chat.transfer.colResult')"
width="88"
>
<template #default="{ row }">
<el-tag size="small" type="success" effect="light" data-testid="transfer-executable-result">
<el-tag
size="small"
type="success"
effect="light"
:title="freshnessHint(row as TransferMatchingItem, t) || undefined"
data-testid="transfer-executable-result"
>
{{ $t('chat.transfer.resultExecutable') }}
</el-tag>
<div v-if="row.stale" class="mt-0.5 text-[10px] text-amber-600">{{ $t('chat.transfer.staleRow') }}</div>
<div v-else-if="row.file_current === false" class="mt-0.5 text-[10px] text-amber-600">{{ $t('chat.transfer.fileChangedRow') }}</div>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colAction')" min-width="90" class-name="whitespace-nowrap">
<el-table-column
fixed="right"
:label="$t('chat.transfer.colAction')"
width="72"
>
<template #default="{ row }">
<el-button
link
@@ -268,7 +333,6 @@ function checkedTime(item: TransferMatchingItem): string {
</template>
</el-table-column>
</el-table>
<!-- 客户端分页(单页时隐藏):文案走全局 ElConfigProvider 四语言 locale -->
<el-pagination
v-if="filtered.length > PAGE_SIZE"
v-model:current-page="currentPage"
@@ -362,7 +362,10 @@ onMounted(async () => {
:data-testid="`transfer-executed-items-${order.doc_no}`"
>
<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.transferPendingMatchColDocNo')" prop="invoice_no" min-width="120" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.external_doc_no || '—' }}</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')" prop="material_name" min-width="140" />
<!-- 拨出批号展示外部形态(WTP→HOW 镜像转换,与匹配卡/可调拨明细/待办池同规则;
@@ -2,7 +2,7 @@
* features/chat/components/messages/TransferMatchCard.spec.ts
* 用途:匹配卡顶栏「来源失败」横幅过滤——路由未解析失败只行内展示,不进顶栏。
* 依赖:@vue/test-utils、i18n。
* 逻辑:来源失败顶栏(sources[].error_code/error_message)防止“安静全 0”;
* 逻辑:来源失败顶栏(sources[].error_code/error_message)防止“安静全 0”。
* 后端分层后路由失败保持行级(result=blocked_route_not_resolved),
* 顶栏需按 error_code 客户端排除(历史卡片回放同样生效)。
*/
@@ -7,20 +7,11 @@
busy)、i18n chat.transfer.*。
逻辑:明细表渲染 pagedItems(filtered 经客户端分页切片);阻断项 checkbox 禁用;
勾选键 = 明细行 item_id(历史回放行无 item_id 禁用防误选);
库存数量下方小字透出查询时刻(checked_at);stale 行置灰 + 重查提示;
file_current=false 行提示文件已更新(自动对齐语义);blocked_file_removed
徽标独立文案;pending_stock_check 行徽标「待查库存」(el-tag warning);
计数卡透出待查库存(pending_stock_check_count)/已失效(invalid_count),
历史回放缺省按 0 展示;blocked_file_removed 行退出主视图(表格不渲染),
表格下方折叠提示去待处理异常池处理——重查救不了已消失的行,主清单只留
可行动项;重查范围含可恢复阻断与可执行行(重查仍按 invoice_no 提交);
阻断原因经结果徽标 title 悬浮透出不占行高;无选择或 busy 时生成按钮禁用;
emit execute(itemIds);来源级解析/文件失败经 sources.error_code 透出
(防"安静全 0"),但路由未解析失败(TRANSFER.ROUTE_NOT_RESOLVED)不进顶栏
——路由失败保持行级(result=blocked_route_not_resolved 行内展示),
顶栏按 error_code 客户端排除,历史卡片回放同样生效;
行定位:el-table 行不支持逐行 attr,经 row-class-name 注入
transfer-item-<invoice_no>(spec/e2e 用类选择器等价定位);
明细表遵循 transferItemTable(EP show-overflow-tooltip、左固定勾选、
右固定结果/重查、单号可滚、库存数量与查询时刻同行、过期顶栏 el-alert 汇总);
blocked_file_removed 退出主视图;重查仍按 invoice_no;emit execute(itemIds);
来源失败顶栏排除 TRANSFER.ROUTE_NOT_RESOLVED;行定位经 row-class-name
注入 transfer-item-<invoice_no>;
[2026-10-12 单据数口径修正] 预计 ERP 单据数(计数卡=全部可执行行、
生成按钮旁=勾选可执行行)按执行建单五元组 (external_org, source_code,
movement_date, from_warehouse, to_warehouse) 去重实时计算(与后端
@@ -49,7 +40,10 @@ import {
import type { CheckboxValueType } from 'element-plus';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import { parseApiUtcDate } from '@/shared/utils/dateTime';
import {
formatStockQuantityCell,
freshnessHint,
} from './transferItemTable';
import type { TransferMatchingItem, TransferMatchingSummary, TransferSourceProgress } from '../../types/transfer.types';
const { t } = useI18n();
@@ -129,7 +123,7 @@ const filtered = computed(() =>
if (isFileRemoved(item)) return false;
const kw = keyword.value.trim().toLowerCase();
if (kw) {
const haystack = [item.material_no, item.material_name, item.invoice_no, item.lot_no]
const haystack = [item.material_no, item.material_name, item.invoice_no, item.external_doc_no, item.lot_no]
.map((value) => String(value ?? '').toLowerCase());
if (!haystack.some((value) => value.includes(kw))) return false;
}
@@ -179,6 +173,22 @@ function requerySelected(): void {
if (nos.length) emit('requery', nos);
}
/** 当前筛选下库存已过期且可重查的单号。 */
const staleInvoiceNos = computed(() =>
filtered.value
.filter((item) => item.stale === true && isRequeryable(item))
.map((item) => item.invoice_no),
);
/**
* 批量重查当前筛选下全部过期行。
* 核心逻辑:顶栏汇总入口,避免结果列刷长文案。
*/
function requeryStaleRows(): void {
if (!staleInvoiceNos.value.length) return;
emit('requery', [...staleInvoiceNos.value]);
}
function isChecked(item: TransferMatchingItem): boolean {
return item.item_id != null && props.selected.has(item.item_id);
}
@@ -217,18 +227,11 @@ const estimatedDocumentCountSelected = computed(
);
/**
* 库存查询时刻小字(HH:mm);后端 naive ISO 按 UTC 解析后转浏览器本地时区
* (仓库约定 parseApiUtcDate,2026-09-29 修复 UTC+8 展示异常);
* 无效/缺省 checked_at 返回 null 不渲染。
* @param item 匹配明细行;checked_at 为后端 ISO 时间
* 库存数量单元格:数量与完整查询时刻同一行。
* @param item 匹配明细行
*/
function checkedAtLabel(item: TransferMatchingItem): string | null {
if (!item.checked_at) return null;
const date = parseApiUtcDate(item.checked_at);
if (Number.isNaN(date.getTime())) return null;
const hh = String(date.getHours()).padStart(2, '0');
const mm = String(date.getMinutes()).padStart(2, '0');
return `${hh}:${mm}`;
function stockCell(item: TransferMatchingItem): string {
return formatStockQuantityCell(formatQuantity(item.from_quantity), item.checked_at);
}
function resultLabel(result: string): string {
@@ -348,6 +351,30 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
</div>
</el-alert>
<el-alert
v-if="staleInvoiceNos.length"
type="warning"
:closable="false"
class="mb-3"
data-testid="transfer-match-stale-banner"
>
<template #title>
<div class="flex flex-wrap items-center gap-2">
<span>{{ $t('chat.transfer.staleBanner', { count: staleInvoiceNos.length }) }}</span>
<el-button
link
type="primary"
size="small"
:disabled="props.requeryBusy"
data-testid="transfer-match-requery-stale"
@click="requeryStaleRows"
>
{{ $t('chat.transfer.staleBannerRequery') }}
</el-button>
</div>
</template>
</el-alert>
<div class="mb-2 flex flex-wrap items-center gap-2">
<div class="w-56 shrink-0">
<el-input
@@ -383,8 +410,7 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
</el-button>
</div>
<!-- EP 表格壳:横向滚动由 el-table 内建(列 min-width 撑开);无行动行时不挂表;
表体只挂当前页切片(pagedItems),全量集合仍在 filtered 供筛选/全选/计数 -->
<!-- EP 表格:show-overflow-tooltip + 左右固定列;表体仅当前页切片 -->
<el-table
v-if="filtered.length"
:data="pagedItems"
@@ -394,7 +420,7 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
class="text-xs"
data-testid="transfer-match-table"
>
<el-table-column width="48" class-name="whitespace-nowrap">
<el-table-column fixed width="48">
<template #header>
<el-checkbox
size="small"
@@ -413,49 +439,57 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
/>
</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">
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="120" show-overflow-tooltip />
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColDocNo')"
prop="invoice_no"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span class="font-semibold">{{ row.invoice_no }}</span>
<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">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColExternalDoc')"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span data-testid="transfer-match-external-doc">{{ row.external_doc_no || '—' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="110" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="140" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="160" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" prop="from_warehouse" min-width="110" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" show-overflow-tooltip>
<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">
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="168" show-overflow-tooltip>
<template #default="{ row }">
<div>{{ formatQuantity(row.from_quantity) }}</div>
<!-- 库存查询时刻小字:数据新鲜度溯源(stale 门禁的可见依据) -->
<div
v-if="checkedAtLabel(row as TransferMatchingItem)"
class="text-[10px] text-muted"
:title="$t('chat.transfer.stockCheckedAtTitle', { time: checkedAtLabel(row as TransferMatchingItem) })"
<span
:class="row.stale === true ? 'text-amber-700' : undefined"
:title="freshnessHint(row as TransferMatchingItem, t) || undefined"
:data-testid="`transfer-checked-at-${row.invoice_no}`"
>
{{ checkedAtLabel(row as TransferMatchingItem) }}
</div>
{{ stockCell(row as TransferMatchingItem) }}
</span>
</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">
<el-table-column :label="$t('chat.transfer.colToWarehouse')" prop="to_warehouse" min-width="110" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" show-overflow-tooltip>
<template #default="{ row }">{{ formatQuantity(row.to_quantity) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colResult')" min-width="200">
<el-table-column
fixed="right"
:label="$t('chat.transfer.colResult')"
width="200"
>
<template #default="{ row }">
<div class="flex flex-wrap items-center gap-1">
<!-- 阻断原因经悬浮提示(title)透出:不占行高;可执行行也提供重查入口 -->
<div class="flex flex-nowrap items-center gap-1">
<el-tag
size="small"
effect="light"
@@ -465,24 +499,25 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
>
{{ $t(resultLabel(row.result)) }}
</el-tag>
<!-- 行级警示小标:stale(仅展示提示,不拦截执行——2026-09-25 TTL 退役)/ 文件版本已过期 -->
<el-tag
v-if="row.stale === true"
size="small"
type="warning"
effect="plain"
:title="$t('chat.transfer.staleRow')"
data-testid="transfer-item-stale"
>
{{ $t('chat.transfer.staleRow') }}
{{ $t('chat.transfer.staleShort') }}
</el-tag>
<el-tag
v-if="row.file_current === false"
size="small"
type="warning"
effect="plain"
:title="$t('chat.transfer.fileChangedRow')"
data-testid="transfer-item-file-changed"
>
{{ $t('chat.transfer.fileChangedRow') }}
{{ $t('chat.transfer.fileChangedShort') }}
</el-tag>
<el-button
v-if="isRequeryable(row as TransferMatchingItem)"
@@ -403,9 +403,12 @@ async function confirmCloseOrder() {
<!-- 行明细常驻展开(物料 × 批号聚合行;Invoice 首列对齐可调拨明细列序) -->
<div class="border-t border-subtle px-3 py-2" :data-testid="`transfer-order-lines-${order.doc_no}`">
<el-table :data="order.lines" size="small" class="text-xs">
<el-table-column :label="$t('chat.transfer.colInvoice')" min-width="110">
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" min-width="110">
<template #default="{ row }">{{ row.invoice_no || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120">
<template #default="{ row }">{{ row.external_doc_no || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="120" />
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="100">
@@ -108,15 +108,17 @@ describe('TransferMatchCard', () => {
expect(wrapper.find('.transfer-item-INV-001').text()).toContain('HOW26082728');
});
it('库存数量下方小字展示查询时刻(HH:mm)', async () => {
it('库存数量与完整查询时刻同一行(数量 · YYYY-MM-DD HH:mm)', async () => {
// [断言意图] 数量与时刻同行,避免第二行撑高整表;完整日期才能判断新旧。
const wrapper = await mountMatchCard({ summary, items, selected: new Set<number>() });
const cell = wrapper.find('[data-testid="transfer-checked-at-INV-001"]');
expect(cell.exists()).toBe(true);
expect(cell.text()).toMatch(/^\d{2}:\d{2}$/);
expect(wrapper.find('[data-testid="transfer-checked-at-INV-041"]').exists()).toBe(false);
expect(cell.text()).toBe('1200 · 2026-09-23 09:05');
// [断言意图] 无查询时刻时仍单行只显示数量,不拆第二行。
expect(wrapper.find('[data-testid="transfer-checked-at-INV-041"]').text()).not.toContain('·');
});
it('stale 行置灰 + 重查小标;file_current=false 行展示文件更新小标', async () => {
it('stale 行置灰 + 短徽标;file_current=false 行展示文件更新短徽标;顶栏汇总过期', async () => {
const flaggedItems = [
{ ...items[0], stale: true, file_current: false },
];
@@ -124,8 +126,12 @@ describe('TransferMatchCard', () => {
// [断言意图] el-table 行类经 row-class-name 注入 opacity-60。
const row = wrapper.find('.transfer-item-INV-001');
expect(row.classes()).toContain('opacity-60');
expect(wrapper.find('[data-testid="transfer-item-stale"]').text()).toContain('重查');
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').text()).toContain('自动对齐');
// [断言意图] 长句只放悬停;行内只留短徽标;顶栏 el-alert 汇总可批量重查。
expect(wrapper.find('[data-testid="transfer-item-stale"]').text()).toContain('已过期');
expect(wrapper.find('[data-testid="transfer-item-stale"]').attributes('title')).toContain('重查');
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').text()).toContain('文件更新');
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').attributes('title')).toContain('自动对齐');
expect(wrapper.find('[data-testid="transfer-match-stale-banner"]').text()).toContain('1');
});
it('计数卡透出待查库存/已失效计数;历史 payload 缺省按 0 展示', async () => {
@@ -0,0 +1,32 @@
/**
* features/chat/components/messages/transferItemTable.spec.ts
* 用途:锁住明细表库存单元格与新鲜度提示的统一格式。
*/
import { describe, expect, it } from 'vitest';
import {
formatStockCheckedAt,
formatStockQuantityCell,
freshnessHint,
} from './transferItemTable';
describe('transferItemTable', () => {
it('完整查询时刻为上海时区 YYYY-MM-DD HH:mm', () => {
// [断言意图] +08:00 墙钟原样保留;无时区 naive 按 UTC 再转上海。
expect(formatStockCheckedAt('2026-09-23T09:05:00+08:00')).toBe('2026-09-23 09:05');
expect(formatStockCheckedAt('2026-10-22T02:57:00')).toBe('2026-10-22 10:57');
expect(formatStockCheckedAt('')).toBe('');
});
it('库存单元格数量与时刻同一行', () => {
// [断言意图] 禁止拆成两行撑高表格。
expect(formatStockQuantityCell('30', '2026-10-20T10:38:00+08:00')).toBe('30 · 2026-10-20 10:38');
expect(formatStockQuantityCell('30', null)).toBe('30');
});
it('新鲜度悬停过期优先于文件更新', () => {
const t = (key: string) => key;
expect(freshnessHint({ stale: true, file_current: false }, t)).toBe('chat.transfer.staleRow');
expect(freshnessHint({ stale: false, file_current: false }, t)).toBe('chat.transfer.fileChangedRow');
expect(freshnessHint({}, t)).toBe('');
});
});
@@ -0,0 +1,61 @@
/**
* features/chat/components/messages/transferItemTable.ts
* 用途:在途调拨明细表(可调拨 / 匹配 / 待恢复)的统一展示约定与单元格格式化。
* 依赖:transferDate.formatShanghaiDateTime、i18n chat.transfer.*。
* 逻辑:三卡共用 Element Plus 密度规则,禁止各卡各自叠第二行或放任折行。
*
* Element Plus 约定:
* 1. 长文本列 show-overflow-tooltip;不够宽就横向滚,不折行。
* 2. 左只固定勾选,右固定结果/操作;单号随表横滚(不钉死,避免挤窄中间区)。
* 3. 库存数量与查询时刻同一行:「数量 · YYYY-MM-DD HH:mm」。
* 4. 过期不占结果列长文;顶栏 el-alert 汇总 + 批量重查。
*/
import { formatShanghaiDateTime } from './transferDate';
const CHECKED_AT_RE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
/**
* 把后端库存查得时刻格式成上海时区完整墙钟。
* @param checkedAt - 后端 ISO(可空)
* @returns `YYYY-MM-DD HH:mm`;无法解析则空串
*/
export function formatStockCheckedAt(checkedAt: string | null | undefined): string {
if (!checkedAt) return '';
const label = formatShanghaiDateTime(checkedAt);
return CHECKED_AT_RE.test(label) ? label : '';
}
/**
* 库存数量单元格主文案:数量与查询时刻同一行。
* @param quantityLabel - 已格式化的数量文本
* @param checkedAt - 后端 ISO
* @returns 如 `30 · 2026-10-20 18:38`;无时刻则仅数量
*/
export function formatStockQuantityCell(
quantityLabel: string,
checkedAt: string | null | undefined,
): string {
const when = formatStockCheckedAt(checkedAt);
return when ? `${quantityLabel} · ${when}` : quantityLabel;
}
export interface TransferFreshnessRow {
stale?: boolean;
file_current?: boolean;
}
/**
* 行新鲜度悬停说明(过期优先于文件更新)。
* @param row - 带 stale / file_current 的明细行
* @param t - vue-i18n t
* @returns 悬停全文;无提示时空串
*/
export function freshnessHint(
row: TransferFreshnessRow,
t: (key: string) => string,
): string {
if (row.stale) return t('chat.transfer.staleRow');
if (row.file_current === false) return t('chat.transfer.fileChangedRow');
return '';
}
@@ -77,6 +77,8 @@ export interface TransferMatchingItem {
material_name: string;
specification: string;
invoice_no: string;
/** 档上的外部单号;没有则为空,列表显示占位 */
external_doc_no?: string;
/** 明细异动日期(Task 3 序列化键更名,明细 movement 语义;旧名见 git 历史) */
movement_date?: string | null;
from_warehouse: string;
@@ -164,8 +166,10 @@ export type TransferOrderStatus = 'pending' | 'executing' | 'success' | 'duplica
/** 单内行(ERP 写入行粒度聚合:物料+批号;quantity 为 6 位小数字符串,与 D14 快照口径一致) */
export interface TransferOrderLine {
/** 行级溯源入站通知号(2026-09-29 契约扩充;一行恒对应一张 invoice,旧 payload 缺省) */
/** 行级溯源单号(档 doc_no;旧 payload 缺省) */
invoice_no?: string;
/** 档上的外部单号;聚合行内多个单号以逗号连接,旧 payload 缺省 */
external_doc_no?: string;
material_no: string;
material_name: string;
lot_no: string;
@@ -218,6 +222,8 @@ export interface TransferBacklogItem {
item_id: number;
source_code: string;
invoice_no: string;
/** 档上的外部单号;没有则为空 */
external_doc_no?: string;
material_no: string;
status: string;
reason: string;
@@ -388,6 +394,8 @@ export interface TransferOrderGroups {
*/
export interface TransferExecutedOrderItem {
invoice_no: string;
/** 档上的外部单号;没有则为空 */
external_doc_no?: string;
material_no: string;
material_name: string;
lot_no: string;
+5 -2
View File
@@ -3807,14 +3807,13 @@
"colMaterial": "Material",
"colName": "Name",
"colSpec": "Spec",
"colInvoice": "Invoice",
"colMovementDate": "Movement Date",
"colFromWarehouse": "From warehouse",
"colFromQty": "Stock qty",
"stockCheckedAtTitle": "Stock checked at {time}",
"colToWarehouse": "To warehouse",
"colFromBatch": "Outbound Batch",
"filterPlaceholder": "Filter by material / name / Invoice / batch",
"filterPlaceholder": "Filter by material / name / doc no. / external doc / batch",
"filterAll": "All results",
"requerySelected": "Requery selected",
"movementDateLabel": "Movement date",
@@ -3830,7 +3829,11 @@
"resultFileRemoved": "Removed from file",
"resultPendingStockCheck": "Pending stock check",
"staleRow": "Stale — requery",
"staleShort": "Stale",
"staleBanner": "{count} rows have stale inventory",
"staleBannerRequery": "Requery stale rows",
"fileChangedRow": "File updated; data will realign",
"fileChangedShort": "File updated",
"fileRemovedQuarantined": "{count} more rows were invalidated (removed from the inbound file) and are hidden from this list; handle them under Pending Exceptions (mark as no further action).",
"runProgress": "Transfer run progress",
"runExecuting": "Executing",
+5 -2
View File
@@ -3807,14 +3807,13 @@
"colMaterial": "รหัสวัสดุ",
"colName": "ชื่อ",
"colSpec": "สเปก",
"colInvoice": "Invoice",
"colMovementDate": "วันที่เคลื่อนไหว",
"colFromWarehouse": "คลังต้นทาง",
"colFromQty": "จำนวนสต๊อก",
"stockCheckedAtTitle": "เวลาตรวจสอบสต๊อก: {time}",
"colToWarehouse": "คลังปลายทาง",
"colFromBatch": "ล็อตต้นทาง",
"filterPlaceholder": "กรองตามรหัสวัสดุ / ชื่อ / Invoice / ล็อต",
"filterPlaceholder": "กรองตามรหัสวัสดุ / ชื่อ / เลขที่เอกสาร / เลขที่เอกสารภายนอก / ล็อต",
"filterAll": "ทุกผลลัพธ์",
"requerySelected": "ตรวจซ้ำที่เลือก",
"movementDateLabel": "วันที่เคลื่อนไหว",
@@ -3830,7 +3829,11 @@
"resultFileRemoved": "ถูกลบออกจากไฟล์",
"resultPendingStockCheck": "รอตรวจสอบสต๊อก",
"staleRow": "ข้อมูลหมดอายุ กรุณาตรวจซ้ำ",
"staleShort": "หมดอายุ",
"staleBanner": "มี {count} แถวที่สต๊อกหมดอายุ",
"staleBannerRequery": "ตรวจซ้ำแถวที่หมดอายุ",
"fileChangedRow": "ไฟล์อัปเดตแล้ว ข้อมูลจะจัดตำแหน่งใหม่อัตโนมัติ",
"fileChangedShort": "ไฟล์อัปเดต",
"fileRemovedQuarantined": "อีก {count} รายการถือเป็นยกเลิกเนื่องจากถูกลบออกจากไฟล์รับเข้า และถูกซ่อนจากรายการนี้ โปรดดำเนินการใน「ข้อยกเว้นที่รอดำเนินการ」โดยสามารถทำเครื่องหมายว่าไม่จำเป็นต้องดำเนินการต่อ",
"runProgress": "ความคืบหน้าการโอน",
"runExecuting": "กำลังดำเนินการ",
+5 -2
View File
@@ -3807,14 +3807,13 @@
"colMaterial": "料号",
"colName": "品名",
"colSpec": "规格",
"colInvoice": "Invoice",
"colMovementDate": "异动日期",
"colFromWarehouse": "拨出仓库",
"colFromQty": "库存数量",
"stockCheckedAtTitle": "库存查询时刻:{time}",
"colToWarehouse": "拨入仓库",
"colFromBatch": "拨出批号",
"filterPlaceholder": "按料号 / 品名 / Invoice / 批号筛选",
"filterPlaceholder": "按料号 / 品名 / 单号 / 外部单号 / 批号筛选",
"filterAll": "全部结果",
"requerySelected": "重查选中",
"movementDateLabel": "异动日期",
@@ -3830,7 +3829,11 @@
"resultFileRemoved": "文件已移除",
"resultPendingStockCheck": "待查库存",
"staleRow": "数据已过期,请重查",
"staleShort": "已过期",
"staleBanner": "{count} 行库存已过期",
"staleBannerRequery": "重查过期行",
"fileChangedRow": "文件已更新,将自动对齐",
"fileChangedShort": "文件更新",
"fileRemovedQuarantined": "另有 {count} 行已随入站文件移除而失效,已移出本清单;请到「待处理异常」处理,可标记无需继续处理。",
"runProgress": "调拨执行进度",
"runExecuting": "执行中",
+5 -2
View File
@@ -3807,14 +3807,13 @@
"colMaterial": "料號",
"colName": "品名",
"colSpec": "規格",
"colInvoice": "Invoice",
"colMovementDate": "異動日期",
"colFromWarehouse": "撥出倉庫",
"colFromQty": "庫存數量",
"stockCheckedAtTitle": "庫存查詢時刻:{time}",
"colToWarehouse": "撥入倉庫",
"colFromBatch": "撥出批號",
"filterPlaceholder": "按料號 / 品名 / Invoice / 批號篩選",
"filterPlaceholder": "按料號 / 品名 / 單號 / 外部單號 / 批號篩選",
"filterAll": "全部結果",
"requerySelected": "重查選中",
"movementDateLabel": "異動日期",
@@ -3830,7 +3829,11 @@
"resultFileRemoved": "檔案已移除",
"resultPendingStockCheck": "待查庫存",
"staleRow": "資料已過期,請重查",
"staleShort": "已過期",
"staleBanner": "{count} 行庫存已過期",
"staleBannerRequery": "重查過期行",
"fileChangedRow": "檔案已更新,將自動對齊",
"fileChangedShort": "檔案更新",
"fileRemovedQuarantined": "另有 {count} 筆已隨入站檔案移除而失效,已移出本清單;請到「待處理異常」處理,可標記無需繼續處理。",
"runProgress": "調撥執行進度",
"runExecuting": "執行中",