完成授权凭证隔离

This commit is contained in:
dushixiang
2021-01-13 22:12:46 +08:00
parent 499dd3ab85
commit 4fe33eaa41
7 changed files with 176 additions and 99 deletions

View File

@ -5,7 +5,8 @@ import {
Badge,
Button,
Col,
Divider, Dropdown,
Divider,
Dropdown,
Input,
Layout,
Menu,
@ -14,6 +15,7 @@ import {
Row,
Space,
Table,
Tag,
Tooltip,
Typography,
} from "antd";
@ -22,9 +24,11 @@ import UserModal from "./UserModal";
import request from "../../common/request";
import {message} from "antd/es";
import {
DeleteOutlined, DownOutlined,
ExclamationCircleOutlined, IssuesCloseOutlined,
PlusOutlined, SmileOutlined,
DeleteOutlined,
DownOutlined,
ExclamationCircleOutlined,
IssuesCloseOutlined,
PlusOutlined,
StopOutlined,
SyncOutlined,
UndoOutlined
@ -261,6 +265,25 @@ class User extends Component {
title: '用户昵称',
dataIndex: 'nickname',
key: 'nickname',
}, {
title: '用户角色',
dataIndex: 'role',
key: 'role',
render: (role, record) => {
if (role === 'normal') {
return (
<Tag>普通用户</Tag>
);
} else if (role === 'admin') {
return (
<Tag color="blue">管理用户</Tag>
);
} else {
return role;
}
}
}, {
title: '在线状态',
dataIndex: 'online',
@ -282,33 +305,13 @@ class User extends Component {
key: 'action',
render: (text, record) => {
const menu = (
<Menu>
<Menu.Item key="1">
<Button type="text" size='small'
onClick={() => this.showDeleteConfirm(record.id, record.name)}>禁用</Button>
</Menu.Item>
<Menu.Item key="2">
<Button type="text" size='small'
onClick={() => this.showDeleteConfirm(record.id, record.name)}>启用</Button>
</Menu.Item>
<Menu.Divider />
<Menu.Item key="3">
<Button type="text" size='small'
onClick={() => this.showDeleteConfirm(record.id, record.name)}>删除</Button>
</Menu.Item>
</Menu>
);
return (
<div>
<Button type="link" size='small'
onClick={() => this.showModal('更新用户', record)}>编辑</Button>
<Dropdown overlay={menu}>
<Button type="link" size='small'>
更多 <DownOutlined />
</Button>
</Dropdown>
<Button type="link" size='small'
onClick={() => this.showDeleteConfirm(record.id, record.name)}>删除</Button>
</div>
)
},
@ -391,51 +394,52 @@ class User extends Component {
</Button>
</Tooltip>
<Tooltip title="批量启用">
<Button type="dashed" danger disabled={!hasSelected} icon={<IssuesCloseOutlined />}
loading={this.state.delBtnLoading}
onClick={() => {
const content = <div>
您确定要启用选中的<Text style={{color: '#1890FF'}}
strong>{this.state.selectedRowKeys.length}</Text>
</div>;
confirm({
icon: <ExclamationCircleOutlined/>,
content: content,
onOk: () => {
{/*<Tooltip title="批量启用">*/}
{/* <Button type="dashed" danger disabled={!hasSelected}*/}
{/* icon={<IssuesCloseOutlined/>}*/}
{/* loading={this.state.delBtnLoading}*/}
{/* onClick={() => {*/}
{/* const content = <div>*/}
{/* 您确定要启用选中的<Text style={{color: '#1890FF'}}*/}
{/* strong>{this.state.selectedRowKeys.length}</Text>条记录吗?*/}
{/* </div>;*/}
{/* confirm({*/}
{/* icon: <ExclamationCircleOutlined/>,*/}
{/* content: content,*/}
{/* onOk: () => {*/}
},
onCancel() {
{/* },*/}
{/* onCancel() {*/}
},
});
}}>
{/* },*/}
{/* });*/}
{/* }}>*/}
</Button>
</Tooltip>
{/* </Button>*/}
{/*</Tooltip>*/}
<Tooltip title="批量禁用">
<Button type="default" danger disabled={!hasSelected} icon={<StopOutlined/>}
loading={this.state.delBtnLoading}
onClick={() => {
const content = <div>
您确定要禁用选中的<Text style={{color: '#1890FF'}}
strong>{this.state.selectedRowKeys.length}</Text>
</div>;
confirm({
icon: <ExclamationCircleOutlined/>,
content: content,
onOk: () => {
{/*<Tooltip title="批量禁用">*/}
{/* <Button type="default" danger disabled={!hasSelected} icon={<StopOutlined/>}*/}
{/* loading={this.state.delBtnLoading}*/}
{/* onClick={() => {*/}
{/* const content = <div>*/}
{/* 您确定要禁用选中的<Text style={{color: '#1890FF'}}*/}
{/* strong>{this.state.selectedRowKeys.length}</Text>条记录吗?*/}
{/* </div>;*/}
{/* confirm({*/}
{/* icon: <ExclamationCircleOutlined/>,*/}
{/* content: content,*/}
{/* onOk: () => {*/}
},
onCancel() {
{/* },*/}
{/* onCancel() {*/}
},
});
}}>
{/* },*/}
{/* });*/}
{/* }}>*/}
</Button>
</Tooltip>
{/* </Button>*/}
{/*</Tooltip>*/}
<Tooltip title="批量删除">
<Button type="primary" danger disabled={!hasSelected} icon={<DeleteOutlined/>}

View File

@ -1,5 +1,5 @@
import React from 'react';
import {Form, Input, Modal} from "antd/lib/index";
import {Form, Input, Modal, Radio} from "antd/lib/index";
const UserModal = ({title, visible, handleOk, handleCancel, confirmLoading, model}) => {
@ -22,7 +22,8 @@ const UserModal = ({title, visible, handleOk, handleCancel, confirmLoading, mode
form.resetFields();
handleOk(values);
})
.catch(info => {});
.catch(info => {
});
}}
onCancel={handleCancel}
confirmLoading={confirmLoading}
@ -43,6 +44,13 @@ const UserModal = ({title, visible, handleOk, handleCancel, confirmLoading, mode
<Input placeholder="请输入用户昵称"/>
</Form.Item>
<Form.Item label="用户角色" name='role' rules={[{required: true, message: '请选择用户角色'}]}>
<Radio.Group >
<Radio value={'user'}>普通用户</Radio>
<Radio value={'admin'}>管理用户</Radio>
</Radio.Group>
</Form.Item>
{
title.indexOf('新增') > -1 ?
(<Form.Item label="登录密码" name='password' rules={[{required: true, message: '请输入登录密码'}]}>