static.common.js.index_bac.js Maven / Gradle / Ivy
/**
* Created by PLC on 2017/8/6.
*/
// 定义菜单组件
Vue.component('menuItem', {
name: 'menu-item',
props: {item: {}},
template: [
'',
' ',
' ',
' {{item.name}}',
' ',
' ',
'',
' ',
' ',
' ',
' {{item.name}}',
' ',
' ',
' ',
' ',
' ',
' '
].join('')
});
window.mainPanel = new Vue({
el: '#main-panel',
data: {
loadUrl: 'homePage.html',
menuList: {},
navTitle: '',
},
methods: {
getMenu: function () {
$.get(ctx + "/sys/resource/findResourceTreeForLoginUser?_" + $.now(), function (o) {
mainPanel.menuList = o.data[0].children;
});
},
openWin:function(title, url,area) {
czy.win._open(title, url,area)
}
},
created: function () {
this.getMenu();
},
updated: function () {
//路由
var router = new Router();
routerList(router, mainPanel.menuList);
router.start();
}
});
function routerList(router, menuList) {
for (var key in menuList) {
var menu = menuList[key];
if (menu.types == 2) {
routerList(router, menu.children);
} else if (menu.types == 1) {
router.add('#' + menu.url, function () {
var url = window.location.hash;
//替换iframe的url
mainPanel.loadUrl = url.replace('#', '') + ".html";
//导航菜单展开
$(".active").removeClass("active");
$("a[href='" + url + "']").parents("li").addClass("active");
mainPanel.navTitle = $("a[href='" + url + "']").text();
// 开启加载条
// mainPanel.$Loading.start();
});
}
}
}
// //设置进度加载条
// mainPanel.$Loading.config({
// color: '#264e6a',
// height: 50
// });