优化数据统计的传参以及部分展示字段以优化

This commit is contained in:
gyq
2025-11-24 16:37:49 +08:00
parent 7f76996829
commit 980f0357c1
5 changed files with 151 additions and 239 deletions

View File

@@ -0,0 +1,50 @@
import dayjs from "dayjs";
// 格式化日期范围
export function formatDateRange(range, format = "YYYY-MM-DD") {
let arr = []
switch (range) {
case "today":
// 今天
arr = [dayjs().format(format), dayjs().format(format)];
break;
case "yesterday":
// 昨天
arr = [
dayjs().add(-1, "d").format(format),
dayjs().add(-1, "d").format(format),
];
break;
case "last_7_days":
// 最近7天
arr = [
dayjs().add(-6, "d").format(format),
dayjs().format(format),
];
break;
case "last_30_days":
// 最近7天
arr = [
dayjs().add(-29, "d").format(format),
dayjs().format(format),
];
break;
case "this_week":
// 本周
arr = [
dayjs().startOf("week").format(format),
dayjs().endOf("week").format(format),
];
break;
case "this_month":
// 本周
arr = [
dayjs().startOf("month").format(format),
dayjs().endOf("month").format(format),
];
break;
default:
break;
}
return arr;
}