695593266@qq.com 5 месяцев назад
Родитель
Сommit
b43064b377
1 измененных файлов с 83 добавлено и 76 удалено
  1. 83 76
      src/views/produce/components/picking/index.vue

+ 83 - 76
src/views/produce/components/picking/index.vue

@@ -522,98 +522,105 @@
         // }
       },
 
+      changeInput(item, index) {
+        if (Number(item.demandQuantity) >= Number(item.availableCountBase)) {
+          this.$set(
+            this.workList[0].pickList[index],
+            'demandQuantity',
+            Number(item.availableCountBase)
+          );
+          const idsList = [];
+          item.warehouseList.forEach((it) => {
+            idsList.push(it.warehouse_id);
+          });
+          this.$set(
+            this.workList[0].pickList[index],
+            'warehouseIdList',
+            idsList
+          );
+        } else if (!Number(item.demandQuantity)) {
+          this.$set(this.workList[0].pickList[index], 'warehouseIdList', []);
+        } else {
+          const idsList = [];
+          let totalNum = 0;
+
+          for (let i = 0; i < item.warehouseList.length; i++) {
+            totalNum += Number(item.warehouseList[i].availableCountBase);
+
+            if (Number(item.demandQuantity) > totalNum) {
+              idsList.push(item.warehouseList[i].warehouse_id);
+            } else {
+              idsList.push(item.warehouseList[i].warehouse_id);
+              break;
+            }
+          }
+
+          this.$set(
+            this.workList[0].pickList[index],
+            'warehouseIdList',
+            idsList
+          );
+        }
+      },
+
       // changeInput(item, index) {
-      //   if (Number(item.demandQuantity) >= Number(item.availableCountBase)) {
-      //     this.$set(
-      //       this.workList[0].pickList[index],
-      //       'demandQuantity',
-      //       Number(item.availableCountBase)
-      //     );
-      //     const idsList = [];
-      //     item.warehouseList.forEach((it) => {
-      //       idsList.push(it.warehouse_id);
-      //     });
-      //     this.$set(
-      //       this.workList[0].pickList[index],
-      //       'warehouseIdList',
-      //       idsList
-      //     );
-      //   } else if (!Number(item.demandQuantity)) {
-      //     this.$set(this.workList[0].pickList[index], 'warehouseIdList', []);
-      //   } else {
-      //     const idsList = [];
-      //     let totalNum = 0;
-
-      //     for (let i = 0; i < item.warehouseList.length; i++) {
-      //       totalNum += Number(item.warehouseList[i].availableCountBase);
-
-      //       if (Number(item.demandQuantity) > totalNum) {
-      //         idsList.push(item.warehouseList[i].warehouse_id);
-      //       } else {
-      //         idsList.push(item.warehouseList[i].warehouse_id);
-      //         break;
-      //       }
-      //     }
+      //   const pickItem = this.workList[0].pickList[index];
 
-      //     this.$set(
-      //       this.workList[0].pickList[index],
-      //       'warehouseIdList',
-      //       idsList
-      //     );
-      //   }
-      // },
+      //   let value = String(item.demandQuantity ?? '');
 
-      changeInput(item, index) {
-        const pickItem = this.workList[0].pickList[index];
+      //   value = value.replace(/[^\d.]/g, '');
 
-        let value = String(item.demandQuantity ?? '');
+      //   value = value
+      //     .replace(/\.{2,}/g, '.')
+      //     .replace('.', '$#$')
+      //     .replace(/\./g, '')
+      //     .replace('$#$', '.');
 
-        value = value.replace(/[^\d.]/g, '');
+      //   if (value.includes('.')) {
+      //     const [intPart, decPart] = value.split('.');
+      //     value = `${intPart}.${decPart.slice(0, 4)}`;
+      //   }
 
-        value = value
-          .replace(/\.{2,}/g, '.')
-          .replace('.', '$#$')
-          .replace(/\./g, '')
-          .replace('$#$', '.');
+      //   console.log(value, 'value');
 
-        if (value.includes('.')) {
-          const [intPart, decPart] = value.split('.');
-          value = `${intPart}.${decPart.slice(0, 4)}`;
-        }
+      //   this.$set(pickItem, 'demandQuantity', value);
 
-        this.$set(pickItem, 'demandQuantity', value);
+      //   console.log(pickItem, 'pickItem');
 
-        const demandQty = Number(value);
-        const maxQty = Number(item.availableCountBase) || 0;
+      //   const demandQty = Number(value);
+      //   console.log(demandQty, 'demandQty');
+      //   const maxQty = Number(item.availableCountBase) || 0;
+      //   console.log(item, 'item');
+      //   console.log(maxQty, 'maxQty');
 
-        if (!demandQty) {
-          this.$set(pickItem, 'warehouseIdList', []);
-          return;
-        }
+      //   if (!demandQty) {
+      //     this.$set(pickItem, 'warehouseIdList', []);
+      //     return;
+      //   }
 
-        if (demandQty >= maxQty) {
-          this.$set(pickItem, 'demandQuantity', maxQty);
+      //   if (demandQty >= maxQty) {
+      //     this.$set(pickItem, 'demandQuantity', maxQty);
 
-          this.$set(
-            pickItem,
-            'warehouseIdList',
-            item.warehouseList.map((w) => w.warehouse_id)
-          );
-          return;
-        }
+      //     this.$set(
+      //       pickItem,
+      //       'warehouseIdList',
+      //       item.warehouseList.map((w) => w.warehouse_id)
+      //     );
+      //     return;
+      //   }
 
-        let total = 0;
-        const idsList = [];
+      //   let total = 0;
+      //   const idsList = [];
 
-        for (const w of item.warehouseList) {
-          total += Number(w.availableCountBase) || 0;
-          idsList.push(w.warehouse_id);
+      //   for (const w of item.warehouseList) {
+      //     total += Number(w.availableCountBase) || 0;
+      //     idsList.push(w.warehouse_id);
 
-          if (total >= demandQty) break;
-        }
+      //     if (total >= demandQty) break;
+      //   }
 
-        this.$set(pickItem, 'warehouseIdList', idsList);
-      },
+      //   this.$set(pickItem, 'warehouseIdList', idsList);
+      // },
 
       detailData(data, dimension, index) {
         const itemData = [];