From 392df0bc53c0b5ea2e3bcca991ef27f4c7d467f9 Mon Sep 17 00:00:00 2001 From: tangjie <122778500@qq.com> Date: Thu, 30 Jul 2026 10:20:38 +0800 Subject: [PATCH] fix --- .../ProjectFlow/TeamContent.js | 245 ++++++++++++++---- 1 file changed, 192 insertions(+), 53 deletions(-) diff --git a/src/pages/Container/SafetyEvalBusiness/ProjectFlow/TeamContent.js b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/TeamContent.js index 4162f40..f0d31bb 100644 --- a/src/pages/Container/SafetyEvalBusiness/ProjectFlow/TeamContent.js +++ b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/TeamContent.js @@ -1,19 +1,31 @@ import React, { useEffect, useState } from "react"; import { - Tag, Button, Card, Row, Col, Table, Statistic, Flex, Modal, Radio, Checkbox, message, Spin, + Tag, + Button, + Card, + Row, + Col, + Table, + Statistic, + Flex, + Modal, + Radio, + Checkbox, + message, + Spin, } from "antd"; import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { NS_SAFETY_EVAL_BUSINESS } from "~/enumerate/namespace"; import { tools } from "@cqsjjb/jjb-common-lib"; -import {ROLE_DEFINITIONS} from '~/enumerate/constant' +import { ROLE_DEFINITIONS } from "~/enumerate/constant"; const { router } = tools; - - const TeamContent = ({ readOnly, ...props }) => { - const { safetyEvalBusiness, evalProjectMemberPage, evalProjectMemberSave } = props; - const { evalProjectDetailData, memberLoading, memberSaveLoading } = safetyEvalBusiness || {}; + const { safetyEvalBusiness, evalProjectMemberPage, evalProjectMemberSave } = + props; + const { evalProjectDetailData, memberLoading, memberSaveLoading } = + safetyEvalBusiness || {}; const participants = evalProjectDetailData?.participants || []; const projectId = router.query?.id; @@ -31,7 +43,10 @@ const TeamContent = ({ readOnly, ...props }) => { ...item, roles: (item.role || []).map((r) => ({ role: r, - duty: item.responsibility || ROLE_DEFINITIONS.find((d) => d.value === r)?.summary || "", + duty: + item.responsibility || + ROLE_DEFINITIONS.find((d) => d.value === r)?.summary || + "", })), })), ); @@ -42,7 +57,9 @@ const TeamContent = ({ readOnly, ...props }) => { if (evalProjectDetailData?.id) fetchData(); }, [projectId, evalProjectDetailData?.id]); - const isUniqueRole = selectedRole && ROLE_DEFINITIONS.find((r) => r.value === selectedRole)?.unique; + const isUniqueRole = + selectedRole && + ROLE_DEFINITIONS.find((r) => r.value === selectedRole)?.unique; const handlePersonChange = (checkedValues) => { if (isUniqueRole && checkedValues.length > 1) { @@ -59,13 +76,24 @@ const TeamContent = ({ readOnly, ...props }) => { }; const handleConfirm = () => { - if (!selectedRole) { message.warning("请选择1个项目角色"); return; } - if (selectedPersons.length === 0) { message.warning("请至少选择1名人员"); return; } + if (!selectedRole) { + message.warning("请选择1个项目角色"); + return; + } + if (selectedPersons.length === 0) { + message.warning("请至少选择1名人员"); + return; + } const role = ROLE_DEFINITIONS.find((r) => r.value === selectedRole); - if (role?.unique && selectedPersons.length > 1) { message.warning("该角色为单人唯一角色,只能选择1名人员"); return; } + if (role?.unique && selectedPersons.length > 1) { + message.warning("该角色为单人唯一角色,只能选择1名人员"); + return; + } // 唯一角色校验:检查是否已有人担任该角色 if (role?.unique) { - const existing = teamMembers.some((m) => m.roles.some((r) => r.role === selectedRole)); + const existing = teamMembers.some((m) => + m.roles.some((r) => r.role === selectedRole), + ); if (existing) { message.warning(`"${role.name}"已配置,不可重复添加`); return; @@ -88,7 +116,9 @@ const TeamContent = ({ readOnly, ...props }) => { setTeamMembers((prev) => { const merged = [...prev]; newEntries.forEach((entry) => { - const existing = merged.find((m) => m.personnelId === entry.personnelId); + const existing = merged.find( + (m) => m.personnelId === entry.personnelId, + ); if (existing) { if (!existing.roles.find((r) => r.role === entry.roles[0].role)) { existing.roles.push(entry.roles[0]); @@ -140,32 +170,63 @@ const TeamContent = ({ readOnly, ...props }) => { { title: "姓名", dataIndex: "personnelName", width: 120, ellipsis: true }, { title: "部门/岗位", dataIndex: "deptName", width: 200, ellipsis: true }, { - title: "项目角色", dataIndex: "roles", width: 350, + title: "项目角色", + dataIndex: "roles", + width: 350, render: (roles, record) => (
- {roles.map((r) => ( - { - setTeamMembers((prev) => prev.map((m) => { - if (m.personnelId !== record.personnelId) return m; - const updated = m.roles.filter((role) => role.role !== r.role); - return updated.length > 0 ? { ...m, roles: updated } : null; - }).filter(Boolean)); - }}> - {ROLE_DEFINITIONS.find((d) => d.value === r.role)?.name || r.role} - - ))} + {roles.map((r) => { + const inOnly = r.role === "PROJECT_LEAD" || r.role === "PROCESS_CONTROL_LEAD"; + return ( + { + setTeamMembers((prev) => + prev + .map((m) => { + if (m.personnelId !== record.personnelId) return m; + const updated = m.roles.filter( + (role) => role.role !== r.role, + ); + return updated.length > 0 + ? { ...m, roles: updated } + : null; + }) + .filter(Boolean), + ); + }} + > + {ROLE_DEFINITIONS.find((d) => d.value === r.role)?.name || + r.role} + + ); + })}
), }, { title: "资质与专业", dataIndex: "capacity", width: 200, ellipsis: true }, { - title: "主要职责", dataIndex: "roles", ellipsis: true, + title: "主要职责", + dataIndex: "roles", + ellipsis: true, render: (roles) => roles.map((r) => r.duty).join(";"), }, { - title: "操作", width: 80, fixed: "right", + title: "操作", + width: 80, + fixed: "right", render: (_, record) => ( - + ), }, ]; @@ -174,7 +235,9 @@ const TeamContent = ({ readOnly, ...props }) => {
- 评价部经理 / 机构主账号 + + 评价部经理 / 机构主账号 + 添加人员时可同时选择多个项目角色和多名人员;普通角色可配置多人。"项目负责人(项目组组长)"和"过程控制负责人"每个项目只能配置1人,选择任一唯一角色时,本次只能选择1名人员。 @@ -183,42 +246,83 @@ const TeamContent = ({ readOnly, ...props }) => { - + - + - + - + - {!readOnly && } + {!readOnly && ( + + )} - +
- 查看11类项目角色职责说明 + + 查看11类项目角色职责说明 +
{ROLE_DEFINITIONS.map((role) => (
{role.name} - {role.unique && 单人唯一} + {role.unique && ( + + 单人唯一 + + )}

{role.summary}

@@ -227,38 +331,62 @@ const TeamContent = ({ readOnly, ...props }) => {
- {!readOnly && } + {!readOnly && ( + + )} - setModalOpen(false)} width={700} + setModalOpen(false)} + width={700} footer={ - + } >
- {selectedRole && ROLE_DEFINITIONS.find((r) => r.value === selectedRole)?.unique + {selectedRole && + ROLE_DEFINITIONS.find((r) => r.value === selectedRole)?.unique ? `已选择唯一角色,人员数量限制为1人。当前已选 ${selectedPersons.length} 人。` : `已选择 ${selectedRole ? 1 : 0} 个角色、${selectedPersons.length} 名人员。`}

1. 选择项目角色

- { setSelectedRole(e.target.value); setSelectedPersons([]); }} + { + setSelectedRole(e.target.value); + setSelectedPersons([]); + }} className="pf-w-full" >
{ROLE_DEFINITIONS.map((role) => ( - @@ -272,16 +400,27 @@ const TeamContent = ({ readOnly, ...props }) => { {participants.length === 0 ? (
暂无可用人员数据
) : ( - +
{participants.map((person) => ( - ))} @@ -295,4 +434,4 @@ const TeamContent = ({ readOnly, ...props }) => { ); }; -export default Connect([NS_SAFETY_EVAL_BUSINESS], true)(TeamContent); \ No newline at end of file +export default Connect([NS_SAFETY_EVAL_BUSINESS], true)(TeamContent);