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);
}
}