Просмотр исходного кода

修改江南自检请托使用编码匹配

695593266@qq.com 5 месяцев назад
Родитель
Сommit
ef8985188e

+ 4 - 4
src/components/CommomSelect/dept-select.vue

@@ -55,9 +55,9 @@
           this.$refs.treeSelect.getNodeByValue(val)
         );
       },
-      async locateByName(name) {
+      async locateByName(code) {
         await this.getData();
-        const res = this.findNodesByNameWithPath(this.treeData, name);
+        const res = this.findNodesByNameWithPath(this.treeData, code);
 
         console.log(res);
         if (!res.length) return;
@@ -80,14 +80,14 @@
         });
       },
 
-      findNodesByNameWithPath(tree, name) {
+      findNodesByNameWithPath(tree, code) {
         const result = [];
 
         function dfs(list, path = []) {
           list.forEach((node) => {
             const currentPath = [...path, node];
 
-            if (node.name === name) {
+            if (node.groupCode == code) {
               result.push({
                 node,
                 path: currentPath

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

@@ -522,45 +522,97 @@
         // }
       },
 
+      // 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;
+        const pickItem = this.workList[0].pickList[index];
 
-          for (let i = 0; i < item.warehouseList.length; i++) {
-            totalNum += Number(item.warehouseList[i].availableCountBase);
+        let value = String(item.demandQuantity ?? '');
 
-            if (Number(item.demandQuantity) > totalNum) {
-              idsList.push(item.warehouseList[i].warehouse_id);
-            } else {
-              idsList.push(item.warehouseList[i].warehouse_id);
-              break;
-            }
-          }
+        value = value.replace(/[^\d.]/g, '');
+
+        value = value
+          .replace(/\.{2,}/g, '.')
+          .replace('.', '$#$')
+          .replace(/\./g, '')
+          .replace('$#$', '.');
+
+        if (value.includes('.')) {
+          const [intPart, decPart] = value.split('.');
+          value = `${intPart}.${decPart.slice(0, 4)}`;
+        }
+
+        this.$set(pickItem, 'demandQuantity', value);
+
+        const demandQty = Number(value);
+        const maxQty = Number(item.availableCountBase) || 0;
+
+        if (!demandQty) {
+          this.$set(pickItem, 'warehouseIdList', []);
+          return;
+        }
+
+        if (demandQty >= maxQty) {
+          this.$set(pickItem, 'demandQuantity', maxQty);
 
           this.$set(
-            this.workList[0].pickList[index],
+            pickItem,
             'warehouseIdList',
-            idsList
+            item.warehouseList.map((w) => w.warehouse_id)
           );
+          return;
         }
+
+        let total = 0;
+        const idsList = [];
+
+        for (const w of item.warehouseList) {
+          total += Number(w.availableCountBase) || 0;
+          idsList.push(w.warehouse_id);
+
+          if (total >= demandQty) break;
+        }
+
+        this.$set(pickItem, 'warehouseIdList', idsList);
       },
 
       detailData(data, dimension, index) {
@@ -678,7 +730,6 @@
             });
           });
         });
-        console.log('cashasisasa', res);
       },
 
       async getOrderCode() {

+ 1 - 1
src/views/produce/components/qualityInspection/components/selfInspectionRequest.vue

@@ -350,7 +350,7 @@
 
         if (this.clientEnvironmentId == 9) {
           this.$nextTick(() => {
-            this.$refs.deptSelect?.locateByName('综合管理室');
+            this.$refs.deptSelect?.locateByName('BM1801');
           });
         }
       },