/**
 * Created by jin.zhouhang on 17-8-11 上午10:31.
 *
 * 权限管理
 */
const permissionUtils = {
  install: function (Vue) {
    Vue.prototype.$permissionUtils = {

      btnPermission(code) {
        if (localStorage.getItem('btnPermission') == null || localStorage.getItem('btnPermission') == '') {
          return false
        }
        var btnPerList = localStorage.getItem('btnPermission').split(",");
        for (var num in btnPerList) {
          if (code == btnPerList[num]) {
            return true
          }
        }
        return false
      },
      menuPermission(code) {
        if (localStorage.getItem('menuPermission') == null || localStorage.getItem('menuPermission') == '') {
          return false
        }

        var menuPerList = localStorage.getItem('menuPermission').split(",");
        for (var num in menuPerList) {
          if (code == menuPerList[num]) {
            return true
          }
        }
        return false
      },

      rolePermission(code) {
        if (localStorage.getItem('userRole') == null || localStorage.getItem('userRole') == '') {
          return false
        }

        var rolePerList = localStorage.getItem('userRole').split(",");
        for (var num in rolePerList) {
          if (code == rolePerList[num]) {
            return true
          }
        }
        return false


      }
    }
  }

}

export default permissionUtils
