diff --git a/src/directive/auth/index.js b/src/directive/auth/index.js index 4e0cd3d..a0f8fbc 100644 --- a/src/directive/auth/index.js +++ b/src/directive/auth/index.js @@ -9,18 +9,12 @@ import Setting from '@/setting' export default { inserted (el, binding, vnode) { if (!Setting.dynamicRoute) return false - let btnText = '' - // 如果有传值,就取传的值,否则,就取页面路由和按钮名字拼接起来 - if(binding.value){ - btnText = binding.value - }else{ - btnText = `${vnode.context.$route.path}:${el.innerText}` - } - const btnPermissions = store.state.btns - if (btnText && btnPermissions && btnPermissions.length) { - const isPermission = btnPermissions.includes(btnText) + const val = binding.value + const text = val && val.includes('/') ? val : vnode.context.$route.path + ':' + (val || el.innerText) + const { btns } = store.state + if (text && btns && btns.length) { // 如果按钮集合里没有该权限,就把该按钮给去除 - if (!isPermission) { + if (!btns.includes(text)) { el.parentNode && el.parentNode.removeChild(el) } } diff --git a/src/libs/auth/generateBtnPermission.js b/src/libs/auth/generateBtnPermission.js index 9433f81..7025ad3 100644 --- a/src/libs/auth/generateBtnPermission.js +++ b/src/libs/auth/generateBtnPermission.js @@ -2,23 +2,19 @@ * @description 生成按钮级别权限组 * */ -import store from '@/store'; -export default function(data){ - let result = [] - data.map(e => { - e.children.map(n => { - if(n.children.length){ - result.push(`${e.path}:${n.name}`) - n.children.map(j => { - e.path ? result.push(`${e.path}:${n.name}:${j.name}`) : result.push(`${n.path}:${j.name}`) - j.children.map(k => { - e.path ? result.push(`${e.path}:${n.name}:${j.name}:${k.name}`) : result.push(`${n.path}:${j.name}:${k.name}`) - }) - }) - }else{ - result.push(`${e.path}:${n.name}`) - } - }) - }) - store.commit('addBtnAuth', result) +import store from '@/store' + +const result = [] +// 递归组合权限 +function createAuth(data, auth) { + data.map(e => { + const text = (auth ? auth + ':' : '') + (auth ? e.name : e.path) // 第一级是路由,取path,子级取name + result.push(text) + e.children && e.children.length && createAuth(e.children, text) + }) +} + +export default function(data) { + createAuth(data) + store.commit('addBtnAuth', result) } diff --git a/src/setting.js b/src/setting.js index dfab01a..2518636 100644 --- a/src/setting.js +++ b/src/setting.js @@ -11,7 +11,7 @@ if (isDev) { jumpPath = 'http://192.168.31.125:8087/' // 本地调试-需要启动本地判分点系统 host = 'http://121.37.12.51/' // host = 'https://huorantech.cn/' - // host = 'http://192.168.31.151:9000/'// 榕 + host = 'http://192.168.31.51:9000/'// 榕 // host = 'http://192.168.31.137:9000/'// 赓 } else if (isPro) { jumpPath = 'https://www.huorantech.cn/judgmentPoint/' @@ -45,7 +45,7 @@ const Setting = { isDev, isPro, // 是否使用动态路由 - dynamicRoute: false, + dynamicRoute: true, /** * @description 默认密码 */ diff --git a/src/views/course/AddCurriculum.vue b/src/views/course/AddCurriculum.vue index 3ca5146..0645255 100644 --- a/src/views/course/AddCurriculum.vue +++ b/src/views/course/AddCurriculum.vue @@ -668,15 +668,14 @@ export default { checkeds.push(e) } }) - if (item.systemId == this.curSystem) this.checkAll = true } else { res.map(e => { const i = checkeds.findIndex(n => n.projectId == e.projectId && n.systemId == e.systemId) i === -1 || checkeds.splice(i, 1) }) - if (item.systemId == this.curSystem) this.checkAll = false } this.checkedAll = JSON.parse(JSON.stringify(checkeds)) // 全部已选项目,另外保存 + this.getProject(item) }).catch(err => {}) }, // 项目全选回调 diff --git a/src/views/course/Curriculum.vue b/src/views/course/Curriculum.vue index ed7faaa..28fe98b 100644 --- a/src/views/course/Curriculum.vue +++ b/src/views/course/Curriculum.vue @@ -93,9 +93,9 @@