fix: 将"近两周"时间范围选项改为"上周数据"

修改时间范围选项从"近两周"变为"上周数据",并调整对应的日期计算逻辑,使其准确获取上周一到上周日的数据
This commit is contained in:
2025-11-02 16:33:50 +08:00
parent 3f69ebd3ba
commit bfc3fcd7fd

View File

@@ -46,21 +46,21 @@
:class="{ active: timeRange === 'daily' }" :class="{ active: timeRange === 'daily' }"
@click="setTimeRange('daily')" @click="setTimeRange('daily')"
> >
</div> </div>
<div <div
class="switch-option" class="switch-option"
:class="{ active: timeRange === 'weekly' }" :class="{ active: timeRange === 'weekly' }"
@click="setTimeRange('weekly')" @click="setTimeRange('weekly')"
> >
</div> </div>
<div <div
class="switch-option" class="switch-option"
:class="{ active: timeRange === 'twoweekly' }" :class="{ active: timeRange === 'lastWeek' }"
@click="setTimeRange('twoweekly')" @click="setTimeRange('lastWeek')"
> >
近两
</div> </div>
</div> </div>
</div> </div>
@@ -309,10 +309,10 @@ export default {
// 本周(周一到周日)- 设置周起始日为周一 // 本周(周一到周日)- 设置周起始日为周一
this.search.startTime = today.startOf("week", { weekStart: 1 }).toDate(); this.search.startTime = today.startOf("week", { weekStart: 1 }).toDate();
this.search.endTime = today.endOf("week", { weekStart: 1 }).toDate(); this.search.endTime = today.endOf("week", { weekStart: 1 }).toDate();
} else if (type === "twoweekly") { } else if (type === "lastWeek") {
// 近两周当前日期向前推14天 // 上周(上周周一到上周周日)- 设置周起始日为周一
this.search.startTime = today.subtract(14, 'day').startOf('day').toDate(); this.search.startTime = today.subtract(1, "week").startOf("week", { weekStart: 1 }).toDate();
this.search.endTime = today.endOf('day').toDate(); this.search.endTime = today.subtract(1, "week").endOf("week", { weekStart: 1 }).toDate();
} }
// 重新查询数据 // 重新查询数据