mirror of
https://github.com/PlayEdu/backend
synced 2025-06-20 01:42:47 +08:00
超级管理员角色不显示角色权限和角色删除按钮
This commit is contained in:
parent
69b87930da
commit
097cbe6b63
@ -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<any>([]);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [selectKey, setSelectKey] = useState<any>([]);
|
||||
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);
|
||||
};
|
||||
|
||||
|
@ -40,6 +40,7 @@ const SystemAdministratorPage = () => {
|
||||
const [role_ids, setRoleIds] = useState<any>([]);
|
||||
const [selLabel, setLabel] = useState<string>("全部管理员");
|
||||
const [roleDelSuccess, setRoleDelSuccess] = useState(false);
|
||||
const [isSuper, setIsSuper] = useState(false);
|
||||
|
||||
const [name, setName] = useState<string>("");
|
||||
|
||||
@ -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);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@ -248,7 +250,7 @@ const SystemAdministratorPage = () => {
|
||||
disabled={null}
|
||||
/>
|
||||
)}
|
||||
{role_ids.length > 0 && (
|
||||
{!isSuper && role_ids.length > 0 && (
|
||||
<>
|
||||
<PerButton
|
||||
text="角色权限"
|
||||
|
Loading…
x
Reference in New Issue
Block a user