添加多条件筛选

This commit is contained in:
xianyi
2025-12-25 11:10:07 +08:00
parent 385bf8fa81
commit 842946d08e
2 changed files with 45 additions and 19 deletions

View File

@@ -9,7 +9,7 @@ import { cls } from '../../utils/cls';
interface ExamSectionProps {
filteredClients: ExamClient[];
selectedExamClient: ExamClient | undefined;
examFilterTag: (typeof EXAM_TAGS)[number];
examFilterTags: Set<(typeof EXAM_TAGS)[number]>;
onFilterChange: (tag: (typeof EXAM_TAGS)[number]) => void;
onOpenModal: (id: string, tab: ExamModalTab) => void;
searchValue: string;
@@ -23,7 +23,7 @@ const LOAD_MORE_COUNT = 9; // 每次加载更多时的数量
export const ExamSection = ({
filteredClients,
selectedExamClient,
examFilterTag,
examFilterTags,
onFilterChange,
onOpenModal,
searchValue,
@@ -87,7 +87,7 @@ export const ExamSection = ({
// 当 filteredClients 变化时,重置显示数量
useEffect(() => {
setDisplayCount(INITIAL_LOAD_COUNT);
}, [filteredClients.length, searchValue, examFilterTag]);
}, [filteredClients.length, searchValue, examFilterTags]);
// 懒加载:使用 Intersection Observer 监听底部元素
useEffect(() => {
@@ -158,8 +158,10 @@ export const ExamSection = ({
key={tag}
onClick={() => onFilterChange(tag)}
className={cls(
'px-3 py-1 rounded-2xl border',
examFilterTag === tag ? 'bg-gray-900 text-white border-gray-900' : 'bg-white text-gray-700',
'px-3 py-1 rounded-2xl border transition-colors',
examFilterTags.has(tag)
? 'bg-gray-900 text-white border-gray-900'
: 'bg-white text-gray-700 border-gray-200 hover:border-gray-300',
)}
>
{tag}