Browse Source

优化权限展示

master
李磊 3 years ago
parent
commit
a838655fb2
  1. 2
      .env.production
  2. 2
      .env.test
  3. 1
      src/directive/permission/permission.js
  4. 29
      src/views/user/role.vue

2
.env.production

@ -22,4 +22,4 @@ VUE_APP_SJ_API = 'http://${VUE_APP_SJ_BASE_IP_ADDRESS}:9092/SJSE/'
VUE_APP_PREVIEW_API = '${VUE_APP_SERVER_API}/sdma-preview/'
# websocket连接地址
VUE_APP_WEBSOCKET = 'ws://${VUE_APP_SERVER_ADDRESS}/sdma-websocket/websocket/'
VUE_APP_WEBSOCKET = 'ws://${VUE_APP_SERVER_ADDRESS}:9100/sdma-websocket/websocket/'

2
.env.test

@ -22,4 +22,4 @@ VUE_APP_SJ_API = 'http://${VUE_APP_SJ_BASE_IP_ADDRESS}:9092/SJSE/'
VUE_APP_PREVIEW_API = '${VUE_APP_SERVER_API}/sdma-preview/'
# websocket连接地址
VUE_APP_WEBSOCKET = 'ws://${VUE_APP_SERVER_ADDRESS}/sdma-websocket/websocket/'
VUE_APP_WEBSOCKET = 'ws://${VUE_APP_SERVER_ADDRESS}:9100/sdma-websocket/websocket/'

1
src/directive/permission/permission.js

@ -4,7 +4,6 @@ export default {
inserted(el, binding, vnode) {
const { value } = binding
const roles = store.getters && store.getters.permissions
console.log(roles)
if (value && value instanceof Array && value.length > 0) {
const permissionRoles = value
const hasPermission = roles.some(role => {

29
src/views/user/role.vue

@ -52,7 +52,7 @@
<el-table-column label="功能选项">
<template v-if="scope.row.children.length === 0" slot-scope="scope">
<el-checkbox
v-for="options in scope.row.resourcePermissionList"
v-for="options in scope.row.resourcePermissions"
:key="options.id"
v-model="options.checked"
:label="options.permissionType"
@ -154,6 +154,7 @@ export default {
},
getRoleMenuList(roleId) {
getPermissionsByRoleId(roleId).then(data => {
data = data.map(row => row.resourcePermissionId)
this.menuList.forEach(permission => {
if (permission.children.length > 0) {
this.echoChildren(permission.children, data)
@ -167,14 +168,14 @@ export default {
//
if (val.children.length > 0) {
if (checked) {
this.checkedIds.add(val.resourcePermissionList[0].id)
this.checkedIds.add(val.resourcePermissions[0].id)
} else {
this.checkedIds.delete(val.resourcePermissionList[0].id)
this.checkedIds.delete(val.resourcePermissions[0].id)
}
this.findChildren(val.children, checked)
} else {
//
val.resourcePermissionList.forEach(options => {
val.resourcePermissions.forEach(options => {
options.checked = checked
if (checked) {
this.checkedIds.add(options.id)
@ -190,9 +191,9 @@ export default {
val.indeterminate = false
},
handleCheckChange(val) {
const length = val.resourcePermissionList.length
const length = val.resourcePermissions.length
let checkedLength = 0
val.resourcePermissionList.forEach(options => {
val.resourcePermissions.forEach(options => {
if (options.checked) {
this.checkedIds.add(options.id)
checkedLength++
@ -211,7 +212,7 @@ export default {
list.forEach(children => {
children.checked = checked
children.indeterminate = false
children.resourcePermissionList.forEach(options => {
children.resourcePermissions.forEach(options => {
options.checked = checked
if (checked) {
this.checkedIds.add(options.id)
@ -240,10 +241,12 @@ export default {
})
result.checked = parentCheckedLength === result.children.length
result.indeterminate = (parentIndeterminateLength > 0 || parentCheckedLength > 0) && parentCheckedLength < result.children.length
if (result.checked || result.indeterminate) {
this.checkedIds.add(result.resourcePermissionList[0].id)
} else {
this.checkedIds.delete(result.resourcePermissionList[0].id)
if (result.permission.component !== 'Layout') {
if (result.checked || result.indeterminate) {
this.checkedIds.add(result.resourcePermissions[0].id)
} else {
this.checkedIds.delete(result.resourcePermissions[0].id)
}
}
//
if (result.permission.pid !== 0) {
@ -265,7 +268,7 @@ export default {
},
settingChecked(result, optionsIds) {
let matching = false
result.resourcePermissionList.forEach(options => {
result.resourcePermissions.forEach(options => {
optionsIds.forEach(optionsId => {
if (options.id === optionsId) {
options.checked = true
@ -282,7 +285,7 @@ export default {
menuList.forEach(permission => {
permission.checked = false
permission.indeterminate = false
permission.resourcePermissionList.forEach(options => {
permission.resourcePermissions.forEach(options => {
options.checked = false
})
if (permission.children.length > 0) {

Loading…
Cancel
Save