fix(shipping-notice): 修复调拨预检全 0 及筛选重查系列缺陷

- movement 表头反查改一列对多字段,doc_no/lot_no 共用 External ASN # 列不再互相覆盖,修复 CRANE 预检全 0
- 来源级失败事实落库 source_job 并经 restore 回读,预检卡片透出失败横幅(四语言)
- 明细表渲染切 filtered 并将行键升为拆票四元组(来源|Invoice|料号|收料日期),筛选真正生效且无重复 key 残影
- 移除规格/拨入批号列,拨出数量更名库存数量,清理孤儿 i18n 键 colToBatch
- requery 端点补用户上下文修复 NameError 500;ERP 网关/绑定故障逐票降级,不再抛全局错误弹窗
- 回归测试:同列双字段提取、失败落库可见、requery 冒烟、同票多行筛选、ERP 绑定缺失降级
This commit is contained in:
hugo committed 2026-09-21 21:23:20 +08:00
1 parent 1ba38e1685
commit 881863478e
16 files changed
+279 -40

No files matched your search

@@ -252,6 +252,7 @@ async function onSourceRetry(sourceCodes: string[]) {
v-else-if="mode === 'precheck' && summaryRef"
:summary="summaryRef"
:items="items"
:sources="transfer.sources.value"
:selected="transfer.selected.value"
:requery-busy="busy"
:busy="busy"
@@ -1,18 +1,20 @@
<!--
features/chat/components/messages/TransferPrecheckCard.vue
用途:预检卡——计数 + 调拨明细表(决策 6 十列)+ 勾选 + “直接生成调拨单”按钮。
依赖:props(summary/items/selected/busy)、i18n chat.transfer.*。
逻辑:阻断/未成熟项 checkbox 禁用;无选择或 busy 时生成按钮禁用;
emit execute(invoiceNos)(决策 4/5:无独立确认页)。
用途:预检卡——计数 + 来源失败提示 + 调拨明细表(含筛选)+ 勾选 + “直接生成调拨单”按钮。
依赖:props(summary/items/sources/selected/busy)、i18n chat.transfer.*。
逻辑:明细表渲染 filtered(关键字/结果筛选生效);阻断/未成熟项 checkbox 禁用;
无选择或 busy 时生成按钮禁用;emit execute(invoiceNos)(决策 4/5:无独立确认页);
来源级解析/文件失败经 sources.error_code 透出(防"安静全 0")。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { deriveBatchNo } from './transferBatch';
import type { TransferPrecheckItem, TransferPrecheckSummary } from '../../types/transfer.types';
import type { TransferPrecheckItem, TransferPrecheckSummary, TransferSourceProgress } from '../../types/transfer.types';
const props = defineProps<{
summary: TransferPrecheckSummary;
items: TransferPrecheckItem[];
sources?: TransferSourceProgress[];
selected: Set<string>;
busy?: boolean;
requeryBusy?: boolean;
@@ -30,6 +32,11 @@ const selectedCount = computed(() =>
);
const executeDisabled = computed(() => props.busy || selectedCount.value === 0);
/** 来源级失败(解析/文件/RPA 触发):必须可见,防止计数全 0 却无任何解释。 */
const failedSources = computed(() =>
(props.sources ?? []).filter((source) => source.error_code || source.error_message),
);
/** 筛选与全选状态(表格交互本地态,勾选集合仍由父级持有)。 */
const keyword = ref('');
const resultFilter = ref<'all' | 'executable' | 'blocked' | 'not_matured'>('all');
@@ -129,7 +136,18 @@ function resultLabel(result: string): string {
</div>
</div>
<div class="mb-2 flex flex-wrap items-center gap-2">
<div
v-if="failedSources.length"
class="mb-3 rounded-lg border border-red-200 bg-red-50 p-3 text-xs text-red-700"
data-testid="transfer-precheck-source-errors"
>
<div class="mb-1 font-bold">{{ $t('chat.transfer.sourceErrorTitle') }}</div>
<div v-for="source in failedSources" :key="source.source_code" class="leading-5">
{{ source.source_code }}:{{ source.error_message || source.error_code }}
</div>
</div>
<div class="mb-2 flex flex-wrap items-center gap-2">
<input
v-model="keyword"
type="text"
@@ -170,20 +188,18 @@ function resultLabel(result: string): string {
<th class="p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
<th class="p-2">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="p-2">{{ $t('chat.transfer.colName') }}</th>
<th class="p-2">{{ $t('chat.transfer.colSpec') }}</th>
<th class="p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
<th class="p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
<th class="p-2">{{ $t('chat.transfer.colFromQty') }}</th>
<th class="p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
<th class="p-2">{{ $t('chat.transfer.colToBatch') }}</th>
<th class="p-2">{{ $t('chat.transfer.colToQty') }}</th>
<th class="p-2">{{ $t('chat.transfer.colResult') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="item in items"
:key="item.invoice_no"
v-for="item in filtered"
:key="`${item.source_code}|${item.invoice_no}|${item.material_no}|${item.receipt_date ?? ''}`"
class="border-b border-subtle"
:class="{ 'bg-surface-soft text-muted': !isSelectable(item) }"
:data-testid="`transfer-item-${item.invoice_no}`"
@@ -202,12 +218,10 @@ function resultLabel(result: string): string {
<td class="p-2">{{ item.receipt_date || '—' }}</td>
<td class="p-2">{{ item.material_no }}</td>
<td class="p-2">{{ item.material_name }}</td>
<td class="p-2">{{ item.specification }}</td>
<td class="p-2">{{ item.from_warehouse }}</td>
<td class="p-2">{{ deriveBatchNo(item.lot_no) }}</td>
<td class="p-2">{{ item.from_quantity ?? '—' }}</td>
<td class="p-2">{{ item.to_warehouse }}</td>
<td class="p-2">{{ deriveBatchNo(item.lot_no) }}</td>
<td class="p-2">{{ item.to_quantity }}</td>
<td class="p-2">
<span
@@ -82,6 +82,27 @@ describe('TransferPrecheckCard', () => {
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
expect(wrapper.emitted('execute')?.[0][0]).toEqual(['INV-001']);
});
it('同 Invoice 跨收料日期拆票(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
// [断言意图] 回归防线(2026-09-21):拆票设计下 invoice_no 不再唯一,
// 行 key 若仍用 invoice_no 会出现重复 key,Vue 列表 diff 错乱导致
// 筛选后不匹配行残留/克隆(用户输入 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' },
];
const wrapper = mount(TransferPrecheckCard, {
props: { summary, items: dupItems, selected: new Set() },
...mountOptions,
});
expect(wrapper.findAll('tbody tr').length).toBe(3);
await wrapper.find('[data-testid="transfer-precheck-filter"]').setValue('HOX');
const rows = wrapper.findAll('tbody tr');
expect(rows.length).toBe(1);
expect(rows[0].text()).toContain('HOX-1');
});
});
describe('TransferResultCard', () => {