Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # jjb.config.jsdev_1.0.1
commit
e73a4d1f87
|
|
@ -1,42 +1,35 @@
|
||||||
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import {
|
|
||||||
buildDepartmentTree,
|
|
||||||
fromDepartmentForm,
|
|
||||||
fromPageResponse,
|
|
||||||
fromSingleResponse,
|
|
||||||
toDepartmentForm,
|
|
||||||
toPageQuery,
|
|
||||||
} from "../../utils/enterpriseInfo/adapter";
|
|
||||||
import { apiGet, apiPost, apiPostDelete, safeAction, safePageResult } from "../../utils/enterpriseInfo/http";
|
|
||||||
|
|
||||||
export const orgDepartmentGet = declareRequest("orgDepartmentLoading", safeAction(async (params) => {
|
|
||||||
const res = await apiGet("/safetyEval/org-department/get", { id: params.id });
|
|
||||||
return fromSingleResponse(res, toDepartmentForm);
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const orgDepartmentTree = declareRequest("orgDepartmentLoading", safeAction(async () => {
|
export const orgDepartmentGet = declareRequest(
|
||||||
const res = await apiGet("/safetyEval/org-department/page", toPageQuery({ current: 1, size: 500 }));
|
"orgDepartmentLoading",
|
||||||
const pageData = fromPageResponse(res, toDepartmentForm);
|
"Get > /safetyEval/org-department/get",
|
||||||
return {
|
"orgDepartmentDetail: {} | res.data || {}",
|
||||||
success: true,
|
);
|
||||||
data: buildDepartmentTree(pageData.data || []),
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const orgDepartmentList = declareRequest("orgDepartmentLoading", safePageResult(async (params) => {
|
export const orgDepartmentTree = declareRequest(
|
||||||
const query = toPageQuery(params, { likeDeptName: "deptName" });
|
"orgDepartmentLoading",
|
||||||
const res = await apiGet("/safetyEval/org-department/page", query);
|
"Get > /safetyEval/org-department/tree",
|
||||||
return fromPageResponse(res, toDepartmentForm);
|
"orgDepartmentTreeData: [] | res.data || []",
|
||||||
}));
|
);
|
||||||
|
|
||||||
export const orgDepartmentAdd = declareRequest("orgDepartmentLoading", safeAction(async (values) => {
|
export const orgDepartmentList = declareRequest(
|
||||||
return apiPost("/safetyEval/org-department/save", fromDepartmentForm(values));
|
"orgDepartmentLoading",
|
||||||
}));
|
"Get > /safetyEval/org-department/page",
|
||||||
|
"dataSource: [] | res.data || [] & total: 0 | res.totalCount || 0",
|
||||||
|
);
|
||||||
|
|
||||||
export const orgDepartmentEdit = declareRequest("orgDepartmentLoading", safeAction(async (values) => {
|
export const orgDepartmentAdd = declareRequest(
|
||||||
return apiPost("/safetyEval/org-department/modify", fromDepartmentForm(values));
|
"orgDepartmentLoading",
|
||||||
}));
|
"Post > @/safetyEval/org-department/save",
|
||||||
|
);
|
||||||
|
|
||||||
export const orgDepartmentRemove = declareRequest("orgDepartmentLoading", safeAction(async ({ id }) => {
|
export const orgDepartmentEdit = declareRequest(
|
||||||
return apiPostDelete("/safetyEval/org-department/delete", id);
|
"orgDepartmentLoading",
|
||||||
}));
|
"Post > @/safetyEval/org-department/modify",
|
||||||
|
);
|
||||||
|
|
||||||
|
export const orgDepartmentRemove = declareRequest(
|
||||||
|
"orgDepartmentLoading",
|
||||||
|
"Post > @/safetyEval/org-department/delete",
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,22 @@
|
||||||
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import {
|
|
||||||
fromPageResponse,
|
|
||||||
fromPositionForm,
|
|
||||||
toPageQuery,
|
|
||||||
toPositionForm,
|
|
||||||
} from "../../utils/enterpriseInfo/adapter";
|
|
||||||
import { apiGet, apiPost, apiPostDelete, safeAction, safePageResult } from "../../utils/enterpriseInfo/http";
|
|
||||||
|
|
||||||
export const orgPositionList = declareRequest("orgPositionLoading", safePageResult(async (params) => {
|
export const orgPositionList = declareRequest(
|
||||||
const query = toPageQuery(params, {
|
"orgPositionLoading",
|
||||||
eqDeptId: "deptId",
|
"Get > /safetyEval/org-position/page",
|
||||||
likePositionName: "positionName",
|
"dataSource: [] | res.data || [] & total: 0 | res.totalCount || 0",
|
||||||
});
|
);
|
||||||
const res = await apiGet("/safetyEval/org-position/page", query);
|
|
||||||
return fromPageResponse(res, toPositionForm);
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const orgPositionAdd = declareRequest("orgPositionLoading", safeAction(async (values) => {
|
export const orgPositionAdd = declareRequest(
|
||||||
return apiPost("/safetyEval/org-position/save", fromPositionForm(values));
|
"orgPositionLoading",
|
||||||
}));
|
"Post > @/safetyEval/org-position/save",
|
||||||
|
);
|
||||||
|
|
||||||
export const orgPositionEdit = declareRequest("orgPositionLoading", safeAction(async (values) => {
|
export const orgPositionEdit = declareRequest(
|
||||||
return apiPost("/safetyEval/org-position/modify", fromPositionForm(values));
|
"orgPositionLoading",
|
||||||
}));
|
"Post > @/safetyEval/org-position/modify",
|
||||||
|
);
|
||||||
|
|
||||||
export const orgPositionRemove = declareRequest("orgPositionLoading", safeAction(async ({ id }) => {
|
export const orgPositionRemove = declareRequest(
|
||||||
return apiPostDelete("/safetyEval/org-position/delete", id);
|
"orgPositionLoading",
|
||||||
}));
|
"Post > @/safetyEval/org-position/delete",
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,30 @@
|
||||||
|
import { PlusOutlined } from "@ant-design/icons";
|
||||||
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import { Button, Empty, Form, Input, message, Modal, Row, Col, Select, Space, Tree } from "antd";
|
import {
|
||||||
|
Button,
|
||||||
|
Empty,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
message,
|
||||||
|
Modal,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Tree,
|
||||||
|
Table,
|
||||||
|
TreeSelect,
|
||||||
|
} from "antd";
|
||||||
|
import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd";
|
||||||
import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction";
|
import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import AddIcon from "zy-react-library/components/Icon/AddIcon";
|
|
||||||
import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
|
import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
|
||||||
import Search from "zy-react-library/components/Search";
|
import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm";
|
||||||
import Table from "zy-react-library/components/Table";
|
|
||||||
import useTable from "zy-react-library/hooks/useTable";
|
import {
|
||||||
import { NS_ORG_DEPARTMENT, NS_ORG_POSITION, NS_STAFF_INFO } from "~/enumerate/namespace";
|
NS_ORG_DEPARTMENT,
|
||||||
|
NS_ORG_POSITION,
|
||||||
|
NS_STAFF_INFO,
|
||||||
|
} from "~/enumerate/namespace";
|
||||||
import { asId, sameId } from "~/utils/enterpriseInfo/idUtil";
|
import { asId, sameId } from "~/utils/enterpriseInfo/idUtil";
|
||||||
import { safeListRequest, safeRequest } from "~/utils";
|
|
||||||
|
|
||||||
function findDeptNode(nodes = [], id) {
|
function findDeptNode(nodes = [], id) {
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
|
|
@ -33,9 +48,9 @@ function toSelectedDept(node) {
|
||||||
return {
|
return {
|
||||||
id: asId(node.id),
|
id: asId(node.id),
|
||||||
deptName: node.deptName || node.title,
|
deptName: node.deptName || node.title,
|
||||||
leaderAccount: node.leaderAccount,
|
managerAccount: node.managerAccount,
|
||||||
leaderName: node.leaderName,
|
managerName: node.managerName,
|
||||||
deptLevel: node.deptLevel,
|
deptLevelName: node.deptLevelName,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,50 +64,62 @@ function DepartmentPositionPage(props) {
|
||||||
const [staffOptions, setStaffOptions] = useState([]);
|
const [staffOptions, setStaffOptions] = useState([]);
|
||||||
const [positionForm] = Form.useForm();
|
const [positionForm] = Form.useForm();
|
||||||
const [modalForm] = Form.useForm();
|
const [modalForm] = Form.useForm();
|
||||||
|
const [dataSource, setDataSource] = useState([]);
|
||||||
|
const [total, setTotal] = useState(0);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [pageIndex, setPageIndex] = useState(1);
|
||||||
|
const [pageSize, setPageSize] = useState(10);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const res = await props.staffInfoList?.({ pageIndex: 1, pageSize: 500 });
|
const res = await props.staffInfoList?.({
|
||||||
setStaffOptions((res?.data || []).map((s) => ({
|
pageIndex: 1,
|
||||||
label: `${s.userName ?? s.staffName}(${s.account})`,
|
pageSize: 500,
|
||||||
value: s.account,
|
});
|
||||||
staffName: s.userName ?? s.staffName,
|
setStaffOptions(
|
||||||
})));
|
(res?.data || []).map((s) => ({
|
||||||
}
|
label: `${s.userName ?? s.staffName}(${s.account})`,
|
||||||
catch (err) {
|
value: s.account,
|
||||||
|
staffName: s.userName ?? s.staffName,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
console.warn("[DepartmentPosition] load staff options failed:", err);
|
console.warn("[DepartmentPosition] load staff options failed:", err);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const { tableProps: positionTableProps, getData: getPositionData } = useTable(
|
const fetchPositionData = async (page = 1, size = 10) => {
|
||||||
safeListRequest(props.orgPositionList),
|
if (!selectedDept?.id) return;
|
||||||
{
|
setLoading(true);
|
||||||
form: positionForm,
|
try {
|
||||||
transform: (formData) => ({
|
const formData = positionForm.getFieldsValue();
|
||||||
|
const res = await props.orgPositionList({
|
||||||
...formData,
|
...formData,
|
||||||
eqDeptId: asId(selectedDept?.id),
|
pageIndex: page,
|
||||||
}),
|
pageSize: size,
|
||||||
},
|
deptId: asId(selectedDept.id),
|
||||||
);
|
});
|
||||||
|
setDataSource(res?.data || []);
|
||||||
|
setTotal(res?.totalCount || 0);
|
||||||
|
} catch {
|
||||||
|
setDataSource([]);
|
||||||
|
setTotal(0);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const loadTree = async () => {
|
const loadTree = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await props.orgDepartmentTree();
|
const res = await props.orgDepartmentTree();
|
||||||
const normalizeTree = (nodes = []) => nodes.map((node) => ({
|
const tree = res?.data || [];
|
||||||
...node,
|
|
||||||
title: node.title || node.deptName,
|
|
||||||
deptName: node.deptName || node.title,
|
|
||||||
children: node.children ? normalizeTree(node.children) : [],
|
|
||||||
}));
|
|
||||||
const tree = normalizeTree(res?.data || []);
|
|
||||||
setTreeData(tree);
|
setTreeData(tree);
|
||||||
if ( tree.length) {
|
if (tree.length) {
|
||||||
setSelectedDept(toSelectedDept(tree[0]));
|
setSelectedDept(toSelectedDept(tree[0]));
|
||||||
}
|
}
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
|
||||||
console.warn("[DepartmentPosition] loadTree failed:", err);
|
console.warn("[DepartmentPosition] loadTree failed:", err);
|
||||||
setTreeData([]);
|
setTreeData([]);
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +131,7 @@ function DepartmentPositionPage(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedDept?.id) {
|
if (selectedDept?.id) {
|
||||||
getPositionData();
|
fetchPositionData(1, 10);
|
||||||
}
|
}
|
||||||
}, [selectedDept?.id]);
|
}, [selectedDept?.id]);
|
||||||
|
|
||||||
|
|
@ -134,7 +161,7 @@ function DepartmentPositionPage(props) {
|
||||||
okText: "是",
|
okText: "是",
|
||||||
cancelText: "否",
|
cancelText: "否",
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
const res = await props.orgDepartmentRemove({ id });
|
const res = await props.orgDepartmentRemove({ data: id });
|
||||||
if (res?.success !== false) {
|
if (res?.success !== false) {
|
||||||
message.success("删除成功");
|
message.success("删除成功");
|
||||||
if (sameId(selectedDept?.id, id)) {
|
if (sameId(selectedDept?.id, id)) {
|
||||||
|
|
@ -156,7 +183,7 @@ function DepartmentPositionPage(props) {
|
||||||
const res = await props.orgPositionRemove({ id });
|
const res = await props.orgPositionRemove({ id });
|
||||||
if (res?.success !== false) {
|
if (res?.success !== false) {
|
||||||
message.success("删除成功");
|
message.success("删除成功");
|
||||||
getPositionData();
|
fetchPositionData(1, 10);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -192,9 +219,11 @@ function DepartmentPositionPage(props) {
|
||||||
deptId: asId(record.deptId || selectedDept.id),
|
deptId: asId(record.deptId || selectedDept.id),
|
||||||
deptName: record.deptName || selectedDept.deptName,
|
deptName: record.deptName || selectedDept.deptName,
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
modalForm.setFieldsValue({
|
||||||
modalForm.setFieldsValue({ deptId: asId(selectedDept.id), deptName: selectedDept.deptName });
|
deptId: asId(selectedDept.id),
|
||||||
|
deptName: selectedDept.deptName,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
setPositionModalOpen(true);
|
setPositionModalOpen(true);
|
||||||
};
|
};
|
||||||
|
|
@ -210,9 +239,8 @@ function DepartmentPositionPage(props) {
|
||||||
if (res?.success !== false) {
|
if (res?.success !== false) {
|
||||||
message.success(currentId ? "编辑成功" : "添加成功");
|
message.success(currentId ? "编辑成功" : "添加成功");
|
||||||
closePositionModal();
|
closePositionModal();
|
||||||
getPositionData();
|
fetchPositionData(pageIndex, pageSize);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
message.error(res?.message || "操作失败");
|
message.error(res?.message || "操作失败");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -220,9 +248,24 @@ function DepartmentPositionPage(props) {
|
||||||
return (
|
return (
|
||||||
<PageLayout title="部门岗位管理">
|
<PageLayout title="部门岗位管理">
|
||||||
<div style={{ display: "flex", gap: 16, minHeight: 480 }}>
|
<div style={{ display: "flex", gap: 16, minHeight: 480 }}>
|
||||||
<div style={{ width: 260, borderRight: "1px solid #f0f0f0", paddingRight: 16, flexShrink: 0 }}>
|
<div
|
||||||
<Space direction="vertical" style={{ width: "100%", marginBottom: 12 }}>
|
style={{
|
||||||
<Button type="primary" icon={<AddIcon />} block onClick={() => openDeptModal()}>
|
width: 260,
|
||||||
|
borderRight: "1px solid #f0f0f0",
|
||||||
|
paddingRight: 16,
|
||||||
|
flexShrink: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Space
|
||||||
|
direction="vertical"
|
||||||
|
style={{ width: "100%", marginBottom: 12 }}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
icon={<PlusOutlined />}
|
||||||
|
block
|
||||||
|
onClick={() => openDeptModal()}
|
||||||
|
>
|
||||||
新增部门
|
新增部门
|
||||||
</Button>
|
</Button>
|
||||||
<Input.Search
|
<Input.Search
|
||||||
|
|
@ -243,24 +286,45 @@ function DepartmentPositionPage(props) {
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
<div style={{ flex: 1, minWidth: 0 }}>
|
||||||
{selectedDept?.id ? (
|
{selectedDept?.id ? (
|
||||||
<>
|
<>
|
||||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 16 }}>
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignItems: "center",
|
||||||
|
marginBottom: 16,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<span>
|
<span>
|
||||||
当前部门:
|
当前部门:
|
||||||
<strong>{selectedDept.deptName}</strong>
|
<strong>{selectedDept.deptName}</strong>
|
||||||
</span>
|
</span>
|
||||||
<Space>
|
<Space>
|
||||||
<Button onClick={() => openDeptModal(selectedDept)}>编辑部门</Button>
|
<Button onClick={() => openDeptModal(selectedDept)}>
|
||||||
<Button danger onClick={() => onDeleteDept(selectedDept.id)}>删除部门</Button>
|
编辑部门
|
||||||
|
</Button>
|
||||||
|
<Button danger onClick={() => onDeleteDept(selectedDept.id)}>
|
||||||
|
删除部门
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
<Search
|
<SearchForm
|
||||||
form={positionForm}
|
form={positionForm}
|
||||||
options={[{ name: "likePositionName", label: "岗位名称", placeholder: "请输入岗位名称" }]}
|
loading={loading}
|
||||||
onFinish={getPositionData}
|
formLine={[
|
||||||
|
<Form.Item key="positionName" name="positionName">
|
||||||
|
<Input allowClear placeholder="请输入岗位名称" />
|
||||||
|
</Form.Item>,
|
||||||
|
]}
|
||||||
|
onFinish={() => fetchPositionData(1, 10)}
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
/>
|
/>
|
||||||
<Table
|
<Table
|
||||||
toolBarRender={() => (
|
footer={() => (
|
||||||
<Button type="primary" icon={<AddIcon />} onClick={() => openPositionModal()}>
|
<Button
|
||||||
|
type="primary"
|
||||||
|
icon={<PlusOutlined />}
|
||||||
|
onClick={() => openPositionModal()}
|
||||||
|
>
|
||||||
新增岗位
|
新增岗位
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
@ -273,13 +337,38 @@ function DepartmentPositionPage(props) {
|
||||||
width: 160,
|
width: 160,
|
||||||
render: (_, record) => (
|
render: (_, record) => (
|
||||||
<TableAction>
|
<TableAction>
|
||||||
<Button type="link" onClick={() => openPositionModal(record)}>编辑</Button>
|
<Button
|
||||||
<Button danger type="link" onClick={() => onDeletePosition(record.id)}>删除</Button>
|
type="link"
|
||||||
|
onClick={() => openPositionModal(record)}
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
danger
|
||||||
|
type="link"
|
||||||
|
onClick={() => onDeletePosition(record.id)}
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
</TableAction>
|
</TableAction>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
{...positionTableProps}
|
dataSource={dataSource}
|
||||||
|
loading={loading}
|
||||||
|
pagination={{
|
||||||
|
current: pageIndex,
|
||||||
|
pageSize,
|
||||||
|
total,
|
||||||
|
showSizeChanger: true,
|
||||||
|
showTotal: (t) => `共 ${t} 条`,
|
||||||
|
}}
|
||||||
|
scroll={{ y: props.scrollY }}
|
||||||
|
onChange={(pag) => {
|
||||||
|
setPageIndex(pag.current);
|
||||||
|
setPageSize(pag.pageSize);
|
||||||
|
fetchPositionData(pag.current, pag.pageSize);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -292,6 +381,7 @@ function DepartmentPositionPage(props) {
|
||||||
<DeptFormModal
|
<DeptFormModal
|
||||||
open={deptModalOpen}
|
open={deptModalOpen}
|
||||||
currentId={currentId}
|
currentId={currentId}
|
||||||
|
selectedDeptId={selectedDept?.id}
|
||||||
staffOptions={staffOptions}
|
staffOptions={staffOptions}
|
||||||
treeData={treeData}
|
treeData={treeData}
|
||||||
requestAdd={props.orgDepartmentAdd}
|
requestAdd={props.orgDepartmentAdd}
|
||||||
|
|
@ -330,10 +420,20 @@ function DepartmentPositionPage(props) {
|
||||||
label="岗位职责"
|
label="岗位职责"
|
||||||
rules={[{ required: true, message: "请输入岗位职责" }]}
|
rules={[{ required: true, message: "请输入岗位职责" }]}
|
||||||
>
|
>
|
||||||
<Input.TextArea rows={3} placeholder="请输入岗位职责" showCount maxLength={500} />
|
<Input.TextArea
|
||||||
|
rows={3}
|
||||||
|
placeholder="请输入岗位职责"
|
||||||
|
showCount
|
||||||
|
maxLength={500}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="remark" label="备注">
|
<Form.Item name="remark" label="备注">
|
||||||
<Input.TextArea rows={2} placeholder="请输入备注" showCount maxLength={500} />
|
<Input.TextArea
|
||||||
|
rows={2}
|
||||||
|
placeholder="请输入备注"
|
||||||
|
showCount
|
||||||
|
maxLength={500}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
@ -342,12 +442,12 @@ function DepartmentPositionPage(props) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveLeaderAccount(dept, options) {
|
function resolveManagerAccount(dept, options) {
|
||||||
if (dept?.leaderAccount) {
|
if (dept?.managerAccount) {
|
||||||
return dept.leaderAccount;
|
return dept.managerAccount;
|
||||||
}
|
}
|
||||||
if (dept?.leaderName) {
|
if (dept?.managerName) {
|
||||||
const matched = options.find((item) => item.staffName === dept.leaderName);
|
const matched = options.find((item) => item.staffName === dept.managerName);
|
||||||
return matched?.value;
|
return matched?.value;
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
@ -363,6 +463,7 @@ function DeptFormModal({
|
||||||
requestDetails,
|
requestDetails,
|
||||||
onCancel,
|
onCancel,
|
||||||
onSuccess,
|
onSuccess,
|
||||||
|
selectedDeptId,
|
||||||
}) {
|
}) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
|
@ -389,8 +490,12 @@ function DeptFormModal({
|
||||||
let dept = null;
|
let dept = null;
|
||||||
const getDetails = requestDetailsRef.current;
|
const getDetails = requestDetailsRef.current;
|
||||||
if (typeof getDetails === "function") {
|
if (typeof getDetails === "function") {
|
||||||
const res = await safeRequest(getDetails, { id: currentId });
|
try {
|
||||||
dept = res?.data || null;
|
const res = await getDetails({ id: currentId });
|
||||||
|
dept = res?.data || null;
|
||||||
|
} catch {
|
||||||
|
dept = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!dept) {
|
if (!dept) {
|
||||||
dept = findDeptNode(treeDataRef.current, currentId);
|
dept = findDeptNode(treeDataRef.current, currentId);
|
||||||
|
|
@ -398,8 +503,8 @@ function DeptFormModal({
|
||||||
if (!cancelled && dept) {
|
if (!cancelled && dept) {
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
...dept,
|
...dept,
|
||||||
leaderAccount: resolveLeaderAccount(dept, staffOptionsRef.current),
|
managerAccount: resolveManagerAccount(dept, staffOptionsRef.current),
|
||||||
leaderName: dept.leaderName,
|
managerName: dept.managerName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -413,9 +518,9 @@ function DeptFormModal({
|
||||||
};
|
};
|
||||||
}, [open, currentId]);
|
}, [open, currentId]);
|
||||||
|
|
||||||
const onLeaderChange = (account) => {
|
const onManagerChange = (account) => {
|
||||||
const staff = staffOptions.find((s) => s.value === account);
|
const staff = staffOptions.find((s) => s.value === account);
|
||||||
form.setFieldValue("leaderName", staff?.staffName || "");
|
form.setFieldValue("managerName", staff?.staffName || "");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (values) => {
|
const handleSubmit = async (values) => {
|
||||||
|
|
@ -432,16 +537,14 @@ function DeptFormModal({
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
onCancel();
|
onCancel();
|
||||||
await onSuccess();
|
await onSuccess();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
message.error(res?.message || "操作失败");
|
message.error(res?.message || "操作失败");
|
||||||
}
|
}
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
console.log(treeData);
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
open={open}
|
open={open}
|
||||||
|
|
@ -454,6 +557,19 @@ function DeptFormModal({
|
||||||
onOk={form.submit}
|
onOk={form.submit}
|
||||||
>
|
>
|
||||||
<Form form={form} layout="vertical" onFinish={handleSubmit}>
|
<Form form={form} layout="vertical" onFinish={handleSubmit}>
|
||||||
|
<Form.Item name="parentId" label="上级部门" initialValue={selectedDeptId}>
|
||||||
|
<TreeSelect
|
||||||
|
treeData={treeData}
|
||||||
|
allowClear
|
||||||
|
fieldNames={{
|
||||||
|
label: "deptName",
|
||||||
|
value: "id",
|
||||||
|
children: "children",
|
||||||
|
}}
|
||||||
|
showSearch
|
||||||
|
placeholder="请选择上级部门"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="deptName"
|
name="deptName"
|
||||||
label="部门名称"
|
label="部门名称"
|
||||||
|
|
@ -461,20 +577,20 @@ function DeptFormModal({
|
||||||
>
|
>
|
||||||
<Input placeholder="请输入部门名称" />
|
<Input placeholder="请输入部门名称" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="leaderAccount" label="负责人">
|
<Form.Item name="managerAccount" label="负责人">
|
||||||
<Select
|
<Select
|
||||||
allowClear
|
allowClear
|
||||||
showSearch
|
showSearch
|
||||||
placeholder="请选择负责人"
|
placeholder="请选择负责人"
|
||||||
options={staffOptions}
|
options={staffOptions}
|
||||||
optionFilterProp="label"
|
optionFilterProp="label"
|
||||||
onChange={onLeaderChange}
|
onChange={onManagerChange}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="leaderName" hidden>
|
<Form.Item name="managerName" hidden>
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="deptLevel" label="部门级别">
|
<Form.Item name="deptLevelName" label="部门级别">
|
||||||
<Input placeholder="请输入部门级别" />
|
<Input placeholder="请输入部门级别" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
@ -482,4 +598,7 @@ function DeptFormModal({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Connect([NS_ORG_DEPARTMENT, NS_ORG_POSITION, NS_STAFF_INFO], true)(DepartmentPositionPage);
|
export default Connect(
|
||||||
|
[NS_ORG_DEPARTMENT, NS_ORG_POSITION, NS_STAFF_INFO],
|
||||||
|
true,
|
||||||
|
)(AntdTableFuncControl(DepartmentPositionPage));
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import { NS_QUAL_EXPERT } from "~/enumerate/namespace";
|
import { NS_QUAL_EXPERT } from "~/enumerate/namespace";
|
||||||
import { GENDER_OPTIONS, GENDER_MAP } from "~/enumerate/constant";
|
import { GENDER_OPTIONS, GENDER_MAP } from "~/enumerate/constant";
|
||||||
import AttachmentUpload from "~/components/AttachmentUpload";
|
import AttachmentUpload from "~/components/AttachmentUpload";
|
||||||
|
import { idCardRule } from "~/utils/validators";
|
||||||
|
|
||||||
const { router } = tools;
|
const { router } = tools;
|
||||||
|
|
||||||
|
|
@ -332,7 +333,7 @@ const ExperManage = (props) => {
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="idCardNo" label="身份证号">
|
<Form.Item name="idCardNo" label="身份证号" rules={[idCardRule()]}>
|
||||||
<Input placeholder="请输入" allowClear />
|
<Input placeholder="请输入" allowClear />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<AttachmentUpload name="certificate" maxCount={1} label="证书" />
|
<AttachmentUpload name="certificate" maxCount={1} label="证书" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue