"use client"; import { Button, Form, Input, Select, DatePicker, Radio, message, Modal, Cascader, InputNumber } from "antd"; import { useState } from "react"; import dayjs from "dayjs"; import { useStaff } from "@nice/client"; import DepartmentChildrenSelect from "@web/src/components/models/department/department-children-select"; import { areaOptions } from './area-options'; import DepartmentSelect from "@web/src/components/models/department/department-select"; import { addLog } from "@web/src/app/main/systemlog/SystemLogPage"; const { TextArea } = Input; const StaffInformation = () => { const [modalForm] = Form.useForm(); const [form] = Form.useForm(); const [loading, setLoading] = useState(false); const [isModalVisible, setIsModalVisible] = useState(false); const [modalType, setModalType] = useState<'awards' | 'punishments' | 'equipment' | 'projects'>('awards'); const [rewardsList, setRewardsList] = useState([]); const [punishmentsList, setPunishmentsList] = useState([]); const [equipmentList, setEquipmentList] = useState([]); // 新增装备列表 const [projectsList, setProjectsList] = useState([]); // 新增任务列表 const {create, update} = useStaff(); const showModal = (type: 'awards' | 'punishments' | 'equipment' | 'projects') => { setModalType(type); setIsModalVisible(true); }; const handleModalOk = async () => { try { const values = await modalForm.validateFields(); const value = values[modalType]; if (value) { switch(modalType) { case 'awards': setRewardsList([...rewardsList, value]); break; case 'punishments': setPunishmentsList([...punishmentsList, value]); break; case 'equipment': setEquipmentList([...equipmentList, value]); break; case 'projects': setProjectsList([...projectsList, value]); break; } modalForm.resetFields(); setIsModalVisible(false); message.success( modalType === 'awards' ? '奖励信息添加成功' : modalType === 'punishments' ? '处分信息添加成功' : modalType === 'equipment' ? '装备信息添加成功' : '任务信息添加成功' ); } } catch (error) { message.warning('请输入内容'); } }; const onFinish = async (values: any) => { console.log('开始提交表单'); try { setLoading(true); const formattedValues = { ...values, birthplace: values.birthplace?.join('/'), // 将数组转换为以'/'分隔的字符串 awards: rewardsList.join(','), punishments: punishmentsList.join(','), equipment: equipmentList.join(','), projects: projectsList.join(','), hireDate: values.hireDate?.toISOString(), seniority: values.seniority?.toISOString(), currentPositionDate: values.currentPositionDate?.toISOString(), rankDate: values.rankDate?.toISOString(), }; await create.mutateAsync( { data: formattedValues } ); console.log('提交的表单数据:', formattedValues); console.log('奖励列表:', rewardsList); console.log('处分列表:', punishmentsList); // 添加日志记录 addLog(`用户 ${values.username || '未知'} 的人员信息已成功添加`); addLog(`提交的数据: 姓名=${values.username}, 身份证号=${values.idNumber}, 警号=${values.officerId}, 部门ID=${values.deptId}`); if (rewardsList.length > 0) { addLog(`${values.username} 的奖励信息: ${rewardsList.join(' | ')}`); } if (punishmentsList.length > 0) { addLog(`${values.username} 的处分信息: ${punishmentsList.join(' | ')}`); } if (equipmentList.length > 0) { addLog(`${values.username} 的装备信息: ${equipmentList.join(' | ')}`); } if (projectsList.length > 0) { addLog(`${values.username} 的任务信息: ${projectsList.join(' | ')}`); } message.success("信息提交成功"); } catch (error) { console.error('提交出错:', error); // 添加错误日志 addLog(`提交人员信息失败: ${error instanceof Error ? error.message : '未知错误'}`); message.error("提交失败,请重试"); } finally { setLoading(false); } }; const handleSubmit = (e: React.MouseEvent) => { e.preventDefault(); // 阻止默认行为 console.log('提交按钮被点击'); form.submit(); }; return (

人员信息填报

{ console.log('表单验证失败:', errorInfo); }} className="space-y-6" > {/* 个人基本信息 */}

个人基本信息

{ return path.some(option => typeof option.label === 'string' && option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1 ); } }} changeOnSelect />
{/* 政治信息 */}

政治信息

{/* 职务信息 */}

职务信息

{/* 入职信息 */}

入职信息

{/* 教育背景 */}

教育背景

{/* 培训信息 */}

培训信息

prevValues.hasTrain !== currentValues.hasTrain} > {({ getFieldValue }) => (
)}
{/* 鉴定信息 */}

鉴定信息

prevValues.hasCert !== currentValues.hasCert} > {({ getFieldValue }) => (
)}
{/* 工作信息 */}

工作信息

{equipmentList.map((equipment, index) => (
{equipment}
))}
{projectsList.map((mission, index) => (
{mission}
))}
{rewardsList.map((reward, index) => (
{reward}
))}
{punishmentsList.map((punishment, index) => (
{punishment}
))}
{ setIsModalVisible(false); modalForm.resetFields(); }} >