|
@@ -186,6 +186,7 @@
|
|
|
highlight-current
|
|
|
:props="defaultProps"
|
|
|
:check-strictly="true"
|
|
|
+ :expand-on-click-node="true"
|
|
|
>
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
<span>{{ node.label }}</span>
|
|
@@ -279,18 +280,76 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ zhaofuji(data, arr) {
|
|
|
+ if (data.parent) {
|
|
|
+ arr.push(data.data.moduleId)
|
|
|
+ this.zhaofuji(data.parent, arr)
|
|
|
+ }
|
|
|
+ },
|
|
|
quanbugouxuan(node, data) {
|
|
|
- var ids = []
|
|
|
- this.diguichazhaoid(data.children, ids)
|
|
|
- this.$refs.tree.setCheckedKeys([data?.moduleId || '', ...ids, ...this.$refs.tree.getCheckedKeys()])
|
|
|
+ let nowChecked = this.$refs.tree.getCheckedKeys()
|
|
|
+ let thisId = data.moduleId
|
|
|
+ let childId = []
|
|
|
+ if (data.children.length) {
|
|
|
+ childId = this.familyTree(data.children)
|
|
|
+ }
|
|
|
+
|
|
|
+ var parentId = []
|
|
|
+ this.zhaofuji(node, parentId)
|
|
|
+ let setChecked = nowChecked.concat([thisId]).concat(childId).concat(parentId)
|
|
|
+
|
|
|
+ this.$refs.tree.setCheckedKeys(setChecked)
|
|
|
+
|
|
|
+ // var ids = []
|
|
|
+ // this.diguichazhaoid(data.children, ids)
|
|
|
+ // this.$refs.tree.setCheckedKeys([data?.moduleId || '', ...ids, ...this.$refs.tree.getCheckedKeys()])
|
|
|
},
|
|
|
quxiaogouxuan(node, data) {
|
|
|
- var ids = []
|
|
|
- this.diguichazhaoid(data.children, ids)
|
|
|
- var keyIds = [data?.moduleId || '', ...ids]
|
|
|
- var keys = this.$refs.tree.getCheckedKeys().filter(k => !keyIds.includes(k))
|
|
|
- this.$refs.tree.setCheckedKeys(keys)
|
|
|
+ let nowChecked = this.$refs.tree.getCheckedKeys()
|
|
|
+ let thisId = data.moduleId
|
|
|
+ let childId = []
|
|
|
+ if (data.children.length) {
|
|
|
+ childId = this.familyTree(data.children)
|
|
|
+ }
|
|
|
+
|
|
|
+ let setChecked = nowChecked
|
|
|
+ if (setChecked.indexOf(thisId) >= 0) {
|
|
|
+ setChecked.splice(setChecked.indexOf(thisId), 1)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (childId.length) {
|
|
|
+ for (var i = 0; i < childId.length; i++) {
|
|
|
+ if (setChecked.indexOf(childId[i]) >= 0) {
|
|
|
+ setChecked.splice(setChecked.indexOf(childId[i]), 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$refs.tree.setCheckedKeys(setChecked)
|
|
|
+
|
|
|
+ // var ids = []
|
|
|
+ // this.diguichazhaoid(data.children, ids)
|
|
|
+ // var keyIds = [data?.moduleId || '', ...ids]
|
|
|
+ // var keys = this.$refs.tree.getCheckedKeys().filter(k => !keyIds.includes(k))
|
|
|
+ // this.$refs.tree.setCheckedKeys(keys)
|
|
|
+ },
|
|
|
+
|
|
|
+ // 递归子id
|
|
|
+ familyTree(arr) {
|
|
|
+ var temp = []
|
|
|
+ var forFn = function (list) {
|
|
|
+ for (var i = 0; i < list.length; i++) {
|
|
|
+ var item = list[i]
|
|
|
+ if (item.children) {
|
|
|
+ temp.push(item.moduleId)
|
|
|
+ forFn(item.children)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ forFn(arr)
|
|
|
+ return temp
|
|
|
},
|
|
|
+
|
|
|
getList() {
|
|
|
this.listLoading = true
|
|
|
let params = {
|