Przeglądaj źródła

选择质检方法去重

wsx 11 miesięcy temu
rodzic
commit
f41e6d893b

+ 9 - 2
src/views/inspectionPlan/components/new-edit.vue

@@ -933,7 +933,14 @@
         });
         console.log('---------------------------');
         this.isScheme = false;
+
         this.schemeList.push(...data);
+
+        const strings = this.schemeList.map((item) => JSON.stringify(item));
+        const removeDupList = [...new Set(strings)];
+        const result = removeDupList.map((item) => JSON.parse(item));
+        this.schemeList = result;
+
         this.schemePagination.total = this.schemeList.length;
       },
       async handleEditOrDetail(row) {
@@ -1368,7 +1375,7 @@
           // this.getFullInspectionWeight(packList);
         } else {
           console.log('进来了这里');
-          
+
           this.sampleList = [];
         }
       },
@@ -2486,7 +2493,7 @@
       },
       handDel(index) {
         console.log(index);
-        this.schemeList.splice(index,1)
+        this.schemeList.splice(index, 1);
       }
     }
   };

+ 37 - 4
src/views/inspectionWork/components/newQualityContentTabs.vue

@@ -405,6 +405,26 @@
               </div>
             </template>
           </el-table-column>
+
+          <el-table-column fixed="right" label="操作" width="80">
+            <template slot-scope="scope">
+              <el-popconfirm
+                class="ele-action"
+                title="确定要删除当前方案吗?"
+                @confirm="handDel(scope.$index)"
+              >
+                <template v-slot:reference>
+                  <el-link
+                    type="danger"
+                    :underline="false"
+                    icon="el-icon-delete"
+                  >
+                    删除
+                  </el-link>
+                </template>
+              </el-popconfirm>
+            </template>
+          </el-table-column>
         </el-table>
         <el-pagination
           @size-change="handleSchemeSizeChange"
@@ -431,6 +451,7 @@
     queryQualityTempleContent,
     queryQualityInventory
   } from '@/api/inspectionWork';
+  import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
   export default {
     components: {
       inspectionTemplateDialog
@@ -941,11 +962,23 @@
       addInspectionTemplate() {
         this.$refs.inspectionTemplateRef.open(2);
       },
-      inspectionTemplateSuccess(select) {
+      async inspectionTemplateSuccess(select) {
+        let data = await getQualityTemplateByIds({
+          templateIds: select.map((item) => item.id)
+        });
         // planTemplateList
-        console.log(select);
-        this.templateList.push(...select);
-        // this.schemePagination.total = this.templateList.length;
+        console.log(data);
+        this.templateList.push(...data);
+        const strings = this.templateList.map((item) => JSON.stringify(item));
+        const removeDupList = [...new Set(strings)];
+        const result = removeDupList.map((item) => JSON.parse(item));
+        this.templateList = result;
+        console.log(this.templateList);
+        this.schemePagination.total = this.templateList.length;
+      },
+      handDel(index) {
+        console.log(index);
+        this.templateList.splice(index, 1);
       }
     }
   };