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 dbfd17e349..b0a53a6ea6 100644 --- a/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue @@ -229,6 +229,10 @@ const relativeToCurrentListRange = computed(() => { { label: t('common.to_this_month'), value: 'YearToThisMonth' + }, + { + label: t('v_query.year_to_last_month_end'), + value: 'YearToLastMonthEnd' } ] break @@ -263,6 +267,10 @@ const relativeToCurrentListRange = computed(() => { label: t('v_query.year_to_date'), value: 'yearBeginning' }, + { + label: t('v_query.year_to_last_month_end'), + value: 'YearToLastMonthEnd' + }, { label: t('common.month_to_yesterday'), value: 'monthToYesterday' diff --git a/core/core-frontend/src/custom-component/v-query/FilterTime.vue b/core/core-frontend/src/custom-component/v-query/FilterTime.vue index be64b1267c..8f7c335ea4 100644 --- a/core/core-frontend/src/custom-component/v-query/FilterTime.vue +++ b/core/core-frontend/src/custom-component/v-query/FilterTime.vue @@ -217,6 +217,10 @@ const relativeToCurrentListRange = computed(() => { { label: t('common.to_this_month'), value: 'YearToThisMonth' + }, + { + label: t('v_query.year_to_last_month_end'), + value: 'YearToLastMonthEnd' } ] break @@ -243,6 +247,10 @@ const relativeToCurrentListRange = computed(() => { label: t('v_query.year_to_date'), value: 'yearBeginning' }, + { + label: t('v_query.year_to_last_month_end'), + value: 'YearToLastMonthEnd' + }, { label: t('common.month_to_yesterday'), value: 'monthToYesterday' 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 3f01a14ebe..0790362ded 100644 --- a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue @@ -2184,6 +2184,10 @@ const relativeToCurrentListRange = computed(() => { { label: t('common.to_this_month'), value: 'YearToThisMonth' + }, + { + label: t('v_query.year_to_last_month_end'), + value: 'YearToLastMonthEnd' } ] break @@ -2210,6 +2214,10 @@ const relativeToCurrentListRange = computed(() => { label: t('v_query.year_to_date'), value: 'yearBeginning' }, + { + label: t('v_query.year_to_last_month_end'), + value: 'YearToLastMonthEnd' + }, { label: t('common.month_to_yesterday'), value: 'monthToYesterday' diff --git a/core/core-frontend/src/custom-component/v-query/RangeFilterTime.vue b/core/core-frontend/src/custom-component/v-query/RangeFilterTime.vue index 3de69630df..163af40690 100644 --- a/core/core-frontend/src/custom-component/v-query/RangeFilterTime.vue +++ b/core/core-frontend/src/custom-component/v-query/RangeFilterTime.vue @@ -228,6 +228,10 @@ const relativeToCurrentListRange = computed(() => { { label: t('common.to_this_month'), value: 'YearToThisMonth' + }, + { + label: t('v_query.year_to_last_month_end'), + value: 'YearToLastMonthEnd' } ] break @@ -254,6 +258,10 @@ const relativeToCurrentListRange = computed(() => { label: t('v_query.year_to_date'), value: 'yearBeginning' }, + { + label: t('v_query.year_to_last_month_end'), + value: 'YearToLastMonthEnd' + }, { label: t('common.month_to_yesterday'), value: 'monthToYesterday' 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 4e0a0a3693..43ba232399 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,11 +1,23 @@ import dayjs from 'dayjs' -import type { ManipulateType } from 'dayjs' -function getThisStart(val = 'month' as ManipulateType | 'quarter') { - return new Date(dayjs().startOf(val).format('YYYY/MM/DD HH:mm:ss')) +import type { ManipulateType, QUnitType } from 'dayjs' +import quarterOfYear from 'dayjs/plugin/quarterOfYear' +type ManipulateTypeWithQuarter = ManipulateType | 'quarter' +dayjs.extend(quarterOfYear) + +function getThisStart(val = 'month' as ManipulateTypeWithQuarter) { + return new Date( + dayjs() + .startOf(val as QUnitType) + .format('YYYY/MM/DD HH:mm:ss') + ) } -function getThisEnd(val = 'month' as ManipulateType | 'quarter') { - return new Date(dayjs().endOf(val).format('YYYY/MM/DD HH:mm:ss')) +function getThisEnd(val = 'month' as ManipulateTypeWithQuarter) { + return new Date( + dayjs() + .endOf(val as QUnitType) + .format('YYYY/MM/DD HH:mm:ss') + ) } function getLastStart(val = 'month' as ManipulateType) { @@ -16,6 +28,15 @@ function getLastEnd(val = 'month' as ManipulateType) { return new Date(dayjs().subtract(1, val).endOf(val).format('YYYY/MM/DD HH:mm:ss')) } +function getYearToLastMonthEnd(): [Date, Date] { + const start = getThisStart('year') + const end = getLastEnd('month') + if (+start > +end) { + return [start, getThisEnd('day')] + } + return [start, end] +} + 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')) @@ -70,6 +91,8 @@ function getCustomRange(relativeToCurrentRange: string): [Date, Date] { ] case 'YearToThisMonth': return [new Date(dayjs().startOf('year').format('YYYY/MM/DD HH:mm:ss')), getThisEnd('month')] + case 'YearToLastMonthEnd': + return getYearToLastMonthEnd() case 'monthToYesterday': const sm = new Date(dayjs().startOf('month').format('YYYY/MM/DD HH:mm:ss')) const ld = getLastEnd('day') @@ -99,6 +122,7 @@ export { getThisEnd, getLastStart, getLastEnd, + getYearToLastMonthEnd, getAround, getCustomRange, getAroundStart diff --git a/core/core-frontend/src/locales/en.ts b/core/core-frontend/src/locales/en.ts index e9ec0419ea..8cf987268c 100644 --- a/core/core-frontend/src/locales/en.ts +++ b/core/core-frontend/src/locales/en.ts @@ -2887,6 +2887,7 @@ export default { last_3_days: 'Last 3 days', month_to_date: 'Month to date', year_to_date: 'Year to date', + year_to_last_month_end: 'Year to end of last month', exact_match: 'Exact', fuzzy_match: 'Fuzzy', option_type: 'Option type', diff --git a/core/core-frontend/src/locales/tw.ts b/core/core-frontend/src/locales/tw.ts index 005784b15e..a3eca8a1bf 100644 --- a/core/core-frontend/src/locales/tw.ts +++ b/core/core-frontend/src/locales/tw.ts @@ -2814,6 +2814,7 @@ export default { last_3_days: '最近3 天', month_to_date: '月初至今', year_to_date: '年初至今', + year_to_last_month_end: '年初至上月底', exact_match: '精確匹配', fuzzy_match: '模糊匹配', option_type: '選項類型', diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index f05cc81aad..896c89b1c1 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -2820,6 +2820,7 @@ export default { last_3_days: '最近 3 天', month_to_date: '月初至今', year_to_date: '年初至今', + year_to_last_month_end: '年初至上月末', exact_match: '精确匹配', fuzzy_match: '模糊匹配', option_type: '选项类型',