增加日历

This commit is contained in:
李瑞
2025-09-08 23:23:19 +08:00
parent 4d79c79a97
commit 8a1a2af1e9
5 changed files with 19 additions and 62 deletions

View File

@@ -6,7 +6,6 @@ import styles from "./index.module.scss";
import { Button } from "@nutui/nutui-react-taro";
import { useListStore } from "src/store/listStore";
import { BubbleOption, FilterPopupProps } from "../../../types/list/types";
import dateRangeUtils from '@/utils/dateRange'
import dayjs from "dayjs";
import { CalendarUI } from "@/components";
// 场地
@@ -16,13 +15,6 @@ import GamePlayType from "@/components/GamePlayType";
import { useDictionaryActions } from "@/store/dictionaryStore";
import { View } from "@tarojs/components";
const dateTrabseformMap = {
'1': dateRangeUtils.getThisWeekend,
'2': dateRangeUtils.getNextWeekRange,
'3': dateRangeUtils.getNextMonthRange
}
const FilterPopup = (props: FilterPopupProps) => {
const {
loading,
@@ -44,12 +36,13 @@ const FilterPopup = (props: FilterPopupProps) => {
* @param dictionaryValue 字典选项
* @returns 选项列表
*/
const [selectedDates, setSelectedDates] = useState<String[]>([])
// const [selectedDates, setSelectedDates] = useState<String[]>([])
const handleDateChange = (dates: Date[]) => {
const dateArray = dates.map(date => dayjs(date).format('YYYY-MM-DD'))
setSelectedDates(dateArray)
console.log('选中的日期:', dateArray)
onChange({
'dateRange': dateArray,
})
}
const handleOptions = (dictionaryValue: []) => {
@@ -89,29 +82,6 @@ const FilterPopup = (props: FilterPopupProps) => {
onCancel();
};
/**
* @description 日期选择
* @param date 日期
*/
const handleDateRangeChange = (date: Date) => {
onChange({
'dateRange': [date, date],
'dateRangeQuick': '',
})
}
/**
* @description 点击 本周末 一周内 一月内
*/
const handleDateRangeQuickClick = (name, value) => {
const date = dateTrabseformMap?.[value]()
onChange({
'dateRange': [date?.start, date?.end],
[name]: value,
})
}
return (
<>
<Popup
@@ -127,22 +97,10 @@ const FilterPopup = (props: FilterPopupProps) => {
<div className={styles.filterPopupWrapper}>
{/* 日历 */}
<View>
{/* 快捷选日期 */}
<View>
<Bubble
options={dateRangeOptions}
value={filterOptions?.dateRangeQuick}
onChange={handleDateRangeQuickClick}
layout="grid"
size="small"
columns={3}
name="dateRangeQuick"
/>
</View>
<CalendarUI
type="multiple"
isBorder={true}
value={selectedDates}
value={filterOptions?.dateRange}
onChange={handleDateChange}
/>
</View>
@@ -164,9 +122,10 @@ const FilterPopup = (props: FilterPopupProps) => {
max={5.0}
step={0.5}
className={styles.filterPopupRange}
onChange={handleFilterChange}
onChange={(value) => {
handleFilterChange("ntrp", value)
}}
value={filterOptions?.ntrp}
name="ntrp"
/>
{/* 场次气泡选项 */}

View File

@@ -16,7 +16,7 @@ interface RangeProps {
};
disabled?: boolean;
className?: string;
name: string;
name?: string;
showTitle?: boolean;
}
@@ -64,7 +64,7 @@ const NtrpRange: React.FC<RangeProps> = ({
if (Number(start) === Number(min) && Number(end) === Number(max)) {
return "不限";
}
return `${start.toFixed(1)} - ${end.toFixed(1)}之间`;
return `${start?.toFixed(1)} - ${end?.toFixed(1)}之间`;
}, [JSON.stringify(currentValue || []), min, max]);
return (