From 07d1135a1913a919679dc23f0a38b9b61987171f Mon Sep 17 00:00:00 2001
From: zhongshujie <2862698242@qq.com>
Date: 星期五, 01 八月 2025 15:29:37 +0800
Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/OAManage

---
 src/components/ApplyIndex/components/staff.tsx |   99 ++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 77 insertions(+), 22 deletions(-)

diff --git a/src/components/ApplyIndex/components/staff.tsx b/src/components/ApplyIndex/components/staff.tsx
index 9a1af18..5b82229 100644
--- a/src/components/ApplyIndex/components/staff.tsx
+++ b/src/components/ApplyIndex/components/staff.tsx
@@ -1,6 +1,7 @@
-import { postOaStaffGetStaffList } from '@/services/WebApi/oaStaff';
-import { Modal, Table } from 'antd';
-import React, { useEffect, useState } from 'react';
+import { postOaStaffGetStaffList } from "@/services/WebApi/oaStaff";
+import type { TableProps } from "antd";
+import { Modal, Table } from "antd";
+import React, { useEffect, useState } from "react";
 
 interface StaffProps {
   open: boolean;
@@ -8,37 +9,71 @@
   onCancel: () => void;
 }
 
+interface DataType {
+  id: number | string;
+  label: string;
+  value: number | string;
+  department?: string;
+  post?: string;
+}
+
 const Staff: React.FC<StaffProps> = (props) => {
   const { open, setData, onCancel } = props;
 
-  const [staffOptions, setStaffOptions] = useState([]);
+  const [staffOptions, setStaffOptions] = useState([]); // 鍛樺伐鏁版嵁
+  const [currentRow, setRow] = useState<DataType>(); // 閫変腑琛�
+  const [loading, setLoading] = useState(false);
 
   const staffColums: any[] = [
     {
-      title: '鍛樺伐濮撳悕',
-      dataIndex: 'label',
+      title: "鍛樺伐濮撳悕",
+      dataIndex: "label",
     },
     {
-      title: '閮ㄩ棬',
-      dataIndex: 'tsetwe',
+      title: "閮ㄩ棬",
+      dataIndex: "department",
     },
     {
-      title: '鑱屼綅',
-      dataIndex: 'post',
+      title: "鑱屼綅",
+      dataIndex: "post",
     },
   ];
 
-  // 鑾峰彇鍛樺伐鍒楄〃
-  const getStaffList = async () => {
-    const res = await postOaStaffGetStaffList({ start: 0, size: 10, orgId: 4 });
-    if (res && res.datas.length > 0) {
-      const data = res.datas.map((item: any) => ({
-        label: item.name,
-        value: item.id,
-      }));
-      setStaffOptions(data);
+  // 鍏抽棴鍛樺伐寮规
+  const onCloseStaff = () => {
+    if (onCancel) {
+      onCancel();
     }
-    return [];
+    setData(null);
+  };
+
+  // 璁剧疆閫変腑琛�
+  const onSelectRow = () => {
+    setData(currentRow);
+    onCloseStaff();
+  };
+
+  // 鑾峰彇鍛樺伐鍒楄〃
+  const getStaffList = () => {
+    setLoading(true);
+    postOaStaffGetStaffList({ start: 0, size: 10, orgId: 4 })
+      .then((res) => {
+        if (res && res.datas.length > 0) {
+          const data = res.datas.map((item: any) => ({
+            label: item.name,
+            value: item.id,
+            ...item,
+          }));
+          setStaffOptions(data);
+        }
+      })
+      .catch((err) => {
+        setLoading(false);
+        setStaffOptions([]);
+      })
+      .finally(() => {
+        setLoading(false);
+      });
   };
 
   useEffect(() => {
@@ -47,9 +82,29 @@
     }
   }, [open]);
 
+  const rowSelection: TableProps<DataType>["rowSelection"] = {
+    onChange: (selectedRowKeys: React.Key[], selectedRows: DataType[]) => {
+      setRow(selectedRows[0]);
+    },
+  };
+
   return (
-    <Modal title={'鍛樺伐鍒楄〃'} width={600} open={open} onCancel={onCancel}>
-      <Table dataSource={staffOptions} columns={staffColums} pagination={false} />
+    <Modal
+      title={"鍛樺伐鍒楄〃"}
+      width={600}
+      open={open}
+      onCancel={onCloseStaff}
+      onOk={onSelectRow}
+    >
+      <Table
+        dataSource={staffOptions}
+        columns={staffColums}
+        pagination={false}
+        loading={loading}
+        rowKey={(record) => record?.id}
+        rowSelection={{ type: "radio", ...rowSelection }}
+        scroll={{ y: 400 }}
+      />
     </Modal>
   );
 };

--
Gitblit v1.9.1