Pārlūkot izejas kodu

拣货-弹框关闭后增加自动跳转扫描库位

zhaohuanhuan 2 mēneši atpakaļ
vecāks
revīzija
8f0eeef9b9
1 mainītis faili ar 24 papildinājumiem un 2 dzēšanām
  1. 24 2
      src/views/outbound/picking/list/index.vue

+ 24 - 2
src/views/outbound/picking/list/index.vue

@@ -170,6 +170,8 @@ const count=ref('')
 const countRef= ref(null)
 const countTrueFalseBy=ref(false)
 const  activeItem=ref({})
+// 存储需要跳转的库位(当弹框显示时扫描到库位)
+const pendingLocationJump=ref('')
 //容器号ref
 const scanCountRef = ref(null)
 onMounted(() => {
@@ -373,7 +375,8 @@ const _handlerScan=(code)=> {
       scannedLocation = locationContainerMap.value[barcodeToUpperCase(code)]
     }
     if (taskMap.value[barcodeToUpperCase(scannedLocation)]) {
-      // 扫描到当前任务中的库位,自动确认
+      // 扫描到当前任务中的库位,自动确认,接口成功后再跳转
+      pendingLocationJump.value = barcodeToUpperCase(scannedLocation)
       onSubmitCount()
       return
     }
@@ -709,7 +712,6 @@ const _setPickingDetail=(params,type)=>{
         }
       })
     }
-    scanSuccess()
     if(selectTask.value.length===taskItem.value.length){
       showDialog({
         title: '温馨提示',
@@ -724,12 +726,32 @@ const _setPickingDetail=(params,type)=>{
         }
       })
     }
+    // 如果任务全部完成,则不跳转,优先执行完成逻辑
+    if (selectTask.value.length === taskItem.value.length) {
+      pendingLocationJump.value = '' // 清空待跳转标记
+      scanSuccess()
+    } else {
+      // 检查是否有待跳转的库位(弹框显示时扫描库位的情况)
+      if (pendingLocationJump.value) {
+        nextTick(() => {
+          nextLocation.value = ''
+          activeIndex.value = locationList.value.findIndex(item => item.location === pendingLocationJump.value)
+          onScan(3)
+          scanSuccess()
+          pendingLocationJump.value = '' // 清空标记
+        })
+      } else {
+        scanSuccess()
+      }
+    }
   }).catch((err)=> {
     closeLoading()
     scanBarcode.value = ''
     onScan(4)
     messageTips.value = err.message
     scanError()
+    // 接口调用失败,清空待跳转库位标记
+    pendingLocationJump.value = ''
     if(err.code=='ERR_NETWORK'){
       messageTips.value = '网络开小车了,请稍后重试!'
     }if(err.code=='ECONNABORTED'){