add
This commit is contained in:
parent
4a111e05f9
commit
2f6e6bd0fe
|
@ -7,8 +7,11 @@ import { useStaff } from "@nice/client";
|
||||||
import DepartmentChildrenSelect from "@web/src/components/models/department/department-children-select";
|
import DepartmentChildrenSelect from "@web/src/components/models/department/department-children-select";
|
||||||
import { areaOptions } from './area-options';
|
import { areaOptions } from './area-options';
|
||||||
import DepartmentSelect from "@web/src/components/models/department/department-select";
|
import DepartmentSelect from "@web/src/components/models/department/department-select";
|
||||||
|
import { addLog } from "@web/src/app/main/systemlog/SystemLogPage";
|
||||||
const { TextArea } = Input;
|
const { TextArea } = Input;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const StaffInformation = () => {
|
const StaffInformation = () => {
|
||||||
const [modalForm] = Form.useForm();
|
const [modalForm] = Form.useForm();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
@ -58,10 +61,8 @@ const StaffInformation = () => {
|
||||||
message.warning('请输入内容');
|
message.warning('请输入内容');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFinish = async (values: any) => {
|
const onFinish = async (values: any) => {
|
||||||
console.log('开始提交表单');
|
console.log('开始提交表单');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const formattedValues = {
|
const formattedValues = {
|
||||||
|
@ -74,7 +75,7 @@ const StaffInformation = () => {
|
||||||
hireDate: values.hireDate?.toISOString(),
|
hireDate: values.hireDate?.toISOString(),
|
||||||
seniority: values.seniority?.toISOString(),
|
seniority: values.seniority?.toISOString(),
|
||||||
currentPositionDate: values.currentPositionDate?.toISOString(),
|
currentPositionDate: values.currentPositionDate?.toISOString(),
|
||||||
rankDate: values.rankDate?.toISOString(), // 修改这里
|
rankDate: values.rankDate?.toISOString(),
|
||||||
};
|
};
|
||||||
|
|
||||||
await create.mutateAsync(
|
await create.mutateAsync(
|
||||||
|
@ -87,9 +88,31 @@ const StaffInformation = () => {
|
||||||
console.log('奖励列表:', rewardsList);
|
console.log('奖励列表:', rewardsList);
|
||||||
console.log('处分列表:', punishmentsList);
|
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("信息提交成功");
|
message.success("信息提交成功");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('提交出错:', error);
|
console.error('提交出错:', error);
|
||||||
|
// 添加错误日志
|
||||||
|
addLog(`提交人员信息失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
||||||
message.error("提交失败,请重试");
|
message.error("提交失败,请重试");
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|
|
@ -57,10 +57,8 @@ export default function StaffTable() {
|
||||||
const [paginationEnabled, setPaginationEnabled] = useState(true);
|
const [paginationEnabled, setPaginationEnabled] = useState(true);
|
||||||
const [importVisible, setImportVisible] = useState(false);
|
const [importVisible, setImportVisible] = useState(false);
|
||||||
const [selectedRows, setSelectedRows] = useState<any[]>([]);
|
const [selectedRows, setSelectedRows] = useState<any[]>([]);
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
setFileNameVisible(true);
|
setFileNameVisible(true);
|
||||||
|
|
||||||
};
|
};
|
||||||
// 添加导出处理函数
|
// 添加导出处理函数
|
||||||
const handleFileNameConfirm = () => {
|
const handleFileNameConfirm = () => {
|
||||||
|
@ -69,7 +67,6 @@ export default function StaffTable() {
|
||||||
console.error('Grid API 未正确初始化');
|
console.error('Grid API 未正确初始化');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改获取节点方式(使用更可靠的 getRenderedNodes)
|
// 修改获取节点方式(使用更可靠的 getRenderedNodes)
|
||||||
const rowNodes = gridApi.getRenderedNodes();
|
const rowNodes = gridApi.getRenderedNodes();
|
||||||
|
|
||||||
|
@ -147,7 +144,6 @@ export default function StaffTable() {
|
||||||
gridApi.onFilterChanged(); // 触发筛选更新
|
gridApi.onFilterChanged(); // 触发筛选更新
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const columnDefs: (ColDef | ColGroupDef)[] = [
|
const columnDefs: (ColDef | ColGroupDef)[] = [
|
||||||
{
|
{
|
||||||
field: 'username',
|
field: 'username',
|
||||||
|
@ -329,8 +325,6 @@ export default function StaffTable() {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
const defaultColDef: ColDef = {
|
const defaultColDef: ColDef = {
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filter: 'agSetColumnFilter',
|
filter: 'agSetColumnFilter',
|
||||||
|
@ -474,7 +468,6 @@ export default function StaffTable() {
|
||||||
utils.book_append_sheet(wb, ws, "员工模板");
|
utils.book_append_sheet(wb, ws, "员工模板");
|
||||||
writeFile(wb, `员工数据模板_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
writeFile(wb, `员工数据模板_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 添加导入API钩子
|
// 添加导入API钩子
|
||||||
const createManyMutation = api.staff.create.useMutation({
|
const createManyMutation = api.staff.create.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
@ -486,7 +479,6 @@ export default function StaffTable() {
|
||||||
message.error(`导入失败: ${error.message}`);
|
message.error(`导入失败: ${error.message}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 处理Excel导入数据
|
// 处理Excel导入数据
|
||||||
const handleImportData = (excelData: any[]) => {
|
const handleImportData = (excelData: any[]) => {
|
||||||
// 转换Excel数据为后端接受的格式
|
// 转换Excel数据为后端接受的格式
|
||||||
|
|
|
@ -1,3 +1,49 @@
|
||||||
export default function SystemLogPage() {
|
"use client";
|
||||||
return <div>SystemLogPage</div>;
|
|
||||||
|
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<string[]>([]);
|
||||||
|
// 组件加载时从全局变量或localStorage获取日志
|
||||||
|
useEffect(() => {
|
||||||
|
// 尝试从localStorage获取日志
|
||||||
|
const storedLogs = localStorage.getItem('systemLogs');
|
||||||
|
if (storedLogs) {
|
||||||
|
setLogs(JSON.parse(storedLogs));
|
||||||
|
} else {
|
||||||
|
setLogs(globalLogs);
|
||||||
}
|
}
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<div className="max-w-4xl mx-auto p-6">
|
||||||
|
<h1 className="text-2xl font-bold mb-6">系统日志</h1>
|
||||||
|
<div className="bg-white p-6 rounded-lg shadow">
|
||||||
|
{logs.length === 0 ? (
|
||||||
|
<p className="text-gray-500">暂无系统日志</p>
|
||||||
|
) : (
|
||||||
|
<ul className="space-y-2">
|
||||||
|
{logs.map((log, index) => (
|
||||||
|
<li key={index} className="p-2 border-b border-gray-200">
|
||||||
|
{log}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SystemLogPage;
|
||||||
|
|
Loading…
Reference in New Issue