fix: reset fair statistics filters on type switch

This commit is contained in:
2026-07-23 18:29:08 +08:00
parent 1c9216dbbb
commit 4ae042dd76

View File

@@ -89,11 +89,19 @@ const FairStatistics: React.FC = () => {
}, []); }, []);
useEffect(() => { useEffect(() => {
loadFairOptions(fairType);
}, [fairType, loadFairOptions]);
const handleFairTypeChange = (type: RecruitmentFairType) => {
if (type === fairType) return;
// 切换类型时同步清空条件,避免新类型携带旧类型招聘会 ID 发起查询。
setSelectedFairId(undefined); setSelectedFairId(undefined);
setDateRange(null); setDateRange(null);
setSummary(undefined); setSummary(undefined);
loadFairOptions(fairType); setFairOptions([]);
}, [fairType, loadFairOptions]); setFairType(type);
};
const queryReady = useMemo(() => { const queryReady = useMemo(() => {
if (scope === 'single') return Boolean(selectedFairId); if (scope === 'single') return Boolean(selectedFairId);
@@ -161,13 +169,13 @@ const FairStatistics: React.FC = () => {
<Button.Group> <Button.Group>
<Button <Button
type={fairType === 'online' ? 'primary' : 'default'} type={fairType === 'online' ? 'primary' : 'default'}
onClick={() => setFairType('online')} onClick={() => handleFairTypeChange('online')}
> >
线 线
</Button> </Button>
<Button <Button
type={fairType === 'outdoor' ? 'primary' : 'default'} type={fairType === 'outdoor' ? 'primary' : 'default'}
onClick={() => setFairType('outdoor')} onClick={() => handleFairTypeChange('outdoor')}
> >
</Button> </Button>