1、树显示
<div style="height: 810px;overflow:auto">
<Card bordered style="height: 810px;margin-top: 5px;overflow:auto">
<Tree :data="tree" :render="renderContent" @on-select-change="treeClick"></Tree>
</Card>
</div>
2、定义
tree:[]
3、在created中(显示)
//获取树结构
this.handTree(this.psid)
4、方法
methods:{
handTree(data){
console.log("dataPsid:",data)
getBomHeader({ psid:data }).then(res => {
this.tree = this.handleToggleExpandNode(res.data, [])
})
},
handleToggleExpandNode(bomList, lastList) {
bomList.forEach(EBom => {
let newEBom = {};
for (let i in EBom) {
if (i !== 'children') newEBom[i] = cloneDeep(EBom[i]);
}
newEBom.expand = false;
if (EBom.children && EBom.children.length) newEBom.children = [];
//在树结构显示的数据:psshowname(物料名称)
newEBom.title = EBom.psshowname;
lastList.push(newEBom);
EBom.children && this.handleToggleExpandNode(EBom.children, newEBom.children);
});
return lastList;
},
}