var tabFilter, menu = [],
liIndex, curNav, delMenu;
layui.define(["element", "jquery"], function (exports) {
var element = layui.element,
$ = layui.jquery,
layId,
Tab = function () {
this.tabConfig = {
closed: true,
openTabNum: 100,
tabFilter: "bodyTab"
}
};
//获取二级菜单数据
Tab.prototype.render = function () {
var _this = this;
$.ajax({
url: 'mainMenu?sysId=' + location.searchObj().sysId,
data: {
requestMode: 0
},
async: false,
success: function (res) {
//layer.closeAll('loading'); //关闭加载层
if (!(res.retHead.errCode - 0)) {
navs = res.retBody.list;
if (!navs) {
return;
}
//显示左侧菜单
if ($(".navBar").html() == '') {
$(".navBar").html(navBar(navs)).height($(window).height() - 60);
element.init(); //初始化页面元素
$(window).resize(function () {
$(".navBar").height($(window).height() - 60);
})
}
} else if ((res.retHead.errCode - 0) == 1004) {
top.location.href = window.hywa.jumpPage.login;
}
}
});
}
//参数设置
Tab.prototype.set = function (option) {
var _this = this;
$.extend(true, _this.tabConfig, option);
return _this;
};
//通过title获取lay-id
Tab.prototype.getLayId = function (title) {
$(".layui-tab-title.top_tab li").each(function () {
if ($(this).find("cite").text() == title) {
layId = $(this).attr("lay-id");
}
})
return layId;
}
//通过title判断tab是否存在
Tab.prototype.hasTab = function (title) {
var tabIndex = -1;
$(".layui-tab-title.top_tab li").each(function () {
if ($(this).find("cite").text() == title) {
tabIndex = 1;
}
})
return tabIndex;
}
//右侧内容tab操作
var tabIdIndex = 0;
Tab.prototype.tabAdd = function (_this) {
if (window.sessionStorage.getItem("menu")) {
menu = JSON.parse(window.sessionStorage.getItem("menu"));
}
var that = this;
var closed = that.tabConfig.closed,
openTabNum = that.tabConfig.openTabNum;
tabFilter = that.tabConfig.tabFilter;
if (_this.find("i.iconfont,i.layui-icon").attr("data-icon") != undefined) {
var title = '';
if (that.hasTab(_this.find("cite").text()) == -1 && _this.siblings("dl.layui-nav-child").length ==
0) {
if ($(".layui-tab-title.top_tab li").length == openTabNum) {
layer.msg('只能同时打开' + openTabNum + '个选项卡哦。不然系统会卡的!');
return;
}
tabIdIndex++;
title += '' + _this.find("cite").text() + '';
title += 'ဆ';
element.tabAdd(tabFilter, {
title: title,
content: "