Commit 6d0763a4 by Lin

fix(clendarCustom): 更新日期范围选择器逻辑以修正结束日期计算

- 修改当前周的结束日期计算逻辑,从今天改为该周的周日,确保日期范围选择的准确性。
- 优化模板结构,保持代码整洁性和可读性。
1 parent b3fbe3ed
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
<!-- 隐藏的日期选择器 --> <!-- 隐藏的日期选择器 -->
<el-date-picker ref="datePicker" <el-date-picker ref="datePicker"
v-model="datePickerValue" v-model="datePickerValue"
type="daterange" class="hidden-date-picker"
end-placeholder="结束日期"
range-separator="至" range-separator="至"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" type="daterange"
:picker-options="pickerOptions" :picker-options="pickerOptions"
class="hidden-date-picker"
@change="handleDatePickerChange" @change="handleDatePickerChange"
@pick="handleDatePick"> @pick="handleDatePick">
</el-date-picker> </el-date-picker>
...@@ -134,12 +134,12 @@ const DateUtils = { ...@@ -134,12 +134,12 @@ const DateUtils = {
// 日期范围策略配置 // 日期范围策略配置
const DateRangeStrategies = { const DateRangeStrategies = {
周: { 周: {
// 初始化:当前周(当前周的周一到今天) // 初始化:当前周(当前周的周一到周日)
init(now) { init(now) {
const currentWeekMonday = DateUtils.getCurrentWeekMonday(now); const currentWeekMonday = DateUtils.getCurrentWeekMonday(now);
return { return {
startDate: currentWeekMonday, startDate: currentWeekMonday,
endDate: DateUtils.resetToEndOfDay(now), endDate: DateUtils.getWeekSunday(currentWeekMonday),
}; };
}, },
...@@ -155,8 +155,8 @@ const DateRangeStrategies = { ...@@ -155,8 +155,8 @@ const DateRangeStrategies = {
let newEndDate; let newEndDate;
if (newStart.getTime() === currentWeekMonday.getTime()) { if (newStart.getTime() === currentWeekMonday.getTime()) {
// 当前周:结束时间为今天 // 当前周:结束时间为该周的周日
newEndDate = DateUtils.resetToEndOfDay(now); newEndDate = DateUtils.getWeekSunday(currentWeekMonday);
} else if (newSunday > now) { } else if (newSunday > now) {
// 未来周:不应该执行(由canSwitchNext控制) // 未来周:不应该执行(由canSwitchNext控制)
return null; return null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!