Commit bd7eec67 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复日期禁用不准确的问题

parent 3c3f685c
......@@ -66,21 +66,14 @@ const RangeTime: React.FC<Iprops> = (props: Iprops) => {
};
const getDisableDate = useCallback((current: Moment, mode: "startTime" | "endTime") => {
const reverseMode = mode === 'startTime' ? 'endTime' : 'startTime';
const modeTime: Moment | null = innerRangeTime[reverseMode];
const { startTime, endTime } = innerRangeTime;
// current 为当前日历上的日期, 如果返回值为true,那么表示当前日期为禁用状态
if (!modeTime) {
if (shouldGtCurrent) {
return current < currentDay.endOf(endOfUnit);
}
return false;
}
if (mode === 'startTime') {
return shouldGtCurrent ? (current < currentDay.endOf(endOfUnit) || current > (modeTime as Moment).endOf(endOfUnit)) : current > (modeTime as Moment).endOf(endOfUnit);
return shouldGtCurrent ? current <= endTime || current <= currentDay : false;
} else {
//现在的时间要大于开始的时间, true 为禁用
return shouldGtCurrent ? (current < currentDay.endOf(endOfUnit) || current < (modeTime as Moment).endOf(endOfUnit)) : current < (modeTime as Moment).endOf(endOfUnit);
return shouldGtCurrent ? current < startTime || current <= currentDay : false;
}
}, [innerRangeTime]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment