From 79cb6a4473597b3bfde8f5b686609a9b6b813bcb Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Mon, 18 Nov 2024 14:06:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=9F=A5=E8=AF=A2=E7=BB=84=E4=BB=B6):=20?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=9F=A5=E8=AF=A2=E7=BB=84=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8E=92=E5=BA=8F=20#12387?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v-query/CustomSortFilter.vue | 104 ++++++++++++++++++ .../v-query/QueryConditionConfiguration.vue | 42 ++++++- .../src/custom-component/v-query/Select.vue | 40 +++---- core/core-frontend/src/locales/zh-CN.ts | 2 + 4 files changed, 163 insertions(+), 25 deletions(-) create mode 100644 core/core-frontend/src/custom-component/v-query/CustomSortFilter.vue diff --git a/core/core-frontend/src/custom-component/v-query/CustomSortFilter.vue b/core/core-frontend/src/custom-component/v-query/CustomSortFilter.vue new file mode 100644 index 0000000000..723ec31c66 --- /dev/null +++ b/core/core-frontend/src/custom-component/v-query/CustomSortFilter.vue @@ -0,0 +1,104 @@ + + + + + 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 faca82ca33..1e483e5e18 100644 --- a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue @@ -23,6 +23,8 @@ import { unref } from 'vue' import { storeToRefs } from 'pinia' +import { enumValueObj } from '@/api/dataset' +import CustomSortFilter from './CustomSortFilter.vue' import { addQueryCriteriaConfig } from './options' import { getCustomTime } from './time-format' import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' @@ -1755,6 +1757,35 @@ const getOptions = (id, component) => { }) } +const handleSortChange = () => { + handleFieldChange() + curComponent.value.sortList = [] + resetSort() +} + +const resetSort = () => { + if (sortComputed.value) { + curComponent.value.sort = '' + } +} + +const customSortFilterRef = ref() + +const sortSave = list => { + curComponent.value.sortList = cloneDeep(list) +} + +const handleCustomClick = async () => { + if (sortComputed.value || curComponent.value.sort !== 'customSort') return + const list = await enumValueObj({ queryId: curComponent.value.sortId, searchText: '' }) + customSortFilterRef.value.sortInit([...new Set(list.map(ele => ele[curComponent.value.sortId]))]) +} + +const sortComputed = computed(() => { + const { sortId, displayId } = curComponent.value + return sortId && displayId && sortId !== displayId +}) + const treeDialog = ref() const startTreeDesign = () => { const [comId] = curComponent.value.checkedFields @@ -2804,6 +2835,7 @@ defineExpose({ :placeholder="t('v_query.display_field')" class="search-field" v-model="curComponent.displayId" + @change="resetSort" > + diff --git a/core/core-frontend/src/custom-component/v-query/Select.vue b/core/core-frontend/src/custom-component/v-query/Select.vue index 72655a9f45..8c4627a7da 100644 --- a/core/core-frontend/src/custom-component/v-query/Select.vue +++ b/core/core-frontend/src/custom-component/v-query/Select.vue @@ -26,6 +26,7 @@ interface SelectConfig { displayType: string showEmpty: boolean id: string + sortList?: string[] queryConditionWidth: number placeholder: string resultMode: number @@ -287,6 +288,14 @@ const setOldMapValue = arr => { return defaultValue } +const customSort = () => { + if (config.value.sortList?.length && config.value.sort === 'customSort') { + options.value.sort( + (a, b) => config.value.sortList.indexOf(a.value) - config.value.sortList.indexOf(b.value) + ) + } +} + const handleFieldIdChange = (val: EnumValue) => { loading.value = true enumValueObj(val) @@ -313,6 +322,7 @@ const handleFieldIdChange = (val: EnumValue) => { checked: oldArr.includes(ele) } }) + customSort() }) .finally(() => { loading.value = false @@ -348,16 +358,6 @@ const handleFieldIdChange = (val: EnumValue) => { } const visible = ref(false) -const visibleChange = (val: boolean) => { - setTimeout(() => { - visible.value = !val - if (!val) { - isFromRemote.value = false - searchText.value = '' - remoteMethod('') - } - }, 50) -} watch( () => config.value.showEmpty, @@ -449,6 +449,11 @@ watch( } ) +watch([() => config.value.sortList], val => { + if (!val?.length || config.value.sort !== 'customSort') return + customSort() +}) + watch( () => config.value.optionValueSource, (valNew, newOld) => { @@ -474,16 +479,6 @@ watch( const searchText = ref('') const isFromRemote = ref(false) -const clear = () => { - remoteMethod('') -} - -const remoteMethod = (query: string) => { - if (config.value.optionValueSource !== 1) return - isFromRemote.value = true - searchText.value = query - debounceOptions(1) -} watch( () => config.value.valueSource, @@ -520,7 +515,7 @@ const setOptions = (num: number) => { handleFieldIdChange({ queryId: field.id, displayId: displayId || field.id, - sort, + sort: sort === 'customSort' ? '' : sort, sortId, resultMode: config.value.resultMode || 0, searchText: searchText.value, @@ -612,7 +607,6 @@ defineExpose({ v-loading="loading" filterable @change="handleValueChange" - @visible-change="visibleChange" :popper-class=" visible ? 'load-select filter-select-popper_class' : 'filter-select-popper_class' " @@ -635,9 +629,7 @@ defineExpose({ ref="single" :style="selectStyle" filterable - @clear="clear" radio - @visible-change="visibleChange" :popper-class=" visible ? 'load-select filter-select-popper_class' : 'filter-select-popper_class' " diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 8ceffb8567..fd0f8ed76a 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -2564,6 +2564,8 @@ export default { variable_mgm: '参数设置' }, v_query: { + display_sort: '显示字段和排序字段不一致,无法进行自定义排序', + custom_sort: '自定义排序', msg_center: '消息中心', to_be_filled: '待填报', the_minimum_value: '数值区间最大值必须大于最小值',