mirror of
https://github.com/dataease/dataease.git
synced 2026-06-13 01:01:20 +08:00
feat(query): add year to last month end range
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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: '選項類型',
|
||||
|
||||
@@ -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: '选项类型',
|
||||
|
||||
Reference in New Issue
Block a user