2026-07-23 18:13:30 +08:00
|
|
|
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
2026-06-26 11:26:08 +08:00
|
|
|
|
import {
|
2026-07-23 18:13:30 +08:00
|
|
|
|
Button,
|
2026-06-26 11:26:08 +08:00
|
|
|
|
Card,
|
|
|
|
|
|
Col,
|
|
|
|
|
|
DatePicker,
|
|
|
|
|
|
Empty,
|
|
|
|
|
|
Row,
|
|
|
|
|
|
Segmented,
|
2026-07-23 18:13:30 +08:00
|
|
|
|
Select,
|
2026-06-26 11:26:08 +08:00
|
|
|
|
Spin,
|
|
|
|
|
|
Statistic,
|
|
|
|
|
|
Table,
|
|
|
|
|
|
message,
|
|
|
|
|
|
} from 'antd';
|
2026-07-23 18:13:30 +08:00
|
|
|
|
import { InfoCircleOutlined } from '@ant-design/icons';
|
2026-06-26 11:26:08 +08:00
|
|
|
|
import { PageContainer } from '@ant-design/pro-components';
|
|
|
|
|
|
import type { ColumnsType } from 'antd/es/table';
|
2026-07-23 18:13:30 +08:00
|
|
|
|
import { getPublicJobFairList } from '@/services/jobfair/publicJobFair';
|
|
|
|
|
|
import { getOutdoorFairList } from '@/services/jobportal/outdoorFair';
|
|
|
|
|
|
import {
|
|
|
|
|
|
getFairStatisticsSummary,
|
|
|
|
|
|
type FairStatisticsFairItem,
|
|
|
|
|
|
type FairStatisticsSummary,
|
|
|
|
|
|
type RecruitmentFairType,
|
|
|
|
|
|
} from '@/services/jobfair/fairStatistics';
|
2026-06-26 11:26:08 +08:00
|
|
|
|
|
|
|
|
|
|
const { RangePicker } = DatePicker;
|
2026-07-23 18:13:30 +08:00
|
|
|
|
|
|
|
|
|
|
type StatisticsScope = 'single' | 'range';
|
|
|
|
|
|
|
|
|
|
|
|
interface FairOption {
|
|
|
|
|
|
value: string;
|
|
|
|
|
|
label: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const formatDate = (value: any): string | undefined =>
|
|
|
|
|
|
value && typeof value.format === 'function' ? value.format('YYYY-MM-DD') : undefined;
|
2026-06-26 11:26:08 +08:00
|
|
|
|
|
|
|
|
|
|
const FairStatistics: React.FC = () => {
|
2026-07-23 18:13:30 +08:00
|
|
|
|
const [fairType, setFairType] = useState<RecruitmentFairType>('online');
|
|
|
|
|
|
const [scope, setScope] = useState<StatisticsScope>('single');
|
|
|
|
|
|
const [fairOptions, setFairOptions] = useState<FairOption[]>([]);
|
|
|
|
|
|
const [selectedFairId, setSelectedFairId] = useState<string>();
|
2026-06-26 11:26:08 +08:00
|
|
|
|
const [dateRange, setDateRange] = useState<any>(null);
|
2026-07-23 18:13:30 +08:00
|
|
|
|
const [loadingFairs, setLoadingFairs] = useState(false);
|
|
|
|
|
|
const [loadingSummary, setLoadingSummary] = useState(false);
|
|
|
|
|
|
const [summary, setSummary] = useState<FairStatisticsSummary>();
|
2026-06-26 11:26:08 +08:00
|
|
|
|
|
2026-07-23 18:13:30 +08:00
|
|
|
|
const interactionLabel = fairType === 'online' ? '投递岗位数' : '签到数';
|
|
|
|
|
|
const interactionUnit = fairType === 'online' ? '个' : '人次';
|
|
|
|
|
|
|
|
|
|
|
|
const loadFairOptions = useCallback(async (type: RecruitmentFairType) => {
|
|
|
|
|
|
setLoadingFairs(true);
|
2026-06-26 11:26:08 +08:00
|
|
|
|
try {
|
2026-07-23 18:13:30 +08:00
|
|
|
|
if (type === 'online') {
|
|
|
|
|
|
const res = await getPublicJobFairList({ pageNum: 1, pageSize: 1000, jobFairType: '1' });
|
|
|
|
|
|
if (res.code !== 200) {
|
|
|
|
|
|
message.error(res.msg || '线上招聘会列表加载失败');
|
|
|
|
|
|
setFairOptions([]);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
setFairOptions(
|
|
|
|
|
|
(res.rows || []).map((item) => ({
|
|
|
|
|
|
value: String(item.jobFairId),
|
|
|
|
|
|
label: `${item.jobFairTitle}${item.jobFairStartTime ? `(${item.jobFairStartTime})` : ''}`,
|
|
|
|
|
|
})),
|
|
|
|
|
|
);
|
2026-06-26 11:26:08 +08:00
|
|
|
|
} else {
|
2026-07-23 18:13:30 +08:00
|
|
|
|
const res = await getOutdoorFairList({ current: 1, pageSize: 1000 });
|
|
|
|
|
|
if (res.code !== 200) {
|
|
|
|
|
|
message.error(res.msg || '户外招聘会列表加载失败');
|
|
|
|
|
|
setFairOptions([]);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
setFairOptions(
|
|
|
|
|
|
(res.rows || []).map((item) => ({
|
|
|
|
|
|
value: String(item.id),
|
|
|
|
|
|
label: `${item.title}${item.holdTime ? `(${item.holdTime})` : ''}`,
|
|
|
|
|
|
})),
|
|
|
|
|
|
);
|
2026-06-26 11:26:08 +08:00
|
|
|
|
}
|
2026-07-23 18:13:30 +08:00
|
|
|
|
} catch {
|
|
|
|
|
|
message.error('招聘会列表加载失败,请稍后重试');
|
|
|
|
|
|
setFairOptions([]);
|
2026-06-26 11:26:08 +08:00
|
|
|
|
} finally {
|
2026-07-23 18:13:30 +08:00
|
|
|
|
setLoadingFairs(false);
|
2026-06-26 11:26:08 +08:00
|
|
|
|
}
|
2026-07-23 18:13:30 +08:00
|
|
|
|
}, []);
|
2026-06-26 11:26:08 +08:00
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2026-07-23 18:13:30 +08:00
|
|
|
|
setSelectedFairId(undefined);
|
|
|
|
|
|
setDateRange(null);
|
|
|
|
|
|
setSummary(undefined);
|
|
|
|
|
|
loadFairOptions(fairType);
|
|
|
|
|
|
}, [fairType, loadFairOptions]);
|
|
|
|
|
|
|
|
|
|
|
|
const queryReady = useMemo(() => {
|
|
|
|
|
|
if (scope === 'single') return Boolean(selectedFairId);
|
|
|
|
|
|
return Boolean(dateRange?.[0] && dateRange?.[1]);
|
|
|
|
|
|
}, [dateRange, scope, selectedFairId]);
|
|
|
|
|
|
|
|
|
|
|
|
const loadSummary = useCallback(async () => {
|
|
|
|
|
|
if (!queryReady) {
|
|
|
|
|
|
setSummary(undefined);
|
|
|
|
|
|
return;
|
2026-06-26 11:26:08 +08:00
|
|
|
|
}
|
2026-07-23 18:13:30 +08:00
|
|
|
|
setLoadingSummary(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getFairStatisticsSummary({
|
|
|
|
|
|
fairType,
|
|
|
|
|
|
fairId: scope === 'single' ? selectedFairId : undefined,
|
|
|
|
|
|
startDate: scope === 'range' ? formatDate(dateRange?.[0]) : undefined,
|
|
|
|
|
|
endDate: scope === 'range' ? formatDate(dateRange?.[1]) : undefined,
|
|
|
|
|
|
});
|
|
|
|
|
|
if (res.code === 200 && res.data) {
|
|
|
|
|
|
setSummary(res.data);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setSummary(undefined);
|
|
|
|
|
|
message.error(res.msg || '统计数据加载失败');
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
setSummary(undefined);
|
|
|
|
|
|
message.error('统计数据加载失败,请稍后重试');
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoadingSummary(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [dateRange, fairType, queryReady, scope, selectedFairId]);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
loadSummary();
|
|
|
|
|
|
}, [loadSummary]);
|
|
|
|
|
|
|
|
|
|
|
|
const columns: ColumnsType<FairStatisticsFairItem> = useMemo(
|
|
|
|
|
|
() => [
|
|
|
|
|
|
{ title: '招聘会名称', dataIndex: 'fairTitle', ellipsis: true },
|
|
|
|
|
|
{ title: '起始时间', dataIndex: 'startTime', width: 180, render: (value) => value || '--' },
|
|
|
|
|
|
{ title: '参会单位数', dataIndex: 'companyCount', width: 110, align: 'right' },
|
|
|
|
|
|
{ title: '职位数', dataIndex: 'jobCount', width: 90, align: 'right' },
|
|
|
|
|
|
{ title: '需求人数', dataIndex: 'demandCount', width: 100, align: 'right' },
|
|
|
|
|
|
{ title: interactionLabel, dataIndex: 'interactionCount', width: 120, align: 'right' },
|
|
|
|
|
|
],
|
|
|
|
|
|
[interactionLabel],
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const statisticsCards = [
|
|
|
|
|
|
{ title: '参会单位数', value: summary?.companyCount ?? 0, suffix: '家' },
|
|
|
|
|
|
{ title: '职位数', value: summary?.jobCount ?? 0, suffix: '个' },
|
|
|
|
|
|
{ title: '需求人数', value: summary?.demandCount ?? 0, suffix: '人' },
|
|
|
|
|
|
{ title: interactionLabel, value: summary?.interactionCount ?? 0, suffix: interactionUnit },
|
2026-06-26 11:26:08 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<PageContainer
|
|
|
|
|
|
header={{ title: '招聘会数据统计' }}
|
2026-07-23 18:13:30 +08:00
|
|
|
|
content="分别统计线上招聘会与户外招聘会;可查看单场招聘会,或按招聘会起始时间汇总一个时间段。"
|
2026-06-26 11:26:08 +08:00
|
|
|
|
>
|
|
|
|
|
|
<Card style={{ marginBottom: 16 }}>
|
2026-07-23 18:13:30 +08:00
|
|
|
|
<Row gutter={[16, 16]} align="middle">
|
|
|
|
|
|
<Col>
|
|
|
|
|
|
<Button.Group>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type={fairType === 'online' ? 'primary' : 'default'}
|
|
|
|
|
|
onClick={() => setFairType('online')}
|
|
|
|
|
|
>
|
|
|
|
|
|
线上招聘会
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type={fairType === 'outdoor' ? 'primary' : 'default'}
|
|
|
|
|
|
onClick={() => setFairType('outdoor')}
|
|
|
|
|
|
>
|
|
|
|
|
|
户外招聘会
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Button.Group>
|
|
|
|
|
|
</Col>
|
2026-06-26 11:26:08 +08:00
|
|
|
|
<Col>
|
2026-07-23 18:13:30 +08:00
|
|
|
|
<span style={{ marginRight: 8 }}>统计范围</span>
|
2026-06-26 11:26:08 +08:00
|
|
|
|
<Segmented
|
2026-07-23 18:13:30 +08:00
|
|
|
|
value={scope}
|
|
|
|
|
|
options={[
|
|
|
|
|
|
{ label: '统计单场', value: 'single' },
|
|
|
|
|
|
{ label: '按起始时间统计', value: 'range' },
|
|
|
|
|
|
]}
|
|
|
|
|
|
onChange={(value) => {
|
|
|
|
|
|
setScope(value as StatisticsScope);
|
|
|
|
|
|
setSummary(undefined);
|
|
|
|
|
|
}}
|
2026-06-26 11:26:08 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col flex="auto">
|
2026-07-23 18:13:30 +08:00
|
|
|
|
{scope === 'single' ? (
|
|
|
|
|
|
<Select
|
|
|
|
|
|
allowClear
|
|
|
|
|
|
showSearch
|
|
|
|
|
|
placeholder={`请选择一场${fairType === 'online' ? '线上' : '户外'}招聘会`}
|
|
|
|
|
|
optionFilterProp="label"
|
|
|
|
|
|
loading={loadingFairs}
|
|
|
|
|
|
value={selectedFairId}
|
|
|
|
|
|
options={fairOptions}
|
|
|
|
|
|
onChange={(value) => setSelectedFairId(value)}
|
|
|
|
|
|
style={{ width: '100%', minWidth: 320 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<RangePicker
|
|
|
|
|
|
value={dateRange}
|
|
|
|
|
|
onChange={(value) => setDateRange(value)}
|
|
|
|
|
|
style={{ width: '100%', minWidth: 320 }}
|
|
|
|
|
|
placeholder={['起始日期', '结束日期']}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
2026-06-26 11:26:08 +08:00
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
2026-07-23 18:13:30 +08:00
|
|
|
|
<Spin spinning={loadingSummary}>
|
|
|
|
|
|
<Card
|
|
|
|
|
|
title={
|
|
|
|
|
|
summary
|
|
|
|
|
|
? `统计结果(共 ${summary.fairCount} 场${fairType === 'online' ? '线上' : '户外'}招聘会)`
|
|
|
|
|
|
: '统计结果'
|
|
|
|
|
|
}
|
|
|
|
|
|
style={{ marginBottom: 16 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
{queryReady ? (
|
|
|
|
|
|
<Row gutter={[16, 16]}>
|
|
|
|
|
|
{statisticsCards.map((item) => (
|
|
|
|
|
|
<Col key={item.title} xs={24} sm={12} lg={6}>
|
|
|
|
|
|
<Card
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style={{ background: item.title === interactionLabel ? '#f0f5ff' : '#fafafa' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Statistic title={item.title} value={item.value} suffix={item.suffix} />
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
))}
|
2026-06-26 11:26:08 +08:00
|
|
|
|
</Row>
|
2026-07-23 18:13:30 +08:00
|
|
|
|
) : (
|
|
|
|
|
|
<Empty
|
|
|
|
|
|
description={
|
|
|
|
|
|
scope === 'single' ? '请选择一场招聘会' : '请选择完整的起始日期和结束日期'
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Card>
|
2026-06-26 11:26:08 +08:00
|
|
|
|
|
2026-07-23 18:13:30 +08:00
|
|
|
|
{summary && (
|
|
|
|
|
|
<Card title="涉及招聘会明细" style={{ marginBottom: 16 }} bodyStyle={{ paddingTop: 8 }}>
|
|
|
|
|
|
<Table<FairStatisticsFairItem>
|
|
|
|
|
|
rowKey="fairId"
|
|
|
|
|
|
columns={columns}
|
|
|
|
|
|
dataSource={summary.fairs || []}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
scroll={{ x: 860 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Card>
|
2026-06-26 11:26:08 +08:00
|
|
|
|
)}
|
|
|
|
|
|
</Spin>
|
|
|
|
|
|
|
2026-07-23 18:13:30 +08:00
|
|
|
|
<Card
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
title={
|
|
|
|
|
|
<span>
|
|
|
|
|
|
<InfoCircleOutlined style={{ color: '#1677ff', marginRight: 8 }} />
|
|
|
|
|
|
统计口径
|
|
|
|
|
|
</span>
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Row gutter={[24, 8]}>
|
|
|
|
|
|
<Col xs={24} lg={12}>
|
|
|
|
|
|
需求人数取岗位招聘数;招聘数填写“若干”、为空或非正数时,按 1 人计算。
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col xs={24} lg={12}>
|
|
|
|
|
|
{fairType === 'online'
|
|
|
|
|
|
? '线上招聘会统计投递岗位数,即本场有效招聘会岗位中至少有一条有效投递记录的岗位数。'
|
|
|
|
|
|
: '户外招聘会不提供报名投递简历,统计现场签到记录数,不显示投递岗位数。'}
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</PageContainer>
|
2026-06-26 11:26:08 +08:00
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default FairStatistics;
|