import {roleList,delRole,getAllMenuList,addRole,updateRole,
  roleInfo} from '@/api/userRole'

const state = {

}

const mutations = {

}

const actions = {
  //1.角色管理 start ---------------------------------------->
  //获取角色列表
  roleList({commit},data) {
    return new Promise((resolve, reject) => {
      roleList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //删除角色
  delRole({commit},data) {
    return new Promise((resolve, reject) => {
      delRole(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获取角色菜单权限  
  getAllMenuList({commit},data) {
    return new Promise((resolve, reject) => {
      getAllMenuList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //添加角色
  addRole({commit},data) {
    return new Promise((resolve, reject) => {
      addRole(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //更新角色
  updateRole({commit},data) {
    return new Promise((resolve, reject) => {
      updateRole(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //查看角色
  roleInfo({commit},data) {
    return new Promise((resolve, reject) => {
      roleInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  }
  //角色管理 end ---------------------------------------->
}


export default {
  namespaced: true,
  state,
  mutations,
  actions
}
