From 8231542d77a49f80a49434be6ca8bfb3ae9e1efe Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期一, 28 八月 2023 09:26:21 +0800
Subject: [PATCH] 8-28

---
 src/views/basicData/index.vue |   79 ++++++---------------------------------
 1 files changed, 12 insertions(+), 67 deletions(-)

diff --git a/src/views/basicData/index.vue b/src/views/basicData/index.vue
index 4ee318a..7aa28c5 100644
--- a/src/views/basicData/index.vue
+++ b/src/views/basicData/index.vue
@@ -52,12 +52,8 @@
           width="30%"
           right
           :before-close="handleClose"
+          :title="isUpdate ? '鏇存柊' : '鏂板'"
         >
-          <template slot="title">
-            <div class="addTop">
-              <span>{{ isUpdate ? "鏇存柊" : "鏂板" }}鍩虹鏁版嵁</span>
-            </div>
-          </template>
           <el-form :model="form" :rules="rules" ref="ruleForm" class="addForm">
             <el-form-item prop="material" required>
               <span>鏍峰搧鍚嶇О锛�</span>
@@ -136,13 +132,14 @@
       <el-table
         :data="tableData"
         style="width: 100%; margin-bottom: 20px"
-        row-key="name"
+        row-key="id"
         border
         height="calc(100vh - 250px)"
         default-expand-all
         ref="multipleTable"
         @select="selectTr"
         @select-all="selectAll"
+        @selection-change="handleSelectionChange"
         :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
       >
         <el-table-column type="selection" label="搴忓彿"> </el-table-column>
@@ -344,20 +341,6 @@
       this.isAllSelect = !this.isAllSelect;
       let data = this.tableData;
       this.toggleSelect(data, this.isAllSelect, "all");
-      // 鑷畾涔�
-      if (this.isAllSelect) {
-        val.forEach((i) => {
-          if (i.id !== undefined) {
-            this.deleteList.push(i.id);
-          } else {
-            i.children.forEach((c) => {
-              this.deleteList.push(c.id);
-            });
-          }
-        });
-      } else {
-        this.deleteList.splice(0, this.deleteList.length);
-      }
     },
     //閫夋嫨鏌愯
     selectTr(selection, row) {
@@ -366,33 +349,6 @@
         this.isAllSelect = row.isChecked;
         this.toggleSelect(row, row.isChecked, "tr");
       });
-
-      if (row.isChecked === true) {
-        if (row.children !== undefined) {
-          row.children.forEach((i) => {
-            this.deleteList.push(i.id);
-          });
-        } else {
-          this.deleteList.push(row.id);
-        }
-      } else if (row.isChecked === false) {
-        if (row.children !== undefined) {
-          row.children.forEach((i) => {
-            this.deleteList.findIndex((c, index) => {
-              if (c === i.id) {
-                this.deleteList.splice(index, 1);
-                return;
-              }
-            });
-          });
-        }
-        this.deleteList.findIndex((c, index) => {
-          if (c === row.id) {
-            this.deleteList.splice(index, 1);
-            return;
-          }
-        });
-      }
     },
     //閫掑綊瀛愮骇
     toggleSelect(data, flag, type) {
@@ -425,6 +381,15 @@
           this.$refs.multipleTable.clearSelection();
         }
       });
+    },
+    handleSelectionChange(val) {
+      this.deleteList = [];
+      val.forEach((v) => {
+        if (v.id !== undefined) {
+          this.deleteList.push(v.id);
+        }
+      });
+      console.log(`output->this.deleteList`, this.deleteList);
     },
     // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆  缁撴潫
     deleteListClick() {
@@ -489,12 +454,6 @@
   position: relative;
   padding: 0 10px 10px 10px;
 }
-.el-dialog__header {
-  padding: 0;
-}
-.el-dialog__headerbtn {
-  top: 0;
-}
 .el-dialog__close {
   padding: 8px 0;
   color: #ffffff !important;
@@ -510,20 +469,6 @@
 }
 .el-dialog__body {
   padding: 30px 20px 0 20px;
-}
-.addTop {
-  border-top-left-radius: 10px;
-  border-top-right-radius: 10px;
-  background-color: #00a5ff;
-  color: #ffffff;
-  padding: 8px 20px;
-  float: left;
-  height: 30px;
-  width: 100%;
-}
-.addTop span {
-  font-size: 16px;
-  font-weight: 700;
 }
 .table_div {
   margin-top: 10px;

--
Gitblit v1.9.3