dev_1.0.1
tangjie 2026-07-09 18:03:32 +08:00
parent 6f76b42841
commit bc292b63ab
1 changed files with 31 additions and 30 deletions

View File

@ -10,6 +10,7 @@ import {
Col, Col,
Select, Select,
Table, Table,
TreeSelect,
} from "antd"; } from "antd";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import dayjs from "dayjs"; import dayjs from "dayjs";
@ -20,7 +21,7 @@ import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction";
import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd"; import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd";
import { tools } from "@cqsjjb/jjb-common-lib"; import { tools } from "@cqsjjb/jjb-common-lib";
import { Get } from "@cqsjjb/jjb-common-lib/http"; import { Get } from "@cqsjjb/jjb-common-lib/http";
import { NS_STAFF_INFO } from "~/enumerate/namespace"; import { NS_STAFF_INFO, NS_ORG_DEPARTMENT } from "~/enumerate/namespace";
import { import {
EDUCATION_LEVEL_OPTIONS, EDUCATION_LEVEL_OPTIONS,
EDUCATION_TYPE_OPTIONS, EDUCATION_TYPE_OPTIONS,
@ -43,7 +44,8 @@ function PersonnelInfoPage(props) {
const [searchForm] = Form.useForm(); const [searchForm] = Form.useForm();
const [deptOptions, setDeptOptions] = useState([]); const [deptOptions, setDeptOptions] = useState([]);
const [positionOptions, setPositionOptions] = useState([]); const [positionOptions, setPositionOptions] = useState([]);
const { staffInfo } = props; const { staffInfo, orgDepartmentTree, orgDepartment } = props;
const { orgDepartmentTreeData } = orgDepartment;
const { const {
staffInfoList: dataSource, staffInfoList: dataSource,
staffInfoTotal: total, staffInfoTotal: total,
@ -51,20 +53,15 @@ function PersonnelInfoPage(props) {
} = staffInfo || {}; } = staffInfo || {};
useEffect(() => { useEffect(() => {
orgDepartmentTree();
let cancelled = false; let cancelled = false;
(async () => { (async () => {
try { try {
const [deptRes, posRes] = await Promise.all([ const [posRes] = await Promise.all([
Get("/safetyEval/org-department/page", { current: 1, size: 200 }),
Get("/safetyEval/org-position/page", { current: 1, size: 200 }), Get("/safetyEval/org-position/page", { current: 1, size: 200 }),
]); ]);
if (cancelled) return; if (cancelled) return;
setDeptOptions(
(deptRes?.data || []).map((d) => ({
label: d.deptName,
value: d.id,
})),
);
setPositionOptions( setPositionOptions(
(posRes?.data || []).map((p) => ({ (posRes?.data || []).map((p) => ({
label: p.positionName, label: p.positionName,
@ -91,9 +88,9 @@ function PersonnelInfoPage(props) {
}; };
const goCertificate = (id, staffName) => { const goCertificate = (id, staffName) => {
props.history.push(
`Certificate?staffId=${id}&staffName=${encodeURIComponent(staffName || "")}`,
props.history.push(`Certificate?staffId=${id}&staffName=${encodeURIComponent(staffName || "")}`); );
}; };
const onDelete = (id) => { const onDelete = (id) => {
@ -162,18 +159,18 @@ function PersonnelInfoPage(props) {
/> />
</Form.Item>, </Form.Item>,
<Form.Item key="deptId" name="deptId"> <Form.Item key="deptId" name="deptId">
<ControlWrapper.Select <ControlWrapper.TreeSelect
label="部门"
placeholder="请选择部门" placeholder="请选择部门"
treeData={orgDepartmentTreeData}
allowClear allowClear
style={{ width: "100%" }} fieldNames={{
> label: "deptName",
{deptOptions.map((d) => ( value: "id",
<Select.Option key={d.value} value={d.value}> key: "id",
{d.label} }}
</Select.Option> treeDefaultExpandAll
))} showSearch
</ControlWrapper.Select> ></ControlWrapper.TreeSelect>
</Form.Item>, </Form.Item>,
<Form.Item key="postId" name="postId"> <Form.Item key="postId" name="postId">
<ControlWrapper.Select <ControlWrapper.Select
@ -288,6 +285,7 @@ function PersonnelInfoPage(props) {
open={formModalOpen} open={formModalOpen}
currentId={currentId} currentId={currentId}
staffInfoGet={props.staffInfoGet} staffInfoGet={props.staffInfoGet}
orgDepartmentTreeData={orgDepartmentTreeData}
staffInfoAdd={props.staffInfoAdd} staffInfoAdd={props.staffInfoAdd}
staffInfoEdit={props.staffInfoEdit} staffInfoEdit={props.staffInfoEdit}
deptOptions={deptOptions} deptOptions={deptOptions}
@ -303,7 +301,6 @@ function PersonnelInfoPage(props) {
<StaffViewModal <StaffViewModal
open={viewModalOpen} open={viewModalOpen}
currentId={currentId} currentId={currentId}
onCancel={() => { onCancel={() => {
setViewModalOpen(false); setViewModalOpen(false);
setCurrentId(""); setCurrentId("");
@ -321,7 +318,7 @@ function StaffFormModal({
staffInfoAdd, staffInfoAdd,
staffInfoEdit, staffInfoEdit,
deptOptions, deptOptions,
positionOptions, orgDepartmentTreeData,
onCancel, onCancel,
onSuccess, onSuccess,
}) { }) {
@ -465,7 +462,6 @@ function StaffFormModal({
handleCancel(); handleCancel();
onSuccess(); onSuccess();
} else { } else {
} }
} finally { } finally {
setSubmitting(false); setSubmitting(false);
@ -534,12 +530,17 @@ function StaffFormModal({
label="部门" label="部门"
rules={[{ required: true, message: "请选择部门" }]} rules={[{ required: true, message: "请选择部门" }]}
> >
<Select <TreeSelect
placeholder="请选择部门" placeholder="请选择部门"
options={deptOptions} treeData={orgDepartmentTreeData}
allowClear allowClear
fieldNames={{
label: "deptName",
value: "id",
key: "id",
}}
treeDefaultExpandAll
showSearch showSearch
optionFilterProp="label"
/> />
</Form.Item> </Form.Item>
</Col> </Col>
@ -690,6 +691,6 @@ function StaffFormModal({
} }
export default Connect( export default Connect(
[NS_STAFF_INFO], [NS_STAFF_INFO, NS_ORG_DEPARTMENT],
true, true,
)(AntdTableFuncControl(PersonnelInfoPage)); )(AntdTableFuncControl(PersonnelInfoPage));