diff --git a/apps/web/src/app/main/staffinfo_show/stafftable/page.tsx b/apps/web/src/app/main/staffinfo_show/stafftable/page.tsx index dce2a80..0e14359 100644 --- a/apps/web/src/app/main/staffinfo_show/stafftable/page.tsx +++ b/apps/web/src/app/main/staffinfo_show/stafftable/page.tsx @@ -57,10 +57,8 @@ export default function StaffTable() { const [paginationEnabled, setPaginationEnabled] = useState(true); const [importVisible, setImportVisible] = useState(false); const [selectedRows, setSelectedRows] = useState([]); - const handleConfirm = async () => { setFileNameVisible(true); - }; // 添加导出处理函数 const handleFileNameConfirm = () => { @@ -69,7 +67,6 @@ export default function StaffTable() { console.error('Grid API 未正确初始化'); return; } - // 修改获取节点方式(使用更可靠的 getRenderedNodes) const rowNodes = gridApi.getRenderedNodes(); @@ -147,7 +144,6 @@ export default function StaffTable() { gridApi.onFilterChanged(); // 触发筛选更新 } }; - const columnDefs: (ColDef | ColGroupDef)[] = [ { field: 'username', @@ -329,8 +325,6 @@ export default function StaffTable() { ] } ]; - - const defaultColDef: ColDef = { sortable: true, filter: 'agSetColumnFilter', @@ -474,7 +468,6 @@ export default function StaffTable() { utils.book_append_sheet(wb, ws, "员工模板"); writeFile(wb, `员工数据模板_${new Date().toISOString().slice(0, 10)}.xlsx`); }; - // 添加导入API钩子 const createManyMutation = api.staff.create.useMutation({ onSuccess: () => { @@ -486,7 +479,6 @@ export default function StaffTable() { message.error(`导入失败: ${error.message}`); } }); - // 处理Excel导入数据 const handleImportData = (excelData: any[]) => { // 转换Excel数据为后端接受的格式 diff --git a/apps/web/src/app/main/staffinformation/page.tsx b/apps/web/src/app/main/staffinformation/page.tsx new file mode 100644 index 0000000..dc558a6 --- /dev/null +++ b/apps/web/src/app/main/staffinformation/page.tsx @@ -0,0 +1,542 @@ +"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(); + }} + > +
+ +