import { Modal, Card, Descriptions, List, Button, Form, Select, Input, DatePicker, message, Empty, Spin } from 'antd'; import React, { useEffect, useState } from 'react'; import { addCmsUserWorkExperiencesList, addCmsInterview, getCmsInterviewList, getAppSkillList, } from '@/services/Management/list'; import dayjs from 'dayjs'; const { TextArea } = Input; const { Option } = Select; export type ListFormProps = { onClose: (flag?: boolean, formVals?: unknown) => void; open: boolean; values?: Partial; matching?: any; }; const ResumeViewModal: React.FC = (props) => { const [loading, setLoading] = useState(false); const [experienceList, setExperienceList] = useState([]); const [skillList, setSkillList] = useState([]); // 面试邀约相关状态 const [interviewForm] = Form.useForm(); const [interviewMethod, setInterviewMethod] = useState('online'); const [submitting, setSubmitting] = useState(false); const [alreadyInvited, setAlreadyInvited] = useState(false); const [checkingInvitation, setCheckingInvitation] = useState(false); // 性别映射 const sexMap: Record = { '0': '男', '1': '女', }; // 学历映射 const educationMap: Record = { '1': '初中及以下', '2': '高中', '3': '中专', '4': '大专', '5': '本科', '6': '硕士', '7': '博士', }; // 政治面貌映射 const politicalMap: Record = { '1': '中共党员', '2': '中共预备党员', '3': '共青团员', '4': '群众', '5': '民主党派', }; useEffect(() => { if (props.open && props.values) { fetchResumeDetail(); fetchSkills(); checkExistingInvitation(); interviewForm.resetFields(); setInterviewMethod('online'); } }, [props.values, props.open]); // 检查是否已存在有效邀约 const checkExistingInvitation = async () => { if (!props.matching?.jobId || !props.values?.userId) return; setCheckingInvitation(true); try { const res = await getCmsInterviewList({ jobId: Number(props.matching.jobId), userId: props.values.userId, }); if (res?.code === 200 && res?.rows?.length > 0) { const hasActive = res.rows.some( (item: API.Management.InterviewInvitation) => item.status !== 'rejected' ); setAlreadyInvited(hasActive); } } catch (error) { console.error('检查邀约状态失败:', error); } finally { setCheckingInvitation(false); } }; const fetchResumeDetail = async () => { if (!props.values?.userId) return; setLoading(true); try { const parm = { userId: props.values.userId, jobId: props.matching?.jobId }; const response = await addCmsUserWorkExperiencesList(parm); if (response.code === 200) { setExperienceList(response.rows); } } catch (error) { console.error('获取经历详情失败:', error); } finally { setLoading(false); } }; const fetchSkills = async () => { if (!props.values?.userId) return; try { const response = await getAppSkillList({ userId: props.values.userId }); if (response.code === 200) { setSkillList(response.rows || []); } } catch (error) { console.error('获取技能信息失败:', error); } }; // 发送面试邀约 const handleInterviewSubmit = async () => { try { const values = await interviewForm.validateFields(); setSubmitting(true); const payload: API.Management.InterviewInvitation = { companyId: props.matching?.companyId, jobId: Number(props.matching?.jobId), userId: props.values?.userId, applyId: props.values?.applyId ? Number(props.values.applyId) : undefined, jobName: props.matching?.jobName, interviewTime: values.interviewTime ? dayjs(values.interviewTime).format('YYYY-MM-DD HH:mm:ss') : undefined, interviewMethod: values.interviewMethod, meetingLink: values.meetingLink, meetingPassword: values.meetingPassword, interviewLocation: values.interviewLocation, contactPhone: values.contactPhone, interviewerName: values.interviewerName, status: 'pending', remark: values.remark, }; const response = await addCmsInterview(payload); if (response.code === 200) { message.success('面试邀约已发送'); setAlreadyInvited(true); interviewForm.resetFields(); setInterviewMethod('online'); } else { message.error(response.msg || '发送失败'); } } catch (error: any) { const errMsg = error?.response?.data?.msg || error?.message || '发送面试邀约失败'; message.error(errMsg); console.error('发送面试邀约失败:', error); } finally { setSubmitting(false); } }; const values = props.values; return ( props.onClose()} title="简历详情" width={900} footer={[ , ]} destroyOnClose > {!values ? ( ) : ( <> {/* 基本信息 */} {values.name || '-'} {sexMap[values.sex || ''] || values.sex || '-'} {values.birthDate || '-'} {values.phone || '-'} {educationMap[values.education || ''] || values.education || '-'} {politicalMap[values.politicalAffiliation || ''] || values.politicalAffiliation || '-'} {values.salaryMin && values.salaryMax ? `${values.salaryMin}-${values.salaryMax}` : '-'} {values.idCard || '-'} {/* 技能列表 */} {skillList.length > 0 && ( ( )} /> )} {/* 工作经历 */} {!experienceList || experienceList.length === 0 ? ( ) : ( ( {item.companyName || '-'} {item.position || '-'} {item.startDate || '-'} {item.endDate || '-'} {item.description || '-'} )} /> )} {/* 面试邀约 */}
{interviewMethod === 'online' && ( )} {interviewMethod === 'offline' && ( )}