diff --git a/core/core-frontend/src/utils/treeSortUtils.ts b/core/core-frontend/src/utils/treeSortUtils.ts index 8e605dba8d..8e29fa8756 100644 --- a/core/core-frontend/src/utils/treeSortUtils.ts +++ b/core/core-frontend/src/utils/treeSortUtils.ts @@ -1,23 +1,25 @@ import { BusiTreeNode } from '@/models/tree/TreeNode' import _ from 'lodash' -export default function treeSort(tree: BusiTreeNode[], sortType: string, historySortType: string) { +export default function treeSort(tree: BusiTreeNode[], sortType: string) { const result = _.cloneDeep(tree) - sortPer(result, sortType, historySortType) + sortPer(result, sortType) _.forEach(result, node => { if (node.children && node.children.length > 0) { - sortPer(node.children, sortType, historySortType) + sortPer(node.children, sortType) } }) return result } -export const sortPer = (subTree: BusiTreeNode[], sortType: string, historySortType: string) => { +export const sortPer = (subTree: BusiTreeNode[], sortType: string) => { if (sortType === 'name_desc') { subTree.sort((a, b) => b.name.localeCompare(a.name, 'zh-Hans-CN', { sensitivity: 'accent' })) } else if (sortType === 'name_asc') { subTree.sort((a, b) => a.name.localeCompare(b.name, 'zh-Hans-CN', { sensitivity: 'accent' })) - } else if (sortType !== historySortType) { + } else if (sortType === 'time_asc') { return subTree.reverse() + } else { + return subTree } } diff --git a/core/core-frontend/src/views/common/DeResourceTree.vue b/core/core-frontend/src/views/common/DeResourceTree.vue index 67f717261a..3634898ddb 100644 --- a/core/core-frontend/src/views/common/DeResourceTree.vue +++ b/core/core-frontend/src/views/common/DeResourceTree.vue @@ -60,6 +60,7 @@ const returnMounted = ref(false) const state = reactive({ curSortType: 'time_desc', resourceTree: [] as BusiTreeNode[], + originResourceTree: [] as BusiTreeNode[], folderMenuList: [ { label: '移动到', @@ -242,6 +243,7 @@ function flatTree(tree: BusiTreeNode[]) { } const afterTreeInit = () => { + state.originResourceTree = _.cloneDeep(state.resourceTree) mounted.value = true if (selectedNodeKey.value && returnMounted.value) { expandedArray.value = getDefaultExpandedKeys() @@ -391,7 +393,7 @@ const getDefaultExpandedKeys = () => { } const sortTypeChange = sortType => { - state.resourceTree = treeSort(state.resourceTree, sortType, state.curSortType) + state.resourceTree = treeSort(state.originResourceTree, sortType) state.curSortType = sortType }