Complete main UI #37
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import FitFullScreen from '@/components/common/FitFullScreen'
|
import FitFullScreen from '@/components/common/FitFullScreen'
|
||||||
import Card from '@/components/common/Card'
|
import Card from '@/components/common/Card'
|
||||||
import { r_getSysLog } from '@/services/system'
|
import { r_sysLog_get } from '@/services/system'
|
||||||
import {
|
import {
|
||||||
COLOR_ERROR_SECONDARY,
|
COLOR_ERROR_SECONDARY,
|
||||||
COLOR_FONT_SECONDARY,
|
COLOR_FONT_SECONDARY,
|
||||||
@@ -209,15 +209,13 @@ const Log: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isRegexLegal) {
|
if (!isRegexLegal) {
|
||||||
void message.error({
|
void message.error('非法正则表达式')
|
||||||
content: '非法正则表达式'
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
void r_getSysLog({
|
void r_sysLog_get({
|
||||||
currentPage: tableParams.pagination?.current,
|
currentPage: tableParams.pagination?.current,
|
||||||
pageSize: tableParams.pagination?.pageSize,
|
pageSize: tableParams.pagination?.pageSize,
|
||||||
sortField:
|
sortField:
|
||||||
@@ -245,9 +243,7 @@ const Log: React.FC = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
void message.error({
|
void message.error('获取失败,请稍后重试')
|
||||||
content: '获取失败,请稍后重试'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
|||||||
@@ -4,16 +4,18 @@ import HideScrollbar from '@/components/common/HideScrollbar'
|
|||||||
import FlexBox from '@/components/common/FlexBox'
|
import FlexBox from '@/components/common/FlexBox'
|
||||||
import Card from '@/components/common/Card'
|
import Card from '@/components/common/Card'
|
||||||
import {
|
import {
|
||||||
r_addRole,
|
r_role_add,
|
||||||
r_changeRoleStatus,
|
r_role_changStatus,
|
||||||
r_getPower,
|
r_power_get,
|
||||||
r_getRole,
|
r_role_get,
|
||||||
r_updateRole
|
r_role_update,
|
||||||
|
r_role_delete
|
||||||
} from '@/services/system.tsx'
|
} from '@/services/system.tsx'
|
||||||
import {
|
import {
|
||||||
COLOR_ERROR_SECONDARY,
|
COLOR_ERROR_SECONDARY,
|
||||||
COLOR_FONT_SECONDARY,
|
COLOR_FONT_SECONDARY,
|
||||||
COLOR_PRODUCTION,
|
COLOR_PRODUCTION,
|
||||||
|
DATABASE_DELETE_SUCCESS,
|
||||||
DATABASE_DUPLICATE_KEY,
|
DATABASE_DUPLICATE_KEY,
|
||||||
DATABASE_INSERT_SUCCESS,
|
DATABASE_INSERT_SUCCESS,
|
||||||
DATABASE_SELECT_SUCCESS,
|
DATABASE_SELECT_SUCCESS,
|
||||||
@@ -23,6 +25,7 @@ import Icon from '@ant-design/icons'
|
|||||||
import { powerListToPowerTree } from '@/utils/common.ts'
|
import { powerListToPowerTree } from '@/utils/common.ts'
|
||||||
|
|
||||||
const Role: React.FC = () => {
|
const Role: React.FC = () => {
|
||||||
|
const [modal, contextHolder] = AntdModal.useModal()
|
||||||
const [form] = AntdForm.useForm<RoleAddEditParam>()
|
const [form] = AntdForm.useForm<RoleAddEditParam>()
|
||||||
const formValues = AntdForm.useWatch([], form)
|
const formValues = AntdForm.useWatch([], form)
|
||||||
const [newFormValues, setNewFormValues] = useState<RoleAddEditParam>()
|
const [newFormValues, setNewFormValues] = useState<RoleAddEditParam>()
|
||||||
@@ -93,7 +96,12 @@ const Role: React.FC = () => {
|
|||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</a>
|
</a>
|
||||||
<a style={{ color: COLOR_PRODUCTION }}>删除</a>
|
<a
|
||||||
|
style={{ color: COLOR_PRODUCTION }}
|
||||||
|
onClick={handleOnDeleteBtnClick(record)}
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</a>
|
||||||
</AntdSpace>
|
</AntdSpace>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
@@ -149,6 +157,37 @@ const Role: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleOnDeleteBtnClick = (value: RoleWithPowerGetVo) => {
|
||||||
|
return () => {
|
||||||
|
modal
|
||||||
|
.confirm({
|
||||||
|
title: '确定删除',
|
||||||
|
content: `确定删除角色 ${value.name} 吗?`
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
(confirmed) => {
|
||||||
|
if (confirmed) {
|
||||||
|
setIsSubmitting(true)
|
||||||
|
r_role_delete(value.id)
|
||||||
|
.then((res) => {
|
||||||
|
const data = res.data
|
||||||
|
if (data.code === DATABASE_DELETE_SUCCESS) {
|
||||||
|
void message.success('删除成功')
|
||||||
|
getRole()
|
||||||
|
} else {
|
||||||
|
void message.error('删除失败,请稍后重试')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setIsSubmitting(false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
() => {}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleOnDrawerClose = () => {
|
const handleOnDrawerClose = () => {
|
||||||
setIsDrawerOpen(false)
|
setIsDrawerOpen(false)
|
||||||
}
|
}
|
||||||
@@ -161,53 +200,41 @@ const Role: React.FC = () => {
|
|||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
|
|
||||||
if (isDrawerEdit) {
|
if (isDrawerEdit) {
|
||||||
void r_updateRole(formValues)
|
void r_role_update(formValues)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const data = res.data
|
||||||
switch (data.code) {
|
switch (data.code) {
|
||||||
case DATABASE_UPDATE_SUCCESS:
|
case DATABASE_UPDATE_SUCCESS:
|
||||||
void message.success({
|
|
||||||
content: '更新成功'
|
|
||||||
})
|
|
||||||
setIsDrawerOpen(false)
|
setIsDrawerOpen(false)
|
||||||
|
void message.success('更新成功')
|
||||||
getRole()
|
getRole()
|
||||||
break
|
break
|
||||||
case DATABASE_DUPLICATE_KEY:
|
case DATABASE_DUPLICATE_KEY:
|
||||||
void message.error({
|
void message.error('已存在相同名称的角色')
|
||||||
content: '已存在相同名称的角色'
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
void message.error({
|
void message.error('更新失败,请稍后重试')
|
||||||
content: '更新失败,请稍后重试'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setIsSubmitting(false)
|
setIsSubmitting(false)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
void r_addRole(formValues)
|
void r_role_add(formValues)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const data = res.data
|
||||||
switch (data.code) {
|
switch (data.code) {
|
||||||
case DATABASE_INSERT_SUCCESS:
|
case DATABASE_INSERT_SUCCESS:
|
||||||
void message.success({
|
|
||||||
content: '添加成功'
|
|
||||||
})
|
|
||||||
setNewFormValues(undefined)
|
|
||||||
setIsDrawerOpen(false)
|
setIsDrawerOpen(false)
|
||||||
|
void message.success('添加成功')
|
||||||
|
setNewFormValues(undefined)
|
||||||
getRole()
|
getRole()
|
||||||
break
|
break
|
||||||
case DATABASE_DUPLICATE_KEY:
|
case DATABASE_DUPLICATE_KEY:
|
||||||
void message.error({
|
void message.error('已存在相同名称的角色')
|
||||||
content: '已存在相同名称的角色'
|
|
||||||
})
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
void message.error({
|
void message.error('添加失败,请稍后重试')
|
||||||
content: '添加失败,请稍后重试'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@@ -262,15 +289,13 @@ const Role: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
void r_changeRoleStatus({ id, enable: newStatus })
|
void r_role_changStatus({ id, enable: newStatus })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const data = res.data
|
||||||
if (data.code === DATABASE_UPDATE_SUCCESS) {
|
if (data.code === DATABASE_UPDATE_SUCCESS) {
|
||||||
getRole()
|
getRole()
|
||||||
} else {
|
} else {
|
||||||
void message.error({
|
void message.error('更新失败,请稍后重试')
|
||||||
content: '更新失败,请稍后重试'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@@ -285,15 +310,13 @@ const Role: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isRegexLegal) {
|
if (!isRegexLegal) {
|
||||||
void message.error({
|
void message.error('非法正则表达式')
|
||||||
content: '非法正则表达式'
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
|
|
||||||
void r_getRole({
|
void r_role_get({
|
||||||
currentPage: tableParams.pagination?.current,
|
currentPage: tableParams.pagination?.current,
|
||||||
pageSize: tableParams.pagination?.pageSize,
|
pageSize: tableParams.pagination?.pageSize,
|
||||||
sortField:
|
sortField:
|
||||||
@@ -332,9 +355,7 @@ const Role: React.FC = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
void message.error({
|
void message.error('获取失败,请稍后重试')
|
||||||
content: '获取失败,请稍后重试'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@@ -349,7 +370,7 @@ const Role: React.FC = () => {
|
|||||||
|
|
||||||
setIsLoadingPower(true)
|
setIsLoadingPower(true)
|
||||||
|
|
||||||
void r_getPower()
|
void r_power_get()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const data = res.data
|
||||||
|
|
||||||
@@ -365,9 +386,7 @@ const Role: React.FC = () => {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
void message.error({
|
void message.error('获取权限列表失败,请稍后重试')
|
||||||
content: '获取权限列表失败,请稍后重试'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@@ -540,6 +559,7 @@ const Role: React.FC = () => {
|
|||||||
</AntdForm.Item>
|
</AntdForm.Item>
|
||||||
</AntdForm>
|
</AntdForm>
|
||||||
</AntdDrawer>
|
</AntdDrawer>
|
||||||
|
{contextHolder}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
import request from '@/services/index'
|
import request from '@/services/index'
|
||||||
import { URL_API_SYS_LOG, URL_API_SYS_POWER, URL_API_SYS_ROLE } from '@/constants/urls.constants'
|
import { URL_API_SYS_LOG, URL_API_SYS_POWER, URL_API_SYS_ROLE } from '@/constants/urls.constants'
|
||||||
|
|
||||||
export const r_getSysLog = (param: SysLogGetParam) =>
|
export const r_sysLog_get = (param: SysLogGetParam) =>
|
||||||
request.get<PageVo<SysLogGetVo>>(URL_API_SYS_LOG, { ...param })
|
request.get<PageVo<SysLogGetVo>>(URL_API_SYS_LOG, { ...param })
|
||||||
|
|
||||||
export const r_getRole = (param: RoleGetParam) =>
|
export const r_role_get = (param: RoleGetParam) =>
|
||||||
request.get<PageVo<RoleWithPowerGetVo>>(URL_API_SYS_ROLE, { ...param })
|
request.get<PageVo<RoleWithPowerGetVo>>(URL_API_SYS_ROLE, { ...param })
|
||||||
|
|
||||||
export const r_changeRoleStatus = (param: RoleChangeStatusParam) =>
|
export const r_role_changStatus = (param: RoleChangeStatusParam) =>
|
||||||
request.patch<never>(URL_API_SYS_ROLE, { ...param })
|
request.patch<never>(URL_API_SYS_ROLE, { ...param })
|
||||||
|
|
||||||
export const r_getPower = () => request.get<PowerSetVo>(URL_API_SYS_POWER)
|
export const r_power_get = () => request.get<PowerSetVo>(URL_API_SYS_POWER)
|
||||||
|
|
||||||
export const r_addRole = (param: RoleAddEditParam) => request.post(URL_API_SYS_ROLE, { ...param })
|
export const r_role_add = (param: RoleAddEditParam) => request.post(URL_API_SYS_ROLE, { ...param })
|
||||||
|
|
||||||
export const r_updateRole = (param: RoleAddEditParam) => request.put(URL_API_SYS_ROLE, { ...param })
|
export const r_role_update = (param: RoleAddEditParam) =>
|
||||||
|
request.put(URL_API_SYS_ROLE, { ...param })
|
||||||
|
|
||||||
|
export const r_role_delete = (id: string) => request.delete(`${URL_API_SYS_ROLE}/${id}`)
|
||||||
|
|
||||||
|
export const r_role_delete_list = (ids: string[]) => request.delete(URL_API_SYS_ROLE, { ids })
|
||||||
|
|||||||
Reference in New Issue
Block a user