import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { Button, Form, Input, Modal, Table } from "antd"; import { useEffect, useState } from "react"; import { NS_STAFF_INFO } from "~/enumerate/namespace"; import StaffViewModal from "~/pages/Container/EnterpriseInfo/PersonnelInfo/StaffViewModal"; function OrgPersonnelSelectModalInner(props) { const { open, onCancel, onConfirm, existingIds = [] } = props; const [searchForm] = Form.useForm(); const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [viewId, setViewId] = useState(""); const [loading, setLoading] = useState(false); const [dataSource, setDataSource] = useState([]); const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0 }); const getData = async (page = 1, pageSize = 10) => { setLoading(true); try { const values = searchForm.getFieldsValue(); const res = await props.staffInfoList({ current: page, pageSize, likeStaffName: values.staffName || undefined, }); if (res?.success !== false) { setDataSource(res?.data || []); setPagination((prev) => ({ ...prev, current: page, pageSize, total: res?.totalCount || 0 })); } } catch (err) { console.warn("[OrgPersonnelSelectModal] list failed:", err); } finally { setLoading(false); } }; useEffect(() => { if (open) { setSelectedRowKeys([]); searchForm.resetFields(); getData(); } }, [open]); const handleSearch = () => { getData(1, pagination.pageSize); }; const handleOk = () => { const ids = selectedRowKeys.filter((id) => !existingIds.includes(String(id))); if (!ids.length) { Modal.warning({ title: "提示", content: "请选择至少一名未添加的人员" }); return; } const rows = dataSource.filter((row) => ids.includes(row.id)); onConfirm?.(ids, rows); }; return ( <>
({ disabled: existingIds.includes(String(record.id)), }), }} pagination={{ ...pagination, showSizeChanger: true, showTotal: (t) => `共 ${t} 条`, onChange: (page, pageSize) => getData(page, pageSize), }} columns={[ { title: "人员姓名", dataIndex: "staffName" }, { title: "类型", dataIndex: "personType" }, { title: "职务", dataIndex: "positionName" }, { title: "职称", dataIndex: "titleName" }, { title: "操作", width: 80, render: (_, record) => ( ), }, ]} /> setViewId("")} /> ); } export default Connect([NS_STAFF_INFO], true)(OrgPersonnelSelectModalInner);