training_data/apps/web/src/app/main/staffpage/page.tsx

67 lines
2.2 KiB
TypeScript
Raw Normal View History

2025-03-12 08:23:33 +08:00
import { MagnifyingGlassIcon } from "@heroicons/react/24/outline";
import { api, useStaff } from "@nice/client";
import { Button, Form, Input, Modal, Select, Table } from "antd";
2025-03-12 11:45:18 +08:00
import { StaffDto, trainSituationDetailSelect } from "@nice/common";
2025-03-12 09:48:35 +08:00
import { useCallback, useEffect, useState } from "react";
import _ from "lodash";
2025-03-12 11:45:18 +08:00
import { useMainContext } from "../layout/MainProvider";
import StaffTable from "./stafftable/page";
import StaffModal from "./staffmodal/page";
2025-03-12 08:23:33 +08:00
export default function StaffMessage() {
2025-03-12 11:45:18 +08:00
const {form, formValue, setFormValue, setVisible, setSearchValue} = useMainContext();
useEffect(()=>{
setFormValue(
{
username: "",
deptId: "",
absent: false,
position: "",
trainSituations: "",
2025-03-12 08:23:33 +08:00
}
2025-03-12 11:45:18 +08:00
)
},[])
2025-03-12 08:23:33 +08:00
const handleNew = () => {
2025-03-12 11:45:18 +08:00
form.setFieldsValue(formValue);
2025-03-12 08:23:33 +08:00
setVisible(true);
}
2025-03-12 09:48:35 +08:00
// 添加防抖的搜索处理函数
const handleSearch = useCallback(
_.debounce((value: string) => {
2025-03-12 11:45:18 +08:00
setSearchValue(value);
2025-03-12 09:48:35 +08:00
}, 500),
[]
);
2025-03-12 08:23:33 +08:00
return (
<div className="p-2 min-h-screen bg-gradient-to-br">
<Form>
<div className="p-4 h-full flex flex-col"> {/* 修改为flex布局 */}
<div className="max-w-full mx-auto flex-1 flex flex-col"> {/* 添加flex容器 */}
{/* 头部区域保持不变... */}
<div className="flex justify-between mb-4 space-x-4 items-center">
2025-03-12 09:48:35 +08:00
<div className="text-2xl"></div>
2025-03-12 08:23:33 +08:00
<div className="relative w-1/3">
<Input
placeholder="输入姓名搜索"
2025-03-12 09:48:35 +08:00
onChange={(e) => handleSearch(e.target.value)}
2025-03-12 08:23:33 +08:00
className="pl-10 w-full border"
/>
<MagnifyingGlassIcon className="absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 " />
</div>
<Button
type="primary"
onClick={handleNew}
className=" font-bold py-2 px-4 rounded"
>
</Button>
</div>
2025-03-12 11:45:18 +08:00
<StaffTable></StaffTable>
<StaffModal></StaffModal>
2025-03-12 08:23:33 +08:00
</div>
</div>
</Form>
</div>
);
}