zhangwencui
5 小时以前 9290ff356436b75d6dff9f13893c141bd352f43d
src/views/energyManagement/energyConsumptionStatistical/index.vue
@@ -657,10 +657,29 @@
  // 统计维度切换
  const handleTypeChange = () => {
    // 重置时间范围
    searchForm.dateRange = [];
    searchForm.monthRange = [];
    // 重置时间范围并设置默认值
    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();
  };