Ver Fonte

宝时快上-切换精准推荐

zhaohuanhuan há 1 mês atrás
pai
commit
402d7192a1
3 ficheiros alterados com 124 adições e 12 exclusões
  1. 14 1
      src/api/haikang/index.ts
  2. 37 0
      src/types/haikang.ts
  3. 73 11
      src/views/inbound/putaway/task/index.vue

+ 14 - 1
src/api/haikang/index.ts

@@ -1,7 +1,7 @@
 // @ts-ignore
 import request from '@/utils/request'
 // @ts-ignore
-import {getWaitPutawayListType, getRecommendedLocationType,setBindAllocateWallType } from '@/types/haikang'
+import {getWaitPutawayListType, getRecommendedLocationType, getRecommendedLocationTypeNew, setBindAllocateWallType } from '@/types/haikang'
 /**
  * 上架任务列表
  * @param params
@@ -24,6 +24,19 @@ export function getRecommendedLocation(params:getRecommendedLocationType) {
     params
   })
 }
+
+/**
+ * 推荐库位-精准推荐
+ * @param data
+ */
+export function getRecommendedLocationNew(data:getRecommendedLocationTypeNew) {
+  return request({
+    url: '/api/wms/inbound/v3/recommended-location',
+    method: 'post',
+    data
+  })
+}
+
 /**
  * 商品绑定分拨墙格口
  * @param data

+ 37 - 0
src/types/haikang.ts

@@ -47,6 +47,43 @@ export interface getRecommendedLocationType {
   [property: string]: any;
 }
 
+/**
+ * 推荐库位查询对象
+ *
+ * LocationRecommendedQO
+ */
+export interface getRecommendedLocationTypeNew {
+  /**
+   * 需排除的库位列表
+   */
+  excludedLocations?: string[];
+  /**
+   * 批次号
+   */
+  lotNum: string;
+  /**
+   * 货主编码
+   */
+  owner: string;
+  /**
+   * 数量
+   */
+  qty: number;
+  /**
+   * 商品SKU
+   */
+  sku: string;
+  /**
+   * 仓库编码
+   */
+  warehouse: string;
+  /**
+   * 库区组
+   */
+  zoneGroup?: string;
+  [property: string]: any;
+}
+
 export interface setBindAllocateWallType {
   /**
    * 仓库

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

@@ -73,6 +73,18 @@
             @focus="scanType=3"
             autocomplete="off"
           >
+            <template #right-icon>
+              <van-button
+                v-if="barcodeActiveList.length > 0"
+                type="primary"
+                size="mini"
+                plain
+                :loading="changeLocationLoading"
+                @click.stop="onChangeLocation"
+              >
+                换一换
+              </van-button>
+            </template>
           </van-search>
         </div>
         <div class="barcode-input">
@@ -163,7 +175,7 @@ import { showNotify, showToast } from 'vant'
 import { getCurrentTime } from '@/utils/date'
 import { getWaitPutawayListNew, setPutawayNew } from '@/api/putaway/index'
 import { barcodeToUpperCase } from '@/utils/dataType.js'
-import { getRecommendedLocation } from '@/api/haikang/index'
+import { getRecommendedLocationNew } from '@/api/haikang/index'
 import { getOwnerList } from '@/hooks/basic/index'
 
 const router = useRouter()
@@ -182,7 +194,7 @@ onMounted(() => {
 })
 const warehouse = store.warehouse
 //容器号
-const containerNo = ref('')
+const containerNo = ref('zhh-p')
 //数据列表
 const dataList = ref([])
 //
@@ -376,6 +388,10 @@ const switchTask = () => {
 const lotBarcodeList = ref([])
 const lotBarcodeTrueFalseBy = ref(false)
 const barcodeActiveList = ref([])
+// 已推荐过的库位,用于换一换时排除
+const excludedLocations = ref([])
+// 换一换按钮 loading
+const changeLocationLoading = ref(false)
 const reset = () => {
   searchCount.value = ''
   searchBarcode.value = ''
@@ -383,14 +399,14 @@ const reset = () => {
   oldSearchBarcode.value = ''
   locationList.value = []
   barcodeActiveList.value = []
+  excludedLocations.value = []
 }
 // 选择单据
 const onDetailActive = (item) => {
   barcodeActiveList.value = item
   lotBarcodeTrueFalseBy.value = false
-  searchCount.value = 1
   scanType.value = 3
-  _getRecommendedLocation(item[0].lotNumber, item[0].owner)
+  _getRecommendedLocation(item[0])
   scanSuccess()
 }
 const onAsnCancel = () => {
@@ -409,7 +425,7 @@ const _handlerScan = (code) => {
     if (lotBarcodeList.value.length > 0) {
       if (lotBarcodeList.value.length == 1) {
         barcodeActiveList.value = lotBarcodeList.value[0]
-        _getRecommendedLocation(barcodeActiveList.value[0].lotNumber, barcodeActiveList.value[0].owner)
+        _getRecommendedLocation(barcodeActiveList.value[0])
         scanType.value = 3
         scanSuccess()
       } else if (lotBarcodeList.value.length > 1) {
@@ -425,22 +441,58 @@ const _handlerScan = (code) => {
       reset()
     }
   } else if (scanType.value == 3) {
-    searchLocation.value = barcodeToUpperCase(code)
+    const scannedLocation = barcodeToUpperCase(code)
+    // 校验是否与推荐库位一致
+    if (locationList.value.length > 0) {
+      const recommendedLocations = locationList.value.map(item => barcodeToUpperCase(item.location || ''))
+      if (!recommendedLocations.includes(scannedLocation)) {
+        showNotify({ type: 'warning', duration: 3000, message: `扫描库位${scannedLocation}与推荐库位不一致,请确认` })
+        searchLocation.value=''
+        scanError()
+        return
+      }
+    }
+    searchLocation.value = scannedLocation
     scanType.value = 4
     searchCount.value = 1
     scanSuccess()
   }
 }
-// 获取库存数据
-const _getRecommendedLocation = async (lotNum, owner) => {
+// 获取推荐库位
+const _getRecommendedLocation = async (item, excludeList = []) => {
+  const { lotNumber, owner, sku, quantity } = item
   try {
-    const params = { warehouse, lotNum, owner }
-    const res = await getRecommendedLocation(params)
-    locationList.value = res.data
+    const params = {
+      warehouse,
+      lotNum: lotNumber,
+      owner,
+      sku,
+      qty: quantity,
+      excludedLocations: excludeList.length > 0 ? [...new Set(excludeList)] : undefined
+    }
+    const res = await getRecommendedLocationNew(params)
+    if (res.data) {
+      const loc = res.data.location ?? res.data
+      excludedLocations.value = [...excludedLocations.value, loc]
+      locationList.value = [res.data]
+      searchCount.value = 1
+    }
   } catch (err) {
     console.error(err)
   }
 }
+
+// 换一换:请求新的推荐库位,排除已推荐过的
+const onChangeLocation = async () => {
+  if (barcodeActiveList.value.length > 0) {
+    changeLocationLoading.value = true
+    try {
+      await _getRecommendedLocation(barcodeActiveList.value[0], excludedLocations.value)
+    } finally {
+      changeLocationLoading.value = false
+    }
+  }
+}
 const numberRef = ref(null)
 const locationRef = ref(null)
 // 完成收货校验
@@ -451,6 +503,16 @@ const isCheck = () => {
     showToast({ duration: 3000, message: '请先扫描库位编号' })
     return false
   }
+  // 校验库位是否与推荐库位一致
+  if (locationList.value.length > 0) {
+    const recommendedLocations = locationList.value.map(item => barcodeToUpperCase(item.location || ''))
+    if (!recommendedLocations.includes(barcodeToUpperCase(searchLocation.value))) {
+      locationRef.value?.focus()
+      scanError()
+      showToast({ duration: 3000, message: '库位与推荐库位不一致,无法上架' })
+      return false
+    }
+  }
   if (searchCount.value == '') {
     numberRef.value?.focus()
     scanError()