From 2f31b1db2968b3864f407e6212424a5fc93116a7 Mon Sep 17 00:00:00 2001 From: linfeng <2819853134@qq.com> Date: Wed, 12 Mar 2025 09:48:35 +0800 Subject: [PATCH] lin --- .../src/app/main/layout/NavigationMenu.tsx | 8 +- apps/web/src/app/main/staffpage/page.tsx | 99 +++++++++++++++---- apps/web/src/routes/index.tsx | 4 + 3 files changed, 90 insertions(+), 21 deletions(-) diff --git a/apps/web/src/app/main/layout/NavigationMenu.tsx b/apps/web/src/app/main/layout/NavigationMenu.tsx index 126b0fa..5537793 100644 --- a/apps/web/src/app/main/layout/NavigationMenu.tsx +++ b/apps/web/src/app/main/layout/NavigationMenu.tsx @@ -1,8 +1,10 @@ import { Menu } from "antd"; -import { useNavigate } from "react-router-dom"; +import { useNavigate, useLocation } from "react-router-dom"; export default function NavigationMenu() { const navigate = useNavigate(); + const location = useLocation(); + console.log(location.pathname); // 导航菜单项配置 const menuItems = [ { key: 'home', label: '首页', path: '/' }, @@ -18,7 +20,9 @@ export default function NavigationMenu() { theme="dark" mode="inline" className="!bg-transparent !border-0 pt-4 [&_.ant-menu-item]:!mt-2" - defaultSelectedKeys={['home']} + defaultSelectedKeys={[ + menuItems.find((item) => item.path === location.pathname)?.key, + ]} > {menuItems.map((item) => ( ) }, + { + title: "应时", + dataIndex: "time", + key: "time", + }, { title: "操作", key: "action", @@ -92,7 +105,6 @@ export default function StaffMessage() { const handleOk = async () => { const values = await form.getFieldsValue(); - const orderValue = values.order ? parseFloat(values.order) : null; console.log(values.username); try { if (editingRecord && editingRecord.id) { @@ -102,12 +114,29 @@ export default function StaffMessage() { where: { id: editingRecord.id, }, - data: { + data : { username: values.username, deptId: values.deptId, - order: orderValue, + position: values.position, + absent: values.absent, + trainSituations: values.trainSituations ? { + upsert: values.trainSituations.map((situation) => ({ + where: { id: situation.id || "" }, + update: { + mustTrainTime: situation.mustTrainTime, + trainContent: { connect: { id: situation.trainContentId } }, + // 其他字段... + }, + create: { + trainContent: { connect: { id: situation.trainContentId } }, + mustTrainTime: situation.mustTrainTime, + staffId: editingRecord.id, + // 其他必填字段... + } + })) + } : undefined, updatedAt: new Date() - } + } as any } ); // console.log(result); @@ -117,7 +146,6 @@ export default function StaffMessage() { data: { username: values.username, deptId: values.deptId, - order: orderValue, createdAt: new Date(), showname: values.username, } @@ -136,9 +164,13 @@ export default function StaffMessage() { setVisible(false); }; - const handleSearch = (e) => { - setSearchName(e.target.value); - }; + // 添加防抖的搜索处理函数 + const handleSearch = useCallback( + _.debounce((value: string) => { + setSearchName(value); + }, 500), + [] + ); return (
@@ -147,11 +179,11 @@ export default function StaffMessage() {
{/* 添加flex容器 */} {/* 头部区域保持不变... */}
-
XX 公司人员信息表
+
人员总览
handleSearch(e.target.value)} className="pl-10 w-full border" /> @@ -175,7 +207,7 @@ export default function StaffMessage() { key={"username"} columns={colnums} dataSource={staffs} - className="bg-gray-900/50 backdrop-blur-sm border-2 + className=" backdrop-blur-sm border-2 [&_.ant-table-tbody>tr>td]:!text-lg [&_.ant-table-tbody>tr>td]:!py-5 [&_.ant-table-thead>tr>th]:!text-lg @@ -184,11 +216,11 @@ export default function StaffMessage() { tableLayout="fixed" pagination={{ position: ["bottomCenter"], - pageSize: 15 + pageSize: 12, }} - onRow={(record) => ({ - className: "hover:bg-gray-800/50 transition-colors even:bg-gray-800/50 hover:shadow-lg hover:shadow-blue-500/20", - })} + // onRow={(record) => ({ + // className: "hover:bg-gray-800/50 transition-colors even:bg-gray-800/50 hover:shadow-lg hover:shadow-blue-500/20", + // })} > @@ -229,7 +261,6 @@ export default function StaffMessage() { visible={visible} onOk={handleOk} onCancel={handleCancel} - className="[&_.ant-modal-content]:bg-gray-800 [&_.ant-modal-title]:text-gray-100" >
+ + {(fields, { add, remove }) => ( + <> + {fields.map(({ key, name, ...restField }) => ( +
+ + + + + + + +
+ ))} + + + )} +
diff --git a/apps/web/src/routes/index.tsx b/apps/web/src/routes/index.tsx index 85a7d84..10a960e 100755 --- a/apps/web/src/routes/index.tsx +++ b/apps/web/src/routes/index.tsx @@ -51,6 +51,10 @@ export const routes: CustomRouteObject[] = [ path: "/staff", element: , }, + { + path: "/day", + element: , + }, ], },