Compare commits
3 Commits
b4b17f2ada
...
5faf09c467
| Author | SHA1 | Date | |
|---|---|---|---|
| 5faf09c467 | |||
| 4ae042dd76 | |||
| 1c9216dbbb |
@@ -1,209 +1,292 @@
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Col,
|
||||
DatePicker,
|
||||
Empty,
|
||||
Row,
|
||||
Segmented,
|
||||
Select,
|
||||
Spin,
|
||||
Statistic,
|
||||
Table,
|
||||
Typography,
|
||||
message,
|
||||
} from 'antd';
|
||||
import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons';
|
||||
import { InfoCircleOutlined } from '@ant-design/icons';
|
||||
import { PageContainer } from '@ant-design/pro-components';
|
||||
import { Line } from '@ant-design/charts';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { getOutdoorFairStatistics } from '@/services/jobportal/outdoorFair';
|
||||
import type {
|
||||
OutdoorFairStatisticsResult,
|
||||
OutdoorFairStatisticsSeriesItem,
|
||||
} from '@/services/jobportal/outdoorFair';
|
||||
import { getPublicJobFairList } from '@/services/jobfair/publicJobFair';
|
||||
import { getOutdoorFairList } from '@/services/jobportal/outdoorFair';
|
||||
import {
|
||||
getFairStatisticsSummary,
|
||||
type FairStatisticsFairItem,
|
||||
type FairStatisticsSummary,
|
||||
type RecruitmentFairType,
|
||||
} from '@/services/jobfair/fairStatistics';
|
||||
|
||||
const { RangePicker } = DatePicker;
|
||||
const { Text } = Typography;
|
||||
|
||||
type Granularity = 'day' | 'week' | 'month' | 'year';
|
||||
type StatisticsScope = 'single' | 'range';
|
||||
|
||||
const GRAN_OPTIONS: { label: string; value: Granularity }[] = [
|
||||
{ label: '按日', value: 'day' },
|
||||
{ label: '按周', value: 'week' },
|
||||
{ label: '按月', value: 'month' },
|
||||
{ label: '按年', value: 'year' },
|
||||
];
|
||||
|
||||
const formatBound = (value: any, suffix: string): string | undefined => {
|
||||
if (value && typeof value.format === 'function') {
|
||||
return `${value.format('YYYY-MM-DD')} ${suffix}`;
|
||||
interface FairOption {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const formatDate = (value: any): string | undefined =>
|
||||
value && typeof value.format === 'function' ? value.format('YYYY-MM-DD') : undefined;
|
||||
|
||||
const FairStatistics: React.FC = () => {
|
||||
const [granularity, setGranularity] = useState<Granularity>('month');
|
||||
const [fairType, setFairType] = useState<RecruitmentFairType>('online');
|
||||
const [scope, setScope] = useState<StatisticsScope>('single');
|
||||
const [fairOptions, setFairOptions] = useState<FairOption[]>([]);
|
||||
const [selectedFairId, setSelectedFairId] = useState<string>();
|
||||
const [dateRange, setDateRange] = useState<any>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [result, setResult] = useState<OutdoorFairStatisticsResult | null>(null);
|
||||
const [loadingFairs, setLoadingFairs] = useState(false);
|
||||
const [loadingSummary, setLoadingSummary] = useState(false);
|
||||
const [summary, setSummary] = useState<FairStatisticsSummary>();
|
||||
|
||||
const fetchStats = async (gran: Granularity, range: any) => {
|
||||
setLoading(true);
|
||||
const interactionLabel = fairType === 'online' ? '投递岗位数' : '签到数';
|
||||
const interactionUnit = fairType === 'online' ? '个' : '人次';
|
||||
|
||||
const loadFairOptions = useCallback(async (type: RecruitmentFairType) => {
|
||||
setLoadingFairs(true);
|
||||
try {
|
||||
const res = await getOutdoorFairStatistics({
|
||||
granularity: gran,
|
||||
startTime: formatBound(range?.[0], '00:00:00'),
|
||||
endTime: formatBound(range?.[1], '23:59:59'),
|
||||
});
|
||||
if (res?.code === 200 && res.data) {
|
||||
setResult(res.data);
|
||||
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})` : ''}`,
|
||||
})),
|
||||
);
|
||||
} else {
|
||||
message.error(res?.msg || '统计失败');
|
||||
const res = await getOutdoorFairList({ current: 1, pageSize: 1000 });
|
||||
if (res.code !== 200) {
|
||||
message.error(res.msg || '户外招聘会列表加载失败');
|
||||
setFairOptions([]);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('统计失败');
|
||||
setFairOptions(
|
||||
(res.rows || []).map((item) => ({
|
||||
value: String(item.id),
|
||||
label: `${item.title}${item.holdTime ? `(${item.holdTime})` : ''}`,
|
||||
})),
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
message.error('招聘会列表加载失败,请稍后重试');
|
||||
setFairOptions([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
setLoadingFairs(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
loadFairOptions(fairType);
|
||||
}, [fairType, loadFairOptions]);
|
||||
|
||||
const handleFairTypeChange = (type: RecruitmentFairType) => {
|
||||
if (type === fairType) return;
|
||||
|
||||
// 切换类型时同步清空条件,避免新类型携带旧类型招聘会 ID 发起查询。
|
||||
setSelectedFairId(undefined);
|
||||
setDateRange(null);
|
||||
setSummary(undefined);
|
||||
setFairOptions([]);
|
||||
setFairType(type);
|
||||
};
|
||||
|
||||
// 粒度或日期变化即查询;区间半选(只选了一端)不查询,避免中途无效查询
|
||||
useEffect(() => {
|
||||
const complete = dateRange && dateRange[0] && dateRange[1];
|
||||
const empty = !dateRange || (!dateRange[0] && !dateRange[1]);
|
||||
if (complete) {
|
||||
fetchStats(granularity, dateRange);
|
||||
} else if (empty) {
|
||||
fetchStats(granularity, null);
|
||||
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;
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [granularity, dateRange]);
|
||||
|
||||
const chartData = useMemo(() => {
|
||||
if (!result?.series) return [];
|
||||
const rows: { time: string; category: string; value: number }[] = [];
|
||||
result.series.forEach((item: OutdoorFairStatisticsSeriesItem) => {
|
||||
rows.push({ time: item.time, category: '招聘会数', value: item.fairCount });
|
||||
rows.push({ time: item.time, category: '参会单位数', value: item.companyCount });
|
||||
rows.push({ time: item.time, category: '职位数', value: item.jobCount });
|
||||
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,
|
||||
});
|
||||
return rows;
|
||||
}, [result]);
|
||||
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]);
|
||||
|
||||
const columns: ColumnsType<OutdoorFairStatisticsSeriesItem> = [
|
||||
{ title: '时间', dataIndex: 'time', width: 140 },
|
||||
{ title: '招聘会数', dataIndex: 'fairCount', width: 120 },
|
||||
{ title: '参会单位数', dataIndex: 'companyCount', width: 120 },
|
||||
{ title: '职位数', dataIndex: 'jobCount', width: 120 },
|
||||
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 },
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
header={{ title: '招聘会数据统计' }}
|
||||
content="按年/周/月/日维度统计时间区间内的招聘会趋势,含累计发布招聘会数及同比、环比。"
|
||||
content="分别统计线上招聘会与户外招聘会;可查看单场招聘会,或按招聘会起始时间汇总一个时间段。"
|
||||
>
|
||||
<Card style={{ marginBottom: 16 }}>
|
||||
<Row gutter={16} align="middle">
|
||||
<Row gutter={[16, 16]} align="middle">
|
||||
<Col>
|
||||
<span style={{ marginRight: 8 }}>统计粒度</span>
|
||||
<Button.Group>
|
||||
<Button
|
||||
type={fairType === 'online' ? 'primary' : 'default'}
|
||||
onClick={() => handleFairTypeChange('online')}
|
||||
>
|
||||
线上招聘会
|
||||
</Button>
|
||||
<Button
|
||||
type={fairType === 'outdoor' ? 'primary' : 'default'}
|
||||
onClick={() => handleFairTypeChange('outdoor')}
|
||||
>
|
||||
户外招聘会
|
||||
</Button>
|
||||
</Button.Group>
|
||||
</Col>
|
||||
<Col>
|
||||
<span style={{ marginRight: 8 }}>统计范围</span>
|
||||
<Segmented
|
||||
value={granularity}
|
||||
onChange={(v) => setGranularity(v as Granularity)}
|
||||
options={GRAN_OPTIONS}
|
||||
value={scope}
|
||||
options={[
|
||||
{ label: '统计单场', value: 'single' },
|
||||
{ label: '按起始时间统计', value: 'range' },
|
||||
]}
|
||||
onChange={(value) => {
|
||||
setScope(value as StatisticsScope);
|
||||
setSummary(undefined);
|
||||
}}
|
||||
/>
|
||||
</Col>
|
||||
<Col flex="auto">
|
||||
<span style={{ marginRight: 8, marginLeft: 16 }}>时间区间</span>
|
||||
{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={(v) => setDateRange(v)}
|
||||
style={{ width: 360 }}
|
||||
onChange={(value) => setDateRange(value)}
|
||||
style={{ width: '100%', minWidth: 320 }}
|
||||
placeholder={['起始日期', '结束日期']}
|
||||
/>
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
<Spin spinning={loading}>
|
||||
{result ? (
|
||||
<>
|
||||
<Row gutter={16} style={{ marginBottom: 16 }}>
|
||||
<Col span={8}>
|
||||
<Card>
|
||||
<Statistic title="累计发布招聘会数" value={result.totals.fairCount} />
|
||||
<div style={{ marginTop: 8 }}>
|
||||
<RateText label="同比" rate={result.yoy?.rate} />
|
||||
<span style={{ marginLeft: 16 }}>
|
||||
<RateText label="环比" rate={result.mom?.rate} />
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card>
|
||||
<Statistic title="参会单位数" value={result.totals.companyCount} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card>
|
||||
<Statistic title="职位数" value={result.totals.jobCount} />
|
||||
<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>
|
||||
))}
|
||||
</Row>
|
||||
|
||||
<Card title="招聘会趋势" style={{ marginBottom: 16 }} bodyStyle={{ padding: 12 }}>
|
||||
{chartData.length > 0 ? (
|
||||
<Line
|
||||
height={320}
|
||||
data={chartData}
|
||||
xField="time"
|
||||
yField="value"
|
||||
seriesField="category"
|
||||
smooth
|
||||
legend={{ position: 'bottom' }}
|
||||
tooltip={{
|
||||
fields: ['value'],
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<Empty description="所选区间无数据" />
|
||||
<Empty
|
||||
description={
|
||||
scope === 'single' ? '请选择一场招聘会' : '请选择完整的起始日期和结束日期'
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card title="分时段明细" bordered={false}>
|
||||
<Table<OutdoorFairStatisticsSeriesItem>
|
||||
rowKey="time"
|
||||
dataSource={result.series || []}
|
||||
{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>
|
||||
</>
|
||||
) : (
|
||||
<Empty description="暂无数据" />
|
||||
)}
|
||||
</Spin>
|
||||
|
||||
<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>
|
||||
);
|
||||
};
|
||||
|
||||
const RateText: React.FC<{ label: string; rate?: number | null }> = ({ label, rate }) => {
|
||||
if (rate === null || rate === undefined) {
|
||||
return (
|
||||
<Text type="secondary">
|
||||
{label}:--
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
const up = rate >= 0;
|
||||
const color = up ? '#cf1322' : '#3f8600';
|
||||
const pct = `${(rate * 100).toFixed(1)}%`;
|
||||
return (
|
||||
<Text style={{ color }}>
|
||||
{label}:
|
||||
{up ? <ArrowUpOutlined /> : <ArrowDownOutlined />} {pct}
|
||||
</Text>
|
||||
);
|
||||
};
|
||||
|
||||
export default FairStatistics;
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
EyeOutlined,
|
||||
QrcodeOutlined,
|
||||
UnorderedListOutlined,
|
||||
ExportOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import {
|
||||
getOutdoorFairList,
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
signupOutdoorFair,
|
||||
getMyOutdoorFairQrCode,
|
||||
getOutdoorFairMiniProgramQrCode,
|
||||
exportOutdoorFair,
|
||||
} from '@/services/jobportal/outdoorFair';
|
||||
import type {
|
||||
OutdoorFairItem,
|
||||
@@ -36,6 +38,8 @@ import EditModal from './components/EditModal';
|
||||
import CompanyBoothMapModal from './components/CompanyBoothMapModal';
|
||||
import CompanyFairDetailModal from './components/CompanyFairDetailModal';
|
||||
import JobEditModal from './Detail/components/JobEditModal';
|
||||
import FairExportModal from '../components/FairExportModal';
|
||||
import type { RecruitmentFairExportParams } from '@/services/jobfair/recruitmentFairExport';
|
||||
|
||||
const OUTDOOR_FAIR_TYPE_DICT = 'outdoor_fair_type';
|
||||
const OUTDOOR_FAIR_REGION_DICT = 'outdoor_fair_region';
|
||||
@@ -70,6 +74,7 @@ const OutdoorFairList: React.FC = () => {
|
||||
const [experienceEnum, setExperienceEnum] = useState<any>({});
|
||||
const [areaEnum, setAreaEnum] = useState<any>({});
|
||||
const [jobTypeEnum, setJobTypeEnum] = useState<any>({});
|
||||
const [exportModalOpen, setExportModalOpen] = useState(false);
|
||||
|
||||
const renderReviewStatus = (status?: string) => {
|
||||
const map: Record<string, { color: string; text: string }> = {
|
||||
@@ -237,6 +242,17 @@ const OutdoorFairList: React.FC = () => {
|
||||
setCompanyBoothFair(record);
|
||||
};
|
||||
|
||||
const handleExport = async (params: RecruitmentFairExportParams) => {
|
||||
message.loading('正在导出...');
|
||||
try {
|
||||
await exportOutdoorFair(params);
|
||||
message.success('导出成功');
|
||||
setExportModalOpen(false);
|
||||
} catch {
|
||||
message.error('导出失败');
|
||||
}
|
||||
};
|
||||
|
||||
const jobColumns: ProColumns<API.OutdoorFairDetail.PostedJob>[] = [
|
||||
{ title: '岗位名称', dataIndex: 'jobTitle', ellipsis: true },
|
||||
{
|
||||
@@ -334,19 +350,19 @@ const OutdoorFairList: React.FC = () => {
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: '截止时间',
|
||||
title: '结束时间',
|
||||
dataIndex: 'endTime',
|
||||
valueType: 'dateTime',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: '开放申请',
|
||||
title: '报名开始时间',
|
||||
dataIndex: 'applyStartTime',
|
||||
valueType: 'dateTime',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: '截止申请',
|
||||
title: '报名截止时间',
|
||||
dataIndex: 'applyEndTime',
|
||||
valueType: 'dateTime',
|
||||
hideInSearch: true,
|
||||
@@ -535,6 +551,14 @@ const OutdoorFairList: React.FC = () => {
|
||||
>
|
||||
新增
|
||||
</Button>,
|
||||
<Button
|
||||
key="export"
|
||||
icon={<ExportOutlined />}
|
||||
hidden={!access.hasPerms('cms:outdoorFair:export')}
|
||||
onClick={() => setExportModalOpen(true)}
|
||||
>
|
||||
导出
|
||||
</Button>,
|
||||
]}
|
||||
/>
|
||||
<EditModal
|
||||
@@ -728,6 +752,15 @@ const OutdoorFairList: React.FC = () => {
|
||||
actionRef.current?.reload();
|
||||
}}
|
||||
/>
|
||||
<FairExportModal
|
||||
open={exportModalOpen}
|
||||
channel="outdoor"
|
||||
fairTypeOptions={fairTypeOptions}
|
||||
regionOptions={regionOptions}
|
||||
venueOptions={venueOptions}
|
||||
onCancel={() => setExportModalOpen(false)}
|
||||
onExport={handleExport}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -22,6 +22,8 @@ import {
|
||||
} from '@/services/jobfair/publicJobFair';
|
||||
import EditModal from './components/EditModal';
|
||||
import CompanyJobManageModal from './components/CompanyJobManageModal';
|
||||
import FairExportModal from '../components/FairExportModal';
|
||||
import type { RecruitmentFairExportParams } from '@/services/jobfair/recruitmentFairExport';
|
||||
|
||||
const PublicJobFairList: React.FC = () => {
|
||||
const access = useAccess();
|
||||
@@ -36,6 +38,7 @@ const PublicJobFairList: React.FC = () => {
|
||||
const [jobFairRegionTypeEnum, setJobFairRegionTypeEnum] = useState<any>({});
|
||||
const [yesNoEnum, setYesNoEnum] = useState<any>({});
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||
const [exportModalOpen, setExportModalOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
getDictValueEnum('job_fair_type', true).then(setJobFairTypeEnum);
|
||||
@@ -76,27 +79,23 @@ const PublicJobFairList: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const buildListSearchParams = (values: Record<string, any>): API.PublicJobFair.ListParams => {
|
||||
const { dateRange, current, pageSize, ...rest } = values || {};
|
||||
const params = { ...rest } as API.PublicJobFair.ListParams;
|
||||
if (dateRange?.[0] && dateRange?.[1]) {
|
||||
params.startDate = dateRange[0];
|
||||
params.endDate = dateRange[1];
|
||||
}
|
||||
return params;
|
||||
};
|
||||
|
||||
const handleExport = async () => {
|
||||
const handleExport = async (params: RecruitmentFairExportParams) => {
|
||||
message.loading('正在导出...');
|
||||
try {
|
||||
const searchVal = formRef.current?.getFieldsValue();
|
||||
await exportPublicJobFair(buildListSearchParams(searchVal || {}));
|
||||
await exportPublicJobFair(params);
|
||||
message.success('导出成功');
|
||||
setExportModalOpen(false);
|
||||
} catch {
|
||||
message.error('导出失败');
|
||||
}
|
||||
};
|
||||
|
||||
const dictOptions = (valueEnum: Record<string, any>) =>
|
||||
Object.entries(valueEnum).map(([value, item]) => ({
|
||||
value,
|
||||
label: item?.text || item?.label || value,
|
||||
}));
|
||||
|
||||
const columns: ProColumns<API.PublicJobFair.JobFairItem>[] = [
|
||||
{
|
||||
title: '时间范围',
|
||||
@@ -336,7 +335,12 @@ const PublicJobFairList: React.FC = () => {
|
||||
批量删除
|
||||
</Button>
|
||||
),
|
||||
<Button key="export" icon={<ExportOutlined />} onClick={handleExport}>
|
||||
<Button
|
||||
key="export"
|
||||
icon={<ExportOutlined />}
|
||||
hidden={!access.hasPerms('cms:publicJobFair:export')}
|
||||
onClick={() => setExportModalOpen(true)}
|
||||
>
|
||||
导出
|
||||
</Button>,
|
||||
]}
|
||||
@@ -373,6 +377,14 @@ const PublicJobFairList: React.FC = () => {
|
||||
setCurrentJobFair(undefined);
|
||||
}}
|
||||
/>
|
||||
<FairExportModal
|
||||
open={exportModalOpen}
|
||||
channel="online"
|
||||
fairTypeOptions={dictOptions(jobFairTypeEnum)}
|
||||
regionOptions={dictOptions(jobFairRegionTypeEnum)}
|
||||
onCancel={() => setExportModalOpen(false)}
|
||||
onExport={handleExport}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
265
src/pages/Jobfair/components/FairExportModal.tsx
Normal file
265
src/pages/Jobfair/components/FairExportModal.tsx
Normal file
@@ -0,0 +1,265 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import { Button, Col, DatePicker, Form, Input, Modal, Row, Select, Space } from 'antd';
|
||||
import type {
|
||||
RecruitmentFairExportChannel,
|
||||
RecruitmentFairExportParams,
|
||||
RecruitmentFairExportType,
|
||||
} from '@/services/jobfair/recruitmentFairExport';
|
||||
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
interface Option {
|
||||
label?: React.ReactNode;
|
||||
text?: React.ReactNode;
|
||||
value: string | number | boolean;
|
||||
}
|
||||
|
||||
interface FormValues {
|
||||
exportType: RecruitmentFairExportType;
|
||||
title?: string;
|
||||
hostUnit?: string;
|
||||
fairType?: string;
|
||||
region?: string;
|
||||
venueId?: number;
|
||||
address?: string;
|
||||
startRange?: [Dayjs, Dayjs];
|
||||
endRange?: [Dayjs, Dayjs];
|
||||
applyRange?: [Dayjs, Dayjs];
|
||||
createRange?: [Dayjs, Dayjs];
|
||||
fairStatus?: RecruitmentFairExportParams['fairStatus'];
|
||||
isCrossDomain?: string;
|
||||
onlineApply?: boolean;
|
||||
reviewStatus?: RecruitmentFairExportParams['reviewStatus'];
|
||||
}
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
channel: RecruitmentFairExportChannel;
|
||||
fairTypeOptions?: Option[];
|
||||
regionOptions?: Option[];
|
||||
venueOptions?: Option[];
|
||||
onCancel: () => void;
|
||||
onExport: (params: RecruitmentFairExportParams) => Promise<void>;
|
||||
}
|
||||
|
||||
const toOptions = (options: Option[] = []) =>
|
||||
options.map((item) => ({
|
||||
label: item.label ?? item.text,
|
||||
value: item.value,
|
||||
}));
|
||||
|
||||
const dateRange = (range?: [Dayjs, Dayjs]) =>
|
||||
range
|
||||
? {
|
||||
start: range[0].format('YYYY-MM-DD HH:mm:ss'),
|
||||
end: range[1].format('YYYY-MM-DD HH:mm:ss'),
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const FairExportModal: React.FC<Props> = ({
|
||||
open,
|
||||
channel,
|
||||
fairTypeOptions,
|
||||
regionOptions,
|
||||
venueOptions,
|
||||
onCancel,
|
||||
onExport,
|
||||
}) => {
|
||||
const [form] = Form.useForm<FormValues>();
|
||||
const isOnline = channel === 'online';
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
form.resetFields();
|
||||
form.setFieldsValue({ exportType: 'companies' });
|
||||
}
|
||||
}, [form, open]);
|
||||
|
||||
const submit = async (values: FormValues) => {
|
||||
const start = dateRange(values.startRange);
|
||||
const end = dateRange(values.endRange);
|
||||
const apply = dateRange(values.applyRange);
|
||||
const create = dateRange(values.createRange);
|
||||
await onExport({
|
||||
exportType: values.exportType,
|
||||
title: values.title?.trim() || undefined,
|
||||
hostUnit: values.hostUnit?.trim() || undefined,
|
||||
fairType: values.fairType,
|
||||
region: values.region,
|
||||
venueId: values.venueId,
|
||||
address: values.address?.trim() || undefined,
|
||||
startTime: start?.start,
|
||||
endTime: end?.end,
|
||||
applyStartTime: apply?.start,
|
||||
applyEndTime: apply?.end,
|
||||
createStartTime: create?.start,
|
||||
createEndTime: create?.end,
|
||||
fairStatus: values.fairStatus,
|
||||
isCrossDomain: isOnline ? values.isCrossDomain : undefined,
|
||||
onlineApply: isOnline ? undefined : values.onlineApply,
|
||||
reviewStatus: values.reviewStatus,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={`${isOnline ? '线上' : '户外'}招聘会参会数据导出`}
|
||||
open={open}
|
||||
width={820}
|
||||
destroyOnClose
|
||||
footer={null}
|
||||
onCancel={onCancel}
|
||||
>
|
||||
<Form<FormValues>
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={{ exportType: 'companies' }}
|
||||
onFinish={submit}
|
||||
>
|
||||
<Form.Item
|
||||
label="导出内容"
|
||||
name="exportType"
|
||||
rules={[{ required: true, message: '请选择导出内容' }]}
|
||||
>
|
||||
<Select
|
||||
options={[
|
||||
{ label: '导出所有参会企业', value: 'companies' },
|
||||
{ label: '导出所有参加岗位', value: 'jobs' },
|
||||
{ label: '导出企业和岗位(每个企业一个 sheet)', value: 'companyJobs' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={8}>
|
||||
<Form.Item label="招聘会标题" name="title">
|
||||
<Input allowClear placeholder="支持模糊查询" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Form.Item label="举办单位" name="hostUnit">
|
||||
<Input allowClear placeholder="支持模糊查询" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Form.Item label="招聘会类型" name="fairType">
|
||||
<Select allowClear options={toOptions(fairTypeOptions)} placeholder="全部" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Form.Item label={isOnline ? '区域类型' : '举办区域'} name="region">
|
||||
<Select allowClear options={toOptions(regionOptions)} placeholder="全部" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
{!isOnline && (
|
||||
<Col span={8}>
|
||||
<Form.Item label="场地" name="venueId">
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
options={toOptions(venueOptions)}
|
||||
placeholder="全部"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
)}
|
||||
<Col span={8}>
|
||||
<Form.Item label="举办地址" name="address">
|
||||
<Input allowClear placeholder="支持模糊查询" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item label="招聘会开始时间范围" name="startRange">
|
||||
<RangePicker showTime format="YYYY-MM-DD HH:mm:ss" style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item label="招聘会结束时间范围" name="endRange">
|
||||
<RangePicker showTime format="YYYY-MM-DD HH:mm:ss" style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item label="报名时间范围" name="applyRange">
|
||||
<RangePicker showTime format="YYYY-MM-DD HH:mm:ss" style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item label="创建时间范围" name="createRange">
|
||||
<RangePicker showTime format="YYYY-MM-DD HH:mm:ss" style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={8}>
|
||||
<Form.Item label="举办状态" name="fairStatus">
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="全部"
|
||||
options={[
|
||||
{ label: '未举办', value: 'NOT_STARTED' },
|
||||
{ label: '正在举办', value: 'ONGOING' },
|
||||
{ label: '已举办', value: 'ENDED' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
{isOnline ? (
|
||||
<Col span={8}>
|
||||
<Form.Item label="是否跨域" name="isCrossDomain">
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="全部"
|
||||
options={[
|
||||
{ label: '是', value: 'Y' },
|
||||
{ label: '否', value: 'N' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
) : (
|
||||
<Col span={8}>
|
||||
<Form.Item label="是否开启线上申请" name="onlineApply">
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="全部"
|
||||
options={[
|
||||
{ label: '是', value: true },
|
||||
{ label: '否', value: false },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
)}
|
||||
<Col span={8}>
|
||||
<Form.Item label="审核状态" name="reviewStatus">
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="全部"
|
||||
options={[
|
||||
{ label: '待审核', value: '0' },
|
||||
{ label: '审核通过', value: '1' },
|
||||
{ label: '审核不通过', value: '2' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Space style={{ width: '100%', justifyContent: 'flex-end' }}>
|
||||
<Button onClick={onCancel}>取消</Button>
|
||||
<Button type="primary" htmlType="submit">
|
||||
开始导出
|
||||
</Button>
|
||||
</Space>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default FairExportModal;
|
||||
45
src/services/jobfair/fairStatistics.ts
Normal file
45
src/services/jobfair/fairStatistics.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { request } from '@umijs/max';
|
||||
|
||||
const BASE_URL = '/api/cms/fair-statistics';
|
||||
|
||||
export type RecruitmentFairType = 'online' | 'outdoor';
|
||||
|
||||
export interface FairStatisticsFairItem {
|
||||
fairId: string;
|
||||
fairTitle: string;
|
||||
startTime?: string;
|
||||
companyCount: number;
|
||||
jobCount: number;
|
||||
demandCount: number;
|
||||
/** 线上为投递岗位数,户外为签到数。 */
|
||||
interactionCount: number;
|
||||
}
|
||||
|
||||
export interface FairStatisticsSummary {
|
||||
fairType: RecruitmentFairType;
|
||||
fairCount: number;
|
||||
companyCount: number;
|
||||
jobCount: number;
|
||||
demandCount: number;
|
||||
interactionCount: number;
|
||||
fairs: FairStatisticsFairItem[];
|
||||
}
|
||||
|
||||
export interface FairStatisticsSummaryParams {
|
||||
fairType: RecruitmentFairType;
|
||||
/** 传该值时统计一场招聘会。 */
|
||||
fairId?: string;
|
||||
/** 与 fairId 二选一,按招聘会起始时间统计。 */
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
}
|
||||
|
||||
export async function getFairStatisticsSummary(params: FairStatisticsSummaryParams) {
|
||||
return request<{ code: number; msg?: string; data?: FairStatisticsSummary }>(
|
||||
`${BASE_URL}/summary`,
|
||||
{
|
||||
method: 'GET',
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { request } from '@umijs/max';
|
||||
import { downLoadXlsx } from '@/utils/downloadfile';
|
||||
import type { RecruitmentFairExportParams } from './recruitmentFairExport';
|
||||
|
||||
const BASE_URL = '/api/cms/publicJobFair';
|
||||
|
||||
@@ -227,6 +228,10 @@ export async function getJobFairCompanies(jobFairId: string) {
|
||||
}
|
||||
|
||||
/** 导出招聘会 */
|
||||
export async function exportPublicJobFair(params?: API.PublicJobFair.ListParams) {
|
||||
return downLoadXlsx(`${BASE_URL}/export`, { params }, `job_fair_${new Date().getTime()}.xlsx`);
|
||||
export async function exportPublicJobFair(params: RecruitmentFairExportParams) {
|
||||
return downLoadXlsx(
|
||||
`${BASE_URL}/export`,
|
||||
{ params },
|
||||
`online_fair_participants_${new Date().getTime()}.xlsx`,
|
||||
);
|
||||
}
|
||||
|
||||
37
src/services/jobfair/recruitmentFairExport.ts
Normal file
37
src/services/jobfair/recruitmentFairExport.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { downLoadXlsx } from '@/utils/downloadfile';
|
||||
|
||||
export type RecruitmentFairExportType = 'companies' | 'jobs' | 'companyJobs';
|
||||
|
||||
export interface RecruitmentFairExportParams {
|
||||
exportType: RecruitmentFairExportType;
|
||||
title?: string;
|
||||
hostUnit?: string;
|
||||
fairType?: string;
|
||||
region?: string;
|
||||
venueId?: number;
|
||||
venueName?: string;
|
||||
address?: string;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
applyStartTime?: string;
|
||||
applyEndTime?: string;
|
||||
createStartTime?: string;
|
||||
createEndTime?: string;
|
||||
fairStatus?: 'NOT_STARTED' | 'ONGOING' | 'ENDED';
|
||||
isCrossDomain?: string;
|
||||
onlineApply?: boolean;
|
||||
reviewStatus?: '0' | '1' | '2';
|
||||
}
|
||||
|
||||
export type RecruitmentFairExportChannel = 'online' | 'outdoor';
|
||||
|
||||
/** 下载线上/户外招聘会参会数据 Excel。 */
|
||||
export function exportRecruitmentFair(
|
||||
channel: RecruitmentFairExportChannel,
|
||||
params: RecruitmentFairExportParams,
|
||||
) {
|
||||
const endpoint =
|
||||
channel === 'online' ? '/api/cms/publicJobFair/export' : '/api/cms/outdoor-fair/export';
|
||||
const filePrefix = channel === 'online' ? 'online_fair' : 'outdoor_fair';
|
||||
return downLoadXlsx(endpoint, { params }, `${filePrefix}_participants_${Date.now()}.xlsx`);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { request } from '@umijs/max';
|
||||
import type { VenueBoothItem } from './venueInfo';
|
||||
import { downLoadXlsx } from '@/utils/downloadfile';
|
||||
import type { RecruitmentFairExportParams } from '@/services/jobfair/recruitmentFairExport';
|
||||
|
||||
/** 户外招聘会列表项 */
|
||||
export interface OutdoorFairItem {
|
||||
@@ -24,11 +26,11 @@ export interface OutdoorFairItem {
|
||||
reservedBoothCount?: number;
|
||||
/** 举办时间 */
|
||||
holdTime: string;
|
||||
/** 截止时间 */
|
||||
/** 招聘会结束时间 */
|
||||
endTime: string;
|
||||
/** 开放申请 */
|
||||
/** 报名开始时间 */
|
||||
applyStartTime: string;
|
||||
/** 截止申请 */
|
||||
/** 报名截止时间 */
|
||||
applyEndTime: string;
|
||||
/** 是否开启线上申请 */
|
||||
onlineApply: boolean;
|
||||
@@ -188,6 +190,15 @@ export async function getOutdoorFairList(params?: OutdoorFairListParams) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出户外招聘会参会企业/岗位。 */
|
||||
export async function exportOutdoorFair(params: RecruitmentFairExportParams) {
|
||||
return downLoadXlsx(
|
||||
`${CMS_OUTDOOR_FAIR_BASE}/export`,
|
||||
{ params },
|
||||
`outdoor_fair_participants_${new Date().getTime()}.xlsx`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取户外招聘会详情
|
||||
* GET /api/cms/outdoor-fair/{id}
|
||||
|
||||
Reference in New Issue
Block a user