mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix: date field range selection excludes the max date (#6418)
This commit is contained in:
parent
f76ce346f7
commit
3e1b828fc7
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user