';
$nav.append(nav);
$bd.append(content);
parent.parent.tabCounter++;
$tab.tabs('refresh');
}
function reinitIframeEND(tabCounter){
var iframe = document.getElementById("iframepage"+tabCounter);
try{
$("#my-modal-loading").modal('close');
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
}catch (ex){}
// 停止定时
window.clearInterval(timer1);
}
/**
* 刷新指定选项卡
*/
function reloadTab(title){
$(".tabTitle",parent.document).each(function(index){
//判断选项卡是否存在
if($(this).text()==title){
var iframeId=$(".am-tab-panel").eq(index).children().attr("id");
document.getElementById(iframeId).contentWindow.location.reload(true);
return false;
}
});
}
/**
* 关闭当前页
* @returns
*/
function closeTab(){
var tab = $('#doc-tab-demo-1',parent.document);
var bd = tab.find('.am-tabs-bd',parent.document);
var item = $(this).closest('li');
item.remove();
$(".tabTitle",parent.document).each(function(index){
var item = $(this).closest('li');
item.remove();
bd.find('.am-tab-panel').eq(index).find("iframe[name=iframepage]").attr("src","");
bd.find('.am-tab-panel').eq(index).find("iframe[name=iframepage]").remove();
bd.find('.am-tab-panel').eq(index).remove();
// tab.tabs('refresh');
return false;
});
}
function changeTab(th){
//alert($(".tabTitle").index(th));
// $("#doc-tab-demo-1").tabs('open',$('.am-tabs-nav a').eq(2));
$(".tabTitle").eq($(".tabTitle").index(th)).parent().addClass("am-active");
$(".tabTitle").eq($(".tabTitle").index(th)).parent().siblings().removeClass("am-active");
$(".am-tab-panel").removeClass("am-active").removeClass("am-in");
$(".am-tab-panel").eq($(".tabTitle").index(th)).addClass("am-active").addClass("am-in");
}
/**
* 判断是否添加选项卡
* @param title
* @param src
* @param type
*/
function checkTab(title,src,type){
var flag=true;
$(".tabTitle",parent.document).each(function(index){
//判断选项卡是否存在
/*if($(this).text()==title){
$(".am-tab-panel",parent.document).removeClass("am-active").removeClass("am-in");
$(".am-tab-panel",parent.document).eq(index).addClass("am-active").addClass("am-in");
$(this).parent().addClass("am-active");
$(this).parent().siblings().removeClass("am-active");
flag=false;
}else */if($(this).attr('title')==type){
var $item = $(this).closest('li');
$item.remove();
var panel = $(".am-tab-panel",parent.document).eq(index);
panel.find("iframe[name=iframepage]").attr("src","");
panel.find("iframe[name=iframepage]").remove();
panel.remove();
flag=true;
}
});
//不存在添加选项卡
if(flag){
addTabC(title,src,type);
//FaddEvent();
}
}
/**
* 判断是否添加选项卡
* @param title
* @param src
* @param type
*/
function checkTab2(title,src,type){
var flag=true;
$(".tabTitle",parent.document).each(function(index){
//判断选项卡是否存在
/*if($(this).text()==title){
$(".am-tab-panel",parent.document).removeClass("am-active").removeClass("am-in");
$(".am-tab-panel",parent.document).eq(index).addClass("am-active").addClass("am-in");
$(this).parent().addClass("am-active");
$(this).parent().siblings().removeClass("am-active");
flag=false;
}else */if($(this).attr('title')==type){
var $item = $(this).closest('li');
$item.remove();
var panel = $(".am-tab-panel",parent.document).eq(index);
panel.find("iframe[name=iframepage]").attr("src","");
panel.find("iframe[name=iframepage]").remove();
panel.remove();
flag=true;
}
});
//不存在添加选项卡
if(flag){
addTabC2(title,src,type);
//FaddEvent();
}
}
/**
* 子页面动态设置所在iframe高度
*
*/
function setIframeHeight(){
// alert("setIframeHeight");
var tab = $('#doc-tab-demo-1',parent.document);
var id = tab.find("div.am-active").find("iframe[name=iframepage]").attr("id");
// var index = tab.find('.am-tabs-nav li',parent.document).index(tab.find('.am-tabs-nav li.am-active',parent.document));
var frame = parent.document.getElementById(id);//获取iframe
var win = frame.contentWindow;
var doc = win.document;
var html = doc.documentElement;
var body = doc.body;
// 获取高度 ,用最大值
var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
frame.setAttribute('height', height);
}
//绑定右键菜单事件
function tabCloseEven() {
//刷新
$('#mm-tabupdate').click(function () {
var iframeId=$(".am-tab-panel").eq(parent.Cindex).children().attr("id");
document.getElementById(iframeId).contentWindow.location.reload(true);
closeRightTab();
return false;
});
//关闭当前
$('#mm-tabclose').click(function () {
var $item = $(".am-tabs-nav li").eq(parent.Cindex).closest('li');
var index = $('#doc-tab-demo-1').find('.am-tabs-nav').children('li').index($item);
$item.remove();
//tabCounter--;
$(".am-tab-panel").eq(parent.Cindex).remove();
$('#doc-tab-demo-1').tabs('open', index > 0 ? index - 1 : index + 1);
$('#doc-tab-demo-1').tabs('refresh');
closeRightTab();
return false;
});
//全部关闭
$('#mm-tabcloseall').click(function () {
var $item = $(".am-tabs-nav li").closest('li');
$item.remove();
//tabCounter=0;
$(".am-tab-panel").remove();
$('#doc-tab-demo-1').tabs('refresh');
closeRightTab();
return false;
});
//关闭除当前之外的TAB
$('#mm-tabcloseother').click(function () {
var $item = $(".am-tabs-nav li").eq(parent.Cindex).siblings().closest('li');
$item.remove();
$(".am-tab-panel").eq(parent.Cindex).siblings().remove();
//tabCounter=1;
//$(".am-tab-panel").children().attr("id",'iframepage0');
$('#doc-tab-demo-1').tabs('refresh');
closeRightTab();
return false;
});
}
/**
* 添加右击事件
*/
function addEvent(index){
$('#am-tabs-nav-1 li').eq(index).on("contextmenu", function(e) {
windowwidth = $(window).width();
windowheight = $(window).height();
checkmenu = 1;
$('#mask').css({
'height': windowheight,
'width': windowwidth
});
$('#myMenu').show();
$('#myMenu').css({
'top': e.pageY + 'px',
'left': e.pageX + 'px'
});
return false;
});
}
/**
* 父页面添加右击事件
*/
/*function FaddEvent(){
$('#am-tabs-nav-1 li',parent.document).eq(parent.tabCounter-1).on("contextmenu", function(e) {
windowwidth = $(window).width();
windowheight = $(window).height();
checkmenu = 1;
$('#mask',parent.document).css({
'height': windowheight,
'width': windowwidth
});
$('#myMenu',parent.document).show();
$('#myMenu',parent.document).css({
'top': e.pageY + 'px',
'left': e.pageX + 'px'
});
return false;
});
}*/
/**
* 关闭右击窗口
*/
function closeRightTab(){
$('#mask').height(0);
$('#mask').width(0);
$('#myMenu').hide();
}
/**
* 关闭当前选项卡打开一个新的选项卡
* @param title
* @param src
* @param type
*/
function openTab(title,src,type){
var tab = $('#doc-tab-demo-1',parent.document);
var nav = tab.find('.am-tabs-nav',parent.document);
var bd = tab.find('.am-tabs-bd',parent.document);
//$(".tabTitle",parent.document).parents().removeClass("am-active");
$(".am-tab-panel",parent.document).removeClass("am-active");
//parent.tabCounter--;
var nav1 = '
' +
'' + title + ' ';
var content = '
';
parent.tabCounter++;
/* $(".tabTitle",parent.document).each(function(index){
if($(this).attr('title')==type){
var _this=$(this);
$(".am-tab-panel",parent.document).eq(index).remove();
// alert(_this.closest('li').html());
_this.closest('li').remove();
// $(item).remove();
}
});*/
$(".am-tabs-nav li",parent.document).each(function(index){
if($(this).hasClass("am-active")){
var _this = $(this);
var panel = $(".am-tab-panel",parent.document).eq(index);
panel.find("iframe[name=iframepage]").attr("src","");
panel.find("iframe[name=iframepage]").remove();
panel.remove();
_this.remove();
}
});
nav.append(nav1);
bd.append(content);
tab.tabs('refresh');
// FaddEvent();
}
/**
* 关闭当前选项卡和标题相同的选项卡打开一个新的选项卡
*/
function savaTab(title,src,type){
var tab = $('#doc-tab-demo-1',parent.document);
var bd = tab.find('.am-tabs-bd',parent.document);
$(".tabTitle",parent.document).each(function(index){
//判断选项卡是否存在
if(type==""&&$(this).text()==title){
var item = $(this).closest('li');
item.remove();
bd.find('.am-tab-panel').eq(index).find("iframe[name=iframepage]").attr("src","");
bd.find('.am-tab-panel').eq(index).find("iframe[name=iframepage]").remove();
bd.find('.am-tab-panel').eq(index).remove();
tab.tabs('refresh');
return false;
}else if($(this).text()==type){
var item = $(this).closest('li');
item.remove();
bd.find('.am-tab-panel').eq(index).find("iframe[name=iframepage]").attr("src","");
bd.find('.am-tab-panel').eq(index).find("iframe[name=iframepage]").remove();
bd.find('.am-tab-panel').eq(index).remove();
tab.tabs('refresh');
return false;
}
});
openTab(title,src,type);
}
/**
* 更改当前选项卡的title和iframe的内容
*/
function replaceTab(title,src,type){
var tab = $('#doc-tab-demo-1',parent.document);
var bd = tab.find('.am-tabs-bd',parent.document);
$(".tabTitle",parent.document).each(function(index){
//判断选项卡是否存在
if($(this).attr("title")==type){
var item = $(this).closest('li');
item.remove();
bd.find('.am-tab-panel').eq(index).find("iframe[name=iframepage]").attr("src","");
bd.find('.am-tab-panel').eq(index).find("iframe[name=iframepage]").remove();
bd.find('.am-tab-panel').eq(index).remove();
//tab.tabs('refresh');
return false;
}
});
tab.find('li.am-active',parent.document).find(".tabTitle").text(title);
tab.find('li.am-active',parent.document).find(".tabTitle").attr("title",type);
tab.find('div.am-active',parent.document).find("iframe[name=iframepage]").attr("src",src);
//tab.tabs('refresh');
}
/**
* 关闭模态窗口
*/
function closeModal(id){
var $modal = $('#'+id);
$modal.modal('close');
}
//具体品名
$(function(){
$(".PingMing").on("click",function(event){
//$("#typeBox").remove();
var _html="";
if ($("#typeBox").length>0){
$("#typeBox").show();
event.stopPropagation();//阻止事件向上冒泡
} else{
var textKH="";
$.ajax({
url : projectAllName+"/common/getKH.do",
type : "post",
dataType : "JSON",
//async : false,
success:function(json){
var rows=json.datas.table.row;
for(var i=0;i
'+rows[i].ItemName+' ';
}else if(i%3==1){
textKH+=''+rows[i].ItemName+' ';
}else if(i%3==2){
textKH+=''+rows[i].ItemName+' ';
}
if(i==rows.length&&i%3!=2){
textKH+='';
}
}
}
});
_html+='';
$(this).parent().append(_html);
}
$(document).one("click", function ()
{//对document绑定一个影藏Div方法
$("#typeBox").remove();
});
event.stopPropagation();//阻止事件向上冒泡
$("#typeBox").click(function(event){
event.stopPropagation();//阻止事件向上冒泡
});
});
});
function nextCheck(){
var spCodesTemp = "";
$('input:checkbox[name=spCodeId]:checked').each(function(i){
if(0==i){
spCodesTemp = $(this).val();
}else{
spCodesTemp += (","+$(this).val());
}
});
//alert(spCodesTemp);
addNext(spCodesTemp);
}
function addNext(spCodesTemp){
var event = window.event || arguments.callee.caller.arguments[0];
$("#typeBox").hide();
textKH="";
$.ajax({
url : projectAllName+"/common/getJTKH2.do",
type : "post",
data :{"ItemCode":spCodesTemp},
dataType : "JSON",
//async : false,
success:function(json){
var rows=json.datas.table.row;
var obj2 = spCodesTemp.split(",");
for(var i=0;i'+rows[i].ItemName+'';
for(var j=obj2.length;j '+rows[j].ItemName+' ';
}
}
textKH+=' ';
}
//alert(textKH);
}
});
_html="";
_html+='';
$("#typeBox").parent().append(_html);
$(document).one("click", function ()
{//对document绑定一个影藏Div方法
$("#typeBox1").remove();
$("#typeBox").remove();
});
$("#typeBox1").click(function(event){
event.stopPropagation();//阻止事件向上冒泡
});
$('input:checkbox[name=spCodeId1]').on("click",function(){
var checkVal="";
var checkVal1="";
$('input:checkbox[name=spCodeId1]:checked').each(function(i){
if(0==i){
checkVal = $(this).next().text();
checkVal1=$(this).val();
}else{
checkVal += (","+$(this).next().text());
checkVal1+= (","+$(this).val());;
}
});
$("#typeBox").prev().prev().val(checkVal);
$("#typeBox").prev().val(checkVal1);
});
}
function closePM(){
$("#typeBox1").remove();
$("#typeBox").remove();
}
/**
* 生成json串
* @param key 数组
* @param value 对应可以的数组
* @returns {String}
*/
function createJSON(key , value){
var json = "{";
for (var i = 0; i < key.length; i++){
if(!(value[i] == null || value[i] == "null" || value[i] == "")){
json += "\"" + key[i] + "\":\"" + $.trim(value[i]) + "\",";
}
}
if(json == "{"){//json为空
return "";
}else{
json = json.substring(0,json.length-1) + "}";
return json;
}
}
$(function(){
if(!isIE()&&!(navigator.userAgent.indexOf('Firefox') >= 0)){
$("#gkBox").css("top","33px");
}
$("#fromGK").on("click",function(event){
//$("#typeBox").remove();
var _html="";
if ($("#GKBox").length>0){
$("#GKBox").show();
$("#GKBox1").remove();
$("#GKBox2").remove();
event.stopPropagation();//阻止事件向上冒泡
} else{
var textKH="";
$.ajax({
url :projectAllName+ "/common/getFJ2.do",
data:{"DictCode":"DM_SF"},
type : "post",
dataType : "JSON",
//async : false,
success:function(json){
var rows=json.datas.table.row;
for(var i=0;i'+rows[i].ItemName+' ';
}else if(i%4==1){
textKH+=''+rows[i].ItemName+' ';
}else if(i%4==2){
textKH+=''+rows[i].ItemName+' ';
}else if(i%4==3){
textKH+=''+rows[i].ItemName+' ';
}
if(i==rows.length&&i%4!=3){
textKH+='';
}
}
}
});
_html+='';
_html+='
省份 ';
_html+=textKH;
_html+='
';
//$(this).parent().append(_html);
$("#gkBox").append(_html);
$(".prover").click(function(event){
addCityBox($(this).text(),$(this).next().val(),event);
});
}
$(document).one("click", function ()
{//对document绑定一个影藏Div方法
$("#GKBox").remove();
});
event.stopPropagation();//阻止事件向上冒泡
$("#gkBox").click(function(event){
event.stopPropagation();//阻止事件向上冒泡
});
});
});
function clearGK(){
$("#fromGK").val('');
$("#fromGK").next().val('');
}
function addCityBox(prov,code,event){
//var event =event || window.event || arguments.callee.caller.arguments[0];
$("#GKBox").hide();
_html="";
textKH="";
$.ajax({
url :projectAllName+ "/common/getZL.do",
data:{"DictCode":"DM_CS","PItemCode":code},
type : "post",
dataType : "JSON",
//async : false,
success:function(json){
var rows=json.datas.table.row;
for(var i=0;i'+rows[i].ItemName+' ';
}else if(i%4==1){
textKH+=''+rows[i].ItemName+' ';
}else if(i%4==2){
textKH+=''+rows[i].ItemName+' ';
}else if(i%4==3){
textKH+=''+rows[i].ItemName+' ';
}
if(i==rows.length&&i%4!=3){
textKH+='';
}
}
}
});
_html+='';
_html+='
选择港口
省份 '+prov+' ';
_html+=textKH;
_html+='
';
$("#GKBox").parent().append(_html);
$(".provct").click(function(event){
addGkBox(prov,$(this).text(),$(this).next().val(),event);
});
$(document).one("click", function ()
{//对document绑定一个影藏Div方法
$("#GKBox1").remove();
$("#GKBox").remove();
});
event.stopPropagation();//阻止事件向上冒泡
$("#gkBox").click(function(event){
event.stopPropagation();//阻止事件向上冒泡
});
}
function showPrev(){
$("#GKBox").show();
$("#GKBox1").remove();
$("#GKBox2").remove();
}
function showCity(){
$("#GKBox1").show();
$("#GKBox2").remove();
}
function addGkBox(fprov,prov,code,event){
//var event = window.event || arguments.callee.caller.arguments[0];
$("#GKBox1").hide();
_html="";
textKH="";
$.ajax({
url : projectAllName+ "/common/getGKByCity.do",
data:{"CityCode":code},
type : "post",
dataType : "JSON",
//async : false,
success:function(json){
if(json.info=="无记录"){
}else{
var rows=json.datas.table.row;
for(var i=0;i'+rows[i].PortName+' ';
}else if(i%4==1){
textKH+=''+rows[i].PortName+' ';
}else if(i%4==2){
textKH+=''+rows[i].PortName+' ';
}else if(i%4==3){
textKH+=''+rows[i].PortName+' ';
}
if(i==rows.length&&i%4!=3){
textKH+='';
}
}
}
}
});
_html+='';
_html+='
选择港口
省份 '+fprov+' '+prov+' ';
_html+=textKH;
_html+='
';
$("#GKBox1").parent().append(_html);
$(".provgk").click(function(){
$("#fromGK").val($(this).text());
$("#fromGK").next().val($(this).next().val());
$("#GKBox2").remove();
$("#GKBox1").remove();
$("#GKBox").remove();
});
$(document).one("click", function ()
{//对document绑定一个影藏Div方法
$("#GKBox2").remove();
$("#GKBox1").remove();
$("#GKBox").remove();
});
event.stopPropagation();//阻止事件向上冒泡
$("#gkBox").click(function(event){
event.stopPropagation();//阻止事件向上冒泡
});
}
$(document).ready(function(){
$("#my-modal-loading",top.window.document).modal('open');
});
window.onload=function(){
$("#my-modal-loading",top.window.document).modal('close');
};