From 7b07e33a1c719f9831fa3c5d81522b9f2da45bc4 Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期四, 14 九月 2023 16:17:58 +0800
Subject: [PATCH] 	modified:   src/components/view/standard.vue

---
 src/components/view/equipmentmaintain.vue |   75 ++++++++++++++++++++++++++++++++++---
 1 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/src/components/view/equipmentmaintain.vue b/src/components/view/equipmentmaintain.vue
index 0defcf5..cf2d491 100644
--- a/src/components/view/equipmentmaintain.vue
+++ b/src/components/view/equipmentmaintain.vue
@@ -262,11 +262,13 @@
 			<div class="right">
                 <el-table
                     :data="tableData"
-                    style="width: 100%;margin-bottom: 20px;"
-                    row-key="name"
+                    style="width: 100%;margin-bottom: 20px;height: 600px;overflow: auto;"
+                    row-key="rowId"
                     border
+                    @select="selectTr"
                     @selection-change="handleSelectionChange"
                     default-expand-all
+                    ref="multipleTable"
                     :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
                     <el-table-column
                     type="selection"
@@ -317,7 +319,7 @@
                         width="200px">
                         <template slot-scope="scope" style="text-align: center;">
                             <div v-if="!scope.row.children">
-                        <el-button type="text" size="mini" @click="childrenClick(scope.row)">缂栬緫</el-button>
+                        <!-- <el-button type="text" size="mini" @click="childrenClick(scope.row)">缂栬緫</el-button> -->
                         <el-button type="text" size="mini" @click="deleteRow(scope.$index, scope.row)">鍒犻櫎</el-button>
                             </div>
                     </template>
@@ -547,12 +549,21 @@
 			}).then(res => {
 				this.tableData = res.data;
                 console.log(this.tableData);
-
+                this.formatData(res.data)
 			})
 			},
             modify(){
                 this.modifyevent = true
             },
+            formatData(data){
+                let arr = data;
+                for(var i=0;i<arr.length;i++){
+                        arr[i].rowId = Math.random();
+                        if(arr[i].children != undefined){
+                        this.formatData(arr[i].children);
+                        }
+                    }
+                },
             //delQueById
             delQueById() {
 				this.$axios.post(this.$api.url.delQueById,{
@@ -567,9 +578,6 @@
 				this.upData.id = row.id
                 console.log(this.upData.id);
 				this.delQueById()
-			},
-            handleSelectionChange(val) {
-				this.selects = val
 			},
             //鎵归噺鍒犻櫎
 			delAllQue() {
@@ -593,6 +601,11 @@
                 let cc = this.selects.map(el => {
 					return el.id
 				})
+                // cc.forEach((el,idx) =>{
+                //     delete  idx[0]
+                // })
+                cc.splice(0,1)
+                console.log(cc);
 				this.delete = cc.join(',')
 				console.log(this.delete);
 				this.delAllQue()
@@ -608,6 +621,54 @@
             // // filterNode(){
 
             // },
+            handleSelectionChange(val) {
+                this.selects = val
+                this.deleteList = [];
+                val.forEach((v) => {
+                if (v.id !== undefined) {
+                    this.deleteList.push(v.id);
+                }
+                });
+			},
+             // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆
+                // 鍏ㄩ��/鍙栨秷閫夋搷浣�
+                selectAll(val) {
+                    this.isAllSelect = !this.isAllSelect;
+                    let data = this.tableData;
+                    this.toggleSelect(data, this.isAllSelect, "all");
+                },
+             //閫夋嫨鏌愯
+		    selectTr(selection, row) {
+                console.log(selection,row);
+                this.$set(row, "isChecked", !row.isChecked);
+                this.$nextTick(() => {
+                    this.isAllSelect = row.isChecked;
+                    this.toggleSelect(row, row.isChecked, "tr");
+                });
+
+            },
+             //閫掑綊瀛愮骇
+            toggleSelect(data, flag, type) {
+                if (type === "all") {
+                    console.log('222');
+                    if (data.length > 0) {
+                        data.forEach((item) => {
+                        this.toggleSelection(item, flag);
+                        if (item.children && item.children.length > 0) {
+                            this.toggleSelect(item.children, flag, type);
+                        }
+                        });
+                    }
+                } else {
+                    if (data.children && data.children.length > 0) {
+                        data.children.forEach((item) => {
+                        item.isChecked = !item.isChecked;
+                        this.$refs.multipleTable.toggleRowSelection(item, flag);
+                        this.toggleSelect(item, flag, type);
+                        });
+                    }
+                }
+            },
           
         }
     }

--
Gitblit v1.9.3