refactor(in-transit-transfer): 行归属解耦、按行执行三层门禁并重构术语为匹配

- 行不迁移:匹配记录降级为评估留痕(scope/counts/hash 留痕不拦执行),
  匹配/重查原地刷新行并续行级新鲜度(updated_at)
- 执行改按行:POST /items/execute 三层门禁(行级新鲜度 TTL/文件版本对账/写前复查),
  Run 留痕不绑匹配记录;消失行 blocked_file_removed fail-closed 入异常池
- 恢复处理收敛为行级重查(batch-resume 删除);待处理池补齐匹配窗口字段,
  排序改业务稳定键(收料日期→Invoice→created_at,操作不再引起跳位)
- 首页待办看板四队列:可调拨明细/待恢复异常/已人工关闭/结果未知;「最近预检」移除;
  收料日期默认 T-1 并加输入期限制;「重新查询 ERP」更名「重查」
- 术语重构 precheck→match:表 transfer_matchings、列 matching_id/matching_no/matching_hash、
  API /matchings、单号前缀 MTG、状态值 prechecking→matching(迁移 rn1a2b3c4d5e6,模块未上线无兼容层)
- 修复 integration_connector mapping 扇出嵌套丢行缺陷;对账结论:0 vs 30/40/36
  系收料仓库映射曾指向错误账套 TGHX(已改 TGHX1),探针留档 backend/tmp
- 测试:后端 in_transit_transfer+api+connector 393 passed;前端 chat 713 passed;build ✓
This commit is contained in:
hugo committed 2026-09-24 00:24:03 +08:00
1 parent f9f5053f0b
commit 0cf3c24119
108 files changed
+3660 -2356

No files matched your search

