From 097cbe6b63b1992a2f313ab7070aeb11bdad5032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Tue, 13 Jun 2023 09:30:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E4=B8=8D=E6=98=BE=E7=A4=BA=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=92=8C=E8=A7=92=E8=89=B2=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compenents/tree-adminroles/index.tsx | 14 ++++++++++++-- src/pages/system/administrator/index.tsx | 6 ++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/compenents/tree-adminroles/index.tsx b/src/compenents/tree-adminroles/index.tsx index e87a5b0..8c5d4b2 100644 --- a/src/compenents/tree-adminroles/index.tsx +++ b/src/compenents/tree-adminroles/index.tsx @@ -13,13 +13,14 @@ interface PropInterface { roleDelSuccess: boolean; type: string; text: string; - onUpdate: (keys: any, title: any) => void; + onUpdate: (keys: any, title: any, isSuper: boolean) => void; } export const TreeAdminroles = (props: PropInterface) => { const [treeData, setTreeData] = useState([]); const [loading, setLoading] = useState(true); const [selectKey, setSelectKey] = useState([]); + const [superId, setSuperId] = useState(0); useEffect(() => { onSelect([], ""); @@ -28,6 +29,7 @@ export const TreeAdminroles = (props: PropInterface) => { useEffect(() => { adminRole.adminRoleList().then((res: any) => { let adminrole = res.data; + let superId = 0; if (adminrole.length > 0) { const new_arr: Option[] = []; for (let i = 0; i < adminrole.length; i++) { @@ -36,9 +38,13 @@ export const TreeAdminroles = (props: PropInterface) => { key: adminrole[i].id, children: [], }); + if (adminrole[i].slug === "super-role") { + superId = adminrole[i].id; + } } setTreeData(new_arr); } + setSuperId(superId); }); }, [props.refresh]); @@ -47,7 +53,11 @@ export const TreeAdminroles = (props: PropInterface) => { if (info) { label = info.node.title; } - props.onUpdate(selectedKeys, label); + let isSuper = false; + if (selectedKeys[0] === superId && superId !== 0) { + isSuper = true; + } + props.onUpdate(selectedKeys, label, isSuper); setSelectKey(selectedKeys); }; diff --git a/src/pages/system/administrator/index.tsx b/src/pages/system/administrator/index.tsx index 6161916..267780f 100644 --- a/src/pages/system/administrator/index.tsx +++ b/src/pages/system/administrator/index.tsx @@ -40,6 +40,7 @@ const SystemAdministratorPage = () => { const [role_ids, setRoleIds] = useState([]); const [selLabel, setLabel] = useState("全部管理员"); const [roleDelSuccess, setRoleDelSuccess] = useState(false); + const [isSuper, setIsSuper] = useState(false); const [name, setName] = useState(""); @@ -216,9 +217,10 @@ const SystemAdministratorPage = () => { refresh={refresh} type="" text={"管理员"} - onUpdate={(keys: any, title: any) => { + onUpdate={(keys: any, title: any, isSuper: boolean) => { setRoleIds(keys); setLabel(title); + setIsSuper(isSuper); }} /> @@ -248,7 +250,7 @@ const SystemAdministratorPage = () => { disabled={null} /> )} - {role_ids.length > 0 && ( + {!isSuper && role_ids.length > 0 && ( <>