import { axios } from '@/utils/request'

// 获取列表数据
export const getPowerRoleList = params => {
  const url = `/yyrole/queryLike/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'POST',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}

// 改变权限状态接口 flag 0：禁用 1：启用
export const updateEnableStatus = params => {
  return axios({
    url: `/yyrole/enable/${params.id}/${params.flag}`,
    data: {},
    method: 'get',
    headers:{
        'module': encodeURIComponent('启用禁用')
    }
  })
}

// 删除用户接口
export const delectRolePower = params => {
  return axios({
    url: `/yyrole/delete/${params.id}`,
    data: {},
    method: 'get',
    headers:{
        'module': encodeURIComponent('删除')
    }
  })
}

// 新增/编辑保存接口
export const saveRolePower = params => {
  return axios({
    url: '/yyrole/save',
    data: params,
    method: 'POST',
    headers:{
        'module': encodeURIComponent('新增/编辑')
    }
  })
}

// 获取菜单树数据
export const getMenuList = params => {
  const url = `/yyrole/findAllMenu/${params.id}`
  return axios({
    url: url,
    method: 'get',
    headers:{
        'module': encodeURIComponent('获取角色菜单数据')
    }
  })
}

// 保存权限分配
export const addMenuPower = params => {
  const url = `/yyrole/saveRoleMenu`
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('权限分配')
    }
  })
}