Commit 5432ea80 authored by coderTomato's avatar coderTomato

tree的数据结构优化

parent 420acd42
...@@ -88,13 +88,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -88,13 +88,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
let data = result.datas; let data = result.datas;
let list = data; let list = data;
let expendList: any[] = []; let expendList: any[] = [];
for(let i=0;i<list.length;i++){
list[i].title=list[i].name;
list[i].key=list[i].id;
if(list[i].isLeaf){
list[i].icon = getIcon(list[i].type);
}
}
list?.map((v: any) => { list?.map((v: any) => {
expendList.push(v.id); expendList.push(v.id);
if (v.children) { if (v.children) {
...@@ -414,8 +407,8 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -414,8 +407,8 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
setAutoExpandParent(false) setAutoExpandParent(false)
}; };
const loop = data => const loop = (data:any) =>
data?.map(item => { data?.map((item:any) => {
const index = item.title.indexOf(searchValue); const index = item.title.indexOf(searchValue);
const beforeStr = item.title.substr(0, index); const beforeStr = item.title.substr(0, index);
const afterStr = item.title.substr(index + searchValue.length); const afterStr = item.title.substr(index + searchValue.length);
...@@ -431,10 +424,14 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -431,10 +424,14 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
<span>{item.title}</span> <span>{item.title}</span>
); );
if (item.children) { if (item.children) {
return {icon:item.isLeaf?item.icon:'', title, key: item.key, children: loop(item.children) }; return {name:item.name,id:item.id,taskId:item.taskId,parentId:item.parentId,path:item.path,icon:item.isLeaf?item.icon:'', title, key: item.key, children: loop(item.children) };
} }
return { return {
name:item.name,
id:item.id,
taskId:item.taskId,
parentId:item.parentId,
path:item.path,
icon:item.isLeaf?item.icon:'', icon:item.isLeaf?item.icon:'',
title, title,
key: item.key, key: item.key,
......
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