Przeglądaj źródła

收货-批次信息-上个货主没清空bug初步修复

zhaohuanhuan 3 godzin temu
rodzic
commit
cb90047bba
1 zmienionych plików z 22 dodań i 9 usunięć
  1. 22 9
      src/views/inbound/takeDelivery/task/index.vue

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

@@ -556,6 +556,9 @@ const setCombineReceiving = ({ dataList, count: setCount }) => {
   showNotify({ type: 'success', duration: 2000, message: `收货套数:${sets},共 ${total} 件,请点击完成收货提交` })
 }
 
+/** 批次拉取与效期计算的代际,避免快速切换商品时异步结果错乱 */
+let productLotGeneration = 0
+
 // 条码扫描:scanType 2商品/4数量/3唯一码/5容器
 const _handlerScan = (code) => {
   if (scanType.value == 2) {
@@ -685,24 +688,33 @@ const setAttribute = (data) => {
 const lotData = ref([])
 const lotMap = ref({})
 const _getProductLot = (item) => {
+  const gen = ++productLotGeneration
+  lotMap.value = {}
+  lotData.value = []
   const params = { warehouse: item.warehouse, owner: item.customerId, barcode: item.sku }
-  getProductLot(params).then(res => {
-    res.data.forEach((lot) => {
+  getProductLot(params).then((res) => {
+    if (gen !== productLotGeneration) return
+    const rows = res.data
+    if (!rows?.length) {
+      lotData.value = []
+      return
+    }
+    rows.forEach((lot) => {
       const lotField = lot.field
       if (lotField.startsWith('lotAtt') && lotField.length === 8) {
         lot.mapping = item[lotField]
       }
-      if(lot.format){
-        const format =JSON.parse(lot.format)
-        lotMap.value= {...lotMap.value, ...format }
+      if (lot.format) {
+        const format = JSON.parse(lot.format)
+        lotMap.value = { ...lotMap.value, ...format }
       }
     })
-    lotData.value = res.data.filter(item => item.lotAttFlag!='隐藏')
-    _calculateShelfLife(item, lotData.value)
+    lotData.value = rows.filter((row) => row.lotAttFlag !== '隐藏')
+    _calculateShelfLife(item, lotData.value, gen)
   })
 }
 // 计算效期
-const _calculateShelfLife = (item, lotData) => {
+const _calculateShelfLife = (item, lotData, generation) => {
   if ((item.lotAtt01 && item.lotAtt02) || (!item.lotAtt01 && !item.lotAtt02)) return
   const params = {
     customer: item.customerId,
@@ -710,7 +722,8 @@ const _calculateShelfLife = (item, lotData) => {
     date: item.lotAtt01 || item.lotAtt02,
     isExpiryDate: item.lotAtt01 ? true : false,
   }
-  calculateShelfLife(params).then(date => {
+  calculateShelfLife(params).then((date) => {
+    if (generation !== productLotGeneration) return
     lotData.forEach((lot) => {
       if ((lot.field === 'lotAtt01' && !params.isExpiryDate) ||
         (lot.field === 'lotAtt02' && params.isExpiryDate)) {