管理人员角色删除功能优化

This commit is contained in:
禺狨 2023-04-04 14:49:28 +08:00
parent 81e925794b
commit 64511b9cba
2 changed files with 14 additions and 4 deletions

View File

@ -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<boolean>(true);
const [selectKey, setSelectKey] = useState<any>([]);
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) {

View File

@ -39,6 +39,7 @@ const SystemAdministratorPage = () => {
const [cid, setCid] = useState<number>(0);
const [role_ids, setRoleIds] = useState<any>([]);
const [selLabel, setLabel] = useState<string>("全部管理员");
const [roleDelSuccess, setRoleDelSuccess] = useState(false);
const [name, setName] = useState<string>("");
@ -55,12 +56,14 @@ const SystemAdministratorPage = () => {
<div className="float-left">
{userRoleIds[id] &&
userRoleIds[id].map((item: any, index: number) => {
return (
return roles[item] ? (
<span key={index}>
{index === userRoleIds[id].length - 1
? roles[item][0].name
: roles[item][0].name + "、"}
</span>
) : (
""
);
})}
</div>
@ -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 = () => {
<div className="tree-main-body">
<div className="left-box">
<TreeAdminroles
roleDelSuccess={roleDelSuccess}
refresh={refresh}
type=""
text={"管理员"}
@ -248,7 +253,7 @@ const SystemAdministratorPage = () => {
<PerButton
text="角色权限"
icon={null}
class="ml-16"
class="mr-16"
type="default"
p="admin-role"
onClick={() => {
@ -259,7 +264,7 @@ const SystemAdministratorPage = () => {
<PerButton
text="删除角色"
icon={null}
class="ml-16"
class="mr-16"
type="default"
p="admin-role"
onClick={() => {