import React, { useEffect, useRef, useState } from 'react'; import { Button, Modal, Tag, message } from 'antd'; import { PlusOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; import { ProTable } from '@ant-design/pro-components'; import { getDictValueEnum } from '@/services/system/dict'; import { getParticipatingCompanies, getParticipatingJobDetail, getParticipatingJobs, removeJobFromCompany, removeParticipatingCompany, } from '@/services/jobportal/outdoorFairDetail'; import CompanyAddModal from './CompanyAddModal'; import JobEditModal from './JobEditModal'; interface Props { fairId: number; } const ParticipatingCompaniesTab: React.FC = ({ fairId }) => { const companyActionRef = useRef(); const jobActionRef = useRef(); const [companyModalOpen, setCompanyModalOpen] = useState(false); const [jobListModalOpen, setJobListModalOpen] = useState(false); const [jobEditModalOpen, setJobEditModalOpen] = useState(false); const [selectedCompany, setSelectedCompany] = useState(null); const [editingJob, setEditingJob] = useState(null); const [educationEnum, setEducationEnum] = useState({}); const [experienceEnum, setExperienceEnum] = useState({}); const [areaEnum, setAreaEnum] = useState({}); const [jobTypeEnum, setJobTypeEnum] = useState({}); const [scaleEnum, setScaleEnum] = useState({}); useEffect(() => { Promise.all([ getDictValueEnum('education', true, true), getDictValueEnum('experience', true, true), getDictValueEnum('area', true, true), getDictValueEnum('job_type', true, true), getDictValueEnum('scale', true, true), ]).then(([education, experience, area, jobType, scale]) => { setEducationEnum(education); setExperienceEnum(experience); setAreaEnum(area); setJobTypeEnum(jobType); setScaleEnum(scale); }); }, []); const openJobEditor = async (job?: API.OutdoorFairDetail.PostedJob) => { if (job?.jobId) { const res = await getParticipatingJobDetail(fairId, job.jobId); if (res.code !== 200) { message.error(res.msg || '岗位详情加载失败'); return; } setEditingJob(res.data); } else { setEditingJob(null); } setJobEditModalOpen(true); }; const jobColumns: ProColumns[] = [ { title: '岗位名称', dataIndex: 'jobTitle', ellipsis: true }, { title: '薪资范围', hideInSearch: true, render: (_, record) => `${record.minSalary}-${record.maxSalary} 元/月`, }, { title: '学历要求', dataIndex: 'education', valueType: 'select', valueEnum: educationEnum, width: 110, }, { title: '工作经验', dataIndex: 'experience', valueType: 'select', valueEnum: experienceEnum, width: 110, }, { title: '招聘人数', dataIndex: 'vacancies', hideInSearch: true, width: 90 }, { title: '发布状态', dataIndex: 'isPublish', hideInSearch: true, width: 90, render: (_, record) => ( {record.isPublish === 1 ? '已发布' : '未发布'} ), }, { title: '操作', valueType: 'option', width: 130, render: (_, record) => [ , , ], }, ]; return ( <> actionRef={companyActionRef} rowKey="id" headerTitle="参会企业" search={{ labelWidth: 'auto' }} options={false} pagination={{ pageSize: 10 }} toolBarRender={() => [ , ]} request={async (params) => { const res = await getParticipatingCompanies(fairId, { current: params.current, pageSize: params.pageSize, companyName: params.companyName, }); return { data: res.rows || [], total: res.total || 0, success: res.code === 200 }; }} columns={[ { title: '企业名称', dataIndex: 'companyName', ellipsis: true }, { title: '行业', dataIndex: 'industry', hideInSearch: true, render: (_, record) => { const v = record.industry; if (!v) return '--'; // 行业分类 id 均为 6 位编号,纯数字裸码(如 4、6)无对应分类项,兜底为“其他” if (/^\d+$/.test(String(v))) return 其他; return {v}; }, }, { title: '规模', dataIndex: 'scale', hideInSearch: true, render: (_, record) => { const v = record.scale; if (v === undefined || v === null || v === '') return '其他'; // 规模为字典码,渲染为标签;匹配不到时兜底“其他”,不显示裸数字 const label = scaleEnum[v]?.label || scaleEnum[v]?.text; return label ? {label} : '其他'; }, }, { title: '联系人', dataIndex: 'contactPerson', hideInSearch: true }, { title: '联系电话', dataIndex: 'contactPhone', hideInSearch: true }, { title: '展位号', dataIndex: 'boothNumber', hideInSearch: true, render: (_, record) => record.boothNumber || '--', }, { title: '岗位数', dataIndex: 'jobCount', hideInSearch: true, width: 80 }, { title: '操作', valueType: 'option', width: 220, render: (_, record) => [ , , , ], }, ]} /> setJobListModalOpen(false)} > {selectedCompany && ( actionRef={jobActionRef} rowKey="jobId" search={{ labelWidth: 'auto' }} options={false} pagination={{ pageSize: 10 }} toolBarRender={() => [ , ]} request={async (params) => { const res = await getParticipatingJobs(fairId, { companyId: selectedCompany.companyId, current: params.current, pageSize: params.pageSize, jobTitle: params.jobTitle, education: params.education, experience: params.experience, }); return { data: res.rows || [], total: res.total || 0, success: res.code === 200 }; }} columns={jobColumns} /> )} setCompanyModalOpen(false)} onSuccess={() => { setCompanyModalOpen(false); companyActionRef.current?.reload(); }} /> { setJobEditModalOpen(false); setEditingJob(null); }} onSuccess={() => { setJobEditModalOpen(false); setEditingJob(null); jobActionRef.current?.reload(); companyActionRef.current?.reload(); }} /> ); }; export default ParticipatingCompaniesTab;