/*
 * @Author: your name
 * @Date: 2021-07-26 10:13:31
 * @LastEditTime: 2021-09-28 09:52:04
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /TracerMethodology_PC/src/pages/UserMana/service.js
 */


import { request } from 'umi';

// 获角色列表
export async function getRoleList(params, options) {
    return request('/api/pfm/role/list', {
      method: 'GET',
      params: {...params},
      ...(options || {}),
    });
}

// 新增角色
export async function addList(body, options) {
    return request('/api/pfm/role/save', {
      method: 'POST',
      data: {...body},
      ...(options || {}),
    });
}

// 编辑角色
export async function editList(body, options) {
  return request('/api/pfm/role/edit', {
    method: 'POST',
    data: {...body},
    ...(options || {}),
  });
}

// 删除角色
export async function delList(params, options) {
  const {ids} = params;
  return request(`/api/pfm/role/delete`, {
    data:ids,
    method: 'POST',
    ...(options || {}),
  });
}

// //根据角色查询已绑用户
// export async function getUsersByRoleId(params, options) {
//   const {roleId} = params;
//   return request(`/api/costAccount/role/editUserRole`, {
//     data:{roleId, userIds},
//     method: 'POST',
//     ...(options || {}),
//   });
// }

// 角色绑定用户
export async function roleBindUser(params, options) {
  const {roleId, userIds} = params;
  return request(`/api/pfm/role/editUserRole`, {
    data:{roleId, userIds},
    method: 'POST',
    ...(options || {}),
  });
}

// 角色绑定菜单
export async function roleBindMenu(params, options) {
  const {roleId, menuIds} = params;
  return request(`/api/pfm/role/editRoleMenu`, {
    data:{roleId, menuIds},
    method: 'POST',
    ...(options || {}),
  });
}


// 获取角色已绑定的用户
export async function roleHasBindUsers(params, options) {
  const {roleId} = params;
  return request(`/api/pfm/role/roleUsers`, {
    params:{roleId},
    method: 'GET',
    ...(options || {}),
  });
}


// 获取角色已绑定的菜单
export async function roleHasBindMenus(params, options) {
  const {roleId} = params;
  return request(`/api/pfm/role/roleMenus`, {
    params:{roleId},
    method: 'GET',
    ...(options || {}),
  });
}