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

同步了质检计划的计量类型的检验方式

wsx пре 11 месеци
родитељ
комит
cf89c0733b
2 измењених фајлова са 89 додато и 5 уклоњено
  1. 88 4
      src/views/inspectionPlan/components/new-edit.vue
  2. 1 1
      src/views/inspectionTemplate/index.vue

+ 88 - 4
src/views/inspectionPlan/components/new-edit.vue

@@ -173,7 +173,7 @@
             tooltip-effect="dark"
             tooltip-effect="dark"
             :max-height="300"
             :max-height="300"
             border
             border
-            row-key="id"
+            row-key="sampleCode"
           >
           >
             <el-table-column
             <el-table-column
               label="序号"
               label="序号"
@@ -1404,11 +1404,95 @@
         return await getCode('sample_code');
         return await getCode('sample_code');
       },
       },
 
 
+      // 创建计量数量为1的样品清单函数,用于计数类型的
+      async createSampleList(list) {
+        if (this.baseForm.qualityMode != null) {
+          const ProductSampleList = [];
+          console.log(list, 'list');
+          for (const oldItem of list) {
+            const count = oldItem.measureQuantity;
+            const newMeasureQuantity = oldItem.measureQuantity / count;
+            const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
+
+            console.log(typeof oldItem.qualitySampleTemplateList, 'ssssss');
+
+            // 遍历新数组设置 qualityResults 默认值
+            this.schemeList.forEach((item) => {
+              if (typeof item === 'object' && item !== null) {
+                item.qualityResults = 1; // 设置默认值
+              }
+              delete item.id;
+            });
+
+            console.log(oldItem, 'oldItem');
+            console.log(count, newMeasureQuantity, newWeight);
+            delete oldItem.id;
+
+            if (
+              oldItem.qualitySampleTemplateList == undefined ||
+              oldItem.qualitySampleTemplateList == null ||
+              oldItem.qualitySampleTemplateList.length == 0
+            ) {
+              oldItem.qualitySampleTemplateList = JSON.parse(
+                JSON.stringify(this.schemeList)
+              );
+              for (let i = 0; i < count; i++) {
+                ProductSampleList.push({
+                  ...oldItem,
+                  measureQuantity: newMeasureQuantity,
+                  weight: newWeight,
+                  sampleCode: await this.getSampleCode(),
+                  qualitySampleTemplateList: JSON.parse(
+                    JSON.stringify(this.schemeList)
+                  )
+                });
+              }
+              console.log(ProductSampleList, 'ProductSampleList');
+              this.sampleList = ProductSampleList;
+              const pNum = ProductSampleList.reduce((sum, item) => {
+                return sum + Number(item.weight || 0);
+              }, 0);
+              this.baseForm.totalWeight = parseFloat(pNum.toFixed(2));
+            } else {
+              for (let i = 0; i < count; i++) {
+                ProductSampleList.push({
+                  ...oldItem,
+                  measureQuantity: newMeasureQuantity,
+                  weight: newWeight,
+                  sampleCode: await this.getSampleCode(),
+                  qualitySampleTemplateList: JSON.parse(
+                    JSON.stringify(oldItem.qualitySampleTemplateList)
+                  )
+                });
+              }
+              console.log(ProductSampleList, 'ProductSampleList');
+              this.sampleList = ProductSampleList;
+              const pNum = ProductSampleList.reduce((sum, item) => {
+                return sum + Number(item.weight || 0);
+              }, 0);
+              this.baseForm.totalWeight = parseFloat(pNum.toFixed(2));
+            }
+          }
+        }
+      },
+
       //更新样品清单数据
       //更新样品清单数据
       async updatePackingList(list) {
       async updatePackingList(list) {
-        for (let i = 0; i < list.length; i++) {
-          list[i].sampleCode = await this.getSampleCode();
+        // 计量类型1是数量,2是重量
+        if (this.baseForm.inspectionStandards == 1) {
+          this.createSampleList(list);
         }
         }
+
+        if (this.baseForm.inspectionStandards == 2) {
+          for (let i = 0; i < list.length; i++) {
+            list[i].sampleCode = await this.getSampleCode();
+          }
+          // this.updatePackingList(list, this.form.total);
+          // this.handleWeightFullSample(this.form.total);
+        }
+
+        console.log(this.baseForm.inspectionStandards);
+
         this.sampleList = list;
         this.sampleList = list;
         this.baseForm.sampleNumber = list.length;
         this.baseForm.sampleNumber = list.length;
         this.samplePagination.currentPage = 1;
         this.samplePagination.currentPage = 1;
@@ -2300,7 +2384,7 @@
           // }
           // }
           return;
           return;
         }
         }
-
+        // 全检
         if (this.baseForm.qualityMode == 1) {
         if (this.baseForm.qualityMode == 1) {
           // console.log('+++++++++1');
           // console.log('+++++++++1');
           // this.handleSampleList();
           // this.handleSampleList();

+ 1 - 1
src/views/inspectionTemplate/index.vue

@@ -15,7 +15,7 @@
         height="calc(100vh - 400px)"
         height="calc(100vh - 400px)"
         tool-class="ele-toolbar-form"
         tool-class="ele-toolbar-form"
         cache-key="inspectionClassify"
         cache-key="inspectionClassify"
-        row-key="qualityLevelId"
+        row-key="id"
         @selection-change="selectionChangeHandle"
         @selection-change="selectionChangeHandle"
       >
       >
         <template v-slot:toolbar>
         <template v-slot:toolbar>