| | |
| | | |
| | | // 统计维度切换 |
| | | const handleTypeChange = () => { |
| | | // 重置时间范围 |
| | | searchForm.dateRange = []; |
| | | searchForm.monthRange = []; |
| | | searchForm.year = new Date().getFullYear(); |
| | | // 重置时间范围并设置默认值 |
| | | const end = new Date(); |
| | | const start = new Date(); |
| | | |
| | | if (statisticsType.value === "day") { |
| | | // 默认最近7天 |
| | | start.setDate(start.getDate() - 6); |
| | | searchForm.dateRange = [ |
| | | start.toISOString().split("T")[0], |
| | | end.toISOString().split("T")[0], |
| | | ]; |
| | | } else if (statisticsType.value === "month") { |
| | | // 默认最近3个月 |
| | | start.setMonth(start.getMonth() - 2); |
| | | searchForm.monthRange = [ |
| | | start.toISOString().slice(0, 7), |
| | | end.toISOString().slice(0, 7), |
| | | ]; |
| | | } else if (statisticsType.value === "year") { |
| | | // 默认当前年份 |
| | | searchForm.year = new Date().getFullYear(); |
| | | } |
| | | |
| | | page.current = 1; |
| | | handleQuery(); |
| | | }; |