// 生成左侧导航菜单
function generateMenu(menuId, systemName) {
if (menuId < 8000) {
$(".panel-header .panel-title:first").html(systemName);
var allPanel = $("#RightAccordion").iAccordion('panels');
var size = allPanel.length;
if (size > 0) {
for (i = 0; i < size; i++) {
var index = $("#RightAccordion").iAccordion('getPanelIndex', allPanel[i]);
$("#RightAccordion").iAccordion('remove', 0);
}
}
var url = "./json/menu/menu_" + menuId + ".json";
if (topJUI.config.appendRefererParam) url = appendRefererParam(url);
$.get(
url, {"levelId": "2"}, // 获取第一层目录
function (data) {
if (data == "0") {
window.location = "/Account";
}
$.each(data, function (i, e) {// 循环创建手风琴的项
var pid = e.pid;
var isSelected = i == 0 ? true : false;
$('#RightAccordion').iAccordion('add', {
fit: false,
title: e.text,
content: "<ul id='tree" + e.id + "' ></ul>",
border: false,
selected: isSelected,
iconCls: e.iconCls
});
//$.parser.parse();
var secondUrl = "./json/menu/menu_" + e.id + ".json";
if (topJUI.config.appendRefererParam) secondUrl = appendRefererParam(secondUrl);
$.get(secondUrl, function (data) {// 循环创建树的项
$("#tree" + e.id).tree({
data: data,
lines: false,
animate: true,
onBeforeExpand: function (node, param) {
var thirdUrl = "./json/menu/menu_" + node.id + ".json";
if (topJUI.config.appendRefererParam) thirdUrl = appendRefererParam(thirdUrl);
$("#tree" + e.id).tree('options').url = thirdUrl;
},
onClick: function (node) {
console.log(node);
if (node.url) {
/*if(typeof node.attributes != "object") {
node.attributes = $.parseJSON(node.attributes);
}*/
addTab(node);
} else {
if (node.state == "closed") {
$("#tree" + e.id).tree('expand', node.target);
} else if (node.state == 'open') {
$("#tree" + e.id).tree('collapse', node.target);
}
}
}
});
}, 'json');
});
}, "json"
);
}
}
//打开Tab窗口
function addTab(params) {
var t = $('#index_tabs');
var $selectedTab = t.iTabs('getSelected');
var selectedTabOpts = $selectedTab.iPanel('options');
if (topJUI.config.appendRefererParam && params.url) params.url = appendRefererParam(params.url);
var iframe = '<iframe src="' + params.url + '" scrolling="auto" frameborder="0" style="width:100%;height:100%;"></iframe>';
var defaults = {
id: getRandomNumByDef(),
refererTab: {},
title: params.text,
iframe: topJUI.config.iframe,
onlyInitParse: true,
iconCls: 'fa fa-file-text-o',
border: true,
fit: true,
closable: true
//cls: 'leftBottomBorder'
};
var opts = $.extend(defaults, params);
var ifOpts = opts.iframe ? {content: iframe} : {href: params.url};
opts = $.extend(opts, ifOpts);
if (t.iTabs('exists', opts.title)) {
t.iTabs('select', opts.title);
} else {
var lastMenuClickTime = $.cookie("menuClickTime");
var nowTime = new Date().getTime();
if ((nowTime - lastMenuClickTime) >= 500) {
$.cookie("menuClickTime", new Date().getTime());
t.iTabs('add', opts);
} else {
$.iMessager.show({
title: '温馨提示',
msg: '操作过快,请稍后重试!'
});
}
}
}
点击左侧一级菜单就显示右侧表单数据而不是点击里面的子菜单才显示,要怎么办
上图是下载演示的代码一部分
求大神指点迷津!