Files
shz-admin/src/pages/Jobfair/Outdoorfair/Detail/index.tsx

113 lines
3.7 KiB
TypeScript
Raw Normal View History

2026-06-18 02:30:11 +08:00
import React, { useState, useEffect } from 'react';
import { history, useSearchParams } from '@umijs/max';
import { PageContainer } from '@ant-design/pro-components';
import { Tabs, Button, Spin, message } from 'antd';
import { ArrowLeftOutlined } from '@ant-design/icons';
import { getOutdoorFairInfo } from '@/services/jobportal/outdoorFair';
2026-06-18 02:30:11 +08:00
import type { OutdoorFairItem } from '@/services/jobportal/outdoorFair';
import FairInfoTab from './components/FairInfoTab';
import BoothTab from './components/BoothTab';
import CompanyReviewTab from './components/CompanyReviewTab';
import AttendeeTab from './components/AttendeeTab';
import DeviceTab from './components/DeviceTab';
import StatisticsTab from './components/StatisticsTab';
const OutdoorFairDetail: React.FC = () => {
const [searchParams] = useSearchParams();
const fairId = Number(searchParams.get('id'));
const [fairInfo, setFairInfo] = useState<OutdoorFairItem | null>(null);
const [loading, setLoading] = useState(true);
const [activeTab, setActiveTab] = useState('fair-info');
const [fairInfoRefreshKey, setFairInfoRefreshKey] = useState(0);
2026-06-18 02:30:11 +08:00
const fetchFairInfo = async () => {
setLoading(true);
try {
const res = await getOutdoorFairInfo(fairId);
if (res.code === 200 && res.data) {
setFairInfo(res.data);
2026-06-18 02:30:11 +08:00
} else {
message.error(res.msg || '未找到该招聘会信息');
2026-06-18 02:30:11 +08:00
}
} finally {
setLoading(false);
}
};
useEffect(() => {
if (fairId) {
fetchFairInfo();
}
}, [fairId]);
const tabItems = [
{ key: 'fair-info', label: '招聘会管理' },
{ key: 'booth', label: '展位图' },
2026-06-18 02:30:11 +08:00
{ key: 'company-review', label: '参会单位管理' },
{ key: 'attendee', label: '参会人员管理' },
{ key: 'device', label: '入场设备管理' },
{ key: 'statistics', label: '数据统计' },
];
const handleTabChange = (key: string) => {
setActiveTab(key);
if (key === 'fair-info') {
setFairInfoRefreshKey((prev) => prev + 1);
}
};
2026-06-18 02:30:11 +08:00
return (
<PageContainer
header={{
title: fairInfo ? `招聘会详情 — ${fairInfo.title}` : '加载中...',
onBack: () => history.back(),
extra: [
<Button key="back" icon={<ArrowLeftOutlined />} onClick={() => history.back()}>
</Button>,
],
}}
>
<Spin spinning={loading}>
{fairInfo && (
<Tabs
activeKey={activeTab}
onChange={handleTabChange}
2026-06-18 02:30:11 +08:00
items={tabItems.map((tab) => ({
key: tab.key,
label: tab.label,
children: (() => {
switch (tab.key) {
case 'fair-info':
return (
<FairInfoTab
fairId={fairId}
fairInfo={fairInfo}
refreshKey={fairInfoRefreshKey}
onFairUpdate={fetchFairInfo}
/>
);
2026-06-18 02:30:11 +08:00
case 'booth':
return <BoothTab fairId={fairId} fairInfo={fairInfo} />;
2026-06-18 02:30:11 +08:00
case 'company-review':
return <CompanyReviewTab fairId={fairId} />;
case 'attendee':
return <AttendeeTab fairId={fairId} />;
case 'device':
return <DeviceTab fairId={fairId} />;
case 'statistics':
return <StatisticsTab fairId={fairId} />;
default:
return null;
}
})(),
}))}
/>
)}
</Spin>
</PageContainer>
);
};
export default OutdoorFairDetail;