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