权限配置


页面中引入权限管理混合器

import {authorize} from '@/mixins'
mixins: [agGridCommon, authorize]

权限使用

  • 指令方式使用:v-permission
如果要配置一个元素有权限才显示,使用指令即可,比如新增按钮配置,有新增权限的时候显示:
<gz-button v-permission="1" type="success" icon="el-icon-plus" @click="onClickAdd">新增</gz-button>

当用户有权限值1的权限时才会显示新增按钮

  • 权限判断方法: this.VerifyPermissions(int) 
该方法在 authorize 混合器中已经实现,参数为要判断的权限值
使用
optionWidth () {
  var width = 0
  // 编辑权限
  if (this.VerifyPermissions(2)) width += (47 + 8)
  // 删除权限
  if (this.VerifyPermissions(4)) width += (47 + 8)

  return width + 8
},

 

权限注册

 src/router/data.js 中配置路由和权限信息

authorize权限信息
authorize.name权限名称
authorize.description权限描述
authorize.value权限值
authorize.urls
权限对用的后台API接口

 

{
	path: '/user',
	name: 'user',
	type: 'normal',
	title: '用户管理',
	defaultURLs: ['/api/microapps/user/search', '/api/microapps/user/get'],
	authorize: [
	  {
		name: 'add',
		description: '新增',
		value: 1,
		urls: ['/api/microapps/user/create'],
	  },
	  {
		name: 'update',
		description: '编辑',
		value: 2,
		urls: ['/api/microapps/user/update'],
	  },
	  {
		name: 'delete',
		description: '删除',
		value: 4,
		urls: ['/api/microapps/user/delete'],
	  },
	  {
		name: 'resetpwd',
		description: '重置密码',
		value: 8,
		urls: ['/api/microapps/user/resetPwd'],
	  },
	  {
		name: 'setAuthorize',
		description: '权限设置',
		value: 16,
		urls: ['/api/microapps/ClientCode/GetDropDownDataSource','/api/microapps/Authorize/treemenus','/api/microapps/authorize/update'],
	  },
	],
	component: () =>
	  import(/* webpackChunkName: "user" */ '../views/user/index.vue'),
},

 

版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
YES开发框架
下一篇:路由配置
评论列表

发表评论

评论内容
昵称:
关联文章