139 lines
4.6 KiB
JavaScript
139 lines
4.6 KiB
JavaScript
var tab;
|
|
$(function () {
|
|
layui.use(['form', 'element'],
|
|
function () {
|
|
layer = layui.layer;
|
|
element = layui.element;
|
|
});
|
|
|
|
//触发事件
|
|
tab = {
|
|
tabAdd: function (title, url, id) {
|
|
//新增一个Tab项
|
|
element.tabAdd('xbs_tab', {
|
|
title: title
|
|
, content: '<iframe tab-id="' + id + '" frameborder="0" src="' + url + (url.indexOf('?') > -1 ? "&" : "?") + "guid=" + GetGuid() + '" scrolling="yes" class="x-iframe"></iframe>'
|
|
, id: id
|
|
|
|
})
|
|
}
|
|
, tabDelete: function (othis) {
|
|
//删除指定Tab项
|
|
element.tabDelete('xbs_tab', '44'); //删除:“商品管理”
|
|
|
|
|
|
othis.addClass('layui-btn-disabled');
|
|
}
|
|
, tabChange: function (id) {
|
|
//切换到指定Tab项
|
|
element.tabChange('xbs_tab', id); //切换到:用户管理
|
|
}
|
|
};
|
|
|
|
|
|
//左侧菜单效果
|
|
// $('#content').bind("click",function(event){
|
|
$('#leftmunu .layui-nav-item a').click(function (event) {
|
|
console.log("不要乱点击");
|
|
var mudulename = $(this).attr('ntitle');
|
|
var id = $(this).attr('mydata-id');
|
|
$("#moduletitle").html(mudulename);
|
|
$("#leftdiv .mytree").addClass("hiddenMenu");
|
|
$("#Module_" + id).removeClass("hiddenMenu");
|
|
//var url = $(this).attr('_href');
|
|
//var mudulename = $(this).attr('ntitle');
|
|
//if (url == null)
|
|
// return;
|
|
//else {
|
|
// if (url == "" || url == "#") {
|
|
// url = "/Account/NoInterface";
|
|
// }
|
|
// var titile = $(this).attr('ntitle');
|
|
// var index = $('#leftmunu .layui-nav-item a').index($(this));
|
|
// var idname = "main_" + index + 1;
|
|
// var isfind = false;
|
|
// $('.x-iframe').each(function (i, my) {
|
|
// if ($(my).attr('tab-id') == idname) {
|
|
// isfind = true;
|
|
// tab.tabChange(idname);
|
|
// event.stopPropagation();
|
|
// tab_click(idname);
|
|
// return false;
|
|
// }
|
|
// });
|
|
// if (isfind) {
|
|
// return;
|
|
// }
|
|
|
|
// tabid++;
|
|
// tabList[tabList.length] = { id: tabid, tab_id: idname };//新增一个tab需要进入tab 列表
|
|
// //console.log(tabList);
|
|
// url = url + "&module=" + encodeURI(mudulename);
|
|
// tab.tabAdd(titile, url, idname);
|
|
// tab.tabChange(idname);
|
|
// event.stopPropagation();
|
|
//}
|
|
|
|
})
|
|
|
|
});
|
|
//判断有相同tab不新增
|
|
var tabRecord = {};
|
|
function AddTab(title, icon, url) {
|
|
//if (icon == null || icon == "") {
|
|
tabid++;
|
|
var idname = "other_" + tabid;
|
|
if (tabRecord[title] == null)
|
|
tabRecord[title] = 1;
|
|
else
|
|
tabRecord[title] += 1;
|
|
//var isfind = false;
|
|
//$('.x-iframe').each(function (i, my) {
|
|
// if ($(my).attr('tab-id') == idname) {
|
|
// isfind = true;
|
|
// tab.tabChange(idname);
|
|
// tab_click(idname);
|
|
// return false;
|
|
// }
|
|
//});
|
|
//if (isfind) {
|
|
// return;
|
|
//}
|
|
//for (var i = 0; i < $('.x-iframe').length; i++) {
|
|
// if ($('.x-iframe').eq(i).attr('tab-id') == idname) {
|
|
// tab.tabChange(idname);
|
|
// tab_click(idname);
|
|
// return;
|
|
// }
|
|
//};
|
|
|
|
tabList[tabList.length] = { id: tabid, tab_id: idname };//新增一个tab需要进入tab 列表
|
|
tab.tabAdd(title + tabRecord[title] , url, idname);
|
|
tab.tabChange(idname);
|
|
//console.log($('#xbs_tab')[0].scrollLeft + 300);
|
|
//$('#xbs_tab').scrollLeft($('#xbs_tab')[0].scrollLeft + 300);
|
|
$("#xbs_tab").animate({
|
|
scrollLeft: $('#xbs_tab')[0].scrollLeft + $('#xbs_tab').width(),
|
|
});
|
|
if ($("#xbs_tab").hasClass("ly_layui-tab-more")) {
|
|
$(".right-div div[lay-filter='xbs_tab']").attr("overflow", "");
|
|
}
|
|
//}
|
|
}
|
|
|
|
var superindex = 0;
|
|
//无条件新增tab
|
|
function AddNewTab(title, icon, url) {
|
|
//if (icon == null || icon == "") {
|
|
//var idname = "other_" + superindex;
|
|
//tab.tabAdd(title, url, idname);
|
|
//tabid++;
|
|
//tabList[tabList.length] = { id: tabid, tab_id: idname };//新增一个tab需要进入tab 列表
|
|
//tab.tabChange(idname);
|
|
////}
|
|
//superindex++;
|
|
AddTab(title, icon, url);
|
|
}
|
|
function ChildAddTab(tabTitle, url, icon) {
|
|
AddTab(tabTitle, icon, url);
|
|
} |