From 1313d2afc30efc601666337b1cfc88a93f6ac72b Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Tue, 28 Nov 2023 14:35:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A5=E6=9C=9F=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=94=AF=E6=8C=81=E5=8A=A8=E6=80=81=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom-component/v-query/DynamicTime.vue | 24 ++- .../v-query/QueryConditionConfiguration.vue | 30 +++- .../custom-component/v-query/time-format.ts | 142 ++++++++++++++++-- core/core-frontend/src/hooks/web/useFilter.ts | 23 ++- 4 files changed, 190 insertions(+), 29 deletions(-) diff --git a/core/core-frontend/src/custom-component/v-query/DynamicTime.vue b/core/core-frontend/src/custom-component/v-query/DynamicTime.vue index 8aa82127b0..1d1677929d 100644 --- a/core/core-frontend/src/custom-component/v-query/DynamicTime.vue +++ b/core/core-frontend/src/custom-component/v-query/DynamicTime.vue @@ -4,7 +4,7 @@ import { Calendar } from '@element-plus/icons-vue' import { type DatePickType } from 'element-plus-secondary' import { getThisYear, - getlastYear, + getLastYear, getThisMonth, getLastMonth, getToday, @@ -15,6 +15,8 @@ import { } from './time-format' interface SelectConfig { timeType: string + defaultValue: string + selectValue: string relativeToCurrent: string defaultValueCheck: boolean id: string @@ -30,6 +32,8 @@ const props = defineProps({ type: Object as PropType, default: () => { return { + defaultValue: '', + selectValue: '', timeType: 'fixed', relativeToCurrent: 'custom', timeNum: 0, @@ -52,6 +56,7 @@ const timeConfig = computed(() => { timeNum, relativeToCurrentType, around, + defaultValueCheck, arbitraryTime, timeGranularity } = config.value @@ -60,6 +65,7 @@ const timeConfig = computed(() => { timeNum, relativeToCurrentType, around, + defaultValueCheck, arbitraryTime, timeGranularity } @@ -75,6 +81,14 @@ watch( } ) +watch( + () => selectValue.value, + val => { + config.value.defaultValue = val + config.value.selectValue = val + } +) + watch( () => config.value.id, () => { @@ -88,13 +102,19 @@ const init = () => { timeNum, relativeToCurrentType, around, + defaultValueCheck, arbitraryTime, timeGranularity } = timeConfig.value + if (!defaultValueCheck) { + selectValue.value = null + return + } if (relativeToCurrent === 'custom') { selectValue.value = getCustomTime( timeNum, relativeToCurrentType, + timeGranularity, around, timeGranularity === 'datetime' ? arbitraryTime : null ) @@ -104,7 +124,7 @@ const init = () => { selectValue.value = getThisYear() break case 'lastYear': - selectValue.value = getlastYear() + selectValue.value = getLastYear() break case 'thisMonth': selectValue.value = getThisMonth() 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 6165beb5c4..6b2218224e 100644 --- a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue @@ -1,5 +1,5 @@