|
@@ -25,6 +25,7 @@
|
|
|
:default-expanded-keys="defaultExpand[index]"
|
|
|
:ref="'tree-'+index"
|
|
|
:filter-node-method="filterNode"
|
|
|
+ @check-change="(node, isCheck, isChildCheck) => handleCheckChange(index, isCheck)"
|
|
|
show-checkbox>
|
|
|
</el-tree>
|
|
|
</el-col>
|
|
@@ -63,6 +64,31 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ handleCheckChange(index, isCheck) {
|
|
|
+ if(isCheck) {
|
|
|
+ this.$refs[`tree-${index}`][0].getHalfCheckedNodes().forEach(i => {
|
|
|
+ i.data.forEach(j => {
|
|
|
+ if(j.isShow == 0) {
|
|
|
+ this.$refs[`tree-${index}`][0].setChecked(j.authorityId, true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ let checked = this.$refs[`tree-${index}`][0].getCheckedKeys()
|
|
|
+ checked.push(...this.$refs[`tree-${index}`][0].getHalfCheckedKeys())
|
|
|
+ this.$refs[`tree-${index}`][0].getHalfCheckedNodes().forEach(i => {
|
|
|
+ let flag = true
|
|
|
+ i.data.forEach(j => {
|
|
|
+ if(j.isShow == 1 && checked.indexOf(j.authorityId) != -1) {
|
|
|
+ flag = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if(flag) {
|
|
|
+ this.$refs[`tree-${index}`][0].setChecked(i.authorityId, false, true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
filterNode(value, data, node) { // 隐藏 isShow=0 的节点
|
|
|
return +data.isShow===1
|
|
|
},
|