This commit is contained in:
2026-10-16 16:19:22 +08:00
parent 45f662ecf2
commit fbee53c9de
2 changed files with 14 additions and 0 deletions
@@ -121,3 +121,13 @@ describe('转运预报与实际签收明细', () => {
expect(wrapper.emitted('summary')!.at(-1)![0]).toMatchObject({ forecastBoxes: 9 })
})
})
// 完成原因直接展示,多个箱保存同一原因时只显示一次。
it('displays saved discrepancy reason once without opening box details', async () => {
const value = fixture()
value.cartons.forEach(box => { box.discrepancyReason = '短收一箱,客户漏发' })
vi.mocked(getWarehouseTransfer).mockResolvedValue(value)
const wrapper = render(); await flushPromises()
expect(wrapper.findAll('.receipt-discrepancy-reason')).toHaveLength(1)
expect(wrapper.find('.receipt-discrepancy-reason').text()).toBe('实收差异原因:短收一箱,客户漏发')
})
@@ -21,6 +21,8 @@ const selectedBox = ref<WarehouseTransferCartonDto | null>(null)
const boxOpen = ref(false)
const cartonsOpen = ref(false)
let generation = 0
// 同一完成原因保存于箱记录,去重后在尾程详情直接展示。
const discrepancyReasons = computed(() => [...new Set((detail.value?.cartons || []).map(box => box.discrepancyReason?.trim()).filter((reason): reason is string => Boolean(reason)))])
const cartons = computed(() => (detail.value?.cartons || []).filter(box => box.status === 'COUNTED'))
function itemFor(box: WarehouseTransferCartonDto) { return detail.value?.items.find(item => box.transferItemId != null && String(item.id) === String(box.transferItemId)) }
function boxLines(box: WarehouseTransferCartonDto) {
@@ -119,6 +121,7 @@ onBeforeUnmount(() => { generation++ })
<section v-loading="loading" class="transfer-receipt-panel" aria-label="仓储转运预报与实际签收">
<LoadErrorState v-if="error" title="签收明细加载失败" :message="error.message" :loading="loading" @retry="load"><template #details><ApiErrorMeta :details="error" /></template></LoadErrorState>
<template v-else-if="detail">
<p v-for="reason in discrepancyReasons" :key="reason" class="receipt-discrepancy-reason"><strong>实收差异原因:</strong>{{ reason }}</p>
<h3>预报与实际签收对比 <small>差异 = 实收 − 预报{{ cartons.length ? '(按当前已清点箱汇总)' : ',待签收后显示' }}</small></h3>
<DataTable class="receipt-aligned-table" :fit="false" :data="comparisonRows" :columns="forecastColumns" row-key="id" :show-pagination="false" empty-text="暂无预报货物明细">
<template #quantityDifference="{ row }"><span :class="{ 'receipt-difference': cartons.length && Number(row.quantityDifference) !== 0 }">{{ differenceText(row.quantityDifference) }}</span></template>
@@ -139,6 +142,7 @@ onBeforeUnmount(() => { generation++ })
<style scoped>
.receipt-box-heading{display:flex;align-items:center;justify-content:flex-start;flex-wrap:wrap;gap:12px}
.receipt-discrepancy-reason{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}
.transfer-receipt-panel{display:grid;gap:var(--admin-space-2)}
.receipt-aligned-table{width:100%;max-width:1490px;min-width:0}
.receipt-difference{color:var(--el-color-danger);font-weight:600}