...
|
...
|
@@ -67,31 +67,34 @@ |
|
|
this.$refs.ruleForm2.resetFields();
|
|
|
},
|
|
|
handleMenuList : function (router,menu) {
|
|
|
var _self = this;
|
|
|
var _this = this;
|
|
|
var routerName = "";
|
|
|
router.forEach(function (v_router) {
|
|
|
var routerTemp = router.concat();
|
|
|
|
|
|
routerTemp.forEach(function (v_router,v_index,v_arr) {
|
|
|
routerName = v_router.name;
|
|
|
menu.forEach(function (v_menu) {
|
|
|
//查找返回的目录列表是否包含路由名称,有就返回匹配到的元素,没有就移除
|
|
|
let result = menu.find(item => {
|
|
|
return item.name === routerName;
|
|
|
});
|
|
|
|
|
|
//匹配到继续判断是否子元素,有子元素继续递归
|
|
|
if (result) {
|
|
|
if(v_router.children) {
|
|
|
_self.handleMenuList(v_router.children,result.children);
|
|
|
}
|
|
|
//没有则可以移除
|
|
|
}else {
|
|
|
router.splice(router.findIndex(itm => itm.name === routerName ),1);
|
|
|
//查找返回的目录列表是否包含路由名称,有就返回匹配到的元素,没有就移除
|
|
|
let result = menu.find(item => {
|
|
|
return item.name === routerName;
|
|
|
});
|
|
|
|
|
|
//匹配到继续判断是否子元素,有子元素继续递归
|
|
|
if (result) {
|
|
|
if (v_router.children && v_router.children.length>0) {
|
|
|
_this.handleMenuList(v_router.children, result.children);
|
|
|
}
|
|
|
})
|
|
|
}else {
|
|
|
//没有则可以移除
|
|
|
let deletRouter = router.findIndex(itm => itm.name === routerName );
|
|
|
router.splice(deletRouter,1);
|
|
|
}
|
|
|
});
|
|
|
console.log("longined router:");
|
|
|
console.log(_self.$router.options.routes);
|
|
|
//本地存储用户目录 ,防刷新目录丢失用
|
|
|
sessionStorage.setItem('menu', JSON.stringify(_self.$router.options.routes));
|
|
|
console.log(routerName);
|
|
|
console.log(_this.$router.options.routes);
|
|
|
// 本地存储用户目录 ,防刷新目录丢失用
|
|
|
sessionStorage.setItem('menu', JSON.stringify(_this.$router.options.routes));
|
|
|
},
|
|
|
handleSubmit2: function (ev) {
|
|
|
var _this = this;
|
...
|
...
|
@@ -127,11 +130,11 @@ |
|
|
console.log("sysMenus:");
|
|
|
console.log(sysMenus);
|
|
|
|
|
|
_this.handleMenuList(sysMenus,_this.userMenus);
|
|
|
_this.handleMenuList(_this.$router.options.routes,_this.userMenus);
|
|
|
|
|
|
console.log("user:");
|
|
|
console.log(_this.$router.options.routes);
|
|
|
this.$router.push({path: '/main'});
|
|
|
_this.$router.push({path: '/main'});
|
|
|
}
|
|
|
}).catch(error => {
|
|
|
let msg = error.message;
|
...
|
...
|
|