diff --git a/apps/web/src/app/main/staffinformation/page.tsx b/apps/web/src/app/main/staffinformation/page.tsx index 5bf9eaf..dc558a6 100644 --- a/apps/web/src/app/main/staffinformation/page.tsx +++ b/apps/web/src/app/main/staffinformation/page.tsx @@ -7,8 +7,11 @@ 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(); @@ -20,7 +23,7 @@ const StaffInformation = () => { const [equipmentList, setEquipmentList] = useState([]); // 新增装备列表 const [projectsList, setProjectsList] = useState([]); // 新增任务列表 const {create, update} = useStaff(); - + const showModal = (type: 'awards' | 'punishments' | 'equipment' | 'projects') => { setModalType(type); setIsModalVisible(true); @@ -58,10 +61,8 @@ const StaffInformation = () => { message.warning('请输入内容'); } }; - const onFinish = async (values: any) => { console.log('开始提交表单'); - try { setLoading(true); const formattedValues = { @@ -74,7 +75,7 @@ const StaffInformation = () => { hireDate: values.hireDate?.toISOString(), seniority: values.seniority?.toISOString(), currentPositionDate: values.currentPositionDate?.toISOString(), - rankDate: values.rankDate?.toISOString(), // 修改这里 + rankDate: values.rankDate?.toISOString(), }; await create.mutateAsync( @@ -87,9 +88,31 @@ const StaffInformation = () => { 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); diff --git a/apps/web/src/app/main/staffpage/stafftable/page.tsx b/apps/web/src/app/main/staffpage/stafftable/page.tsx index 5b8bb17..23116f2 100644 --- a/apps/web/src/app/main/staffpage/stafftable/page.tsx +++ b/apps/web/src/app/main/staffpage/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/systemlog/SystemLogPage.tsx b/apps/web/src/app/main/systemlog/SystemLogPage.tsx index e73543a..a0bbe4a 100644 --- a/apps/web/src/app/main/systemlog/SystemLogPage.tsx +++ b/apps/web/src/app/main/systemlog/SystemLogPage.tsx @@ -1,3 +1,49 @@ -export default function SystemLogPage() { - return
SystemLogPage
; -} \ No newline at end of file +"use client"; + +import React, { useState, useEffect } from 'react'; + +// 创建一个全局变量来存储日志 +let globalLogs: string[] = []; + +// 添加日志的函数 +export const addLog = (log: string) => { + const timestamp = new Date().toLocaleString(); + const formattedLog = `[${timestamp}] ${log}`; + globalLogs = [...globalLogs, formattedLog]; + // 如果需要,可以将日志保存到localStorage + localStorage.setItem('systemLogs', JSON.stringify(globalLogs)); +}; + +const SystemLogPage = () => { + const [logs, setLogs] = useState([]); + // 组件加载时从全局变量或localStorage获取日志 + useEffect(() => { + // 尝试从localStorage获取日志 + const storedLogs = localStorage.getItem('systemLogs'); + if (storedLogs) { + setLogs(JSON.parse(storedLogs)); + } else { + setLogs(globalLogs); + } + }, []); + return ( +
+

系统日志

+
+ {logs.length === 0 ? ( +

暂无系统日志

+ ) : ( +
    + {logs.map((log, index) => ( +
  • + {log} +
  • + ))} +
+ )} +
+
+ ); +}; + +export default SystemLogPage;