forked from github/dataease
fix(数据集、数据源): 数据集、数据源列表的排序切换页面后会变化 #10023
This commit is contained in:
parent
a4d7978953
commit
463c015dc8
@ -35,7 +35,9 @@ import type { TabPaneName } from 'element-plus-secondary'
|
||||
import { timestampFormatDate } from './form/util'
|
||||
import { interactiveStoreWithOut } from '@/store/modules/interactive'
|
||||
import { XpackComponent } from '@/components/plugin'
|
||||
import { useCache } from '@/hooks/web/useCache'
|
||||
const interactiveStore = interactiveStoreWithOut()
|
||||
const { wsCache } = useCache()
|
||||
interface Field {
|
||||
fieldShortName: string
|
||||
name: string
|
||||
@ -86,6 +88,7 @@ let originResourceTree = []
|
||||
const sortTypeChange = sortType => {
|
||||
state.datasetTree = treeSort(originResourceTree, sortType)
|
||||
state.curSortType = sortType
|
||||
wsCache.set('TreeSort-dataset', state.curSortType)
|
||||
}
|
||||
|
||||
const resourceCreate = (pid, name) => {
|
||||
@ -211,10 +214,12 @@ const getData = () => {
|
||||
rootManage.value = nodeData[0]['weight'] >= 7
|
||||
state.datasetTree = nodeData[0]['children'] || []
|
||||
originResourceTree = cloneDeep(unref(state.datasetTree))
|
||||
sortTypeChange(state.curSortType)
|
||||
return
|
||||
}
|
||||
state.datasetTree = nodeData
|
||||
originResourceTree = cloneDeep(unref(state.datasetTree))
|
||||
sortTypeChange(state.curSortType)
|
||||
})
|
||||
.finally(() => {
|
||||
dtLoading.value = false
|
||||
@ -252,6 +257,7 @@ const dfsDatasetTree = (ds, id) => {
|
||||
|
||||
onBeforeMount(() => {
|
||||
nodeInfo.id = (route.params.id as string) || ''
|
||||
loadInit()
|
||||
getData()
|
||||
})
|
||||
|
||||
@ -471,6 +477,13 @@ const sortList = [
|
||||
}
|
||||
]
|
||||
|
||||
const loadInit = () => {
|
||||
const historyTreeSort = wsCache.get('TreeSort-dataset')
|
||||
if (historyTreeSort) {
|
||||
state.curSortType = historyTreeSort
|
||||
}
|
||||
}
|
||||
|
||||
const sortTypeTip = computed(() => {
|
||||
return sortList.find(ele => ele.value === state.curSortType).name
|
||||
})
|
||||
|
@ -42,6 +42,7 @@ import { useMoveLine } from '@/hooks/web/useMoveLine'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { interactiveStoreWithOut } from '@/store/modules/interactive'
|
||||
import treeSort from '@/utils/treeSortUtils'
|
||||
import { useCache } from '@/hooks/web/useCache'
|
||||
const route = useRoute()
|
||||
const interactiveStore = interactiveStoreWithOut()
|
||||
interface Field {
|
||||
@ -51,7 +52,7 @@ interface Field {
|
||||
originName: string
|
||||
deType: number
|
||||
}
|
||||
|
||||
const { wsCache } = useCache()
|
||||
const { t } = useI18n()
|
||||
const router = useRouter()
|
||||
const appStore = useAppStoreWithOut()
|
||||
@ -165,6 +166,7 @@ let originResourceTree = []
|
||||
const sortTypeChange = sortType => {
|
||||
state.datasourceTree = treeSort(originResourceTree, sortType)
|
||||
state.curSortType = sortType
|
||||
wsCache.set('TreeSort-datasource', state.curSortType)
|
||||
}
|
||||
const handleSizeChange = pageSize => {
|
||||
state.paginationConfig.currentPage = 1
|
||||
@ -391,10 +393,12 @@ const listDs = () => {
|
||||
rootManage.value = nodeData[0]['weight'] >= 7
|
||||
state.datasourceTree = nodeData[0]['children'] || []
|
||||
originResourceTree = cloneDeep(unref(state.datasourceTree))
|
||||
sortTypeChange(state.curSortType)
|
||||
return
|
||||
}
|
||||
originResourceTree = cloneDeep(unref(state.datasourceTree))
|
||||
state.datasourceTree = nodeData
|
||||
sortTypeChange(state.curSortType)
|
||||
})
|
||||
.finally(() => {
|
||||
mounted.value = true
|
||||
@ -693,8 +697,17 @@ const defaultProps = {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
}
|
||||
|
||||
const loadInit = () => {
|
||||
const historyTreeSort = wsCache.get('TreeSort-datasource')
|
||||
if (historyTreeSort) {
|
||||
state.curSortType = historyTreeSort
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
nodeInfo.id = (route.params.id as string) || ''
|
||||
loadInit()
|
||||
listDs()
|
||||
const { opt } = router.currentRoute.value.query
|
||||
if (opt && opt === 'create') {
|
||||
|
Loading…
Reference in New Issue
Block a user