diff --git a/config/routes.ts b/config/routes.ts index 19eb389..40a9833 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -84,6 +84,10 @@ export default [ path: '/job-portal/personal-center/interviews', // 我的面试邀约 component: './JobPortal/PersonalCenter/Interviews', }, + { + path: '/job-portal/personal-center/complaints', // 我的投诉 + component: './JobPortal/PersonalCenter/Complaints', + }, { path: '/job-portal/message', // 消息通知页面 component: './JobPortal/Message', @@ -204,6 +208,11 @@ export default [ path: '/management/showcase-review', component: './Management/Showcase', }, + { + name: '投诉管理', + path: '/management/complaint', + component: './Complaint', + }, ], }, { diff --git a/src/components/JobComplaintModal/index.tsx b/src/components/JobComplaintModal/index.tsx new file mode 100644 index 0000000..4a2b168 --- /dev/null +++ b/src/components/JobComplaintModal/index.tsx @@ -0,0 +1,182 @@ +import React, { useEffect, useState } from 'react'; +import { + Modal, + Form, + Select, + Input, + Button, + message, + Spin, + Space, +} from 'antd'; +import { getDictValueEnum } from '@/services/system/dict'; +import type { DictValueEnumObj } from '@/components/DictTag'; +import { getJobPortalUserId, ensureJobPortalLogin } from '@/utils/jobPortalAuth'; +import { submitJobComplaint } from '@/services/jobportal/user'; + +const { TextArea } = Input; + +interface JobComplaintModalProps { + open: boolean; + jobId: string | number; + onCancel: () => void; + onSuccess?: () => void; +} + +const JobComplaintModal: React.FC = ({ + open, + jobId, + onCancel, + onSuccess, +}) => { + const [form] = Form.useForm(); + const [complaintTypeEnum, setComplaintTypeEnum] = useState({}); + const [loadingDict, setLoadingDict] = useState(false); + const [submitting, setSubmitting] = useState(false); + + // 加载投诉类型字典 + useEffect(() => { + if (open) { + setLoadingDict(true); + getDictValueEnum('complaint_type', false, true) + .then((data) => { + setComplaintTypeEnum(data); + }) + .catch(() => { + message.error('加载投诉类型失败'); + }) + .finally(() => { + setLoadingDict(false); + }); + } + }, [open]); + + // 打开时重置表单 + useEffect(() => { + if (open) { + form.resetFields(); + } + }, [open, form]); + + const handleSubmit = async () => { + try { + const values = await form.validateFields(); + + // 检查登录状态 + if (!ensureJobPortalLogin('提交投诉')) { + return; + } + + const userId = getJobPortalUserId(); + if (!userId) { + message.warning('无法获取用户信息,请稍后重试'); + return; + } + + setSubmitting(true); + const res = await submitJobComplaint({ + userId: String(userId), + jobId: String(jobId), + complaintType: values.complaintType, + complaintContent: values.complaintContent, + contactPhone: values.contactPhone, + }); + + if (res?.code === 200) { + message.success('投诉提交成功'); + form.resetFields(); + onSuccess?.(); + onCancel(); + } else { + message.error(res?.msg || '投诉提交失败'); + } + } catch (error) { + // 表单校验失败不提示 + if (error && typeof error === 'object' && 'errorFields' in error) { + return; + } + console.error('提交投诉失败:', error); + message.error('投诉提交失败,请重试'); + } finally { + setSubmitting(false); + } + }; + + // 手机号校验规则 + const phoneRules = [ + { required: true, message: '请输入联系方式' }, + { + pattern: /^1[3-9]\d{9}$/, + message: '请输入正确的11位手机号码', + }, + ]; + + return ( + + + + + } + > + +
+ +