<tree-table
ref="tree"
:height="clientHeight"
:data="powerOpt"
:columns="columns"
show-checkbox
show-header
children-key="child"
arrow-icon-down="md-arrow-dropdown"
arrow-icon-right="md-arrow-dropright"
@on-check-change="onCheckChange"
>
</tree-table>
js
columns: [
{
title: " ",
key: "menuName",
template: "menuName"
},
],
递归算法:
// 格式化
formatting(arr) {
// 获取选中的节点
let menuIdList = [];
this.roleInfo.menuIdList && this.roleInfo.menuIdList.map(item => {
if (item.isCheck === 'true') {
menuIdList.push(item.id);
}
});
if (arr) {
arr.map(item => {
if (menuIdList.length) {
this.$set(item, "checked", menuIdList.includes(item.id));
this.$set(item, "expand", false);
}
if (item.child) {
this.formatting(item.child);
}
});
return arr;
}
},