diff --git a/src/pages/user/DeviceDetailModal.jsx b/src/pages/user/DeviceDetailModal.jsx index 36b947a..b87d040 100644 --- a/src/pages/user/DeviceDetailModal.jsx +++ b/src/pages/user/DeviceDetailModal.jsx @@ -60,20 +60,27 @@ export default function DeviceDetailModal({ visiable, device, onclose }) { }, [visiable, device?.deviceId]); const { RangePicker } = DatePicker; - const disabledDate = (current) => { + const disabledDate = (current, { from } = {}) => { if (!current) return false; + const today = dayjs().startOf("day"); const currentDay = current.startOf("day"); + + // 禁用过去日期 const isPastDate = current.isBefore(today); + // 禁用不可预约时间段 dayjs.extend(isBetween); - const isUnavailable = unavailableTimes.some(({ startTime, endTime }) => { const start = dayjs(startTime).startOf("day"); const end = dayjs(endTime).endOf("day"); return currentDay.isBetween(start, end, null, "[]"); }); - return isPastDate || isUnavailable; + + // 限制选择范围为 7 天内(从 from 开始算起) + const isExceedingRange = from && Math.abs(current.diff(from, "day")) >= 7; + + return isPastDate || isUnavailable || isExceedingRange; }; const handleOK = async () => {