EasyUI tree 点击输出tabs 正常
但是点击在点击多个的时候出现错误 ,第2个tab 出现2个日期查询,其中一个是第一个的
如图,第一的消失 日期查询
代码如下:
$('#center').tabs();
var vhref = function(text){
switch(text){
case '验证用户':
return url;
break;
case '职工管理':
return zggl;
break;
case '供餐':
return gc;
break;
case '已供情况':
return ygqk;
break;
case '订餐情况':
return dcqk;
break;
case '首页':
return 'http://www.hao123.com';
break;
default:
break;
}
};
$('#tt').tree({
lines:'true',
onClick: function(node){
if($('#center').tabs('exists',node.text)){
$('#center').tabs('select',node.text)
}else{
$('#center').tabs('add',{
title : node.text,
closable : true,
href:vhref(node.text),
});
}
},
});
$("#tree").tree({
data: treeData,
lines: true,
onClick: function (node) {
if (node.attributes) {
Open(node.text, node.attributes.url);
}
}
});
/**
* 截取字符串进行拼装
**/
function newUrl() {
var pathName = window.location.pathname.substring(0, window.location.pathname.length - 5);
var localhost = window.location.origin;
var url = localhost + pathName;
console.log(url);
return url;
}
//在右边center区域打开菜单,新增tab
function Open(text, url) {
if ($("#tabs").tabs('exists', text)) {
$('#tabs').tabs('select', text);
} else {
$('#tabs').tabs('add', {
title: text,
closable: true,
href: newUrl() + url,
toolbar: [{
text: '查找',
iconCls: 'icon-search',
}]
});
}
}
//绑定tabs的右键菜单
$("#tabs").tabs({
onContextMenu: function (e, title) {
e.preventDefault();
$('#tabsMenu').menu('show', {
left: e.pageX,
top: e.pageY
}).data("tabTitle", title);
}
});
//实例化menu的onClick事件
$("#tabsMenu").menu({
onClick: function (item) {
CloseTab(this, item.name);
}
});
//几个关闭事件的实现
function CloseTab(menu, type) {
var curTabTitle = $(menu).data("tabTitle");
var tabs = $("#tabs");
if (type === "close") {
tabs.tabs("close", curTabTitle);
return;
}
var allTabs = tabs.tabs("tabs");
var closeTabsTitle = [];
$.each(allTabs, function () {
var opt = $(this).panel("options");
if (opt.closable && opt.title != curTabTitle && type === "Other") {
closeTabsTitle.push(opt.title);
} else if (opt.closable && type === "All") {
closeTabsTitle.push(opt.title);
}
});
for (var i = 0; i < closeTabsTitle.length; i++) {
tabs.tabs("close", closeTabsTitle[i]);
}
}