From 5c6f44eabbb747aceff8933b0734b05b493e39d3 Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Thu, 18 Sep 2025 15:19:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=9F=A5=E8=AF=A2=E7=BB=84=E4=BB=B6):=20?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4=E7=9A=84=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=87=AA=E5=AE=9A=E4=B9=89=E4=BC=9A=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=20=E9=BB=98=E8=AE=A4=E5=80=BC=E8=B6=85=E5=87=BA?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E7=AD=9B=E9=80=89=E8=8C=83=E5=9B=B4=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v-query/DynamicTimeFiltering.vue | 4 ++-- .../v-query/DynamicTimeRangeFiltering.vue | 10 +++++++--- .../v-query/QueryConditionConfiguration.vue | 15 ++++++++++----- .../src/custom-component/v-query/Time.vue | 5 +++-- .../v-query/time-format-dayjs.ts | 19 ++++++++++++++++++- 5 files changed, 40 insertions(+), 13 deletions(-) diff --git a/core/core-frontend/src/custom-component/v-query/DynamicTimeFiltering.vue b/core/core-frontend/src/custom-component/v-query/DynamicTimeFiltering.vue index d8fdc094a5..62e53255e5 100644 --- a/core/core-frontend/src/custom-component/v-query/DynamicTimeFiltering.vue +++ b/core/core-frontend/src/custom-component/v-query/DynamicTimeFiltering.vue @@ -3,7 +3,7 @@ import { toRefs, PropType, onBeforeMount, watch, computed } from 'vue' import { Calendar } from '@element-plus/icons-vue' import { type DatePickType } from 'element-plus-secondary' import type { ManipulateType } from 'dayjs' -import { getThisStart, getThisEnd, getLastStart, getAround } from './time-format-dayjs' +import { getThisStart, getThisEnd, getLastStart, getAroundStart } from './time-format-dayjs' interface SelectConfig { intervalType: string regularOrTrendsValue: Date @@ -86,7 +86,7 @@ const init = () => { return } if (relativeToCurrent === 'custom') { - config.value.regularOrTrendsValue = getAround( + config.value.regularOrTrendsValue = getAroundStart( relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum diff --git a/core/core-frontend/src/custom-component/v-query/DynamicTimeRangeFiltering.vue b/core/core-frontend/src/custom-component/v-query/DynamicTimeRangeFiltering.vue index 270d53edbd..c85845b551 100644 --- a/core/core-frontend/src/custom-component/v-query/DynamicTimeRangeFiltering.vue +++ b/core/core-frontend/src/custom-component/v-query/DynamicTimeRangeFiltering.vue @@ -3,7 +3,7 @@ import { toRefs, PropType, onBeforeMount, watch, computed } from 'vue' import { Calendar } from '@element-plus/icons-vue' import { type DatePickType } from 'element-plus-secondary' import type { ManipulateType } from 'dayjs' -import { getAround, getCustomRange } from './time-format-dayjs' +import { getAround, getCustomRange, getAroundStart } from './time-format-dayjs' interface SelectConfig { regularOrTrends: string regularOrTrendsValue: [Date, Date] @@ -109,13 +109,17 @@ const init = () => { ) return config.value.regularOrTrendsValue = [ - getAround(relativeToCurrentTypeRange, 'add', 0), + getAroundStart(relativeToCurrentTypeRange, 'add', 0), getAround(relativeToCurrentTypeRange, 'add', 1) ] return } - const startTime = getAround(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum) + const startTime = getAroundStart( + relativeToCurrentType, + around === 'f' ? 'subtract' : 'add', + timeNum + ) const endTime = getAround( relativeToCurrentTypeRange, aroundRange === 'f' ? 'subtract' : 'add', 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 69aeb854ef..cd0a46d97e 100644 --- a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue @@ -33,6 +33,7 @@ import { getThisEnd, getLastStart, getAround, + getAroundStart, getCustomRange } from './time-format-dayjs' import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot' @@ -1087,7 +1088,7 @@ const isInRange = (ele, startWindowTime, timeStamp) => { } let startTime if (relativeToCurrent === 'custom') { - startTime = getAround(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum) + startTime = getAroundStart(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum) } else { switch (relativeToCurrent) { case 'thisYear': @@ -1130,6 +1131,7 @@ const isInRange = (ele, startWindowTime, timeStamp) => { break } } + const startValue = regularOrTrends === 'fixed' ? regularOrTrendsValue : startTime if (intervalType === 'start') { return startWindowTime < +new Date(startValue) || isDynamicWindowTime @@ -1147,7 +1149,7 @@ const isInRange = (ele, startWindowTime, timeStamp) => { ? new Date( dayjs(new Date(regularOrTrendsValue[0])).startOf(noTime).format('YYYY/MM/DD HH:mm:ss') ) - : getAround(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum) + : getAroundStart(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum) endTime = regularOrTrends === 'fixed' ? new Date( @@ -1508,6 +1510,8 @@ const validate = () => { return true } if (!ele.setTimeRange) return false + console.log(startTime, endTime) + if ( isInRange( ele, @@ -3723,14 +3727,15 @@ defineExpose({ margin-bottom: 8px; .field-select--input { - .ed-select-tags-wrapper.has-prefix { - margin-left: 25px; + .ed-select__prefix { + padding-right: 0; } + .ed-select__input { margin-left: 6px !important; } .ed-tag { - max-width: 52px; + max-width: 46px !important; .ed-tag__close { margin-left: 2px; } diff --git a/core/core-frontend/src/custom-component/v-query/Time.vue b/core/core-frontend/src/custom-component/v-query/Time.vue index 1016c5e992..5322378bf8 100644 --- a/core/core-frontend/src/custom-component/v-query/Time.vue +++ b/core/core-frontend/src/custom-component/v-query/Time.vue @@ -12,6 +12,7 @@ import { getThisEnd, getLastStart, getAround, + getAroundStart, getCustomRange } from './time-format-dayjs' import VanPopup from 'vant/es/popup' @@ -298,7 +299,7 @@ const disabledDate = val => { } let startTime if (relativeToCurrent === 'custom') { - startTime = getAround(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum) + startTime = getAroundStart(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum) } else { switch (relativeToCurrent) { case 'thisYear': @@ -361,7 +362,7 @@ const disabledDate = val => { .startOf(queryTimeType.value) .format('YYYY/MM/DD HH:mm:ss') ) - : getAround(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum) + : getAroundStart(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum) endTime = regularOrTrends === 'fixed' ? new Date( diff --git a/core/core-frontend/src/custom-component/v-query/time-format-dayjs.ts b/core/core-frontend/src/custom-component/v-query/time-format-dayjs.ts index 708edbc95b..0cd1514a79 100644 --- a/core/core-frontend/src/custom-component/v-query/time-format-dayjs.ts +++ b/core/core-frontend/src/custom-component/v-query/time-format-dayjs.ts @@ -23,6 +23,15 @@ function getAround(val = 'month' as ManipulateType, type = 'add', num = 0) { return new Date(dayjs()[type](num, val).endOf('day').format('YYYY/MM/DD HH:mm:ss')) } +function getAroundStart(val = 'month' as ManipulateType, type = 'add', num = 0) { + if (val === 'week') { + return new Date( + dayjs().startOf('week').add(1, 'day').startOf('day').format('YYYY/MM/DD HH:mm:ss') + ) + } + return new Date(dayjs()[type](num, val).startOf('day').format('YYYY/MM/DD HH:mm:ss')) +} + function getThisWeek(): [Date, Date] { return [ new Date(dayjs().startOf('week').add(1, 'day').startOf('day').format('YYYY/MM/DD HH:mm:ss')), @@ -76,4 +85,12 @@ function getCustomRange(relativeToCurrentRange: string): [Date, Date] { return [new Date(), new Date()] } } -export { getThisStart, getThisEnd, getLastStart, getLastEnd, getAround, getCustomRange } +export { + getThisStart, + getThisEnd, + getLastStart, + getLastEnd, + getAround, + getCustomRange, + getAroundStart +}