Browse Source

feat: 新增检测方案批量删除功能

yusheng 2 tháng trước cách đây
mục cha
commit
3e182adb99

+ 39 - 2
src/views/inspectionWork/components/newQualityContentTabs.vue

@@ -433,6 +433,13 @@
           style="margin-top: 5px"
           >选择检测方案</el-button
         >
+        <el-button
+          v-if="type !== 'detail'"
+          @click="delAll"
+          type="danger"
+          style="margin-top: 5px"
+          >批量删除</el-button
+        >
 
         <el-table
           :data="paginatedSchemeList"
@@ -440,7 +447,19 @@
           height="500"
           border
           row-key="id"
+          @selection-change="handleSelectionChange1"
         >
+          <el-table-column
+            type="selection"
+            width="55"
+            align="center"
+            :selectable="
+              (row) => {
+                return type == 'detail' || ![1, 2, 3, 4].includes(row.status);
+              }
+            "
+          >
+          </el-table-column>
           <el-table-column
             label="序号"
             type="index"
@@ -688,6 +707,7 @@
       return {
         // 不良品类型列表
         fileTableList: [],
+        selection1: [],
         badTypeList: [],
         // 不良名称列表
         badNameList: [],
@@ -1588,7 +1608,22 @@
 
         this.$emit('handleSelectionChange', selection);
       },
+      handleSelectionChange1(selection) {
+        this.selection1 = selection;
+      },
+      delAll() {
+        if (!this.selection1.length) {
+          this.$message.error('请至少选择一条数据!');
+          return;
+        }
+        this.selection1.forEach((item) => {
+          this.handDel(
+            this.templateList.findIndex((temp) => temp.id == item.id)
+          );
+        });
 
+        console.log(this.selection1, 'this.selection1');
+      },
       handleSampleNumber(val) {
         this.conditionType = val;
         this.form.sampleUnit = '';
@@ -1777,12 +1812,14 @@
 
         if (this.form.recordingMethod != 1) {
           this.templateList = [];
+        } else {
+          this.templateList = this.templateList.filter((item) => item.status);
         }
-        this.templateList.push(...data);
-        this.templateList.forEach((item) => {
+        data.forEach((item) => {
           item['qualityResults'] = 1;
           item['status'] = 0;
         });
+        this.templateList.push(...data);
 
         // this.templateList = result.map((item) => {
         //   item['qualityResults'] = 1;