管理人员角色删除功能以及选择权限弹窗样式优化

This commit is contained in:
禺狨 2023-04-04 14:32:01 +08:00
parent b2d6b4af75
commit 81e925794b
5 changed files with 72 additions and 25 deletions

View File

@ -34,6 +34,7 @@ export const TreeAdminroles = (props: PropInterface) => {
}
setTreeData(new_arr);
}
onSelect([], "");
});
}, [props.refresh]);
const onSelect = (selectedKeys: any, info: any) => {

View File

@ -450,6 +450,12 @@ textarea.ant-input {
background-color: #fff2f0 !important;
border-radius: 6px !important;
overflow: hidden;
.ant-tree-node-content-wrapper {
background-color: transparent !important;
}
.ant-tree-node-content-wrapper-normal {
background-color: transparent !important;
}
}
.ant-tree-node-content-wrapper {
width: 100% !important;

View File

@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
import { Typography, Input, Button, Space, Table, Modal, message } from "antd";
import type { ColumnsType } from "antd/es/table";
import { PlusOutlined, ExclamationCircleFilled } from "@ant-design/icons";
import { adminUser } from "../../../api/index";
import { adminUser, adminRole } from "../../../api/index";
import { dateFormat } from "../../../utils/index";
import { useNavigate } from "react-router-dom";
import { TreeAdminroles, PerButton } from "../../../compenents";
@ -180,6 +180,29 @@ const SystemAdministratorPage = () => {
});
};
const delAdminRole = () => {
if (role_ids.length === 0) {
return;
}
confirm({
title: "操作确认",
icon: <ExclamationCircleFilled />,
content: "删除此角色会同时删除管理员对应关联权限,确认删除?",
centered: true,
okText: "确认",
cancelText: "取消",
onOk() {
adminRole.destroyAdminRole(role_ids[0]).then((res: any) => {
message.success("操作成功");
setRefresh(!refresh);
});
},
onCancel() {
console.log("Cancel");
},
});
};
return (
<>
<div className="tree-main-body">
@ -200,26 +223,52 @@ const SystemAdministratorPage = () => {
</div>
<div className="float-left j-b-flex mb-24">
<div className="d-flex">
<PerButton
type="primary"
text="添加管理员"
class="mr-16"
icon={<PlusOutlined />}
p="admin-user-cud"
onClick={() => setCreateVisible(true)}
disabled={null}
/>
{role_ids.length === 0 && (
<PerButton
text="新建角色"
icon={<PlusOutlined />}
icon={null}
class="mr-16"
type="primary"
type="default"
p="admin-role"
onClick={() => setCreateRoleVisible(true)}
disabled={null}
/>
)}
<PerButton
type="default"
text="添加管理员"
class="mr-16"
icon={null}
p="admin-user-cud"
onClick={() => setCreateVisible(true)}
disabled={null}
/>
{role_ids.length > 0 && (
<>
<PerButton
text="角色权限"
icon={null}
class="ml-16"
type="default"
p="admin-role"
onClick={() => {
setUpdateRoleVisible(true);
}}
disabled={null}
/>
<PerButton
text="删除角色"
icon={null}
class="ml-16"
type="default"
p="admin-role"
onClick={() => {
delAdminRole();
}}
disabled={null}
/>
</>
)}
</div>
<div className="d-flex">
<div className="d-flex mr-24">
@ -246,19 +295,6 @@ const SystemAdministratorPage = () => {
>
</Button>
{role_ids.length > 0 && (
<PerButton
text="角色权限"
icon={null}
class="ml-16"
type="default"
p="admin-role"
onClick={() => {
setUpdateRoleVisible(true);
}}
disabled={null}
/>
)}
</div>
</div>
</div>

View File

@ -177,6 +177,7 @@ export const SystemAdminrolesCreate: React.FC<PropInterface> = ({
</Form.Item>
<Form.Item label="操作权限" name="action_ids">
<TreeSelect
listHeight={600}
style={{ width: 424 }}
treeCheckable={true}
placeholder="请选择权限"
@ -187,6 +188,7 @@ export const SystemAdminrolesCreate: React.FC<PropInterface> = ({
</Form.Item>
<Form.Item label="数据权限" name="permission_ids">
<TreeSelect
listHeight={600}
style={{ width: 424 }}
treeCheckable={true}
placeholder="请选择权限"

View File

@ -187,6 +187,7 @@ export const SystemAdminrolesUpdate: React.FC<PropInterface> = ({
<Form.Item label="操作权限" name="action_ids">
<TreeSelect
style={{ width: 424 }}
listHeight={600}
treeCheckable={true}
placeholder="请选择权限"
multiple
@ -197,6 +198,7 @@ export const SystemAdminrolesUpdate: React.FC<PropInterface> = ({
<Form.Item label="数据权限" name="permission_ids">
<TreeSelect
style={{ width: 424 }}
listHeight={600}
treeCheckable={true}
placeholder="请选择权限"
multiple