diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/store-overview/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/store-overview/index.vue index 843c4960..381176f3 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/store-overview/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/store-overview/index.vue @@ -46,9 +46,9 @@ const selectedExportShopIds = ref([]); const platformExportMode = ref(false); const selectedExportPlatformIds = ref([]); -// 日期范围 +// 日期范围(默认:本月至今日) const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([ - dayjs().subtract(30, 'day'), + dayjs().startOf('month'), dayjs(), ]); @@ -96,8 +96,8 @@ const parseTaxRate = (value: string | undefined) => { // 当前选中的时间范围类型 const activeTimeRange = ref< - '7days' | '30days' | 'custom' | 'today' | 'yesterday' ->('30days'); + '7days' | '30days' | 'thisMonth' | 'custom' | 'today' | 'yesterday' +>('thisMonth'); // 自定义日期范围 const customDateRange = ref<[dayjs.Dayjs, dayjs.Dayjs] | undefined>([ @@ -112,7 +112,7 @@ const shopChartsRef = ref<{ renderShopBarChart: () => void; renderShopScatterCha // 切换时间范围 const switchTimeRange = async ( - type: '7days' | '30days' | 'custom' | 'today' | 'yesterday', + type: '7days' | '30days' | 'thisMonth' | 'custom' | 'today' | 'yesterday', ) => { activeTimeRange.value = type; let startDate: dayjs.Dayjs; @@ -127,6 +127,11 @@ const switchTimeRange = async ( startDate = dayjs().subtract(30, 'day'); break; } + case 'thisMonth': { + startDate = dayjs().startOf('month'); + endDate = dayjs(); + break; + } case 'custom': { if (customDateRange.value) { dateRange.value = customDateRange.value; @@ -188,6 +193,15 @@ const setTimeRangeTypeByDates = ( 'day', ); + if ( + isEndDateToday && + startDate.isSame(today.startOf('month'), 'day') + ) { + activeTimeRange.value = 'thisMonth'; + customDateRange.value = [startDate, endDate]; + return; + } + if (daysDiff === 0 && startDate.isSame(today, 'day')) { activeTimeRange.value = 'today'; customDateRange.value = [startDate, endDate]; @@ -534,6 +548,19 @@ const navigateToShopOverview = (shopId: number) => { > 近30日 +
diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/components/TimeRangeBar.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/components/TimeRangeBar.vue index 6b37d0dd..a6daf8f7 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/components/TimeRangeBar.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/components/TimeRangeBar.vue @@ -6,7 +6,13 @@ import type { Dayjs } from 'dayjs'; interface Props { modelValue: { taxRate: number; - activeTimeRange: '7days' | '30days' | 'custom' | 'today' | 'yesterday'; + activeTimeRange: + | '7days' + | '30days' + | 'thisMonth' + | 'custom' + | 'today' + | 'yesterday'; customDateRange: [Dayjs, Dayjs] | undefined; dateRange: [Dayjs, Dayjs]; }; @@ -34,7 +40,9 @@ const parseTaxRate = (value: string | undefined) => { return Number.isFinite(num) ? num / 100 : 0; }; -const switchTimeRange = (type: '7days' | '30days' | 'custom' | 'today' | 'yesterday') => { +const switchTimeRange = ( + type: '7days' | '30days' | 'thisMonth' | 'custom' | 'today' | 'yesterday', +) => { let startDate: Dayjs; let endDate: Dayjs = dayjs(); @@ -45,6 +53,10 @@ const switchTimeRange = (type: '7days' | '30days' | 'custom' | 'today' | 'yester case '30days': startDate = dayjs().subtract(30, 'day'); break; + case 'thisMonth': + startDate = dayjs().startOf('month'); + endDate = dayjs(); + break; case 'custom': if (props.modelValue.customDateRange) { emit('update:modelValue', { @@ -178,6 +190,19 @@ const handleTaxRateChange = (val: number | string | undefined) => { > 近30日 +
diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/index.vue index fcc50e36..c5e751a7 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/index.vue @@ -56,16 +56,16 @@ const normalizeOverview = (raw: any) => { }; }; -// 日期范围 +// 日期范围(默认:本月至今日) const dateRange = ref<[Dayjs, Dayjs]>([ - dayjs().subtract(30, 'day'), + dayjs().startOf('month'), dayjs(), ]); // 当前选中的时间范围类型 const activeTimeRange = ref< - '7days' | '30days' | 'custom' | 'today' | 'yesterday' ->('30days'); + '7days' | '30days' | 'thisMonth' | 'custom' | 'today' | 'yesterday' +>('thisMonth'); // 自定义日期范围 const customDateRange = ref<[Dayjs, Dayjs] | undefined>([ diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/TimeRangeBar.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/TimeRangeBar.vue index 49b59543..f06f7b2b 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/TimeRangeBar.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/TimeRangeBar.vue @@ -6,7 +6,13 @@ import type { Dayjs } from 'dayjs'; interface Props { modelValue: { taxRate: number; - activeTimeRange: '7days' | '30days' | 'custom' | 'today' | 'yesterday'; + activeTimeRange: + | '7days' + | '30days' + | 'thisMonth' + | 'custom' + | 'today' + | 'yesterday'; customDateRange: [Dayjs, Dayjs] | undefined; dateRange: [Dayjs, Dayjs]; }; @@ -34,7 +40,9 @@ const parseTaxRate = (value: string | undefined) => { return Number.isFinite(num) ? num / 100 : 0; }; -const switchTimeRange = (type: '7days' | '30days' | 'custom' | 'today' | 'yesterday') => { +const switchTimeRange = ( + type: '7days' | '30days' | 'thisMonth' | 'custom' | 'today' | 'yesterday', +) => { let startDate: Dayjs; let endDate: Dayjs = dayjs(); @@ -45,6 +53,10 @@ const switchTimeRange = (type: '7days' | '30days' | 'custom' | 'today' | 'yester case '30days': startDate = dayjs().subtract(30, 'day'); break; + case 'thisMonth': + startDate = dayjs().startOf('month'); + endDate = dayjs(); + break; case 'custom': if (props.modelValue.customDateRange) { emit('update:modelValue', { @@ -178,6 +190,19 @@ const handleTaxRateChange = (val: number | string | undefined) => { > 近30日 + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue index 8f1af6b5..f7cc27c7 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue @@ -58,16 +58,16 @@ const categoryExportMode = ref(false); const selectedExportCategoryIds = ref([]); const categoryExportLoading = ref(false); -// 日期范围 +// 日期范围(默认:本月至今日) const dateRange = ref<[Dayjs, Dayjs]>([ - dayjs().subtract(7, 'day'), + dayjs().startOf('month'), dayjs(), ]); // 当前选中的时间范围类型 const activeTimeRange = ref< - '7days' | '30days' | 'custom' | 'today' | 'yesterday' ->('7days'); + '7days' | '30days' | 'thisMonth' | 'custom' | 'today' | 'yesterday' +>('thisMonth'); // 自定义日期范围 const customDateRange = ref<[Dayjs, Dayjs] | undefined>([ @@ -122,6 +122,15 @@ const setTimeRangeTypeByDates = ( 'day', ); + if ( + isEndDateToday && + startDate.isSame(today.startOf('month'), 'day') + ) { + activeTimeRange.value = 'thisMonth'; + customDateRange.value = [startDate, endDate]; + return; + } + if (daysDiff === 0 && startDate.isSame(today, 'day')) { activeTimeRange.value = 'today'; customDateRange.value = [startDate, endDate];