user-operate.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import { http } from '@/utils/http/axios';
  2. export interface UserType {
  3. userId?: number;
  4. password?: string;
  5. deptId?: number | null;
  6. username?: string;
  7. staffNo?: string;
  8. mobile?: string;
  9. isEnable?: boolean;
  10. nickname?: string;
  11. roleIds?: number[];
  12. passwordRe?: string;
  13. /** 租户id */
  14. tenantId?: number;
  15. }
  16. interface AdminUserType {
  17. /** 昵称 */
  18. nickname: string;
  19. /** 登录用户名 */
  20. username: string;
  21. /** 部门id */
  22. deptId?: number;
  23. /** 员工编号 */
  24. staffNo?: string;
  25. /** 密码 */
  26. password: string;
  27. /** 所属租户id */
  28. tenantId: number;
  29. }
  30. /** root用户给某个租户添加管理员 */
  31. export function addAdminUser(params: AdminUserType) {
  32. return http.request({
  33. url: '/user/adds',
  34. method: 'POST',
  35. params,
  36. });
  37. }
  38. //添加用户
  39. export function addSingleUser(params: UserType) {
  40. return http.request(
  41. {
  42. url: '/user/add',
  43. method: 'POST',
  44. params,
  45. },
  46. {
  47. isTransformResponse: false,
  48. },
  49. );
  50. }
  51. //添加批量用户
  52. export function addMultipleUser(params: File) {
  53. return http.request({
  54. url: '/user/import',
  55. method: 'POST',
  56. params,
  57. });
  58. }
  59. export interface UserTypeDel {
  60. deleteStatus?: string;
  61. deptId?: number;
  62. email?: string;
  63. isEnable?: boolean;
  64. mobile?: string;
  65. nickname?: string;
  66. opertor?: string;
  67. password?: string;
  68. postId?: string;
  69. remark?: string;
  70. roleIds?: string[];
  71. sex?: string;
  72. staffNo?: string;
  73. userId?: number;
  74. username?: string;
  75. updateTime?: string;
  76. createTime?: string;
  77. certify?: string;
  78. }
  79. //删除用户
  80. export function delUser(params: UserTypeDel) {
  81. return http.request({
  82. url: '/user/delete',
  83. method: 'POST',
  84. params,
  85. });
  86. }
  87. //修改用户
  88. export function updateUser(params: UserType) {
  89. return http.request(
  90. {
  91. url: '/user/update',
  92. method: 'POST',
  93. params,
  94. },
  95. {
  96. isTransformResponse: false,
  97. },
  98. );
  99. }
  100. //获取单个用户信息
  101. // export function getUser(params: string): Promise<UserType> {
  102. // return http.request({
  103. // url: '/user/info',
  104. // method: 'get',
  105. // params,
  106. // });
  107. // }
  108. export interface UserList {
  109. pageNumber: number;
  110. totalPage: number;
  111. pageSize: number;
  112. page: number;
  113. list: UserTypeDel[];
  114. totalCount: number;
  115. pageNum: number;
  116. }
  117. export interface QueryUser {
  118. staffNo?: string; //工号
  119. nickname?: string; //姓名
  120. mobile?: string; //手机号
  121. roleName?: string; //角色
  122. deptName?: string; //组织
  123. page?: number; //当前页数
  124. pageRow?: number; //每页个数
  125. deptId?: string;
  126. roleId?:string;
  127. }
  128. //获取单个用户信息
  129. export function getUserList(params: QueryUser | null): Promise<UserList> {
  130. return http.request({
  131. url: '/user/list',
  132. method: 'get',
  133. params,
  134. });
  135. }
  136. interface ResetCodeType {
  137. password?: string;
  138. userId?: number;
  139. }
  140. // 修改密码
  141. export function resetCode(params: ResetCodeType) {
  142. return http.request({
  143. url: '/user/changePassword',
  144. method: 'POST',
  145. params,
  146. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  147. });
  148. }