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