@@ -1,6 +1,6 @@
/**
* features/chat/components/messages/transferCards.spec.ts
* 用途:验证在途调拨三张核心卡片(文件进度/预检/结果)+ 关闭弹窗的交互与禁用语义。
* 用途:验证在途调拨三张核心卡片(文件进度/匹配/结果)+ 关闭弹窗的交互与禁用语义。
* 依赖:@vue/test-utils、i18n、transfer.types。
* 逻辑:断言按钮禁用、勾选禁用、ERP 单号展开/收起、异常展示、下载按钮与
* 结果页不出现“查看执行审计”入口(决策 19)。
@@ -9,27 +9,27 @@ import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import i18n from '@/i18n';
import TransferFileProgressCard from './TransferFileProgressCard.vue';
import TransferPrecheckCard from './TransferPrecheckCard.vue';
import TransferMatchCard from './TransferMatchCard.vue';
import TransferResultCard from './TransferResultCard.vue';
import TransferManualCloseDialog from './TransferManualCloseDialog.vue';
const mountOptions = { global: { plugins: [i18n] } };
const summary = {
precheck_id: 'TPC-1',
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, prechecked_count: 2, executable_count: 2, blocked_count: 0 },
counts: { file_invoice_count: 3, not_matured_count: 1, matched_count: 2, executable_count: 2, blocked_count: 0 },
estimated_transfer_quantity: '2400',
estimated_external_write_count: 2,
precheck_hash: 'sha256:x',
matching_hash: 'sha256:x',
};
const items = [
{ 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' },
{ 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: 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' },
];
describe('TransferFileProgressCard', () => {
@@ -46,41 +46,88 @@ describe('TransferFileProgressCard', () => {
});
});
describe('TransferPrecheckCard', () => {
it('阻断/未成熟项 checkbox 禁用;可执行项可选', () => {
const wrapper = mount(TransferPrecheckCard, {
props: { summary, items, selected: new Set(['INV-001']) },
describe('TransferMatchCard', () => {
it('勾选键为明细行 item_id:阻断/未成熟项 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"]');
expect((executableCheck.element as HTMLInputElement).disabled).toBe(false);
expect((executableCheck.element as HTMLInputElement).checked).toBe(true);
expect((maturedCheck.element as HTMLInputElement).disabled).toBe(true);
});
it('历史回放行(无 item_id)checkbox 禁用,防误选', () => {
// [断言意图] 行式执行重构(2026-09-23):chat 消息流回放的旧 payload 行没有
// item_id,不能作为执行勾选键;这类行必须禁选(防误选后 400)。
const legacyItems = [{ ...items[0], item_id: undefined }];
const wrapper = mount(TransferMatchCard, {
props: { summary, items: legacyItems, selected: new Set<number>() },
...mountOptions,
});
expect((wrapper.find('[data-testid="transfer-check-INV-001"]').element as HTMLInputElement).disabled).toBe(true);
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
});
it('未选择任何项时生成按钮禁用', () => {
const wrapper = mount(TransferPrecheckCard, {
props: { summary, items, selected: new Set() },
const wrapper = mount(TransferMatchCard, {
props: { summary, items, selected: new Set<number>() },
...mountOptions,
});
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
});
it('busy 时生成按钮禁用', () => {
const wrapper = mount(TransferPrecheckCard, {
props: { summary, items, selected: new Set(['INV-001']), busy: true },
const wrapper = mount(TransferMatchCard, {
props: { summary, items, selected: new Set<number>([101]), busy: true },
...mountOptions,
});
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
});
it('点击生成按钮仅提交可执行勾选项', async () => {
const wrapper = mount(TransferPrecheckCard, {
props: { summary, items, selected: new Set(['INV-001']) },
it('点击生成按钮提交可执行勾选行的 item_id 数组', async () => {
const wrapper = mount(TransferMatchCard, {
props: { summary, items, selected: new Set<number>([101]) },
...mountOptions,
});
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
expect(wrapper.emitted('execute')?.[0][0]).toEqual(['INV-001']);
expect(wrapper.emitted('execute')?.[0][0]).toEqual([101]);
});
it('库存数量下方小字展示查询时刻(HH:mm)', () => {
const wrapper = mount(TransferMatchCard, {
props: { summary, items, selected: new Set<number>() },
...mountOptions,
});
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);
});
it('stale 行置灰 + 重查小标;file_current=false 行展示文件更新小标', () => {
const flaggedItems = [
{ ...items[0], stale: true, file_current: false },
];
const wrapper = mount(TransferMatchCard, {
props: { summary, items: flaggedItems, selected: new Set<number>() },
...mountOptions,
});
const row = wrapper.find('[data-testid="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('重新匹配');
});
it('blocked_file_removed 结果行展示「文件已移除」独立徽标', () => {
const removedItems = [{ ...items[0], result: 'blocked_file_removed' }];
const wrapper = mount(TransferMatchCard, {
props: { summary, items: removedItems, selected: new Set<number>() },
...mountOptions,
});
expect(wrapper.find('[data-testid="transfer-item-result"]').text()).toContain('文件已移除');
});
it('同 Invoice 跨收料日期拆票(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
@@ -89,16 +136,16 @@ describe('TransferPrecheckCard', () => {
// 筛选后不匹配行残留/克隆(用户输入 HOX 仍见 SLC2PHX 行)。
// 行身份 = (来源, Invoice, 料号, 收料日期),key 必须用同一粒度。
const dupItems = [
{ 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' },
{ 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' },
{ 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', 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' },
];
const wrapper = mount(TransferPrecheckCard, {
props: { summary, items: dupItems, selected: new Set() },
const wrapper = mount(TransferMatchCard, {
props: { summary, items: dupItems, selected: new Set<number>() },
...mountOptions,
});
expect(wrapper.findAll('tbody tr').length).toBe(3);
await wrapper.find('[data-testid="transfer-precheck-filter"]').setValue('HOX');
await wrapper.find('[data-testid="transfer-match-filter"]').setValue('HOX');
const rows = wrapper.findAll('tbody tr');
expect(rows.length).toBe(1);
expect(rows[0].text()).toContain('HOX-1');