From b2b665dfb6b89a4e1fd07eb0195618844828db65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=B1=E9=87=8E?= Date: Sat, 22 Nov 2025 11:44:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=89=E4=B8=AD=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Picker/CalendarUI/CalendarUI.tsx | 21 ++++++++++++++++--- .../Picker/CalendarUI/index.module.scss | 7 +++++++ src/components/TimeSelector/TimeSelector.tsx | 3 --- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/components/Picker/CalendarUI/CalendarUI.tsx b/src/components/Picker/CalendarUI/CalendarUI.tsx index 1835e94..c4d5719 100644 --- a/src/components/Picker/CalendarUI/CalendarUI.tsx +++ b/src/components/Picker/CalendarUI/CalendarUI.tsx @@ -71,6 +71,7 @@ const NutUICalendar = React.forwardRef( const [current, setCurrent] = useState(startOfMonth(new Date())); const calendarRef = useRef(null); const [visible, setvisible] = useState(false); + const [activeQuickAction, setActiveQuickAction] = useState<'weekend' | 'week' | 'month' | null>(null); console.log("current", current); // 当外部 value 变化时更新内部状态 useEffect(() => { @@ -94,6 +95,7 @@ const NutUICalendar = React.forwardRef( const handleDateChange = (newValue: any) => { if (type === "range") return; setSelectedValue(newValue); + setActiveQuickAction(null); onChange?.(newValue as any); }; const formatHeader = (date: Date) => `${getMonth(date)}`; @@ -106,6 +108,7 @@ const NutUICalendar = React.forwardRef( const handleDayClick = (day: any) => { const { type, year, month, date } = day; if (type === "next") return; + setActiveQuickAction(null); onChange?.([new Date(year, month - 1, date)]); }; @@ -157,18 +160,21 @@ const NutUICalendar = React.forwardRef( const [start, end] = getWeekend(); setSelectedValue([start, end]); syncMonthTo(start); + setActiveQuickAction('weekend'); onChange?.([start, end]); }; const selectWeek = () => { const dayList = getWeekendOfCurrentWeek(7); setSelectedValue(dayList); syncMonthTo(dayList[0]); + setActiveQuickAction('week'); onChange?.(dayList); }; const selectMonth = () => { const dayList = getOneMonth(); setSelectedValue(dayList); syncMonthTo(dayList[0]); + setActiveQuickAction('month'); onChange?.(dayList); }; @@ -184,13 +190,22 @@ const NutUICalendar = React.forwardRef( {/* 快速操作行 */} {showQuickActions && ( - + 本周末 - + 一周内 - + 一个月 diff --git a/src/components/Picker/CalendarUI/index.module.scss b/src/components/Picker/CalendarUI/index.module.scss index e330a04..d8472ee 100644 --- a/src/components/Picker/CalendarUI/index.module.scss +++ b/src/components/Picker/CalendarUI/index.module.scss @@ -270,8 +270,15 @@ justify-content: center; align-items: center; font-size: 14px; + font-weight: 600; color: #000; flex: 1; + box-sizing: border-box; + &.active { + background: rgba(0, 0, 0, 0.9); + color: #fff; + border-color: rgba(0, 0, 0, 0.9); + } } diff --git a/src/components/TimeSelector/TimeSelector.tsx b/src/components/TimeSelector/TimeSelector.tsx index ea39047..672cf9c 100644 --- a/src/components/TimeSelector/TimeSelector.tsx +++ b/src/components/TimeSelector/TimeSelector.tsx @@ -10,10 +10,7 @@ import dayjs from 'dayjs' const parseDate = (dateStr: string): Date => { if (!dateStr) return new Date(); // 将 "yyyy-MM-dd HH:mm:ss" 转换为 "yyyy-MM-ddTHH:mm:ss" - console.log(dateStr, 'dateStrdateStrdateStr'); const isoStr = dateStr.replace(/^(\d{4}-\d{2}-\d{2})\s(\d{2}:\d{2}(?::\d{2})?)$/, '$1T$2'); - console.log(isoStr, 'isoStr'); - console.log(new Date(isoStr), 'new Date'); return new Date(isoStr); };