fix: reset fair statistics filters on type switch
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user