修复单双打 ,多选功能
This commit is contained in:
@@ -51,10 +51,10 @@ const defaultDateRange: [string, string] = [dayjs().format('YYYY-MM-DD'), dayjs(
|
||||
|
||||
const defaultFilterOptions: IFilterOptions = {
|
||||
dateRange: defaultDateRange, // 日期区间
|
||||
timeSlot: "", // 时间段
|
||||
timeSlot: [], // 时间段(多选,默认为空数组)
|
||||
ntrp: [1, 5], // NTRP 水平区间
|
||||
venueType: "", // 场地类型
|
||||
playType: "", // 玩法
|
||||
venueType: [], // 场地类型(多选,默认为空数组)
|
||||
playType: [], // 玩法(多选,默认为空数组)
|
||||
};
|
||||
|
||||
// const defaultDistance = "all"; // 默认距离
|
||||
@@ -502,7 +502,20 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
const state = get();
|
||||
const { currentPageState } = state.getCurrentPageState();
|
||||
const filterOptions = { ...currentPageState?.filterOptions, ...payload };
|
||||
const filterCount = Object.values(filterOptions).filter(Boolean).length;
|
||||
|
||||
// 计算筛选数量:排除 dateRange、ntrp 默认值,以及空数组和空字符串
|
||||
const filterCount = Object.entries(filterOptions).filter(([key, value]) => {
|
||||
if (key === 'dateRange') return false; // 日期区间不算筛选
|
||||
if (key === 'ntrp') {
|
||||
// NTRP 只有不是默认值 [1, 5] 时才算筛选
|
||||
const ntrp = value as [number, number];
|
||||
return ntrp && (ntrp[0] !== 1 || ntrp[1] !== 5);
|
||||
}
|
||||
// 数组为空数组或字符串为空字符串时不算筛选
|
||||
if (Array.isArray(value)) return value.length > 0;
|
||||
if (typeof value === 'string') return value !== '';
|
||||
return Boolean(value);
|
||||
}).length;
|
||||
|
||||
// 先更新状态
|
||||
state.updateCurrentPageState({
|
||||
|
||||
Reference in New Issue
Block a user