From a5b6b9c75f73d3b44b3c7abaefe17205fb20be40 Mon Sep 17 00:00:00 2001 From: zhutianqi Date: Wed, 8 Dec 2021 16:54:54 +0800 Subject: [PATCH] commit --- src/components/roleTree/index.vue | 55 ++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/src/components/roleTree/index.vue b/src/components/roleTree/index.vue index 64c8f8a1e..c21e09c28 100644 --- a/src/components/roleTree/index.vue +++ b/src/components/roleTree/index.vue @@ -143,26 +143,33 @@ } }), checkChange2 (row, type, c) { - if (type) { - this.nodeList.push(row.id) + if (this.checkBox) { } else { - for (let a = 0; a < this.nodeList.length; a ++) { - if (row.id === this.nodeList[a]) { - this.nodeList.splice(a, 1) + if (type) { + this.nodeList.push(row.id) + } else { + for (let a = 0; a < this.nodeList.length; a ++) { + if (row.id === this.nodeList[a]) { + this.nodeList.splice(a, 1) + } } } } }, checkChange (row, type, c) { - if (type) { - this.nodeList.push(row.id) + if (this.checkBox) { } else { - for (let a = 0; a < this.nodeList.length; a ++) { - if (row.id === this.nodeList[a]) { - this.nodeList.splice(a, 1) + if (type) { + this.nodeList.push(row.id) + } else { + for (let a = 0; a < this.nodeList.length; a ++) { + if (row.id === this.nodeList[a]) { + this.nodeList.splice(a, 1) + } } } } + }, handleTreeDrawerCancel () { this.filterText = '' @@ -200,17 +207,27 @@ this.open1 = true }, drawerCheck (data) { - if (this.checkBox) { + if (this.checkBox) { // 单选 // 单选判断 - var getlist = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes()); - if(getlist.length == 1) { - this.roleRow = getlist[0] - } else { - this.$refs.tree.setCheckedKeys([data.id]); - this.roleRow = this.$refs.tree.getCheckedNodes()[0] + let getlist = this.$refs.tree.getCheckedNodes() + if (getlist.length > 1) { + this.$refs.tree.setCheckedKeys([]) + this.$refs.tree.setCheckedKeys([data.id]) + this.roleList = [data] + } else if (getlist.length === 0) { + this.roleList = [{}] + } else if (getlist.length === 1) { + this.roleList = [data] } - this.roleList = [this.roleRow] - } else { + // var getlist = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes()); + // if(getlist.length == 1) { + // this.roleRow = getlist[0] + // } else { + // this.$refs.tree.setCheckedKeys([data.id]) + // this.roleRow = this.$refs.tree.getCheckedNodes()[0] + // } + // this.roleList = [this.roleRow] + } else { // 多选 this.roleList = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes()) } },