feat:增加权限表设计,增加禁用、重置密码操作

feature/price_manager
Jimmy Liow 1 year ago
parent 0c91e88674
commit 680364eae3

@ -0,0 +1,66 @@
CREATE TABLE auth_role
(
[role_id] [int] IDENTITY(1,1) NOT NULL,
[role_name] [nvarchar](255) NOT NULL,
[created_on] [datetime] NOT NULL,
CONSTRAINT [PK_auth_role] PRIMARY KEY CLUSTERED
(
[role_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE auth_role ADD CONSTRAINT [DF_auth_role_created_on] DEFAULT (getdate()) FOR [created_on]
CREATE TABLE auth_permission
(
[role_id] [int] NOT NULL,
[res_id] [int] NOT NULL
) ON [PRIMARY]
CREATE TABLE auth_resource
(
[res_id] [int] IDENTITY(1,1) NOT NULL,
[res_name] [nvarchar](255) NOT NULL,
[res_pattern] [nvarchar](255) NOT NULL,
[res_category] [nvarchar](255) NOT NULL,
CONSTRAINT [PK_auth_resource] PRIMARY KEY CLUSTERED
(
[res_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
INSERT INTO [dbo].[auth_role] ([role_name])
VALUES ('系统管理员')
INSERT INTO [dbo].[auth_role] ([role_name])
VALUES ('国内供应商')
INSERT INTO [dbo].[auth_role] ([role_name])
VALUES ('海外供应商')
INSERT INTO [dbo].[auth_role] ([role_name])
VALUES ('客服组')
INSERT INTO [dbo].[auth_role] ([role_name])
VALUES ('产品组')
INSERT INTO [dbo].[auth_role] ([role_name])
VALUES ('技术研发部')
INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category])
VALUES ('所有权限', '*', 'system')
INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category])
VALUES ('最新团计划', '/reservation/newest', 'oversea')
INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category])
VALUES ('账单', '/invoice', 'oversea')
INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category])
VALUES ('账号权限管理', '/account/management', 'system')
INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category])
VALUES ('新增角色', '/account/new-role', 'system')
INSERT INTO [dbo].[auth_permission] ([role_id] ,[res_id])
VALUES (1, 1)
INSERT INTO [dbo].[auth_permission] ([role_id] ,[res_id])
VALUES (6, 2)
INSERT INTO [dbo].[auth_permission] ([role_id] ,[res_id])
VALUES (6, 3)
INSERT INTO [dbo].[auth_permission] ([role_id] ,[res_id])
VALUES (6, 4)
INSERT INTO [dbo].[auth_permission] ([role_id] ,[res_id])
VALUES (6, 5)

Binary file not shown.

@ -1,8 +1,6 @@
import { NavLink, useLocation } from 'react-router-dom'
import { useState, useEffect } from 'react'
import { useState } from 'react'
import { Row, Col, Space, Button, Table, Select, TreeSelect, Typography, Modal, App, Form, Input } from 'antd'
import dayjs from 'dayjs'
import { isEmpty } from '@/utils/commons'
import { ExclamationCircleFilled } from '@ant-design/icons'
import { useTranslation } from 'react-i18next'
import useFormStore from '@/stores/Form'
import useReservationStore from '@/stores/Reservation'
@ -88,6 +86,7 @@ function Management() {
{
title: t('account:role'),
dataIndex: 'role',
render: roleRender
},
{
title: t('account:lastLogin'),
@ -102,15 +101,21 @@ function Management() {
function accountRender(text) {
return (
<Button type='link' onClick={() => console.info('account:action.assignRole')}>{text}</Button>
<Button type='link' onClick={() => setAccountModalOpen(true)}>{text}</Button>
)
}
function roleRender(text) {
return (
<Button type='link' onClick={() => setRoleModalOpen(true)}>{text}</Button>
)
}
function actionRender() {
return (
<Space key='actionRenderSpace' size='middle'>
<Button type='link' key='disable' onClick={() => console.info('account:action.disable')}>{t('account:action.disable')}</Button>
<Button type='link' key='resetPassword' onClick={() => console.info('account:action.resetPassword')}>{t('account:action.resetPassword')}</Button>
<Button type='link' key='disable' onClick={() => showDisableConfirm()}>{t('account:action.disable')}</Button>
<Button type='link' key='resetPassword' onClick={() => showResetPasswordConfirm()}>{t('account:action.resetPassword')}</Button>
</Space>
)
}
@ -119,6 +124,7 @@ function Management() {
console.log('onChange ', newValue);
setPermissionValue(newValue);
}
const [permissionValue, setPermissionValue] = useState(['0-0-0'])
const [isAccountModalOpen, setAccountModalOpen] = useState(false)
const [isRoleModalOpen, setRoleModalOpen] = useState(false)
@ -168,12 +174,12 @@ function Management() {
const formValuesToSub = useFormStore((state) => state.formValuesToSub)
const [form] = Form.useForm()
const [editAccountForm, editRoleForm] = Form.useForm()
const [fetchReservationList] =
useReservationStore((state) =>
[state.fetchAllGuideList, state.fetchReservationList, state.reservationList, state.reservationPage, state.cityList, state.selectReservation, state.getCityListByReservationId])
const { notification } = App.useApp()
const { notification, modal } = App.useApp()
const handleAccountOk = () => {
}
@ -202,6 +208,34 @@ function Management() {
const onSearchClick = (current=1, status=null) => {
}
const showDisableConfirm = () => {
modal.confirm({
title: 'Do you want to disable this account?',
icon: <ExclamationCircleFilled />,
content: 'Username: Ivy, Realname: 怡小芳',
onOk() {
console.log('OK')
},
onCancel() {
console.log('Cancel')
},
})
}
const showResetPasswordConfirm = () => {
modal.confirm({
title: 'Do you want to reset password?',
icon: <ExclamationCircleFilled />,
content: 'Username: Ivy, Realname: 怡小芳',
onOk() {
console.log('OK')
},
onCancel() {
console.log('Cancel')
},
})
}
return (
<>
<Modal
@ -210,7 +244,7 @@ function Management() {
>
<Form
name='basic'
form={form}
form={editAccountForm}
layout='vertical'
size='large'
style={{
@ -276,7 +310,7 @@ function Management() {
>
<Form
name='basic'
form={form}
form={editRoleForm}
layout='vertical'
size='large'
style={{

Loading…
Cancel
Save