mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 17:09:20 +08:00
feat(ecom-dmb): 概览页时间范围新增'本月'快捷选项,默认改为本月至今
This commit is contained in:
@@ -46,9 +46,9 @@ const selectedExportShopIds = ref<number[]>([]);
|
||||
const platformExportMode = ref(false);
|
||||
const selectedExportPlatformIds = ref<number[]>([]);
|
||||
|
||||
// 日期范围
|
||||
// 日期范围(默认:本月至今日)
|
||||
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日
|
||||
</Button>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none !transition-colors sm:!px-5"
|
||||
:class="
|
||||
activeTimeRange === 'thisMonth'
|
||||
? '!bg-white !text-blue-600 dark:!bg-blue-900/30 dark:!text-blue-400 !shadow-sm dark:!shadow-none'
|
||||
: '!bg-transparent !text-slate-600 dark:!bg-[hsl(222.34deg_10.43%_12.27%/50%)] dark:!text-[hsl(240deg_5%_64.9%)] hover:!bg-[hsl(240deg_3.7%_22%)]'
|
||||
"
|
||||
@click="switchTimeRange('thisMonth')"
|
||||
>
|
||||
本月
|
||||
</Button>
|
||||
</div>
|
||||
<!-- 日期选择器 -->
|
||||
<div class="flex items-center gap-2">
|
||||
|
||||
Reference in New Issue
Block a user