代码:// 禁止选中日期的函数
const disabledDate = (current) => {
const monthEnd = dayjs().subtract(2, "day").endOf("month"); // 截止日期
return (
dayDisable.some((item) => {
const currentDate = dayjs(current).format("YYYY-MM-DD");
return dayjs(item).isSame(currentDate);
}) || current >= monthEnd
);
};
// 禁止选择的周日期
const weekdisabledDate = (current) => {
return dayDisable.some((item) => {
return current >= dayjs(item) && current <= dayjs(item).endOf("week");
});
};
// 禁止选择的月日期
const monthdisabledDate = (current) => {
return dayDisable.some((item) => {
return current >= dayjs(item) && current <= dayjs(item).endOf("month");
});
};
// 禁止选择的季度日期
const quarterdisabledDate = (current) => {
return dayDisable.some((item) => {
return current >= dayjs(item) && current <= dayjs(item).endOf("quarter");
});
};
最终效果
其他周、月、季度 只需要后端返回起始的日期就行,通过dayjs(‘2024-04-01’).endOf("month");来获取截至日期