|
|
@ -29,12 +29,11 @@ import menusdata from './leftMenusData.js' |
|
|
|
import { mirlist } from '@/api/user' |
|
|
|
import { mirlist } from '@/api/user' |
|
|
|
|
|
|
|
|
|
|
|
//console.log(menusdata); |
|
|
|
//console.log(menusdata); |
|
|
|
|
|
|
|
var dfdg = 10; |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
components: { SidebarItem, Logo }, |
|
|
|
components: { SidebarItem, Logo }, |
|
|
|
created: function () { |
|
|
|
created: function () { |
|
|
|
this.getmunusdata(); |
|
|
|
this.getmunusdata(); |
|
|
|
//this.menusdatas = '' |
|
|
|
|
|
|
|
var fe = 10; |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
return { |
|
|
@ -48,12 +47,23 @@ export default { |
|
|
|
// routes() { |
|
|
|
// routes() { |
|
|
|
// return this.$router.options.routes |
|
|
|
// return this.$router.options.routes |
|
|
|
// }, |
|
|
|
// }, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前激活菜单的index,默认选中的菜单 |
|
|
|
activeMenu() { |
|
|
|
activeMenu() { |
|
|
|
const route = this.$route |
|
|
|
const route = this.$route |
|
|
|
const { meta, path } = route |
|
|
|
const { meta, path } = route |
|
|
|
|
|
|
|
const menusindex = window.location.href |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 因为菜单栏的生成和路由是解耦的,因为动态获取以及添加的菜单都是用的同一个path带不同参数,路由没法获取,所以通过获取地址来选中 |
|
|
|
|
|
|
|
let getcan = menusindex.split('?id'); |
|
|
|
|
|
|
|
if (getcan[1]) { |
|
|
|
|
|
|
|
//console.log(menusindex.split('/#')); |
|
|
|
|
|
|
|
return menusindex.split('/#')[1] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// if set path, the sidebar will highlight the path you set |
|
|
|
// if set path, the sidebar will highlight the path you set |
|
|
|
if (meta.activeMenu) { |
|
|
|
if (meta.activeMenu) { |
|
|
|
return meta.activeMenu |
|
|
|
return meta.activeMenu //当前激活的菜单 |
|
|
|
} |
|
|
|
} |
|
|
|
return path |
|
|
|
return path |
|
|
|
}, |
|
|
|
}, |
|
|
@ -77,39 +87,29 @@ export default { |
|
|
|
// this.$set(this.menusdata,'children', []) |
|
|
|
// this.$set(this.menusdata,'children', []) |
|
|
|
// //menusdata[0].children = [] |
|
|
|
// //menusdata[0].children = [] |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
newMenu = { |
|
|
|
newMenu = { |
|
|
|
path: '/subfile?id='+item.id, |
|
|
|
path: '/filemange/subfile?id='+item.id, |
|
|
|
meta: { title: item.directory, icon: 'dashboard' }, |
|
|
|
meta: { title: item.directory, activeMenu:'subfile?id='+item.id, icon: 'dashboard' }, |
|
|
|
children:[] |
|
|
|
children:[] |
|
|
|
} |
|
|
|
} |
|
|
|
//console.log(item.directories.length); |
|
|
|
|
|
|
|
if (item.directories && item.directories.length > 0) { |
|
|
|
if (item.directories && item.directories.length > 0) { |
|
|
|
newMenu.children = this.SplicingMenuTree(item.directories,) |
|
|
|
newMenu.children = this.SplicingMenuTree(item.directories) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
arrMenus.push(newMenu); |
|
|
|
arrMenus.push(newMenu); |
|
|
|
//console.log(arrMenus); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
return arrMenus; |
|
|
|
return arrMenus; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
getmunusdata() { |
|
|
|
getmunusdata() { |
|
|
|
let thiss = this; |
|
|
|
let thiss = this; |
|
|
|
// console.log(this.$route); |
|
|
|
//console.log(this.$route); |
|
|
|
// console.log(this.$store); |
|
|
|
// console.log(this.$store); |
|
|
|
|
|
|
|
|
|
|
|
mirlist().then(response => { |
|
|
|
mirlist().then(response => { |
|
|
|
let datamain = response.data; |
|
|
|
let datamain = response.data; |
|
|
|
//routesData(datamain.data.menus); |
|
|
|
|
|
|
|
//console.log(response); |
|
|
|
this.routes[0].children = this.SplicingMenuTree(datamain.data.menus); |
|
|
|
console.log(this.menusdatas); |
|
|
|
|
|
|
|
menusdata[0].children = this.SplicingMenuTree(datamain.data.menus); |
|
|
|
|
|
|
|
//menusdatas[0] = addmunst |
|
|
|
|
|
|
|
console.log(menusdata); |
|
|
|
|
|
|
|
//this.routes = menusdata |
|
|
|
|
|
|
|
//console.log(menusdata); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).catch(function (error) { |
|
|
|
}).catch(function (error) { |
|
|
|
thiss.$message({ |
|
|
|
thiss.$message({ |
|
|
|