Ver Fonte

库位合并

zh há 3 meses atrás
pai
commit
e1a767f527
1 ficheiros alterados com 59 adições e 0 exclusões
  1. 59 0
      src/views/robot/merge/index.vue

+ 59 - 0
src/views/robot/merge/index.vue

@@ -956,6 +956,56 @@ const stopPolling = () => {
   }
 }
 
+// 静默刷新盒子数据(调用getWorkingDetailsByBox更新库存信息)
+const refreshBoxData = async () => {
+  if (!boxCode.value) return
+
+  try {
+    // 调用 getWorkingDetailsByBox 获取最新任务详情
+    const res = await getWorkingDetailsByBox(boxCode.value, warehouse)
+    const boxDetailsList: BoxRelatedMergeDetailsVO[] = res.data || []
+
+    if (boxDetailsList.length === 0) {
+      return
+    }
+
+    // 保存返回的数据
+    mergeDataList.value = boxDetailsList
+
+    // 遍历 mergeDetails 取源库位和目标库位,去重
+    const locationSet = new Set<string>()
+    boxDetailsList.forEach(boxDetail => {
+      boxDetail.mergeDetails?.forEach((detail: LocationMergeDetails) => {
+        if (detail.sourceLocation) locationSet.add(detail.sourceLocation)
+        if (detail.targetLocation) locationSet.add(detail.targetLocation)
+      })
+    })
+
+    const locations = Array.from(locationSet)
+
+    if (locations.length > 0) {
+      // 调用 getBoxSplitCode 获取库位分割信息
+      const splitRes = await getBoxSplitCode(warehouse, locations)
+      const splitMap: Record<string, number> = splitRes.data || {}
+
+      // 构建可点击库位信息
+      buildClickableLocationsMap(boxDetailsList)
+
+      // 更新站台区域
+      updateStationList(boxDetailsList, splitMap)
+    }
+
+    // 检查是否需要启动轮询
+    if (hasWaitingBox()) {
+      startPolling()
+    } else {
+      stopPolling()
+    }
+  } catch (error) {
+    console.error('刷新盒子数据失败', error)
+  }
+}
+
 // 执行重新下发任务
 const doReissueTask = async (station: StationItem) => {
   if (!station.boxCode) {
@@ -1201,11 +1251,20 @@ const submitMove = () => {
         toLocation: productInfo.targetLocationNew
       }
       showLoadingToast({ message: '提交中...', forbidClick: true })
+      // 保存移库前的数据用于判断是否清空
+      const movedQty = Number(productInfo.actualMoveQty)
+      const availableQty = Number(productInfo.moveQty)
       inventoryMovement(data)
         .then(() => {
           closeToast()
           scanSuccess()
           showToast('提交移库成功')
+          // 如果源库位被清空,更新盒子信息
+          if (movedQty >= availableQty) {
+            setTimeout(() => {
+              refreshBoxData()
+            }, 500)
+          }
           // 重置除料箱号外的数据,继续下一个移库
           resetExceptBoxCode()
         })