From 01fb5ff6659d95928e2223c59072e4ccc1584ec3 Mon Sep 17 00:00:00 2001
From: yujialong <479214531@qq.com>
Date: Sun, 22 Aug 2021 00:06:32 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/libs/auth/generateBtnPermission.js | 2 +-
src/pages/classification.vue | 1 +
src/pages/courseConfig.vue | 2 ++
src/pages/role.vue | 4 ++++
src/plugins/auth/index.js | 4 +++-
5 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/libs/auth/generateBtnPermission.js b/src/libs/auth/generateBtnPermission.js
index a6bbc80..1715fca 100644
--- a/src/libs/auth/generateBtnPermission.js
+++ b/src/libs/auth/generateBtnPermission.js
@@ -6,7 +6,7 @@ import store from '@/store';
export default function(data){
let result = []
data.map(e => {
- if(e.select){
+ if(e.select){ // select为true则表示拥有该权限
e.children.map(n => {
if(n.select){
if(n.children.length){
diff --git a/src/pages/classification.vue b/src/pages/classification.vue
index 6fca144..cbd017f 100644
--- a/src/pages/classification.vue
+++ b/src/pages/classification.vue
@@ -64,6 +64,7 @@ export default {
this.$get(`${this.api.queryAllClassification}?schoolId=${this.schoolId}`).then(res => {
let list = res.data.classificationList
let result = []
+ // 排序
list.map(n => {
if(n.distinguish) result.push(n)
})
diff --git a/src/pages/courseConfig.vue b/src/pages/courseConfig.vue
index 82ee1a2..91c816d 100644
--- a/src/pages/courseConfig.vue
+++ b/src/pages/courseConfig.vue
@@ -220,6 +220,7 @@ export default {
this.insertScript()
this.id = this.$route.query.id
this.id && this.getData()
+ // 处理预览资源后返回弹框不会消失的问题
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener("popstate", this.goBack, false);
@@ -572,6 +573,7 @@ export default {
}
}
},
+ // 排序
sortSection(chapterIndex,type,disabled,index){
if(!disabled){
let list = this.chapters[chapterIndex].subsectionList
diff --git a/src/pages/role.vue b/src/pages/role.vue
index 58a1825..0364b39 100644
--- a/src/pages/role.vue
+++ b/src/pages/role.vue
@@ -142,6 +142,7 @@ export default {
this.pageNo = val;
this.getData();
},
+ // 获取权限树
getPer(){
if(!this.permissions.length){
this.$get(this.api.queryPermissionMenu).then(res => {
@@ -156,11 +157,13 @@ export default {
this.permissions.length && this.$refs.per.setCheckedNodes([])
this.roleVisible = true
},
+ // 递归处理勾选的权限
handleRolePer(data,permissions){
let result = data
if(permissions.length){
permissions.map(e => {
if(result.includes(e.id) && e.children.length){
+ // 如果该权限下的子权限不是每个都勾选了,就把该权限的id从已勾选的id集合里去除,因为如果不去除的话,这个权限就会勾选,同时会把该权限下的所有子权限都一起勾选
e.children.every(n => result.includes(n)) || result.splice(result.indexOf(e.id),1)
}
e.children.length && this.handleRolePer(data,e.children)
@@ -204,6 +207,7 @@ export default {
}
let roleRes = await this.$post(this.api.saveOrUpdate,roleData)
if(roleRes.success){
+ // 获取已勾选的,和半勾选的(即子级没有全部勾选的节点),半勾选的一样要传给后端
let permissionId = [...this.$refs.per.getHalfCheckedKeys(),...this.$refs.per.getCheckedKeys()]
let perData = {
clientId: this.clientId,
diff --git a/src/plugins/auth/index.js b/src/plugins/auth/index.js
index e30c93b..b1f1763 100644
--- a/src/plugins/auth/index.js
+++ b/src/plugins/auth/index.js
@@ -1,13 +1,14 @@
/**
* @description 鉴权指令
* 当传入的权限当前用户没有时,会移除该组件
- * 用例:text 或者:text
+ * 用例:text 或者:text
* */
import store from '@/store';
export default {
inserted (el, binding, vnode) {
let btnText = ''
+ // 如果没传值,则取当前页面路由和按钮名字,否则,直接取传的值
if(binding.value){
btnText = binding.value
}else{
@@ -17,6 +18,7 @@ export default {
if (btnText && btnPermissions && btnPermissions.length) {
const isPermission = btnPermissions.includes(btnText);
if (!isPermission) {
+ // 如果权限集合里没有这个按钮,则把这个按钮给移除
el.parentNode && el.parentNode.removeChild(el);
}
}