فهرست منبع

修改质检计划BUG

695593266@qq.com 1 سال پیش
والد
کامیت
b24f2082a5
1فایلهای تغییر یافته به همراه125 افزوده شده و 65 حذف شده
  1. 125 65
      src/views/inspectionPlan/components/edit.vue

+ 125 - 65
src/views/inspectionPlan/components/edit.vue

@@ -40,7 +40,8 @@
             :columns="tableColumns"
             :datasource="datasource"
             :needPage="
-              btnType == 'add' || (btnType == 'edit' && !isScheme && !isOrder)
+              btnType == 'add' ||
+              (btnType == 'edit' && !isFormNumber && !isOrder)
                 ? false
                 : true
             "
@@ -485,7 +486,8 @@
         productItem: {}, //产品信息
         isUpdateData: true,
         isChangeNumber: true,
-        isChangeType: true
+        isChangeType: true,
+        isOnce: true
       };
     },
     computed: {
@@ -693,6 +695,7 @@
           list.push(obj);
         }
         console.log('数据22222');
+        console.log(this.isOrder);
         this.$refs.table12.setData(list);
 
         // *** 如果检验方式是全量的话 还需要同步样品清单数据
@@ -732,9 +735,12 @@
       getInspectionStandards(data) {
         console.log(data, 'data');
         this.baseForm.inspectionStandards = data;
-        this.isOrder = false;
         console.log(1313322);
-        this.handleSampleList();
+        if (this.btnType == 'edit' && !this.isOnce) {
+          this.isOrder = false;
+          this.handleSampleList();
+        }
+        this.isOnce = false;
       },
       async datasource({ page, limit, where }) {
         console.log(this.btnType);
@@ -829,6 +835,7 @@
           this.samplePagination.total = 0;
           this.isFormNumber = true;
           this.isOrder = true;
+          console.log('edit true');
 
           if (row.isUnpack === 1) {
             this.isCheck = true;
@@ -989,7 +996,7 @@
           this.btnType
         );
 
-        if (this.baseForm.type == '1') {
+        if (this.baseForm.type == '1' && this.btnType != 'detail') {
           if (this.baseForm.inspectionStandards == '2') {
             console.log(13131313213);
             this.sampleList = [];
@@ -1009,25 +1016,46 @@
               };
               list.push(obj);
             }
+            if (list.length > 0 && list[0].categoryCode) {
+              this.$refs.table12.setData(list);
+              let packList = this.$refs.table12.getData();
+              this.getFullInspectionWeight(packList);
+            }
 
-            this.$refs.table12.setData(list);
-            let packList = this.$refs.table12.getData();
+            // this.$refs.table12.setData(list);
+            // let packList = this.$refs.table12.getData();
             // console.log(list);
             // console.log(1654646);
-            this.getFullInspectionWeight(packList);
+            // this.getFullInspectionWeight(packList);
             // this.getFullInspectionWeight(list);
           } else {
-            let packingList = this.$refs.table12.getData();
-            if (
-              Math.ceil(Number(this.baseForm.productNumber || 0)) ===
-              packingList.length
-            ) {
-              await this.handleUnpackCase(packingList);
-
-              return;
-            } else {
-              this.getFullInspectionWeight(packingList);
+            if (this.$refs.table12) {
+              let packingList = this.$refs.table12.getData();
+              if (
+                Math.ceil(Number(this.baseForm.productNumber || 0)) ===
+                packingList.length
+              ) {
+                console.log(
+                  '--->',
+                  Math.ceil(Number(this.baseForm.productNumber || 0))
+                );
+                console.log('--->', packingList.length);
+                await this.handleUnpackCase(packingList);
+                return;
+              } else {
+                this.getFullInspectionWeight(packingList);
+              }
             }
+            // let packingList = this.$refs.table12.getData();
+            // if (
+            //   Math.ceil(Number(this.baseForm.productNumber || 0)) ===
+            //   packingList.length
+            // ) {
+            //   await this.handleUnpackCase(packingList);
+            //   return;
+            // } else {
+            //   this.getFullInspectionWeight(packingList);
+            // }
           }
         }
 
@@ -1041,30 +1069,56 @@
           console.log(this.baseForm, '---isUnpack---');
           if (this.baseForm.productNumber) {
             console.log('数据777777');
-            this.$refs.table12.setData([]);
-            let nums = Number(this.baseForm.productNumber);
-            let p = this.productItem;
-            let list = [];
+            if (this.$refs.table12) {
+              this.$refs.table12.setData([]);
+              let nums = Number(this.baseForm.productNumber);
+              let p = this.productItem;
+              let list = [];
+
+              for (let i = 0; i < nums; i++) {
+                let obj = {
+                  id: p.id,
+                  batchNo: p.batchNo,
+                  categoryCode: p.code, //编码
+                  categoryName: p.name, //名称
+                  measureQuantity: 1,
+                  measureUnit: p.measuringUnit, //计量单位
+                  weightUnit: p.weightUnit, //重量单位
+                  weight: p.netWeight //重量
+                };
+                list.push(obj);
+              }
+              console.log('数据666666');
+              this.$refs.table12.setData(list);
+              let packList = this.$refs.table12.getData();
+              await this.handleUnpackCase(packList);
 
-            for (let i = 0; i < nums; i++) {
-              let obj = {
-                id: p.id,
-                batchNo: p.batchNo,
-                categoryCode: p.code, //编码
-                categoryName: p.name, //名称
-                measureQuantity: 1,
-                measureUnit: p.measuringUnit, //计量单位
-                weightUnit: p.weightUnit, //重量单位
-                weight: p.netWeight //重量
-              };
-              list.push(obj);
+              return;
             }
-            console.log('数据666666');
-            this.$refs.table12.setData(list);
-            let packList = this.$refs.table12.getData();
-            await this.handleUnpackCase(packList);
+            // this.$refs.table12.setData([]);
+            // let nums = Number(this.baseForm.productNumber);
+            // let p = this.productItem;
+            // let list = [];
+
+            // for (let i = 0; i < nums; i++) {
+            //   let obj = {
+            //     id: p.id,
+            //     batchNo: p.batchNo,
+            //     categoryCode: p.code, //编码
+            //     categoryName: p.name, //名称
+            //     measureQuantity: 1,
+            //     measureUnit: p.measuringUnit, //计量单位
+            //     weightUnit: p.weightUnit, //重量单位
+            //     weight: p.netWeight //重量
+            //   };
+            //   list.push(obj);
+            // }
+            // console.log('数据666666');
+            // this.$refs.table12.setData(list);
+            // let packList = this.$refs.table12.getData();
+            // await this.handleUnpackCase(packList);
 
-            return;
+            // return;
           }
           // if (this.rowIds) {
           //   const res = await getInventoryListByPlanId({
@@ -1121,11 +1175,11 @@
           }
           console.log('数据55555');
           console.log(list);
-          // if (list[0].categoryCode) {
-          this.$refs.table12.setData(list);
-          let packList = this.$refs.table12.getData();
-          this.getFullInspectionWeight(packList);
-          // }
+          if (list.length > 0 && list[0].categoryCode) {
+            this.$refs.table12.setData(list);
+            let packList = this.$refs.table12.getData();
+            this.getFullInspectionWeight(packList);
+          }
           // this.$refs.table12.setData(list);
           // let packList = this.$refs.table12.getData();
           // this.getFullInspectionWeight(packList);
@@ -1156,6 +1210,7 @@
       //更新样品清单数据
       async updatePackingList(list) {
         console.log(list);
+        console.log(this.isScheme, this.isOrder);
         for (let i = 0; i < list.length; i++) {
           list[i].sampleCode = await this.getSampleCode();
         }
@@ -1400,32 +1455,34 @@
         console.log(val, '产品信息');
 
         if (this.baseForm.type == 2 && this.baseForm.planSource == '4') {
-          const res1 = await getProductSteup(val.category.id);
+          if (val.category.id) {
+            const res1 = await getProductSteup(val.category.id);
 
-          const index = res1.findIndex(
-            (item) => item.taskId == val.category.taskId
-          );
+            const index = res1.findIndex(
+              (item) => item.taskId == val.category.taskId
+            );
 
-          if (index) {
-            const res2 = await getProductOrder({
-              taskId: res1[index - 1].taskId,
-              workOrderId: val.category.id
-            });
+            if (index) {
+              const res2 = await getProductOrder({
+                taskId: res1[index - 1].taskId,
+                workOrderId: val.category.id
+              });
 
-            if (res2[0].semiProductList.length > 1) {
-              this.baseForm.productNumber = res2[0].semiProductList.length;
-            } else {
-              this.baseForm.productNumber =
-                res2[0].semiProductList.measureQuantity;
+              if (res2[0].semiProductList.length > 1) {
+                this.baseForm.productNumber = res2[0].semiProductList.length;
+              } else {
+                this.baseForm.productNumber =
+                  res2[0].semiProductList.measureQuantity;
+              }
             }
-          }
 
-          this.isConsumable = val.category.isConsumable;
-          this.netWeight = val.category.netWeight;
-          this.productItem = val.category;
+            this.isConsumable = val.category.isConsumable;
+            this.netWeight = val.category.netWeight;
+            this.productItem = val.category;
 
-          this.handleSampleList();
-          return;
+            this.handleSampleList();
+            return;
+          }
         }
 
         this.isConsumable = val.category.isConsumable;
@@ -1563,6 +1620,7 @@
               (item.remainingQuantity >= sampleQuantity && remainingCount > 0)
             ) {
               // 添加到结果数组
+              this.samplePagination.total = 0;
               let sampleCode = await this.getSampleCode();
               if (
                 this.conditionType == 1 &&
@@ -1601,8 +1659,8 @@
 
         console.log('样品清单', this.sampleList);
         this.sampleList = result;
+        this.samplePagination.total = result.length;
         this.baseForm.sampleNumber = this.sampleList.length; // 更新样品数量
-
         this.changeSamUnit(sampleUnit);
       },
 
@@ -1763,6 +1821,7 @@
           this.baseForm = { ...this.defaultForm() };
           this.isChangeNumber = true;
           this.isChangeType = true;
+          this.isOnce = true;
         });
       },
 
@@ -1890,6 +1949,7 @@
           this.baseForm.productNumber,
           'productNumberproductNumber数量'
         );
+
         if (this.baseForm.qualityMode == 1) {
           this.handleSampleList();
         } else {