You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

role.ts 3.3 kB

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