Quellcode durchsuchen

换一换排除库位逻辑调整

zhaohuanhuan vor 1 Woche
Ursprung
Commit
244dcf2e11
1 geänderte Dateien mit 12 neuen und 28 gelöschten Zeilen
  1. 12 28
      src/views/inbound/putaway/task/index.vue

+ 12 - 28
src/views/inbound/putaway/task/index.vue

@@ -243,9 +243,9 @@ const isLocationInRecommendedList = (locationCode) => {
 }
 }
 
 
 // 从已排除库位记录中提取 locationId 列表(换一换时使用)
 // 从已排除库位记录中提取 locationId 列表(换一换时使用)
-const getExcludedLocationIds = (listByLot) => {
-  if (!listByLot.length) return undefined
-  return [...new Set(listByLot.map(loc => (typeof loc === 'string' ? loc : loc?.locationId)).filter(Boolean))]
+const getExcludedLocationIds = (list) => {
+  if (!list.length) return undefined
+  return [...new Set(list.map(loc => (typeof loc === 'string' ? loc : loc?.locationId)).filter(Boolean))]
 }
 }
 
 
 // 单一批次命中:获取推荐库位并进入库位扫描
 // 单一批次命中:获取推荐库位并进入库位扫描
@@ -467,7 +467,7 @@ const matchingBarcodeItem = (data, barcode) => {
 const switchTask = () => {
 const switchTask = () => {
   inputBarcodeType.value = 'switchTask'
   inputBarcodeType.value = 'switchTask'
   back.value = false
   back.value = false
-  if (systemForcePublishEnabled.value) excludedLocations.value = {}
+  if (systemForcePublishEnabled.value) excludedLocations.value = []
   locationType.value = ''
   locationType.value = ''
   changeLocationTypePickerRef.value?.clearCache()
   changeLocationTypePickerRef.value?.clearCache()
   inputBarcodeRef.value?.show('', `请扫描容器号`, '')
   inputBarcodeRef.value?.show('', `请扫描容器号`, '')
@@ -481,8 +481,8 @@ const barcodeActiveList = ref([])
 const barcodeCombineRef = ref(null)
 const barcodeCombineRef = ref(null)
 const putawayCombineData = ref(null)
 const putawayCombineData = ref(null)
 const combineMatchedSku = ref([])
 const combineMatchedSku = ref([])
-// 已推荐过的库位,按 lotNum 批次维度存储,用于换一换时排除
-const excludedLocations = ref({})
+// 已推荐过的库位,用于换一换时排除
+const excludedLocations = ref([])
 // 换一换按钮 loading
 // 换一换按钮 loading
 const changeLocationLoading = ref(false)
 const changeLocationLoading = ref(false)
 // 上架区域,默认全部
 // 上架区域,默认全部
@@ -499,7 +499,7 @@ const onSelectLocationType = async (value = '') => {
   locationType.value = value
   locationType.value = value
   locationTypeSheetShow.value = false
   locationTypeSheetShow.value = false
   if (value !== prev && barcodeActiveList.value.length > 0) {
   if (value !== prev && barcodeActiveList.value.length > 0) {
-    excludedLocations.value = {}
+    excludedLocations.value = []
     await _getRecommendedLocation(barcodeActiveList.value[0])
     await _getRecommendedLocation(barcodeActiveList.value[0])
   }
   }
 }
 }
@@ -512,7 +512,7 @@ const reset = () => {
   barcodeActiveList.value = []
   barcodeActiveList.value = []
   putawayCombineData.value = null
   putawayCombineData.value = null
   combineMatchedSku.value = []
   combineMatchedSku.value = []
-  excludedLocations.value = {}
+  excludedLocations.value = []
   forbidForcePutaway.value = true // 重置为默认不强制,待下次推荐接口返回后再更新
   forbidForcePutaway.value = true // 重置为默认不强制,待下次推荐接口返回后再更新
   locationType.value = ''
   locationType.value = ''
 }
 }
@@ -595,7 +595,7 @@ const _handlePutawayCombineProduct = (code) => {
 // 扫描条码监听
 // 扫描条码监听
 const _handlerScan = (code) => {
 const _handlerScan = (code) => {
   if (scanType.value === SCAN_TYPE.BARCODE) {
   if (scanType.value === SCAN_TYPE.BARCODE) {
-    excludedLocations.value = {}
+    excludedLocations.value = []
     searchBarcode.value = code
     searchBarcode.value = code
     oldSearchBarcode.value = code
     oldSearchBarcode.value = code
     lotBarcodeList.value = matchingBarcodeItem(dataMap.value, code)
     lotBarcodeList.value = matchingBarcodeItem(dataMap.value, code)
@@ -639,8 +639,7 @@ const _getRecommendedLocation = async (item, options = {}) => {
     return
     return
   }
   }
   const { fromChangeLocation = false } = options
   const { fromChangeLocation = false } = options
-  const listByLot = fromChangeLocation ? (excludedLocations.value[lotNumber] || []) : []
-  const uniqueLocationIds = getExcludedLocationIds(listByLot)
+  const uniqueLocationIds = fromChangeLocation ? getExcludedLocationIds(excludedLocations.value) : undefined
   try {
   try {
     const total = barcodeQuantity(barcodeActiveList.value)
     const total = barcodeQuantity(barcodeActiveList.value)
     const params = { warehouse, lotNum: lotNumber, owner, sku, qty: total, lotAtt08 }
     const params = { warehouse, lotNum: lotNumber, owner, sku, qty: total, lotAtt08 }
@@ -651,15 +650,6 @@ const _getRecommendedLocation = async (item, options = {}) => {
     if (res.data) {
     if (res.data) {
       forbidForcePutaway.value = res.data.forbidForcePutaway // 货主策略:是否禁止强制上架
       forbidForcePutaway.value = res.data.forbidForcePutaway // 货主策略:是否禁止强制上架
       const loc = res.data.locationList
       const loc = res.data.locationList
-      if (fromChangeLocation) {
-        // 按批次维度存储已推荐库位(与接口 locationList 项一致,含 locationId),用于后续换一换排除
-        const lotExcluded = excludedLocations.value[lotNumber] || []
-        const recommended = Array.isArray(loc) ? loc : []
-        excludedLocations.value = {
-          ...excludedLocations.value,
-          [lotNumber]: [...lotExcluded, ...recommended]
-        }
-      }
       locationList.value = loc
       locationList.value = loc
       searchCount.value = 1
       searchCount.value = 1
     }
     }
@@ -681,14 +671,8 @@ const doChangeLocationWithType = async (item) => {
   changeLocationLoading.value = true
   changeLocationLoading.value = true
   try {
   try {
     const batchItem = barcodeActiveList.value[0]
     const batchItem = barcodeActiveList.value[0]
-    const lotNumber = batchItem.lotNumber
-    const currentLoc = locationList.value?.[0]
-    if (currentLoc) {
-      const lotExcluded = excludedLocations.value[lotNumber] || []
-      excludedLocations.value = {
-        ...excludedLocations.value,
-        [lotNumber]: [...lotExcluded, currentLoc]
-      }
+    if (locationList.value?.length) {
+      excludedLocations.value = [...excludedLocations.value, ...locationList.value]
     }
     }
     const reqOpts = { fromChangeLocation: true }
     const reqOpts = { fromChangeLocation: true }
     if (item?.value) reqOpts.changeTypeName = item.value
     if (item?.value) reqOpts.changeTypeName = item.value