diff --git a/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue b/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue index 8050fb695f..ce09102f1c 100644 --- a/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue @@ -200,6 +200,10 @@ const relativeToCurrentListRange = computed(() => { label: t('dynamic_month.last'), value: 'lastMonth' }, + { + label: t('dynamic_time.tquarter'), + value: 'thisQuarter' + }, { label: t('v_query.last_3_months'), value: 'LastThreeMonths' @@ -225,6 +229,10 @@ const relativeToCurrentListRange = computed(() => { label: t('dynamic_time.yesterday'), value: 'yesterday' }, + { + label: t('dynamic_time.cweek'), + value: 'thisWeek' + }, { label: t('v_query.last_3_days'), value: 'LastThreeDays' 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 fe013406f5..b8e589582d 100644 --- a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue @@ -1050,6 +1050,14 @@ const isInRange = (ele, startWindowTime, timeStamp) => { case 'lastMonth': startTime = getLastStart('month') break + case 'thisQuarter': + startTime = getThisStart('quarter') + break + case 'thisWeek': + startTime = new Date( + dayjs().startOf('week').add(1, 'day').startOf('day').format('YYYY/MM/DD HH:mm:ss') + ) + break case 'today': startTime = getThisStart('day') break 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 2ee9baf4df..3b503cca0d 100644 --- a/core/core-frontend/src/custom-component/v-query/Time.vue +++ b/core/core-frontend/src/custom-component/v-query/Time.vue @@ -297,6 +297,14 @@ const disabledDate = val => { case 'lastMonth': startTime = getLastStart('month') break + case 'thisQuarter': + startTime = getThisStart('quarter') + break + case 'thisWeek': + startTime = new Date( + dayjs().startOf('week').add(1, 'day').startOf('day').format('YYYY/MM/DD HH:mm:ss') + ) + break case 'today': startTime = getThisStart('day') break 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 a74df747d0..8399546f12 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 @@ -1,10 +1,10 @@ import dayjs from 'dayjs' import type { ManipulateType } from 'dayjs' -function getThisStart(val = 'month' as ManipulateType) { +function getThisStart(val = 'month' as ManipulateType | 'quarter') { return new Date(dayjs().startOf(val).format('YYYY/MM/DD HH:mm:ss')) } -function getThisEnd(val = 'month' as ManipulateType) { +function getThisEnd(val = 'month' as ManipulateType | 'quarter') { return new Date(dayjs().endOf(val).format('YYYY/MM/DD HH:mm:ss')) } @@ -17,9 +17,19 @@ function getLastEnd(val = 'month' as ManipulateType) { } function getAround(val = 'month' as ManipulateType, type = 'add', num = 0) { + if (val === 'week') { + return new Date(dayjs().endOf('week').add(1, 'day').endOf('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')), + new Date(dayjs().endOf('week').add(1, 'day').endOf('day').format('YYYY/MM/DD HH:mm:ss')) + ] +} + function getCustomRange(relativeToCurrentRange: string): [Date, Date] { switch (relativeToCurrentRange) { case 'thisYear': @@ -30,6 +40,10 @@ function getCustomRange(relativeToCurrentRange: string): [Date, Date] { return [getThisStart('month'), getThisEnd('month')] case 'lastMonth': return [getLastStart('month'), getLastEnd('month')] + case 'thisQuarter': + return [getThisStart('quarter'), getThisEnd('quarter')] + case 'thisWeek': + return getThisWeek() case 'LastThreeMonths': return [ new Date(dayjs().subtract(3, 'month').startOf('month').format('YYYY/MM/DD HH:mm:ss')), diff --git a/core/core-frontend/src/locales/en.ts b/core/core-frontend/src/locales/en.ts index dd3db45efd..1212eee338 100644 --- a/core/core-frontend/src/locales/en.ts +++ b/core/core-frontend/src/locales/en.ts @@ -376,6 +376,7 @@ export default { lweek: 'Last week', cmonth: 'This month', cquarter: 'This quarter', + tquarter: 'This quarter', lquarter: 'Last quarter', cyear: 'This year' }, diff --git a/core/core-frontend/src/locales/tw.ts b/core/core-frontend/src/locales/tw.ts index 9b051f1ced..f1b10a1f06 100644 --- a/core/core-frontend/src/locales/tw.ts +++ b/core/core-frontend/src/locales/tw.ts @@ -366,6 +366,7 @@ export default { lweek: '上週', cmonth: '本月', cquarter: '本季', + tquarter: '本季', lquarter: '上季', cyear: '本年' }, diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 4a1f4e32a1..e2f5981a07 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -367,6 +367,7 @@ export default { lweek: '上周', cmonth: '本月', cquarter: '本季', + tquarter: '本季度', lquarter: '上季', cyear: '本年' },