Commit 3631a794 by caoyanzhi

权限控制

parent cfe1690f
......@@ -17,13 +17,14 @@ import axios from 'axios';
import ElementUI from 'element-ui';
import App from './App.vue';
import router from './router';
import { routes } from './router/routes.js';
import filters from '@/filters/index.js';
// import { isRequest, itemCode } from '@/config';
// eslint-disable-next-line
import { permission, itemPerm } from '@/utils/permission.js';
Vue.use(VueRouter);
Vue.use(ElementUI);
// 请求头这种添加请求标识
// Object.assign(axios.defaults.headers.common, isRequest);
axios.defaults.withCredentials = true;
Vue.prototype.axios = axios;
......@@ -37,8 +38,16 @@ Vue.config.productionTip = false;
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key]);
});
new Vue({
permission({
whiteRoute: ['/login', '/gic-error', '/403', '/404', '/500'],
router,
routes,
createApp() {
new Vue({
router,
render: h => h(App)
}).$mount('#app')
}).$mount('#app')
}
});
......@@ -9,10 +9,10 @@ let accessPath = [];
let itemPermission = {};
function getGicMenu() {
const getUserMenu = request({ url: '/hb-manage-web/list-menus-auth' }).then(res => {
const getUserMenu = request({ url: '/hb-manage-web//list-staff-role-menu' }).then(res => {
accessPath = getProjectMenu(res.result || []);
});
const getUserOperation = request({ url: '/hb-manage-web/list-operation-auth' }).then(res => {
const getUserOperation = request({ url: '/hb-manage-web/list-staff-role-opeation' }).then(res => {
itemPermission = getItemPerm(res.result || []);
})
return Promise.all([getUserMenu, getUserOperation]);
......@@ -75,7 +75,7 @@ function itemPerm(itemPermCode) {
}
let permission = function(config) {
const { writeRoute, router, routes, createApp } = config;
const { whiteRoute, router, routes, createApp } = config;
window.onload = async function() {
// 获取菜单数据
......@@ -84,8 +84,8 @@ let permission = function(config) {
if (path.indexOf('/login') == -1) {
await getGicMenu();
}
if (Array.isArray(writeRoute)) {
accessPath = accessPath.concat(writeRoute);
if (Array.isArray(whiteRoute)) {
accessPath = accessPath.concat(whiteRoute);
}
if (Array.isArray(routes)) {
// 项目中路由文件配置的路径
......
......@@ -100,7 +100,7 @@ export default {
// appType 1好办后台2应用后台3好办小程序4小程序应用
// roleType 1管理员角色 2门店角色
prom.push(menuList(Object.assign({}, params, { appType: el.appType, roleType: 1 })).then(res => {
el.menuList = res.result || [];
el.menuList = this.flatDataToTree(res.result || []);
el.menuList.forEach(item => {
this.$set(el.checkedId, item.menuId, []);
});
......@@ -141,11 +141,11 @@ export default {
flatDataToTree(data) {
return data.filter(el => {
// 返回当前节点下的子节点
const children = data.filter(item => item.parentId == el.menuId);
const children = data.filter(item => item.parentCode == el.menuCode);
if (children.length > 0) {
el.children = children; // 如果存在子级,则给父级添加一个children属性,并赋值
}
return el.parentId == 0;
return el.parentCode == '';
})
},
getActiveMenuList() {
......
......@@ -173,11 +173,11 @@ export default {
flatDataToTree(data) {
return data.filter(el => {
// 返回当前节点下的子节点
const children = data.filter(item => item.parentId == el.menuId);
const children = data.filter(item => item.parentCode == el.menuCode);
if (children.length > 0) {
el.children = children; // 如果存在子级,则给父级添加一个children属性,并赋值
}
return el.parentId == 0;
return el.parentCode == '';
})
},
// 保存选中的子节点id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment