import request from '/@/utils/request'

/** 查询角色列表 */
export function getList(params?: any) {
  return request({
    url: '/system/role/list',
    method: 'get',
    params,
  })
}

/** 新增角色 */
export const doAdd = (data: any) => {
  return request({
    url: '/system/role',
    method: 'post',
    data,
  })
}

/** 编辑角色 */
export const doEdit = (data: any) => {
  return request({
    url: '/system/role',
    method: 'put',
    data,
  })
}

/** 删除角色 */
export const doDelete = (roleId: any) => {
  return request({
    url: `/system/role/${roleId}`,
    method: 'delete',
  })
}

// 查询角色详细
export function getRole(roleId: any) {
  return request({
    url: `/system/role/${roleId}`,
    method: 'get',
  })
}

// 角色状态修改
export function changeRoleStatus(roleId: any, status: any) {
  const data = {
    roleId,
    status,
  }
  return request({
    url: '/system/role/changeStatus',
    method: 'put',
    data,
  })
}

// 根据角色ID查询部门树结构
export function deptTreeSelect(roleId: any) {
  return request({
    url: `/system/role/deptTree/${roleId}`,
    method: 'get',
  })
}

// 角色数据权限
export function dataScope(data: any) {
  return request({
    url: '/system/role/dataScope',
    method: 'put',
    data,
  })
}

// 查询角色已授权用户列表
export function allocatedUserList(params: any) {
  return request({
    url: '/system/role/authUser/allocatedList',
    method: 'get',
    params,
  })
}

// 取消用户授权角色
export function authUserCancel(data: any) {
  return request({
    url: '/system/role/authUser/cancel',
    method: 'put',
    data,
  })
}

// 批量取消用户授权角色
export function authUserCancelAll(data: any) {
  return request({
    url: '/system/role/authUser/cancelAll',
    method: 'put',
    params: data,
  })
}

// 授权用户选择
export function authUserSelectAll(params: any) {
  return request({
    url: '/system/role/authUser/selectAll',
    method: 'put',
    params,
  })
}

// 查询角色未授权用户列表
export function unallocatedUserList(params: any) {
  return request({
    url: '/system/role/authUser/unallocatedList',
    method: 'get',
    params,
  })
}
