From c8fd19b3b8d8cf975738c173ba46e42b23938505 Mon Sep 17 00:00:00 2001 From: tangjie <122778500@qq.com> Date: Wed, 8 Jul 2026 09:37:21 +0800 Subject: [PATCH 1/2] feat --- jjb.config.js | 2 +- src/api/orgDepartment/index.js | 63 ++-- src/api/orgPosition/index.js | 41 ++- .../DepartmentPosition/index.js | 285 +++++++++++++----- 4 files changed, 248 insertions(+), 143 deletions(-) diff --git a/jjb.config.js b/jjb.config.js index c15b130..aa068d2 100644 --- a/jjb.config.js +++ b/jjb.config.js @@ -10,7 +10,7 @@ module.exports = { javaGitBranch: "", // 本地联调 safetyEval-service(context-path: /safetyEval,默认端口 8095) // 可通过环境变量覆盖: SAFETY_EVAL_API_HOST=http://192.168.x.x:8095 - API_HOST: "http://127.0.0.1", + API_HOST: "http://192.168.0.152", }, production: { // 应用后端分支名称,部署上线需要 diff --git a/src/api/orgDepartment/index.js b/src/api/orgDepartment/index.js index b8a8d35..9ed703a 100644 --- a/src/api/orgDepartment/index.js +++ b/src/api/orgDepartment/index.js @@ -1,42 +1,35 @@ 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 () => { - const res = await apiGet("/safetyEval/org-department/page", toPageQuery({ current: 1, size: 500 })); - const pageData = fromPageResponse(res, toDepartmentForm); - return { - success: true, - data: buildDepartmentTree(pageData.data || []), - }; -})); +export const orgDepartmentGet = declareRequest( + "orgDepartmentLoading", + "Get > /safetyEval/org-department/get", + "orgDepartmentDetail: {} | res.data || {}", +); -export const orgDepartmentList = declareRequest("orgDepartmentLoading", safePageResult(async (params) => { - const query = toPageQuery(params, { likeDeptName: "deptName" }); - const res = await apiGet("/safetyEval/org-department/page", query); - return fromPageResponse(res, toDepartmentForm); -})); +export const orgDepartmentTree = declareRequest( + "orgDepartmentLoading", + "Get > /safetyEval/org-department/tree", + "orgDepartmentTreeData: [] | res.data || []", + ); -export const orgDepartmentAdd = declareRequest("orgDepartmentLoading", safeAction(async (values) => { - return apiPost("/safetyEval/org-department/save", fromDepartmentForm(values)); -})); +export const orgDepartmentList = declareRequest( + "orgDepartmentLoading", + "Get > /safetyEval/org-department/page", + "dataSource: [] | res.data || [] & total: 0 | res.totalCount || 0", +); -export const orgDepartmentEdit = declareRequest("orgDepartmentLoading", safeAction(async (values) => { - return apiPost("/safetyEval/org-department/modify", fromDepartmentForm(values)); -})); +export const orgDepartmentAdd = declareRequest( + "orgDepartmentLoading", + "Post > @/safetyEval/org-department/save", +); -export const orgDepartmentRemove = declareRequest("orgDepartmentLoading", safeAction(async ({ id }) => { - return apiPostDelete("/safetyEval/org-department/delete", id); -})); +export const orgDepartmentEdit = declareRequest( + "orgDepartmentLoading", + "Post > @/safetyEval/org-department/modify", +); + +export const orgDepartmentRemove = declareRequest( + "orgDepartmentLoading", + "Post > @/safetyEval/org-department/delete", +); diff --git a/src/api/orgPosition/index.js b/src/api/orgPosition/index.js index 41571be..0fb09d1 100644 --- a/src/api/orgPosition/index.js +++ b/src/api/orgPosition/index.js @@ -1,29 +1,22 @@ 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) => { - const query = toPageQuery(params, { - eqDeptId: "deptId", - likePositionName: "positionName", - }); - const res = await apiGet("/safetyEval/org-position/page", query); - return fromPageResponse(res, toPositionForm); -})); +export const orgPositionList = declareRequest( + "orgPositionLoading", + "Get > /safetyEval/org-position/page", + "dataSource: [] | res.data || [] & total: 0 | res.totalCount || 0", +); -export const orgPositionAdd = declareRequest("orgPositionLoading", safeAction(async (values) => { - return apiPost("/safetyEval/org-position/save", fromPositionForm(values)); -})); +export const orgPositionAdd = declareRequest( + "orgPositionLoading", + "Post > @/safetyEval/org-position/save", +); -export const orgPositionEdit = declareRequest("orgPositionLoading", safeAction(async (values) => { - return apiPost("/safetyEval/org-position/modify", fromPositionForm(values)); -})); +export const orgPositionEdit = declareRequest( + "orgPositionLoading", + "Post > @/safetyEval/org-position/modify", +); -export const orgPositionRemove = declareRequest("orgPositionLoading", safeAction(async ({ id }) => { - return apiPostDelete("/safetyEval/org-position/delete", id); -})); +export const orgPositionRemove = declareRequest( + "orgPositionLoading", + "Post > @/safetyEval/org-position/delete", +); diff --git a/src/pages/Container/EnterpriseInfo/DepartmentPosition/index.js b/src/pages/Container/EnterpriseInfo/DepartmentPosition/index.js index f164d65..67556da 100644 --- a/src/pages/Container/EnterpriseInfo/DepartmentPosition/index.js +++ b/src/pages/Container/EnterpriseInfo/DepartmentPosition/index.js @@ -1,15 +1,30 @@ +import { PlusOutlined } from "@ant-design/icons"; 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 { 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 Search from "zy-react-library/components/Search"; -import Table from "zy-react-library/components/Table"; -import useTable from "zy-react-library/hooks/useTable"; -import { NS_ORG_DEPARTMENT, NS_ORG_POSITION, NS_STAFF_INFO } from "~/enumerate/namespace"; +import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm"; + +import { + NS_ORG_DEPARTMENT, + NS_ORG_POSITION, + NS_STAFF_INFO, +} from "~/enumerate/namespace"; import { asId, sameId } from "~/utils/enterpriseInfo/idUtil"; -import { safeListRequest, safeRequest } from "~/utils"; function findDeptNode(nodes = [], id) { for (const node of nodes) { @@ -33,9 +48,9 @@ function toSelectedDept(node) { return { id: asId(node.id), deptName: node.deptName || node.title, - leaderAccount: node.leaderAccount, - leaderName: node.leaderName, - deptLevel: node.deptLevel, + managerAccount: node.managerAccount, + managerName: node.managerName, + deptLevelName: node.deptLevelName, }; } @@ -49,50 +64,62 @@ function DepartmentPositionPage(props) { const [staffOptions, setStaffOptions] = useState([]); const [positionForm] = 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(() => { (async () => { try { - const res = await props.staffInfoList?.({ pageIndex: 1, pageSize: 500 }); - setStaffOptions((res?.data || []).map((s) => ({ - label: `${s.userName ?? s.staffName}(${s.account})`, - value: s.account, - staffName: s.userName ?? s.staffName, - }))); - } - catch (err) { + const res = await props.staffInfoList?.({ + pageIndex: 1, + pageSize: 500, + }); + setStaffOptions( + (res?.data || []).map((s) => ({ + label: `${s.userName ?? s.staffName}(${s.account})`, + value: s.account, + staffName: s.userName ?? s.staffName, + })), + ); + } catch (err) { console.warn("[DepartmentPosition] load staff options failed:", err); } })(); }, []); - const { tableProps: positionTableProps, getData: getPositionData } = useTable( - safeListRequest(props.orgPositionList), - { - form: positionForm, - transform: (formData) => ({ + const fetchPositionData = async (page = 1, size = 10) => { + if (!selectedDept?.id) return; + setLoading(true); + try { + const formData = positionForm.getFieldsValue(); + const res = await props.orgPositionList({ ...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 () => { try { const res = await props.orgDepartmentTree(); - const normalizeTree = (nodes = []) => nodes.map((node) => ({ - ...node, - title: node.title || node.deptName, - deptName: node.deptName || node.title, - children: node.children ? normalizeTree(node.children) : [], - })); - const tree = normalizeTree(res?.data || []); + const tree = res?.data || []; setTreeData(tree); - if ( tree.length) { + if (tree.length) { setSelectedDept(toSelectedDept(tree[0])); } - } - catch (err) { + } catch (err) { console.warn("[DepartmentPosition] loadTree failed:", err); setTreeData([]); } @@ -104,7 +131,7 @@ function DepartmentPositionPage(props) { useEffect(() => { if (selectedDept?.id) { - getPositionData(); + fetchPositionData(1, 10); } }, [selectedDept?.id]); @@ -134,7 +161,7 @@ function DepartmentPositionPage(props) { okText: "是", cancelText: "否", onOk: async () => { - const res = await props.orgDepartmentRemove({ id }); + const res = await props.orgDepartmentRemove({ data: id }); if (res?.success !== false) { message.success("删除成功"); if (sameId(selectedDept?.id, id)) { @@ -156,7 +183,7 @@ function DepartmentPositionPage(props) { const res = await props.orgPositionRemove({ id }); if (res?.success !== false) { message.success("删除成功"); - getPositionData(); + fetchPositionData(1, 10); } }, }); @@ -192,9 +219,11 @@ function DepartmentPositionPage(props) { deptId: asId(record.deptId || selectedDept.id), deptName: record.deptName || selectedDept.deptName, }); - } - else { - modalForm.setFieldsValue({ deptId: asId(selectedDept.id), deptName: selectedDept.deptName }); + } else { + modalForm.setFieldsValue({ + deptId: asId(selectedDept.id), + deptName: selectedDept.deptName, + }); } setPositionModalOpen(true); }; @@ -210,9 +239,8 @@ function DepartmentPositionPage(props) { if (res?.success !== false) { message.success(currentId ? "编辑成功" : "添加成功"); closePositionModal(); - getPositionData(); - } - else { + fetchPositionData(pageIndex, pageSize); + } else { message.error(res?.message || "操作失败"); } }; @@ -220,9 +248,24 @@ function DepartmentPositionPage(props) { return (
-
- - {selectedDept?.id ? ( <> -
+
当前部门: {selectedDept.deptName} - - + +
- + + , + ]} + onFinish={() => fetchPositionData(1, 10)} + style={{ marginBottom: 16 }} /> ( - )} @@ -273,13 +337,38 @@ function DepartmentPositionPage(props) { width: 160, render: (_, record) => ( - - + + ), }, ]} - {...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) { - + - + @@ -342,12 +442,12 @@ function DepartmentPositionPage(props) { ); } -function resolveLeaderAccount(dept, options) { - if (dept?.leaderAccount) { - return dept.leaderAccount; +function resolveManagerAccount(dept, options) { + if (dept?.managerAccount) { + return dept.managerAccount; } - if (dept?.leaderName) { - const matched = options.find((item) => item.staffName === dept.leaderName); + if (dept?.managerName) { + const matched = options.find((item) => item.staffName === dept.managerName); return matched?.value; } return undefined; @@ -363,6 +463,7 @@ function DeptFormModal({ requestDetails, onCancel, onSuccess, + selectedDeptId, }) { const [form] = Form.useForm(); const [submitting, setSubmitting] = useState(false); @@ -389,8 +490,12 @@ function DeptFormModal({ let dept = null; const getDetails = requestDetailsRef.current; if (typeof getDetails === "function") { - const res = await safeRequest(getDetails, { id: currentId }); - dept = res?.data || null; + try { + const res = await getDetails({ id: currentId }); + dept = res?.data || null; + } catch { + dept = null; + } } if (!dept) { dept = findDeptNode(treeDataRef.current, currentId); @@ -398,8 +503,8 @@ function DeptFormModal({ if (!cancelled && dept) { form.setFieldsValue({ ...dept, - leaderAccount: resolveLeaderAccount(dept, staffOptionsRef.current), - leaderName: dept.leaderName, + managerAccount: resolveManagerAccount(dept, staffOptionsRef.current), + managerName: dept.managerName, }); } }; @@ -413,9 +518,9 @@ function DeptFormModal({ }; }, [open, currentId]); - const onLeaderChange = (account) => { + const onManagerChange = (account) => { const staff = staffOptions.find((s) => s.value === account); - form.setFieldValue("leaderName", staff?.staffName || ""); + form.setFieldValue("managerName", staff?.staffName || ""); }; const handleSubmit = async (values) => { @@ -432,16 +537,14 @@ function DeptFormModal({ form.resetFields(); onCancel(); await onSuccess(); - } - else { + } else { message.error(res?.message || "操作失败"); } - } - finally { + } finally { setSubmitting(false); } }; - + console.log(treeData); return (
+ + + - + - + @@ -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)); From bea20fd2978bd9eca4ea9f5298ee1ead80a6c6e4 Mon Sep 17 00:00:00 2001 From: tangjie <122778500@qq.com> Date: Wed, 8 Jul 2026 09:53:55 +0800 Subject: [PATCH 2/2] fix --- src/pages/Container/Supervision/ExperManage/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/Container/Supervision/ExperManage/index.js b/src/pages/Container/Supervision/ExperManage/index.js index 846dee1..f690d29 100644 --- a/src/pages/Container/Supervision/ExperManage/index.js +++ b/src/pages/Container/Supervision/ExperManage/index.js @@ -19,6 +19,7 @@ import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { NS_QUAL_EXPERT } from "~/enumerate/namespace"; import { GENDER_OPTIONS, GENDER_MAP } from "~/enumerate/constant"; import AttachmentUpload from "~/components/AttachmentUpload"; +import { idCardRule } from "~/utils/validators"; const { router } = tools; @@ -332,7 +333,7 @@ const ExperManage = (props) => { ))} - +