if(data !== undefined) {
let temp: ITreeData[] = [{key: '0', title: '工厂管理', children: new Array<ITreeData>()}];
//向从数据库查询到的数据中添加Tree结构所需要的字段,key使用id,title使用name;
data.forEach(it => {
it['key'] = `${it.id}`;
it['title'] = it.name;
it['isPlant'] = true;
it.children && it.children.forEach((item: any)=>{
item['key'] = `${it.id}-${item.id}`;
item['title'] = item.name
item['isLine'] = true;
})
});
temp[0].children = data;
setTreeData(temp);
}