From 64511b9cba16047b9b2ee0b4760531f75558b066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Tue, 4 Apr 2023 14:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BA=BA=E5=91=98=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compenents/tree-adminroles/index.tsx | 7 ++++++- src/pages/system/administrator/index.tsx | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/compenents/tree-adminroles/index.tsx b/src/compenents/tree-adminroles/index.tsx index 67d0b90..e87a5b0 100644 --- a/src/compenents/tree-adminroles/index.tsx +++ b/src/compenents/tree-adminroles/index.tsx @@ -10,6 +10,7 @@ interface Option { interface PropInterface { refresh: boolean; + roleDelSuccess: boolean; type: string; text: string; onUpdate: (keys: any, title: any) => void; @@ -20,6 +21,10 @@ export const TreeAdminroles = (props: PropInterface) => { const [loading, setLoading] = useState(true); const [selectKey, setSelectKey] = useState([]); + useEffect(() => { + onSelect([], ""); + }, [props.roleDelSuccess]); + useEffect(() => { adminRole.adminRoleList().then((res: any) => { let adminrole = res.data; @@ -34,9 +39,9 @@ export const TreeAdminroles = (props: PropInterface) => { } setTreeData(new_arr); } - onSelect([], ""); }); }, [props.refresh]); + const onSelect = (selectedKeys: any, info: any) => { let label = "全部" + props.text; if (info) { diff --git a/src/pages/system/administrator/index.tsx b/src/pages/system/administrator/index.tsx index d84573a..4293adc 100644 --- a/src/pages/system/administrator/index.tsx +++ b/src/pages/system/administrator/index.tsx @@ -39,6 +39,7 @@ const SystemAdministratorPage = () => { const [cid, setCid] = useState(0); const [role_ids, setRoleIds] = useState([]); const [selLabel, setLabel] = useState("全部管理员"); + const [roleDelSuccess, setRoleDelSuccess] = useState(false); const [name, setName] = useState(""); @@ -55,12 +56,14 @@ const SystemAdministratorPage = () => {
{userRoleIds[id] && userRoleIds[id].map((item: any, index: number) => { - return ( + return roles[item] ? ( {index === userRoleIds[id].length - 1 ? roles[item][0].name : roles[item][0].name + "、"} + ) : ( + "" ); })}
@@ -195,6 +198,7 @@ const SystemAdministratorPage = () => { adminRole.destroyAdminRole(role_ids[0]).then((res: any) => { message.success("操作成功"); setRefresh(!refresh); + setRoleDelSuccess(!roleDelSuccess); }); }, onCancel() { @@ -208,6 +212,7 @@ const SystemAdministratorPage = () => {
{ { @@ -259,7 +264,7 @@ const SystemAdministratorPage = () => { {