Преглед изворни кода

Merge branch 'zhaohuanhuan_强制上架' into testing

# Conflicts:
#	src/types/haikang.ts
#	src/views/inbound/putaway/components/LocationList.vue
#	src/views/inbound/putaway/task/index.vue
zhaohuanhuan пре 1 недеља
родитељ
комит
5fda94f4f9

+ 9 - 0
src/api/basic/index.ts

@@ -36,6 +36,15 @@ export function getWarehouse(){
   })
 }
 
+/** 按 key 查询系统参数 */
+export function findSysParamByKey(params: { paramKey: string }) {
+  return request({
+    url: '/api/basic/sys/params/findByParamKey',
+    method: 'get',
+    params,
+  })
+}
+
 
 
 /**

+ 4 - 0
src/types/haikang.ts

@@ -81,6 +81,10 @@ export interface getRecommendedLocationTypeNew {
    * 库区组
    */
   zoneGroup?: string;
+  /**
+   * 推荐场景,如退货上架 RETURN_SHELVE
+   */
+  scene?: string;
   [property: string]: any;
 }
 

+ 5 - 4
src/views/inbound/putaway/components/LocationList.vue

@@ -11,9 +11,9 @@
       </thead>
       <tbody>
       <tr v-for="(item, index) in props.locationList" :key="index" v-if="props.locationList.length>0">
-        <td>{{ item.locationId }}</td>
-        <td>{{ locationType[item.locationUsage] || item.locationUsage }}</td>
-        <td>{{ item.qty || 0 }}</td>
+        <td>{{ legacy ? item.location : item.locationId }}</td>
+        <td>{{ legacy ? (locationType[item.type] || item.type) : (locationType[item.locationUsage] || item.locationUsage) }}</td>
+        <td>{{ legacy ? (item.quantity || 0) : (item.qty || 0) }}</td>
         <td>{{ item.max || '无' }}</td>
       </tr>
       <tr v-else>
@@ -41,7 +41,8 @@ const locationType = {
 }
 const props = defineProps({
   locationList: Array,
-});
+  legacy: { type: Boolean, default: false },
+})
 </script>
 <style scoped lang="sass">
 .move-stock-list

+ 65 - 38
src/views/inbound/putaway/task/index.vue

@@ -75,7 +75,7 @@
           >
             <template #right-icon>
               <van-button
-                v-if="barcodeActiveList.length > 0"
+                v-if="forcePublishEnabled && barcodeActiveList.length > 0"
                 type="primary"
                 size="mini"
                 plain
@@ -133,7 +133,7 @@
         <div class="btn" type="primary" size="large" round style="height: 36px" @click="onConfirm">上架</div>
       </div>
       <div>
-        <location-list :locationList="locationList" />
+        <location-list :locationList="locationList" :legacy="!forcePublishEnabled" />
       </div>
     </div>
   </div>
@@ -157,7 +157,7 @@
   <van-action-sheet v-model:show="locationTrueFalseBy" cancel-text="取消" description="推荐库位列表"
                     close-on-click-action>
     <div style="max-height: 60vh;overflow: auto;">
-      <location-list :locationList="locationList" />
+      <location-list :locationList="locationList" :legacy="!forcePublishEnabled" />
     </div>
   </van-action-sheet>
   <!--  组合商品上架数量-->
@@ -179,7 +179,8 @@ import { getCurrentTime } from '@/utils/date'
 import { getWaitPutawayListNew, setPutawayNew } from '@/api/putaway/index'
 import { getListCombineSku } from '@/api/picking'
 import { barcodeToUpperCase } from '@/utils/dataType.js'
-import { getRecommendedLocationNew } from '@/api/haikang/index'
+import { getRecommendedLocation, getRecommendedLocationNew } from '@/api/haikang/index'
+import { findSysParamByKey } from '@/api/basic/index'
 import { getOwnerList } from '@/hooks/basic/index'
 
 const router = useRouter()
@@ -190,10 +191,27 @@ try {
 } catch (error) {
   router.push('/login')
 }
