|
|
@ -5,8 +5,6 @@ import Module from '../../public/module' |
|
|
|
import { getBusTierList } from '../../../actions/example' |
|
|
|
import './style.less' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Left = (props) => { |
|
|
|
const [treeData, setTreeData] = useState([]) |
|
|
|
const [treeDataList, setTreeDataList] = useState([]) |
|
|
@ -29,12 +27,12 @@ const Left = (props) => { |
|
|
|
|
|
|
|
const onChange = (e) => { |
|
|
|
const { value } = e.target; |
|
|
|
let keys = [] |
|
|
|
const newExpandedKeys = treeDataList.filter(e => e.key.match(value)) |
|
|
|
let titles = [] |
|
|
|
const newExpandedKeys = treeDataList.filter(e => e.title != null && e.title.match(value)) |
|
|
|
newExpandedKeys.forEach(e => { |
|
|
|
keys.push(e.key) |
|
|
|
titles.push(e.title) |
|
|
|
}) |
|
|
|
setExpandedKeys(keys); |
|
|
|
setExpandedKeys(titles); |
|
|
|
setSearchValue(value); |
|
|
|
setAutoExpandParent(true); |
|
|
|
}; |
|
|
@ -78,51 +76,53 @@ const Left = (props) => { |
|
|
|
let busTierOpen = [] |
|
|
|
let dataList = [] |
|
|
|
let busTierNewList = [] |
|
|
|
if (busTier && busTier.data && busTier.data.length > 0) { |
|
|
|
busTierNewList.push(busTier && busTier.data && busTier.data[0]) |
|
|
|
} |
|
|
|
if (busTierNewList.length > 0) { |
|
|
|
busTierNewList.forEach((e, index) => { |
|
|
|
if (index == 0) { |
|
|
|
busTierOpen.push(e.name) |
|
|
|
} |
|
|
|
busTierList.push({ |
|
|
|
key: e.name, |
|
|
|
title: e.name, |
|
|
|
children: e.child.map(s => { |
|
|
|
return { |
|
|
|
key: s.name, |
|
|
|
title: s.name, |
|
|
|
children: s.child.map(i => { |
|
|
|
return { |
|
|
|
key: i.name, |
|
|
|
title: i.name, |
|
|
|
children: i.child.map(x => { |
|
|
|
return { |
|
|
|
key: x.name, |
|
|
|
title: x.name, |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
// Math.ceil(Math.random() * 100);
|
|
|
|
// if (busTier && busTier.data && busTier.data.length > 0) {
|
|
|
|
// busTierNewList.push(busTier && busTier.data && busTier.data[0])
|
|
|
|
// }
|
|
|
|
// if (busTierNewList.length > 0) {
|
|
|
|
// }
|
|
|
|
busTier && busTier.data && busTier.data.forEach((e, index) => { |
|
|
|
if (index == 0) { |
|
|
|
busTierOpen.push(e.name) |
|
|
|
} |
|
|
|
busTierList.push({ |
|
|
|
key: e.name, |
|
|
|
title: e.name, |
|
|
|
children: e.child.map(s => { |
|
|
|
return { |
|
|
|
key: s.name, |
|
|
|
title: s.name, |
|
|
|
children: s.child.map(i => { |
|
|
|
return { |
|
|
|
key: i.name == '--' || i.name == null ? Math.ceil(Math.random() * 100) : i.name, |
|
|
|
title: i.name, |
|
|
|
children: i.child.map(x => { |
|
|
|
return { |
|
|
|
key: x.name == '--' || x.name == null ? Math.ceil(Math.random() * 100) : x.name, |
|
|
|
title: x.name == null ? '--' : x.name, |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
busTierNewList.forEach(e => { |
|
|
|
e.child.forEach(i => { |
|
|
|
i.child.forEach(s => { |
|
|
|
s.child.forEach(x => { |
|
|
|
dataList.push({ |
|
|
|
key: x.name, |
|
|
|
title: x.name |
|
|
|
}) |
|
|
|
}) |
|
|
|
busTier && busTier.data && busTier.data.forEach(e => { |
|
|
|
e.child.forEach(i => { |
|
|
|
i.child.forEach(s => { |
|
|
|
s.child.forEach(x => { |
|
|
|
dataList.push({ |
|
|
|
key: x.name, |
|
|
|
title: x.name |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
setTreeData(busTierList) |
|
|
|
setExpandedKeys(busTierOpen) |
|
|
|
setTreeDataList(dataList) |
|
|
|