Commit 62840d05 by 李伟康

Merge branch 'SAAS+V5.6.0' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into SAAS+V5.6.0
2 parents 769b0cfe 70c18034
...@@ -162,8 +162,8 @@ const DateRangeStrategies = { ...@@ -162,8 +162,8 @@ const DateRangeStrategies = {
let newEndDate; let newEndDate;
if (newStart.getTime() === currentWeekMonday.getTime()) { if (newStart.getTime() === currentWeekMonday.getTime()) {
// 当前周:结束时间为当前时间 // 当前周:结束时间为整周的周日(即使时间未到也按整周显示)
newEndDate = new Date(now); newEndDate = newSunday;
} else if (newSunday > now) { } else if (newSunday > now) {
// 未来周:不应该执行(由canSwitchNext控制) // 未来周:不应该执行(由canSwitchNext控制)
return null; return null;
...@@ -180,9 +180,20 @@ const DateRangeStrategies = { ...@@ -180,9 +180,20 @@ const DateRangeStrategies = {
// 检查是否可以切换到下一个时间段 // 检查是否可以切换到下一个时间段
canSwitchNext(currentRange, now) { canSwitchNext(currentRange, now) {
const currentWeekMonday = DateUtils.getCurrentWeekMonday(now);
const currentWeekSunday = DateUtils.getWeekSunday(currentWeekMonday);
// 如果当前范围是当前周,则不能再往前切换
if (currentRange.startDate.getTime() === currentWeekMonday.getTime()) {
return false;
}
// 计算下一个时间段的结束日期
const newEndDate = new Date(currentRange.endDate); const newEndDate = new Date(currentRange.endDate);
newEndDate.setDate(currentRange.endDate.getDate() + 7); newEndDate.setDate(currentRange.endDate.getDate() + 7);
return newEndDate <= now;
// 允许切换到当前周(即使当前周还没结束)
return newEndDate <= currentWeekSunday;
} }
}, },
...@@ -205,11 +216,15 @@ const DateRangeStrategies = { ...@@ -205,11 +216,15 @@ const DateRangeStrategies = {
const newStartDate = DateUtils.getMonthFirstDay(targetDate); const newStartDate = DateUtils.getMonthFirstDay(targetDate);
const currentMonthFirstDay = DateUtils.getMonthFirstDay(now); const currentMonthFirstDay = DateUtils.getMonthFirstDay(now);
const currentMonthLastDay = DateUtils.getMonthLastDay(now);
let newEndDate; let newEndDate;
if (newStartDate >= currentMonthFirstDay) { if (newStartDate.getTime() === currentMonthFirstDay.getTime()) {
// 当前月或未来月:结束时间限制为当前时间 // 当前月:结束时间为整月的最后一天(即使时间未到也按整月取值)
newEndDate = new Date(now); newEndDate = currentMonthLastDay;
} else if (newStartDate > currentMonthFirstDay) {
// 未来月:不应该执行(由canSwitchNext控制)
return null;
} else { } else {
// 过去月:结束时间为该月的最后一天 // 过去月:结束时间为该月的最后一天
newEndDate = DateUtils.getMonthLastDay(targetDate); newEndDate = DateUtils.getMonthLastDay(targetDate);
...@@ -223,9 +238,21 @@ const DateRangeStrategies = { ...@@ -223,9 +238,21 @@ const DateRangeStrategies = {
// 检查是否可以切换到下一个时间段 // 检查是否可以切换到下一个时间段
canSwitchNext(currentRange, now) { canSwitchNext(currentRange, now) {
const newEndDate = new Date(currentRange.endDate); const currentMonthFirstDay = DateUtils.getMonthFirstDay(now);
newEndDate.setMonth(currentRange.endDate.getMonth() + 1);
return newEndDate <= now; // 如果当前范围是当前月,则不能再往前切换
if (currentRange.startDate.getTime() === currentMonthFirstDay.getTime()) {
return false;
}
// 计算下一个月的第一天
const nextMonthDate = new Date(currentRange.startDate);
nextMonthDate.setMonth(currentRange.startDate.getMonth() + 1);
const nextMonthStart = DateUtils.getMonthFirstDay(nextMonthDate);
// 如果下一个时间段是当前月或之前,则允许切换
// 允许切换到当前月(即使当前月还没结束)
return nextMonthStart.getTime() <= currentMonthFirstDay.getTime();
} }
}, },
...@@ -684,4 +711,3 @@ $bg-white: #fff; ...@@ -684,4 +711,3 @@ $bg-white: #fff;
} }
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!