ComplianceServer/oldcode/WEB/Scripts/op/home_jmd.js

268 lines
8.7 KiB
JavaScript

$(function () {
$('#tab_menu-tabrefresh').click(function () {
/*重新设置该标签 */
var url = $(".tabs-panels .panel").eq($('.tabs-selected').index()).find("iframe").attr("src");
$(".tabs-panels .panel").eq($('.tabs-selected').index()).find("iframe").attr("src", url);
});
//在新窗口打开该标签
$('#tab_menu-openFrame').click(function () {
var url = $(".tabs-panels .panel").eq($('.tabs-selected').index()).find("iframe").attr("src");
window.open(url);
});
//关闭当前
$('#tab_menu-tabclose').click(function () {
var currtab_title = $('.tabs-selected .tabs-inner span').text();
$('#mainTab').tabs('close', currtab_title);
if ($(".tabs li").length == 0) {
//open menu
$(".layout-button-right").trigger("click");
}
});
//全部关闭
$('#tab_menu-tabcloseall').click(function () {
$('.tabs-inner span').each(function (i, n) {
if ($(this).parent().next().is('.tabs-close')) {
var t = $(n).text();
$('#mainTab').tabs('close', t);
}
});
//open menu
$(".layout-button-right").trigger("click");
});
//关闭除当前之外的TAB
$('#tab_menu-tabcloseother').click(function () {
var currtab_title = $('.tabs-selected .tabs-inner span').text();
$('.tabs-inner span').each(function (i, n) {
if ($(this).parent().next().is('.tabs-close')) {
var t = $(n).text();
if (t != currtab_title)
$('#mainTab').tabs('close', t);
}
});
});
//关闭当前右侧的TAB
$('#tab_menu-tabcloseright').click(function () {
var tab = $('#mainTab').tabs('getSelected');
var ntitle = tab.panel('options').title;
var nextall = $('.tabs-selected').nextAll();
if (nextall.length == 0) {
$.messager.alert('提示', '前面没有了!', 'warning');
return false;
}
nextall.each(function (i, n) {
if ($('a.tabs-close', $(n)).length > 0) {
var t = $('a:eq(0) span', $(n)).text();
$('#mainTab').tabs('close', t);
}
});
$("#mainTab").tabs('select', ntitle);
return false;
});
//关闭当前左侧的TAB
$('#tab_menu-tabcloseleft').click(function () {
var tab = $('#mainTab').tabs('getSelected');
var ntitle = tab.panel('options').title;
var prevall = $('.tabs-selected').prevAll();
if (prevall.length == 0) {
$.messager.alert('提示', '后面没有了!', 'warning');
return false;
}
prevall.each(function (i, n) {
if ($('a.tabs-close', $(n)).length > 0) {
var t = $('a:eq(0) span', $(n)).text();
$('#mainTab').tabs('close', t);
}
});
$("#mainTab").tabs('select', ntitle);
return false;
});
});
$(function () {
/*为选项卡绑定右键*/
$(".tabs li").live('contextmenu', function (e) {
/*选中当前触发事件的选项卡 */
var subtitle = $(this).text();
$('#mainTab').tabs('select', subtitle);
//显示快捷菜单
$('#tab_menu').menu('show', {
left: e.pageX,
top: e.pageY
});
return false;
});
});
var maxTabIndex = 30;
var tabRecord = {};
var ifId = 0;
//去除了
function addTab(subtitle, url, icon) {
if (url.indexOf("?") > -1)
url = url + "&Ieguid=" + GetGuid();
else
url = url + "?Ieguid=" + GetGuid();
if (!$("#mainTab").tabs('exists', subtitle)) {
var prevall = $('.tabs').children("li");
if (prevall.length >= maxTabIndex) {
$.messager.alert('提示', '打开的页面不能超过' + maxTabIndex + '个,请关闭一些页面!', 'warning');
return;
}
ifId++;
$("#mainTab").tabs('add', {
title: subtitle,
content: createFrame(url, ifId),
closable: true,
icon: icon
});
$("#iframe" + ifId).attr("src", url);
}
else {
$("#mainTab").tabs('select', subtitle);
//$("#tab_menu-tabrefresh").trigger("click");prevallx
}
//$(".layout-button-left").trigger("click");
//tabClose();
}
function ChildAddTab(tabTitle, url, icon) {
var prevall = $('.tabs').children("li");
if (prevall.length >= maxTabIndex) {
$.messager.alert('提示', '打开的页面不能超过' + maxTabIndex + '个,请关闭一些页面!', 'warning');
return;
}
//if (tabTitle == "客户详细") {
if (tabRecord[tabTitle] == null)
tabRecord[tabTitle] = 1;
else
tabRecord[tabTitle] += 1;
addTab(tabTitle + tabRecord[tabTitle], url, icon);
//} else
// addTab(tabTitle, url, icon);
}
function GetGuid() {
var s4 = function () {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
return s4() + s4() + s4() + "-" + s4();
}
function createFrame(url, ifId) {
var s = '<iframe id="iframe' + ifId + '" frameborder="0" scrolling="no" style="width:100%; height:99%"></iframe>';
return s;
}
function currenttabclose() {
var currtab_title = $('.tabs-selected .tabs-inner span').text();
$('#mainTab').tabs('close', currtab_title);
}
$(function () {
$(".ui-skin-nav .li-skinitem span").click(function () {
var theme = $(this).attr("rel");
$.messager.confirm('提示', '切换皮肤将重新加载系统!', function (r) {
if (r) {
$.post("../../Home/SetThemes", { value: theme }, function (data) { window.location.reload(); }, "json");
}
});
});
});
$(function () {
var id = $("#hidChooseId").val();//默认ID
//获取树形
var o = {
// showcheck: false,
// url: "/Home/GetTree",
// iConShow: true,
// isexpand:false,
onnodeclick: function (item) {
var tabTitle = item.text;
var url = "../../" + item.value;
if (url.indexOf("http://") > -1)
url = item.value;
var icon = item.Icon;
if (!item.hasChildren) {
addTab(tabTitle, url, icon);
} else {
$(this).parent().find("img").trigger("click");
}
}
}
var xmn = $("[nid='" + id + "']");
if (xmn != null)
$(xmn).addClass($(xmn).attr("nclass"));
$.post("/Home/GetTreeByModuleId", { "id": id },
function (data) {
if (data == "0") {
window.location = "/Account";
}
o.data = data;
$("#RightTree" + id).treeview(o);
}, "json");
$(".main-Menu a").live("click", function () {
$(".onnav").removeClass("onnav");
$(this).addClass("onnav");
ShowChildTree($(this).attr("nid"));
$(".panel-title").text($(this).text())
});
});
function SetIframeScrolling(url, isScrolling) {
if (isScrolling) {
$("iframe").each(function () {
var nscr = $(this).attr("src");
nscr = nscr.replace("../../", "");
if (url.indexOf(nscr) > -1) {
$(this).attr("scrolling", "yes");
}
});
}
}
function ShowChildTree(id) {
var o = {
// showcheck: false,
// url: "/Home/GetTree",
// iConShow: true,
// isexpand:false,
onnodeclick: function (item) {
var tabTitle = item.text;
var url = "../../" + item.value;
if (url.indexOf("http://") > -1)
url = item.value;
var icon = item.Icon;
if (!item.hasChildren) {
addTab(tabTitle, url, icon);
} else {
$(this).parent().find("img").trigger("click");
}
}
}
$("[ntype='treeGroup']").css("display", "none");
var divobj = $("#RightTree" + id).html();
if (divobj == null) {
$("#comtreenb").append(" <div ntype='treeGroup' id='RightTree" + id + "' style='background-color:#fff;'><div class='panel-loading'>加载中...</div></div>");
$.post("/Home/GetTreeByModuleId", { "id": id },
function (data) {
if (data == "0") {
window.location = "/Account";
}
o.data = data;
$("#RightTree" + id).treeview(o);
}, "json");
}
$("#RightTree" + id).css("display", "");
}
function showModule(nid) {
var xmn = $("[nid='" + nid + "']");
$(".toolBarClass").each(function () {
var chidlxm = $(this);
$(chidlxm).removeClass($(chidlxm).attr("nclass"));
});
$(xmn).addClass($(xmn).attr("nclass"));
ShowChildTree(nid);
}