Jelajahi Sumber

宝时快上-移除扫描商品排除库位逻辑

zhaohuanhuan 1 Minggu lalu
induk
melakukan
704fb1aa97
1 mengubah file dengan 21 tambahan dan 11 penghapusan
  1. 21 11
      src/views/inbound/putaway/task/index.vue

+ 21 - 11
src/views/inbound/putaway/task/index.vue

@@ -560,7 +560,8 @@ const _handlerScan = (code) => {
   }
 }
 // 获取推荐库位(false:master GET 多行列表;true:精准推荐 POST)
-const _getRecommendedLocation = async (item, excludeList) => {
+const _getRecommendedLocation = async (item, options = {}) => {
+  const { fromChangeLocation = false } = options
   const { lotNumber, owner } = item
   if (!forcePublishEnabled.value) {
     try {
@@ -572,23 +573,24 @@ const _getRecommendedLocation = async (item, excludeList) => {
     return
   }
   const { sku, quantity, lotAtt08 } = item
-  // 扫描商品时先看有没有推荐过
-  const listByLot = excludeList ?? (excludedLocations.value[lotNumber] || [])
+  const listByLot = fromChangeLocation ? (excludedLocations.value[lotNumber] || []) : []
   const uniqueLocationIds = listByLot.length > 0
     ? [...new Set(listByLot.map(loc => loc.locationId))]
     : undefined
   try {
     const params = { warehouse, lotNum: lotNumber, owner, sku, qty: quantity, lotAtt08 }
-    if (uniqueLocationIds) params.excludedLocations = uniqueLocationIds
+    if (fromChangeLocation && uniqueLocationIds) params.excludedLocations = uniqueLocationIds
     if (containerNo.value?.includes('TH-')) params.scene = 'RETURN_SHELVE'
     const res = await getRecommendedLocationNew(params)
     if (res.data) {
       const loc = res.data.location ?? res.data
-      // 按批次维度存储已推荐库位
-      const lotExcluded = excludedLocations.value[lotNumber] || []
-      excludedLocations.value = {
-        ...excludedLocations.value,
-        [lotNumber]: [...lotExcluded, loc]
+      if (fromChangeLocation) {
+        // 按批次维度存储已推荐库位,用于后续换一换排除
+        const lotExcluded = excludedLocations.value[lotNumber] || []
+        excludedLocations.value = {
+          ...excludedLocations.value,
+          [lotNumber]: [...lotExcluded, loc]
+        }
       }
       locationList.value = [res.data]
       searchCount.value = 1
@@ -605,8 +607,16 @@ const onChangeLocation = async () => {
     changeLocationLoading.value = true
     try {
       const item = barcodeActiveList.value[0]
-      const lotExcluded = excludedLocations.value[item.lotNumber] || []
-      await _getRecommendedLocation(item, lotExcluded)
+      const lotNumber = item.lotNumber
+      const currentLoc = locationList.value?.[0]?.location ?? locationList.value?.[0]
+      if (currentLoc) {
+        const lotExcluded = excludedLocations.value[lotNumber] || []
+        excludedLocations.value = {
+          ...excludedLocations.value,
+          [lotNumber]: [...lotExcluded, currentLoc]
+        }
+      }
+      await _getRecommendedLocation(item, { fromChangeLocation: true })
     } finally {
       changeLocationLoading.value = false
     }