From 0b2c1432250ee4eb738d705cf78c91dc3638fd44 Mon Sep 17 00:00:00 2001 From: BenjaminNH <1249376374@qq.com> Date: Mon, 21 Jul 2025 12:06:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E6=80=A7=E5=8F=AA=E8=83=BD=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E4=B8=83=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/user/DeviceDetailModal.jsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 () => {