Commit eddde649 authored by jingnan's avatar jingnan 👀

合并产品【8067】 权限设置,勾选父级自动勾选子级

parent a8682b52
......@@ -155,6 +155,7 @@ export default {
},
onCheckBoxClick(nodeData) {
let node = this.$refs.tree.getNode(nodeData.id)
const clickNode = node
const isChecked = node.checked
const items = [node.data]
const nodePath = []
......@@ -173,8 +174,23 @@ export default {
items.push(dataPath[i])
}
}
// 当前节点选中,自动勾选它所有的后代节点
const subNodesData = this.getSubNodes(clickNode).map(node => node.data)
items.push(...subNodesData)
}
this.updatePermState(items, isChecked)
},
// 获取指定节点下所有子节点
getSubNodes(parentNode, nodes = []) {
if (!parentNode) return nodes
const childNodes = parentNode.childNodes
if (Array.isArray(childNodes)) {
childNodes.forEach(node => {
nodes.push(node)
this.getSubNodes(node, nodes)
})
}
return nodes
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment