diff --git a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue index 542daa524d..5b2ef85457 100644 --- a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue @@ -44,8 +44,11 @@ import dayjs from 'dayjs' import ConditionDefaultConfiguration from '@/custom-component/v-query/ConditionDefaultConfiguration.vue' import { iconChartMap } from '@/components/icon-group/chart-list' import { iconFieldMap } from '@/components/icon-group/field-list' +import treeSort from '@/utils/treeSortUtils' +import { useCache } from '@/hooks/web/useCache' const { t } = useI18n() +const { wsCache } = useCache() const dvMainStore = dvMainStoreWithOut() const { componentData, canvasViewInfo } = storeToRefs(dvMainStore) const defaultConfigurationRef = ref(null) @@ -879,16 +882,20 @@ const cancelClick = () => { const initDataset = () => { getDatasetTree({}).then(res => { - datasetTree.value = (res as unknown as Tree[]) || [] + const result = (res as unknown as Tree[]) || [] + if (result[0]?.id === '0') { + sortTypeChange(dfs(result[0].children)) + } else { + sortTypeChange(dfs(result)) + } }) } -const computedTree = computed(() => { - if (datasetTree.value[0]?.id === '0') { - return dfs(datasetTree.value[0].children) - } - return dfs(datasetTree.value) -}) +const sortTypeChange = arr => { + const sortType = wsCache.get('TreeSort-dataset') || 'time_desc' + datasetTree.value = treeSort(arr, sortType) +} + let newDatasetId = '' let oldDatasetId = '' const handleCurrentChange = node => { @@ -2655,8 +2662,9 @@ defineExpose({ @@ -3651,7 +3662,8 @@ defineExpose({ .content { display: flex; align-items: center; - .label { + width: 100%; + .label-tree { margin-left: 5px; width: calc(100% - 45px); } diff --git a/core/core-frontend/src/views/chart/components/editor/dataset-select/DatasetSelect.vue b/core/core-frontend/src/views/chart/components/editor/dataset-select/DatasetSelect.vue index 95b4c4eb5c..4d0ef5c086 100644 --- a/core/core-frontend/src/views/chart/components/editor/dataset-select/DatasetSelect.vue +++ b/core/core-frontend/src/views/chart/components/editor/dataset-select/DatasetSelect.vue @@ -14,8 +14,9 @@ import { useEmitt } from '@/hooks/web/useEmitt' import { useCache } from '@/hooks/web/useCache' import { useUserStoreWithOut } from '@/store/modules/user' import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' -const dvMainStore = dvMainStoreWithOut() +import treeSort from '@/utils/treeSortUtils' +const dvMainStore = dvMainStoreWithOut() const { wsCache } = useCache('localStorage') const userStore = useUserStoreWithOut() @@ -43,18 +44,20 @@ const loadingDatasetTree = ref(false) const orgCheck = ref(true) const datasetTree = ref([]) -const toolTip = computed(() => { - return props.themes === 'dark' ? 'ndark' : 'dark' -}) const sourceName = computed(() => (props.sourceType === 'datasource' ? '数据源' : '数据集')) +const sortTypeChange = arr => { + const sortType = wsCache.get('TreeSort-dataset') || 'time_desc' + datasetTree.value = treeSort(arr, sortType) +} + const initDataset = () => { loadingDatasetTree.value = true const method = props.sourceType === 'datasource' ? getDatasourceList : getDatasetTree method({}) .then(res => { - datasetTree.value = (res as unknown as Tree[]) || [] + sortTypeChange((res as unknown as Tree[]) || []) }) .finally(() => { loadingDatasetTree.value = false