+/** 查询参数配置-精准推荐是否开启 */
+const forcePublishEnabled = ref(true)
+async function loadForcePublishParam() {
+  try {
+    const res = await findSysParamByKey({ paramKey: 'FORCE_PUBLISH_ENABLED' })
+    console.log(res)
+    if (res?.data && res.data=='true') {
+      forcePublishEnabled.value = true
+    }else{
+      forcePublishEnabled.value = false
+    }
+  } catch (e) {
+    console.error(e)
+  }
+}
+
 // 页面初始化
-onMounted(() => {
+onMounted(async () => {
   openListener()
   scanInit(_handlerScan)
+  await loadForcePublishParam()
   loadData()
 })
 const warehouse = store.warehouse
@@ -385,7 +403,7 @@ const matchingBarcodeItem = (data, barcode) => {
 const switchTask = () => {
   inputBarcodeType.value = 'switchTask'
   back.value = false
-  excludedLocations.value = {}
+  if (forcePublishEnabled.value) excludedLocations.value = {}
   inputBarcodeRef.value?.show('', `请扫描容器号`, '')
 }
 
@@ -398,7 +416,7 @@ const barcodeCombineRef = ref(null)
 const putawayCombineData = ref(null)
 const combineMatchedSku = ref([])
 // 已推荐过的库位,按 lotNum 批次维度存储,用于换一换时排除
-const excludedLocations = ref({}) // { [lotNumber]: [locationId, ...] }
+const excludedLocations = ref({})
 // 换一换按钮 loading
 const changeLocationLoading = ref(false)
 const reset = () => {
@@ -523,14 +541,16 @@ const _handlerScan = (code) => {
     }
   } else if (scanType.value == 3) {
     const scannedLocation = barcodeToUpperCase(code)
-    const { lotAtt02 } = barcodeActiveList.value[0]
-    if (locationList.value.length > 0 && !lotAtt02) {
-      const recommendedLocations = locationList.value.map(item => barcodeToUpperCase(item.locationId || ''))
-      if (!recommendedLocations.includes(scannedLocation)) {
-        showNotify({ type: 'warning', duration: 3000, message: `扫描库位${scannedLocation}与推荐库位不一致,请确认` })
-        searchLocation.value=''
-        scanError()
-        return
+    if (forcePublishEnabled.value) {
+      const { lotAtt02 } = barcodeActiveList.value[0]
+      if (locationList.value.length > 0 && !lotAtt02) {
+        const recommendedLocations = locationList.value.map(item => barcodeToUpperCase(item.locationId || ''))
+        if (!recommendedLocations.includes(scannedLocation)) {
+          showNotify({ type: 'warning', duration: 3000, message: `扫描库位${scannedLocation}与推荐库位不一致,请确认` })
+          searchLocation.value=''
+          scanError()
+          return
+        }
       }
     }
     searchLocation.value = scannedLocation
@@ -539,24 +559,28 @@ const _handlerScan = (code) => {
     scanSuccess()
   }
 }
-// 获取推荐库位
+// 获取推荐库位(false:master GET 多行列表;true:精准推荐 POST)
 const _getRecommendedLocation = async (item, excludeList) => {
-  const { lotNumber, owner, sku, quantity, lotAtt08 } = item
+  const { lotNumber, owner } = item
+  if (!forcePublishEnabled.value) {
+    try {
+      const res = await getRecommendedLocation({ warehouse, lotNum: lotNumber, owner })
+      locationList.value = res.data || []
+    } catch (err) {
+      console.error(err)
+    }
+    return
+  }
+  const { sku, quantity, lotAtt08 } = item
   // 扫描商品时先看有没有推荐过
   const listByLot = excludeList ?? (excludedLocations.value[lotNumber] || [])
   const uniqueLocationIds = listByLot.length > 0
     ? [...new Set(listByLot.map(loc => loc.locationId))]
     : undefined
   try {
-    const params = {
-      warehouse,
-      lotNum: lotNumber,
-      owner,
-      sku,
-      qty: quantity,
-      lotAtt08,
-      ...(uniqueLocationIds && { excludedLocations: uniqueLocationIds })
-    }
+    const params = { warehouse, lotNum: lotNumber, owner, sku, qty: quantity, lotAtt08 }
+    if (uniqueLocationIds) params.excludedLocations = uniqueLocationIds
+    if (containerNo.value?.includes('TH-')) params.scene = 'RETURN_SHELVE'
     const res = await getRecommendedLocationNew(params)
     if (res.data) {
       const loc = res.data.location ?? res.data
@@ -576,6 +600,7 @@ const _getRecommendedLocation = async (item, excludeList) => {
 
 // 换一换:请求新的推荐库位,排除当前批次已推荐过的
 const onChangeLocation = async () => {
+  if (!forcePublishEnabled.value) return
   if (barcodeActiveList.value.length > 0) {
     changeLocationLoading.value = true
     try {
@@ -597,19 +622,21 @@ const isCheck = () => {
     showToast({ duration: 3000, message: '请先扫描库位编号' })
     return false
   }
-  if(barcodeActiveList.value.length ==0) {
-    showToast({ duration: 3000, message: '数据异常请重新扫描' })
-    scanError()
-    return
-  }
-  const { lotAtt02 } = barcodeActiveList.value[0]
-  if (locationList.value.length > 0 && !lotAtt02) {
-    const recommendedLocations = locationList.value.map(item => barcodeToUpperCase(item.locationId || ''))
-    if (!recommendedLocations.includes(barcodeToUpperCase(searchLocation.value))) {
-      locationRef.value?.focus()
+  if (forcePublishEnabled.value) {
+    if(barcodeActiveList.value.length ==0) {
+      showToast({ duration: 3000, message: '数据异常请重新扫描' })
       scanError()
-      showToast({ duration: 3000, message: '库位与推荐库位不一致,无法上架' })
-      return false
+      return
+    }
+    const { lotAtt02 } = barcodeActiveList.value[0]
+    if (locationList.value.length > 0 && !lotAtt02) {
+      const recommendedLocations = locationList.value.map(item => barcodeToUpperCase(item.locationId || ''))
+      if (!recommendedLocations.includes(barcodeToUpperCase(searchLocation.value))) {
+        locationRef.value?.focus()
+        scanError()
+        showToast({ duration: 3000, message: '库位与推荐库位不一致,无法上架' })
+        return false
+      }
     }
   }
   if (searchCount.value == '') {

+ 6 - 6
src/views/inbound/takeDelivery/task/index.vue

@@ -712,12 +712,12 @@ const isCheck = () => {
       showToast({ duration: 3000, message: `失效日期不能小于等于生产日期` })
       return false
     }
-    // 检查失效日期是否小于当前日期
-    if (expirationDate <= currentDate) {
-      scanError()
-      showToast({ duration: 3000, message: `失效日期不能小于等于当前日期` })
-      return false
-    }
+    // // 检查失效日期是否小于当前日期
+    // if (expirationDate <= currentDate) {
+    //   scanError()
+    //   showToast({ duration: 3000, message: `失效日期不能小于等于当前日期` })
+    //   return false
+    // }
   }
   if(productionDate){
     // 如果有生产日期,进行有效性检查

+ 2 - 2
src/views/returned/register/index.vue

@@ -371,7 +371,7 @@ const uploadSingleImage = async (
   imageObj.status = UPLOAD_STATUS.UPLOADING
 
   try {
-    const compressedFile = await compressImage(imageObj.file, 0.5)
+    const compressedFile = await compressImage(imageObj.file, 5*1024 * 1024)
     const data = new FormData()
     data.set('file', compressedFile)
     data.set('type', category)
@@ -699,7 +699,7 @@ const changeFile = async (
     )
 
     // 压缩图片(EditImage保存的是PNG,可能很大)
-    const compressedFile = await compressImage(editedFile)
+    const compressedFile = await compressImage(editedFile,5*1024 * 1024)
 
     // 释放旧的预览URL(内存管理)
     if (imageObj.url && imageObj.url.startsWith('blob:')) {