86133 | aaa3f5d | 2025-04-20 21:33:29 +0800 | [diff] [blame] | 1 | import { ContentType } from '@/enums/httpEnum'; |
| 2 | import { request } from '@umijs/max'; |
| 3 | import { downLoadXlsx } from '@/utils/downloadfile'; |
| 4 | |
| 5 | // 查询角色信息列表 |
| 6 | export async function getRoleList(params?: API.System.RoleListParams) { |
| 7 | return request<API.System.RolePageResult>('/api/system/role/list', { |
| 8 | method: 'GET', |
| 9 | headers: { 'Content-Type': ContentType.FORM_URLENCODED }, |
| 10 | params |
| 11 | }); |
| 12 | } |
| 13 | |
| 14 | // 查询角色信息详细 |
| 15 | export function getRole(roleId: number) { |
| 16 | return request<API.System.RoleInfoResult>(`/api/system/role/${roleId}`, { |
| 17 | method: 'GET' |
| 18 | }); |
| 19 | } |
| 20 | |
| 21 | // 新增角色信息 |
| 22 | export async function addRole(params: API.System.Role) { |
| 23 | return request<API.Result>('/api/system/role', { |
| 24 | method: 'POST', |
| 25 | headers: { |
| 26 | 'Content-Type': 'application/json;charset=UTF-8', |
| 27 | }, |
| 28 | data: params |
| 29 | }); |
| 30 | } |
| 31 | |
| 32 | // 修改角色信息 |
| 33 | export async function updateRole(params: API.System.Role) { |
| 34 | return request<API.Result>('/api/system/role', { |
| 35 | method: 'PUT', |
| 36 | headers: { |
| 37 | 'Content-Type': 'application/json;charset=UTF-8', |
| 38 | }, |
| 39 | data: params |
| 40 | }); |
| 41 | } |
| 42 | |
| 43 | // 删除角色信息 |
| 44 | export async function removeRole(ids: string) { |
| 45 | return request<API.Result>(`/api/system/role/${ids}`, { |
| 46 | method: 'DELETE' |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | // 导出角色信息 |
| 51 | export function exportRole(params?: API.System.RoleListParams) { |
| 52 | return downLoadXlsx(`/api/system/role/export`, { params }, `role_${new Date().getTime()}.xlsx`); |
| 53 | } |
| 54 | |
| 55 | // 获取角色菜单列表 |
| 56 | export function getRoleMenuList(id: number) { |
| 57 | return request<API.System.RoleMenuResult>(`/api/system/menu/roleMenuTreeselect/${id}`, { |
| 58 | method: 'get', |
| 59 | }); |
| 60 | } |
| 61 | |
| 62 | // 角色数据权限 |
| 63 | export function updateRoleDataScope(data: Record<string, any>) { |
| 64 | return request('/api/system/role/dataScope', { |
| 65 | method: 'put', |
| 66 | data |
| 67 | }) |
| 68 | } |
| 69 | |
| 70 | // 角色状态修改 |
| 71 | export function changeRoleStatus(roleId: number, status: string) { |
| 72 | const data = { |
| 73 | roleId, |
| 74 | status |
| 75 | } |
| 76 | return request<API.Result>('/api/system/role/changeStatus', { |
| 77 | method: 'put', |
| 78 | data: data |
| 79 | }) |
| 80 | } |
| 81 | |
| 82 | // 查询角色已授权用户列表 |
| 83 | export function allocatedUserList(params?: API.System.RoleListParams) { |
| 84 | return request('/api/system/role/authUser/allocatedList', { |
| 85 | method: 'get', |
| 86 | params |
| 87 | }) |
| 88 | } |
| 89 | |
| 90 | // 查询角色未授权用户列表 |
| 91 | export function unallocatedUserList(params?: API.System.RoleListParams) { |
| 92 | return request('/api/system/role/authUser/unallocatedList', { |
| 93 | method: 'get', |
| 94 | params |
| 95 | }) |
| 96 | } |
| 97 | |
| 98 | // 取消用户授权角色 |
| 99 | export function authUserCancel(data: any) { |
| 100 | return request<API.Result>('/api/system/role/authUser/cancel', { |
| 101 | method: 'put', |
| 102 | data: data |
| 103 | }) |
| 104 | } |
| 105 | |
| 106 | // 批量取消用户授权角色 |
| 107 | export function authUserCancelAll(data: any) { |
| 108 | return request<API.Result>('/api/system/role/authUser/cancelAll', { |
| 109 | method: 'put', |
| 110 | params: data |
| 111 | }) |
| 112 | } |
| 113 | |
| 114 | // 授权用户选择 |
| 115 | export function authUserSelectAll(data: Record<string, any>) { |
| 116 | return request<API.Result>('/api/system/role/authUser/selectAll', { |
| 117 | method: 'put', |
| 118 | params: data, |
| 119 | headers: { 'Content-Type': ContentType.FORM_URLENCODED }, |
| 120 | }) |
| 121 | } |
| 122 | |
| 123 | // 根据角色ID查询部门树结构 |
| 124 | export function getDeptTreeSelect(roleId: number) { |
| 125 | return request('/api/system/role/deptTree/' + roleId, { |
| 126 | method: 'get' |
| 127 | }) |
| 128 | } |