修改日历

This commit is contained in:
筱野
2025-10-11 21:36:12 +08:00
parent 6dc4c57e5b
commit f7ebe5471c
11 changed files with 43 additions and 29 deletions

View File

@@ -2,7 +2,7 @@
.common-popup {
position: fixed;
z-index: 99999!important;
z-index: 9999!important;
.common-popup__drag-handle-container {
position: position;
}

View File

@@ -39,10 +39,21 @@ const FilterPopup = (props: FilterPopupProps) => {
// const [selectedDates, setSelectedDates] = useState<String[]>([])
const handleDateChange = (dates: Date[]) => {
const dateArray = dates.map(date => dayjs(date).format('YYYY-MM-DD'))
console.log(dates,'datesdatesdatesdatesdates');
let times: String[] = [];
if (Array.isArray(dates)) {
const currentDay = dayjs(dates[0]).format('YYYY-MM-DD');
if (filterOptions.dateRange.length === 0 || filterOptions.dateRange.length === 2) {
times.push(currentDay);
} else {
times = [...filterOptions.dateRange, currentDay].sort(
(a, b) => new Date(a).getTime() - new Date(b).getTime()
)
}
}
onChange({
'dateRange': dateArray,
'dateRange': times,
})
}
@@ -113,8 +124,9 @@ const FilterPopup = (props: FilterPopupProps) => {
{/* 日历 */}
<View>
<CalendarUI
type="multiple"
type="range"
isBorder={true}
showRangeStart={false}
value={filterOptions?.dateRange}
onChange={handleDateChange}
/>

View File

@@ -18,6 +18,7 @@ interface NutUICalendarProps {
isBorder?: boolean;
showQuickActions?: boolean;
onHeaderClick?: (date: Date) => void;
showRangeStart?: boolean;
}
export interface CalendarUIRef {
@@ -32,6 +33,7 @@ const NutUICalendar = React.forwardRef<CalendarUIRef, NutUICalendarProps>(
value,
onChange,
isBorder = false,
showRangeStart = true,
showQuickActions = true,
onHeaderClick,
},
@@ -195,7 +197,7 @@ const NutUICalendar = React.forwardRef<CalendarUIRef, NutUICalendarProps>(
isBorder ? styles["border"] : ""
}`}
>
{type === "range" && (
{type === "range" && showRangeStart && (
<View className={styles["date-range-container"]}>
<Text
className={`${styles["date-text-placeholder"]} ${

View File

@@ -125,7 +125,7 @@
}
.cell {
height: 44px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
@@ -142,8 +142,8 @@
}
.cell-text.selected {
width: 44px;
height: 44px;
width: 40px;
height: 40px;
border-radius: 22px;
background: rgba(0, 0, 0, 0.9);
color: #fff;
@@ -154,8 +154,8 @@
// 时间段选择样式
.cell-text.range-start {
width: 44px;
height: 44px;
width: 40px;
height: 40px;
border-radius: 22px;
background: rgba(0, 0, 0, 0.9);
color: #fff;
@@ -165,8 +165,8 @@
}
.cell-text.range-end {
width: 44px;
height: 44px;
width: 40px;
height: 40px;
border-radius: 22px;
background: rgba(0, 0, 0, 0.9);
color: #fff;
@@ -176,8 +176,8 @@
}
.cell-text.in-range {
width: 44px;
height: 44px;
width: 40px;
height: 40px;
border-radius: 22px;
background: rgba(0, 0, 0, 0.1);
color: #000;
@@ -193,7 +193,7 @@
.btn {
flex: 1;
height: 44px;
height: 40px;
border-radius: 22px;
background: rgba(0, 0, 0, 0.06);
display: flex;
@@ -299,18 +299,18 @@
.nut-calendarcard-day {
margin-bottom: 0px !important;
height: 44px;
width: 44px !important;
height: 40px;
width: 40px !important;
&.active {
background-color: #000 !important;
color: #fff !important;
height: 44px;
height: 40px;
border-radius: 22px !important;
display: flex;
align-items: center;
justify-content: center;
width: 44px !important;
width: 40px !important;
font-size: 24px !important;
.day-container {
@@ -333,8 +333,8 @@
.day-container {
background-color: #f5f5f5;
border-radius: 22px;
width: 44px;
height: 44px;
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;