fix: date field range selection excludes the max date (#6418)

This commit is contained in:
Katherine 2025-03-11 21:51:44 +08:00 committed by GitHub
parent f76ce346f7
commit 3e1b828fc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -90,13 +90,13 @@ export const DatePicker: ComposedDatePicker = (props: any) => {
// 根据最小日期和最大日期限定日期时间 // 根据最小日期和最大日期限定日期时间
const disabledDate = (current) => { const disabledDate = (current) => {
if (!current || (!minDateTime && !maxDateTime)) { if (!dayjs.isDayjs(current)) return false;
return false;
}
// 确保 current 是一个 dayjs 对象
const currentDate = dayjs(current); const currentDate = dayjs(current);
//在minDateTime或maxDateTime为null时 dayjs的比较函数会默认返回false 所以不做特殊判断 const min = minDateTime ? dayjs(minDateTime) : null;
return currentDate.isBefore(minDateTime, 'minute') || currentDate.isAfter(maxDateTime, 'minute'); const max = maxDateTime ? dayjs(maxDateTime).endOf('day') : null; // 设为 23:59:59
return (min && currentDate.isBefore(min, 'minute')) || (max && currentDate.isAfter(max, 'minute'));
}; };
// 禁用时分秒 // 禁用时分秒
@ -154,6 +154,8 @@ export const DatePicker: ComposedDatePicker = (props: any) => {
}); });
}; };
console.log(disabledDate);
const newProps = { const newProps = {
utc, utc,
...props, ...props,