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', () => {
+2 -2
View File
@@ -3718,10 +3718,9 @@
"colInvoice": "Invoice",
"colReceiptDate": "Receipt Date",
"colFromWarehouse": "From warehouse",
"colFromQty": "From qty",
"colFromQty": "Stock qty",
"colToWarehouse": "To warehouse",
"colFromBatch": "Outbound Batch",
"colToBatch": "Inbound Batch",
"filterPlaceholder": "Filter by material / name / Invoice / batch",
"filterAll": "All results",
"requerySelected": "Requery selected ERP stock",
@@ -3793,6 +3792,7 @@
"fileReady": "File ready",
"fileFetching": "Fetching",
"fileFailed": "Fetch failed",
"sourceErrorTitle": "Source processing failed",
"fileNone": "Pending",
"needReadyFile": "A selected source has no receipt file / is fetching / failed. Retry receipt RPA first.",
"selectVisible": "Select visible",
+2 -2
View File
@@ -3718,10 +3718,9 @@
"colInvoice": "Invoice",
"colReceiptDate": "วันที่รับสินค้า",
"colFromWarehouse": "คลังต้นทาง",
"colFromQty": "จำนวนต้นทาง",
"colFromQty": "จำนวนสต๊อก",
"colToWarehouse": "คลังปลายทาง",
"colFromBatch": "ล็อตต้นทาง",
"colToBatch": "ล็อตปลายทาง",
"filterPlaceholder": "กรองตามรหัสวัสดุ / ชื่อ / Invoice / ล็อต",
"filterAll": "ทุกผลลัพธ์",
"requerySelected": "ตรวจซ้ำ ERP ที่เลือก",
@@ -3793,6 +3792,7 @@
"fileReady": "ไฟล์พร้อมแล้ว",
"fileFetching": "กำลังดึง",
"fileFailed": "ดึงล้มเหลว",
"sourceErrorTitle": "ประมวลผลแหล่งข้อมูลล้มเหลว",
"fileNone": "รอดำเนินการ",
"needReadyFile": "แหล่งที่เลือกไม่มีไฟล์รับของ / กำลังดึง / ล้มเหลว โปรดลอง RPA รับของก่อน",
"selectVisible": "เลือกที่เห็นทั้งหมด",
+2 -2
View File
@@ -3792,10 +3792,9 @@
"colInvoice": "Invoice",
"colReceiptDate": "收料日期",
"colFromWarehouse": "拨出仓库",
"colFromQty": "拨出数量",
"colFromQty": "库存数量",
"colToWarehouse": "拨入仓库",
"colFromBatch": "拨出批号",
"colToBatch": "拨入批号",
"filterPlaceholder": "按料号 / 品名 / Invoice / 批号筛选",
"filterAll": "全部结果",
"requerySelected": "重查选中 ERP 库存",
@@ -3867,6 +3866,7 @@
"fileReady": "文件已就绪",
"fileFetching": "抓取中",
"fileFailed": "抓取失败",
"sourceErrorTitle": "来源处理失败",
"fileNone": "待抓取",
"needReadyFile": "所选来源存在无收料文件/或抓取中/或失败,请先重试收料 RPA",
"selectVisible": "全选可见",
+2 -2
View File
@@ -3718,10 +3718,9 @@
"colInvoice": "Invoice",
"colReceiptDate": "收料日期",
"colFromWarehouse": "撥出倉庫",
"colFromQty": "撥出數量",
"colFromQty": "庫存數量",
"colToWarehouse": "撥入倉庫",
"colFromBatch": "撥出批號",
"colToBatch": "撥入批號",
"filterPlaceholder": "按料號 / 品名 / Invoice / 批號篩選",
"filterAll": "全部結果",
"requerySelected": "重查選中 ERP 庫存",
@@ -3793,6 +3792,7 @@
"fileReady": "檔案已就緒",
"fileFetching": "抓取中",
"fileFailed": "抓取失敗",
"sourceErrorTitle": "來源處理失敗",
"fileNone": "待抓取",
"needReadyFile": "所選來源存在無收料檔案/或抓取中/或失敗,請先重試收料 RPA",
"selectVisible": "全選可見",