From fa9a165e9fa65a144b39981fd027810ad6daac28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9F=91=E8=9E=82?= Date: Tue, 28 Apr 2026 09:34:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(ecom-dmb):=20=E6=A6=82=E8=A7=88=E9=A1=B5?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4=E6=96=B0=E5=A2=9E'?= =?UTF-8?q?=E6=9C=AC=E6=9C=88'=E5=BF=AB=E6=8D=B7=E9=80=89=E9=A1=B9?= =?UTF-8?q?=EF=BC=8C=E9=BB=98=E8=AE=A4=E6=94=B9=E4=B8=BA=E6=9C=AC=E6=9C=88?= =?UTF-8?q?=E8=87=B3=E4=BB=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/dashboard/store-overview/index.vue | 37 ++++++++++++++++--- .../overview/components/TimeRangeBar.vue | 29 ++++++++++++++- .../ecommerce/product/overview/index.vue | 8 ++-- .../shop/overview/components/TimeRangeBar.vue | 29 ++++++++++++++- .../views/ecommerce/shop/overview/index.vue | 17 +++++++-- 5 files changed, 103 insertions(+), 17 deletions(-) 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];