Prechádzať zdrojové kódy

宝时快上-推荐库位调整

zhaohuanhuan 3 týždňov pred
rodič
commit
a23948d1b4

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

@@ -31,7 +31,7 @@ export function getRecommendedLocation(params:getRecommendedLocationType) {
  */
  */
 export function getRecommendedLocationNew(data:getRecommendedLocationTypeNew) {
 export function getRecommendedLocationNew(data:getRecommendedLocationTypeNew) {
   return request({
   return request({
-    url: '/api/wms/inbound/v3/recommended-location',
+    url: '/api/basic/location/resource/getRecommendedLocation',
     method: 'post',
     method: 'post',
     data
     data
   })
   })

+ 2 - 2
src/views/inbound/putaway/components/LocationList.vue

@@ -11,8 +11,8 @@
       </thead>
       </thead>
       <tbody>
       <tbody>
       <tr v-for="(item, index) in props.locationList" :key="index" v-if="props.locationList.length>0">
       <tr v-for="(item, index) in props.locationList" :key="index" v-if="props.locationList.length>0">
-        <td>{{ item.location }}</td>
-        <td>{{ locationType[item.type] || item.type }}</td>
+        <td>{{ item.locationId }}</td>
+        <td>{{ locationType[item.locationUsage] || item.locationUsage }}</td>
         <td>{{ item.quantity || 0 }}</td>
         <td>{{ item.quantity || 0 }}</td>
         <td>{{ item.max || '无' }}</td>
         <td>{{ item.max || '无' }}</td>
       </tr>
       </tr>

+ 22 - 9
src/views/inbound/putaway/task/index.vue

@@ -381,6 +381,7 @@ const matchingBarcodeItem = (data, barcode) => {
 const switchTask = () => {
 const switchTask = () => {
   inputBarcodeType.value = 'switchTask'
   inputBarcodeType.value = 'switchTask'
   back.value = false
   back.value = false
+  excludedLocations.value = {}
   inputBarcodeRef.value?.show('', `请扫描容器号`, '')
   inputBarcodeRef.value?.show('', `请扫描容器号`, '')
 }
 }
 
 
@@ -388,8 +389,8 @@ const switchTask = () => {
 const lotBarcodeList = ref([])
 const lotBarcodeList = ref([])
 const lotBarcodeTrueFalseBy = ref(false)
 const lotBarcodeTrueFalseBy = ref(false)
 const barcodeActiveList = ref([])
 const barcodeActiveList = ref([])
-// 已推荐过的库位,用于换一换时排除
-const excludedLocations = ref([])
+// 已推荐过的库位,按 lotNum 批次维度存储,用于换一换时排除
+const excludedLocations = ref({}) // { [lotNumber]: [locationId, ...] }
 // 换一换按钮 loading
 // 换一换按钮 loading
 const changeLocationLoading = ref(false)
 const changeLocationLoading = ref(false)
 const reset = () => {
 const reset = () => {
@@ -399,7 +400,6 @@ const reset = () => {
   oldSearchBarcode.value = ''
   oldSearchBarcode.value = ''
   locationList.value = []
   locationList.value = []
   barcodeActiveList.value = []
   barcodeActiveList.value = []
-  excludedLocations.value = []
 }
 }
 // 选择单据
 // 选择单据
 const onDetailActive = (item) => {
 const onDetailActive = (item) => {
@@ -459,8 +459,13 @@ const _handlerScan = (code) => {
   }
   }
 }
 }
 // 获取推荐库位
 // 获取推荐库位
-const _getRecommendedLocation = async (item, excludeList = []) => {
-  const { lotNumber, owner, sku, quantity } = item
+const _getRecommendedLocation = async (item, excludeList) => {
+  const { lotNumber, owner, sku, quantity, lotAtt08 } = item
+  // 扫描商品时先看有没有推荐过
+  const listByLot = excludeList ?? (excludedLocations.value[lotNumber] || [])
+  const uniqueLocationIds = listByLot.length > 0
+    ? [...new Set(listByLot.map(loc => loc.locationId))]
+    : undefined
   try {
   try {
     const params = {
     const params = {
       warehouse,
       warehouse,
@@ -468,12 +473,18 @@ const _getRecommendedLocation = async (item, excludeList = []) => {
       owner,
       owner,
       sku,
       sku,
       qty: quantity,
       qty: quantity,
-      excludedLocations: excludeList.length > 0 ? [...new Set(excludeList)] : undefined
+      lotAtt08,
+      ...(uniqueLocationIds && { excludedLocations: uniqueLocationIds })
     }
     }
     const res = await getRecommendedLocationNew(params)
     const res = await getRecommendedLocationNew(params)
     if (res.data) {
     if (res.data) {
       const loc = res.data.location ?? res.data
       const loc = res.data.location ?? res.data
-      excludedLocations.value = [...excludedLocations.value, loc]
+      // 按批次维度存储已推荐库位
+      const lotExcluded = excludedLocations.value[lotNumber] || []
+      excludedLocations.value = {
+        ...excludedLocations.value,
+        [lotNumber]: [...lotExcluded, loc]
+      }
       locationList.value = [res.data]
       locationList.value = [res.data]
       searchCount.value = 1
       searchCount.value = 1
     }
     }
@@ -482,12 +493,14 @@ const _getRecommendedLocation = async (item, excludeList = []) => {
   }
   }
 }
 }
 
 
-// 换一换:请求新的推荐库位,排除已推荐过的
+// 换一换:请求新的推荐库位,排除当前批次已推荐过的
 const onChangeLocation = async () => {
 const onChangeLocation = async () => {
   if (barcodeActiveList.value.length > 0) {
   if (barcodeActiveList.value.length > 0) {
     changeLocationLoading.value = true
     changeLocationLoading.value = true
     try {
     try {
-      await _getRecommendedLocation(barcodeActiveList.value[0], excludedLocations.value)
+      const item = barcodeActiveList.value[0]
+      const lotExcluded = excludedLocations.value[item.lotNumber] || []
+      await _getRecommendedLocation(item, lotExcluded)
     } finally {
     } finally {
       changeLocationLoading.value = false
       changeLocationLoading.value = false
     }
     }