|
@@ -549,54 +549,61 @@ const mergeDataList = ref<BoxRelatedMergeDetailsVO[]>([])
|
|
|
const buildClickableLocationsMap = (boxDetailsList: BoxRelatedMergeDetailsVO[]) => {
|
|
const buildClickableLocationsMap = (boxDetailsList: BoxRelatedMergeDetailsVO[]) => {
|
|
|
const map = new Map<string, ClickableLocationInfo>()
|
|
const map = new Map<string, ClickableLocationInfo>()
|
|
|
|
|
|
|
|
|
|
+ // 先对所有移库任务去重,避免同一条任务被处理多次导致数量翻倍
|
|
|
|
|
+ const uniqueTaskMap = new Map<string, LocationMergeDetails>()
|
|
|
boxDetailsList.forEach(boxDetail => {
|
|
boxDetailsList.forEach(boxDetail => {
|
|
|
boxDetail.mergeDetails?.forEach((detail: LocationMergeDetails) => {
|
|
boxDetail.mergeDetails?.forEach((detail: LocationMergeDetails) => {
|
|
|
- const sourceLocation = detail.sourceLocation
|
|
|
|
|
- const targetLocation = detail.targetLocation
|
|
|
|
|
- const moveQty = detail.moveQty || 0
|
|
|
|
|
-
|
|
|
|
|
- // 处理源库位(推荐清空库位)
|
|
|
|
|
- if (sourceLocation) {
|
|
|
|
|
- if (!map.has(sourceLocation)) {
|
|
|
|
|
- map.set(sourceLocation, {
|
|
|
|
|
- recommendType: 'clear',
|
|
|
|
|
- relatedLocations: [],
|
|
|
|
|
- sku: detail.sku || ''
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- const sourceInfo = map.get(sourceLocation)!
|
|
|
|
|
- // 添加对应的保留库位
|
|
|
|
|
- if (targetLocation) {
|
|
|
|
|
- const existingIdx = sourceInfo.relatedLocations.findIndex(r => r.location === targetLocation)
|
|
|
|
|
- if (existingIdx === -1) {
|
|
|
|
|
- sourceInfo.relatedLocations.push({ location: targetLocation, quantity: moveQty })
|
|
|
|
|
- } else {
|
|
|
|
|
- sourceInfo.relatedLocations[existingIdx].quantity += moveQty
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 使用 sourceLocation + targetLocation + sku 作为唯一键
|
|
|
|
|
+ const key = `${detail.sourceLocation || ''}_${detail.targetLocation || ''}_${detail.sku || ''}_${detail.lotNum || ''}`
|
|
|
|
|
+ if (!uniqueTaskMap.has(key)) {
|
|
|
|
|
+ uniqueTaskMap.set(key, detail)
|
|
|
}
|
|
}
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- // 处理目标库位(推荐保留库位)
|
|
|
|
|
|
|
+ // 遍历去重后的任务
|
|
|
|
|
+ uniqueTaskMap.forEach((detail) => {
|
|
|
|
|
+ const sourceLocation = detail.sourceLocation
|
|
|
|
|
+ const targetLocation = detail.targetLocation
|
|
|
|
|
+ const moveQty = detail.moveQty || 0
|
|
|
|
|
+
|
|
|
|
|
+ // 处理源库位(推荐清空库位)
|
|
|
|
|
+ if (sourceLocation) {
|
|
|
|
|
+ if (!map.has(sourceLocation)) {
|
|
|
|
|
+ map.set(sourceLocation, {
|
|
|
|
|
+ recommendType: 'clear',
|
|
|
|
|
+ relatedLocations: [],
|
|
|
|
|
+ sku: detail.sku || ''
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ const sourceInfo = map.get(sourceLocation)!
|
|
|
|
|
+ // 添加对应的保留库位
|
|
|
if (targetLocation) {
|
|
if (targetLocation) {
|
|
|
- if (!map.has(targetLocation)) {
|
|
|
|
|
- map.set(targetLocation, {
|
|
|
|
|
- recommendType: 'keep',
|
|
|
|
|
- relatedLocations: [],
|
|
|
|
|
- sku: detail.sku || ''
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ const existingIdx = sourceInfo.relatedLocations.findIndex(r => r.location === targetLocation)
|
|
|
|
|
+ if (existingIdx === -1) {
|
|
|
|
|
+ sourceInfo.relatedLocations.push({ location: targetLocation, quantity: moveQty })
|
|
|
}
|
|
}
|
|
|
- const targetInfo = map.get(targetLocation)!
|
|
|
|
|
- // 添加对应的清空库位
|
|
|
|
|
- if (sourceLocation) {
|
|
|
|
|
- const existingIdx = targetInfo.relatedLocations.findIndex(r => r.location === sourceLocation)
|
|
|
|
|
- if (existingIdx === -1) {
|
|
|
|
|
- targetInfo.relatedLocations.push({ location: sourceLocation, quantity: moveQty })
|
|
|
|
|
- } else {
|
|
|
|
|
- targetInfo.relatedLocations[existingIdx].quantity += moveQty
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 处理目标库位(推荐保留库位)
|
|
|
|
|
+ if (targetLocation) {
|
|
|
|
|
+ if (!map.has(targetLocation)) {
|
|
|
|
|
+ map.set(targetLocation, {
|
|
|
|
|
+ recommendType: 'keep',
|
|
|
|
|
+ relatedLocations: [],
|
|
|
|
|
+ sku: detail.sku || ''
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ const targetInfo = map.get(targetLocation)!
|
|
|
|
|
+ // 添加对应的清空库位
|
|
|
|
|
+ if (sourceLocation) {
|
|
|
|
|
+ const existingIdx = targetInfo.relatedLocations.findIndex(r => r.location === sourceLocation)
|
|
|
|
|
+ if (existingIdx === -1) {
|
|
|
|
|
+ targetInfo.relatedLocations.push({ location: sourceLocation, quantity: moveQty })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
clickableLocationsMap.value = map
|
|
clickableLocationsMap.value = map
|