From bef0978ab26369e2000820fafe76a1494ef7a3f0 Mon Sep 17 00:00:00 2001 From: 王震 <10952869+daywangzhen@user.noreply.gitee.com> Date: 星期三, 13 九月 2023 14:34:50 +0800 Subject: [PATCH] 改bug --- src/components/view/Technicalindex.vue | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/components/view/Technicalindex.vue b/src/components/view/Technicalindex.vue index 9211f57..54ba8fe 100644 --- a/src/components/view/Technicalindex.vue +++ b/src/components/view/Technicalindex.vue @@ -91,7 +91,7 @@ placeholder="璇疯緭鍏ユ悳绱㈠唴瀹�" size="small" clearable @input="query" ></el-input> - <el-tree :data="list" ref="tree" :props="{children: 'children',label: 'father'}" node-key="name" default-expand-all + <el-tree :data="list" ref="tree" :props="{children: 'children',label: 'father'}" style="height: 500px;overflow-y: auto;" node-key="name" default-expand-all @node-click="handleNodeClick" highlight-current > <div class="custom-tree-node" slot-scope="{ node, data }"> @@ -107,11 +107,13 @@ <div class="right"> <el-table :data="tableData" - style="width: 100%;margin-bottom: 20px;" + style="width: 100%;margin-bottom: 20px; height: 580px;overflow: auto;" row-key="name" border + @select="selectTr" @selection-change="handleSelectionChange" default-expand-all + ref="multipleTable" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"> <el-table-column type="selection" @@ -397,7 +399,8 @@ unit:'', id:'', - } + }, + isAllSelect:false, } }, @@ -407,6 +410,44 @@ }, methods:{ + // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆 + // 鍏ㄩ��/鍙栨秷閫夋搷浣� + 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); + }); + } + } + }, handleClose(){ }, @@ -631,6 +672,7 @@ // rows.splice(index, 1); // }, handleSelectionChange(val) { + console.log(val); this.selects = val; }, //缂栬緫 -- Gitblit v1.9.3