Forráskód Böngészése

海柔快上-增加释放分拨墙功能

zhaohuanhuan 5 hónapja
szülő
commit
a4170edd62
2 módosított fájl, 84 hozzáadás és 5 törlés
  1. 12 0
      src/api/robot/index.ts
  2. 72 5
      src/views/robot/putaway/index.vue

+ 12 - 0
src/api/robot/index.ts

@@ -14,3 +14,15 @@ export function bindAllocateWall(data:bindAllocateWallType) {
   })
 }
 
+/**
+ * 释放分拨墙
+ * @param params
+ */
+export function unbindAllocateWall(params:any) {
+  return request({
+    url: '/api/device/check/putaway/unbindAllocateWall',
+    method: 'post',
+    params
+  })
+}
+

+ 72 - 5
src/views/robot/putaway/index.vue

@@ -1,11 +1,14 @@
 <template>
   <div class="container">
     <van-nav-bar
-      title="海柔快上" left-arrow fixed placeholder @click-left="goBack">
+      title="海柔快上" left-arrow fixed placeholder @click-left="goBack" @click-right="handleReleaseWall">
       <template #left>
         <van-icon name="arrow-left" size="25" />
         <div style="color: #fff">返回</div>
       </template>
+      <template #right>
+        <div style="color: #fff">释放分拨墙</div>
+      </template>
     </van-nav-bar>
     <div class="allocation">
       <div class="code">
@@ -115,7 +118,7 @@ import {  getRecommendedLocation } from '@/api/haikang'
 import { barcodeToUpperCase } from '@/utils/dataType'
 import { closeLoading, showLoading } from '@/utils/loading'
 import { getWaitPutawayListNew } from '@/api/putaway'
-import { bindAllocateWall } from '@/api/robot'
+import { bindAllocateWall, unbindAllocateWall } from '@/api/robot'
 try {
   getHeader()
   androidFocus()
@@ -204,6 +207,7 @@ const setBarcode = (code) => {
       scanType.value = 3
       containerNo.value = code
       locationActive.value=[]
+      tips.value='请扫描分拨墙'
     }
   }).catch(err => {
     scanError()
@@ -458,6 +462,71 @@ const submitBinBinding = (data, storedData) => {
     closeLoading()
   })
 }
+
+// 执行释放分拨墙操作
+const executeReleaseWall = (storedData, hasCache) => {
+  showLoading()
+  unbindAllocateWall({ equipment: wallNo.value })
+    .then(() => {
+      // 接口成功后,删除缓存数据(如果有)
+      if (hasCache) {
+        for (const container in storedData) {
+          if (storedData[container][wallNo.value]) {
+            delete storedData[container][wallNo.value]
+          }
+        }
+        saveBinStorageData(storedData)
+      }
+      
+      // 重置相关状态
+      bin.value = ''
+      searchBarcode.value = ''
+      locationActive.value = []
+      scanType.value = 2
+      tips.value = '请扫描商品条码'
+
+      closeLoading()
+      const successMsg = hasCache ? '分拨墙已释放成功,已删除相关容器数据' : '分拨墙已释放成功'
+      showNotify({ type: 'success', duration: 3000, message: successMsg })
+      scanSuccess()
+    })
+    .catch(err => {
+      closeLoading()
+      scanError()
+    })
+}
+
+// 释放分拨墙
+const handleReleaseWall = () => {
+  // 检查是否有分拨墙号
+  if (!wallNo.value) {
+    showToast({ duration: 3000, message: '请先扫描分拨墙号' })
+    return
+  }
+
+  // 获取存储的数据并检查是否有该分拨墙的绑定数据
+  const storedData = getBinStorageData()
+  const containerList = []
+  
+  for (const container in storedData) {
+    if (storedData[container][wallNo.value] && Object.keys(storedData[container][wallNo.value]).length > 0) {
+      containerList.push(container)
+    }
+  }
+
+  const hasCache = containerList.length > 0
+  const message = hasCache 
+    ? `确定要释放分拨墙 ${wallNo.value} 吗?\n将会删除以下容器的分拨墙数据:\n${containerList.join(', ')}`
+    : `确定要释放分拨墙 ${wallNo.value} 吗?`
+
+  // 弹窗确认后执行释放操作
+  showConfirmDialog({
+    title: '释放分拨墙',
+    message,
+  })
+    .then(() => executeReleaseWall(storedData, hasCache))
+    .catch(() => {})
+}
 // 数据刷新
 const loadData = () => {
   if (!containerNo.value) {
@@ -498,9 +567,7 @@ const reset = () => {
 }
 
 // 注册页面刷新函数
-if (typeof window !== 'undefined') {
-  ;(window as any).onRefresh = loadData
-}
+window.onRefresh = loadData
 </script>
 <style scoped lang="sass">
 .container