优化
This commit is contained in:
@@ -46,7 +46,8 @@ 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'))
|
||||
// 已签收是历史事实,后续废弃占用、废弃或出库不能从实收汇总中移除。
|
||||
const cartons = computed(() => (detail.value?.cartons || []).filter(box => ['COUNTED', 'DISCARD_PENDING', 'DISCARDED', 'SHIPPED'].includes(box.status)))
|
||||
function itemFor(box: WarehouseTransferCartonDto) { return detail.value?.items.find(item => box.transferItemId != null && String(item.id) === String(box.transferItemId)) }
|
||||
function boxLines(box: WarehouseTransferCartonDto) {
|
||||
if (box.items?.length) return box.items
|
||||
@@ -64,9 +65,10 @@ watch([detail, totals], () => emit('summary', detail.value ? { ...totals.value,
|
||||
const comparisonRows = computed(() => (detail.value?.items || []).map(item => {
|
||||
const boxes = cartons.value.filter(box => boxLines(box).some(line => String(line.transferItemId) === String(item.id)))
|
||||
const receivedQuantity = boxes.reduce((sum, box) => sum + boxLines(box).filter(line => String(line.transferItemId) === String(item.id)).reduce((total, line) => total + Number(line.quantity), 0), 0)
|
||||
return { ...item, receivedQuantity, receivedBoxes: boxes.length, quantityDifference: receivedQuantity - Number(item.quantity || 0), boxDifference: boxes.length - Number(item.packageCount || 0) }
|
||||
return { ...item, receivedQuantity, receivedBoxes: boxes.length, quantityDifference: item.quantity == null ? null : receivedQuantity - Number(item.quantity), boxDifference: boxes.length - Number(item.packageCount || 0) }
|
||||
}))
|
||||
function differenceText(value: unknown) {
|
||||
if (value == null) return '未记录'
|
||||
if (!cartons.value.length) return '待签收'
|
||||
const difference = Number(value)
|
||||
return difference > 0 ? `+${difference}` : String(difference)
|
||||
|
||||
Reference in New Issue
Block a user