Merge pull request #8790 from dataease/pr@dev-v2@refactor_sort-tree2

refactor(仪表板): 资源数排序规则支持缓存到本地
This commit is contained in:
王嘉豪 2024-03-29 11:24:19 +08:00 committed by GitHub
commit ace9ce5810
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,13 +3,18 @@ import _ from 'lodash'
export default function treeSort(tree: BusiTreeNode[], sortType: string) {
const result = _.cloneDeep(tree)
sortPer(result, sortType)
_.forEach(result, node => {
sortCircle(result, sortType)
return result
}
export function sortCircle(tree: BusiTreeNode[], sortType: string) {
sortPer(tree, sortType)
_.forEach(tree, node => {
if (node.children && node.children.length > 0) {
sortPer(node.children, sortType)
sortCircle(node.children, sortType)
}
})
return result
return tree
}
export const sortPer = (subTree: BusiTreeNode[], sortType: string) => {