fix(dispatch): preserve return sources when restoring prearrangement drafts

This commit is contained in:
2026-10-03 15:57:53 +08:00
parent 6a135c3982
commit 9fa73f50d6
7 changed files with 107 additions and 9 deletions
@@ -84,6 +84,7 @@ const orderGroups = computed(() => {
})
const activePallets = computed(() => orderGroups.value.find((item) => item.key === activeOrderKey.value)?.pallets || [])
const assignedIds = computed(() => containers.value.flatMap((item) => item.palletIds))
const unresolvedAssignedIds = computed(() => assignedIds.value.filter(id => !palletSnapshot(id)))
const assigned = computed(() => assignedIds.value.map((id) => palletSnapshot(id)).filter((item): item is DispatchPalletCandidateDto => Boolean(item)))
const assignedPackages = computed(() => assigned.value.reduce((sum, item) => sum + Number(item.packageCount || 0), 0))
const assignedVolume = computed(() => assigned.value.reduce((sum, item) => sum + Number(item.volumeCbm || 0), 0))
@@ -98,6 +99,7 @@ const containerOverweight = (container: LoadingContainer) => {
}
function palletId(item: DispatchPalletCandidateDto) {
if (item.sourceType === 'RETURN_RECEIPT') return item.returnReceiptId ? `RETURN:${item.returnReceiptId}` : ''
return String(item.planPalletId || item.warehousePalletId || '')
}
function text(value: unknown) {
@@ -175,6 +177,8 @@ async function load() {
draftToken: ensureDraftToken(),
})
rememberPallets(candidates.value)
if (unresolvedAssignedIds.value.length) await hydrateDraftPallets()
if (unresolvedAssignedIds.value.length) throw new Error('草稿中部分已选来源尚未恢复,请重试加载;原选择已保留')
activeOrderKey.value = orderGroups.value[0]?.key || ''
} catch (error) {
candidates.value = []
@@ -300,6 +304,10 @@ async function close(value = false) {
}
async function submit() {
if (loading.value || unresolvedAssignedIds.value.length) {
ElMessage.warning('草稿中部分已选来源尚未恢复,请重试加载后再预排;原选择已保留')
return
}
if (!assignedIds.value.length) {
ElMessage.warning('请至少移入一个托盘')
return
@@ -322,7 +330,8 @@ async function submit() {
mutationError.value = null
try {
await preArrangeDispatch({
planPalletIds: assignedIds.value,
planPalletIds: assigned.value.filter(item => item.sourceType !== 'RETURN_RECEIPT').map(palletId),
returnReceiptIds: assigned.value.filter(item => item.sourceType === 'RETURN_RECEIPT').map(item => String(item.returnReceiptId)),
...(relabelOrders.length ? { relabelNo: relabelOrders[0] } : { draftToken: ensureDraftToken() }),
})
emit('update:modelValue', false)
@@ -364,7 +373,6 @@ watch(
palletIds: c.palletIds || [],
}
})
await hydrateDraftPallets().catch(() => undefined)
}
await load()
})()
@@ -484,6 +492,7 @@ watch([warehouseTab, () => query.orderType], () => {
<div class="pallet-copy">
<strong>{{ text(item.palletNo) }}</strong
><span>{{ Number(item.packageCount || 0) }}箱 · {{ formatWeightLb(weightLb(item)) }}</span>
<span v-if="item.sourceType === 'RETURN_RECEIPT'">退回实收:{{ text(item.returnReceiptNo) }}</span>
<div v-if="relabelCartonMarks(item).length" class="carton-marks">
<div v-for="mark in relabelCartonMarks(item)" :key="`relabel-${mark}`" class="carton-mark-line">
<span>{{ mark }}</span