index.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import { UserVO } from '@/api/system/user/types';
  2. import { UserQuery } from '@/api/system/user/types';
  3. import { AxiosPromise } from 'axios';
  4. import { RoleQuery, RoleVO, RoleDeptTree } from './types';
  5. import request from '@/utils/request';
  6. export const listRole = (query: RoleQuery): AxiosPromise<RoleVO[]> => {
  7. return request({
  8. url: '/system/role/list',
  9. method: 'get',
  10. params: query
  11. });
  12. };
  13. /**
  14. * 查询角色详细
  15. */
  16. export const getRole = (roleId: string | number): AxiosPromise<RoleVO> => {
  17. return request({
  18. url: '/system/role/' + roleId,
  19. method: 'get'
  20. });
  21. };
  22. /**
  23. * 新增角色
  24. */
  25. export const addRole = (data: any) => {
  26. return request({
  27. url: '/system/role',
  28. method: 'post',
  29. data: data
  30. });
  31. };
  32. /**
  33. * 修改角色
  34. * @param data
  35. */
  36. export const updateRole = (data: any) => {
  37. return request({
  38. url: '/system/role',
  39. method: 'put',
  40. data: data
  41. });
  42. };
  43. /**
  44. * 角色数据权限
  45. */
  46. export const dataScope = (data: any) => {
  47. return request({
  48. url: '/system/role/dataScope',
  49. method: 'put',
  50. data: data
  51. });
  52. };
  53. /**
  54. * 角色状态修改
  55. */
  56. export const changeRoleStatus = (roleId: string | number, status: string) => {
  57. const data = {
  58. roleId,
  59. status
  60. };
  61. return request({
  62. url: '/system/role/changeStatus',
  63. method: 'put',
  64. data: data
  65. });
  66. };
  67. /**
  68. * 删除角色
  69. */
  70. export const delRole = (roleId: Array<string | number> | string | number) => {
  71. return request({
  72. url: '/system/role/' + roleId,
  73. method: 'delete'
  74. });
  75. };
  76. /**
  77. * 查询角色已授权用户列表
  78. */
  79. export const allocatedUserList = (query: UserQuery): AxiosPromise<UserVO[]> => {
  80. return request({
  81. url: '/system/role/authUser/allocatedList',
  82. method: 'get',
  83. params: query
  84. });
  85. };
  86. /**
  87. * 查询角色未授权用户列表
  88. */
  89. export const unallocatedUserList = (query: UserQuery): AxiosPromise<UserVO[]> => {
  90. return request({
  91. url: '/system/role/authUser/unallocatedList',
  92. method: 'get',
  93. params: query
  94. });
  95. };
  96. /**
  97. * 取消用户授权角色
  98. */
  99. export const authUserCancel = (data: any) => {
  100. return request({
  101. url: '/system/role/authUser/cancel',
  102. method: 'put',
  103. data: data
  104. });
  105. };
  106. /**
  107. * 批量取消用户授权角色
  108. */
  109. export const authUserCancelAll = (data: any) => {
  110. return request({
  111. url: '/system/role/authUser/cancelAll',
  112. method: 'put',
  113. params: data
  114. });
  115. };
  116. /**
  117. * 授权用户选择
  118. */
  119. export const authUserSelectAll = (data: any) => {
  120. return request({
  121. url: '/system/role/authUser/selectAll',
  122. method: 'put',
  123. params: data
  124. });
  125. };
  126. // 根据角色ID查询部门树结构
  127. export const deptTreeSelect = (roleId: string | number): AxiosPromise<RoleDeptTree> => {
  128. return request({
  129. url: '/system/role/deptTree/' + roleId,
  130. method: 'get'
  131. });
  132. };