/** * MC版本:v1.0.12 (初始) * * 前台JS工具类 * by:hxh 2017-01-20 * **/ function closePopIcoFp(tempPopupDivId,thisObj,isFocus){ $("#"+tempPopupDivId).parent().remove(); top.$("#"+tempPopupDivId).parent().remove(); if(isFocus=="1"){ $("#"+thisObj).focus().select(); } //$("#"+shadowPopupDivId).remove(); } var topDocument=top.document; var UtilsDivFor=0; //定义全局变量用于存储消息 var helpMsgObj = {}; var _showLoadingMsg = ""; var _isShowLoading = false; var _isMothMakrControl=true;// 用于标记用户是否超时未操作平台功能, cjd ldg var _showTopLoadingMsg = ""; var _isShowTopLoading = false; // _isMothMakrControl=false To Cjd 2018-01-25 var _DICT_MAP_GOL = new Object(); var _LANG_MAP_GOL = new Object(); function UtilsFp() { /** * MC版本:v3.0.1 * * 取contextPath,如/mes */ this.submit_default_info = "\u6570\u636e\u52a0\u8f7d\u4e2d\uff0c\u8bf7\u7a0d\u5019..."; this.getContextPath = function () { var contextPath = document.location.pathname; if ("/" == contextPath.substr(0, 1)) { index = contextPath.substr(1).indexOf("/"); } else { contextPath = "/" + contextPath; } var index = contextPath.substr(1).indexOf("/"); contextPath = contextPath.substr(0, index + 1); if(contextPath == "" || contextPath == null ){ contextPath = "/ml"; } return contextPath; }; /** * MC版本:v1.0.12 (初始) * * 弹出确认窗口,入参:(回调函数,要显示的字符串,回调参数) */ this.confirm = function(callBackFun, msg,paramObj){ UtilsDivFor++;//cjd 2017-12-11 16:14 if (null == msg || "" == msg) { msg = "\u786E\u8BA4\u6267\u884C\u64CD\u4F5C";//确认执行操作 utilsFp.initLangMap('["确认执行操作"]'); msg = utilsFp.getLangShow("确认执行操作"); } var divStr = "
\n" +"\n" +"\n" +"
\n" +"
"+msg+"?
\n" +"
" +""//确定 +""//取消 +"
" +"
" +"
"; //+"
"; if($("#shadowConfirmId0").length == 0){ divStr += "
"; top.zcount++; } var tmpDiv = topDocument.createElement("div"); tmpDiv.innerHTML = divStr; var body = topDocument.getElementsByTagName("body")[0]; body.appendChild(tmpDiv); top.$(".dialog-mask#shadowConfirmId0").show(); top.$("#confirmId0").draggable(); var confirmId0 = topDocument.getElementById("confirmId0"); var confirmOkBtn0 = topDocument.getElementById("confirmOkBtn0"); //var maskId0 = topDocument.getElementById(".dialog-mask"); confirmOkBtn0.focus();//默认选中确定按钮 confirmOkBtn0.onclick = function () { //confirmId0.style.display = "none"; //maskId0.style.display = "none"; callBackFun(paramObj); $(confirmId0).remove(); //$(maskId0).remove(); top.$(".dialog-mask#shadowConfirmId0").hide(); top.$(".dialog-mask#shadowConfirmId0").remove(); }; topDocument.getElementById("confirmCancelBtn0").onclick = function () { //confirmId0.style.display = "none"; //maskId0.style.display = "none"; $(confirmId0).remove(); top.$(".dialog-mask#shadowConfirmId0").hide(); top.$(".dialog-mask#shadowConfirmId0").remove(); //$(maskId0).remove(); }; $("#confirmId0").keyup(function (event) { // 获取键值 var keyEvent = event || window.event; var key = keyEvent.keyCode; //获得当前对象 var input_blur = $(this); switch (key) { case 27://按下esc键,取消 $(confirmId0).remove(); top.$(".dialog-mask#shadowConfirmId0").hide(); top.$(".dialog-mask#shadowConfirmId0").remove(); break; } }); } /** * MC版本:v1.0.12 (初始) * * 根据提示信息的长度动态设置弹出框宽高 */ function setWidthAndHeight(msgLength,param){ if(msgLength>20 &&msgLength<=56 ){ param+=50; }else if(msgLength>56 && msgLength<=86){ param+=100; }else if(msgLength>86 && msgLength<=116){ param+=150; }else if(msgLength>116 && msgLength<=146){ param+=200; }else if(msgLength>146 && msgLength<=176){ param+=250; } return param; } /** * MC版本:v1.0.13 * * 跨站点特殊字符替换*/ this.replaceLikeVal=function(comp){ if (comp.value.indexOf("'") != -1 ||comp.value.indexOf("\"") != -1||comp.value.indexOf("<") != -1||comp.value.indexOf(">") != -1 ||comp.value.indexOf("{") != -1||comp.value.indexOf("}") != -1||comp.value.indexOf("[") != -1||comp.value.indexOf("]") != -1 ||comp.value.indexOf("(") != -1||comp.value.indexOf(")") != -1||comp.value.indexOf("/") != -1) { comp.value = comp.value.replace(/\'/g,"").replace(/\"/g,"").replace(//g,"") .replace(/{/g,"").replace(/\(/g,"").replace(/\)/g,"").replace(/\[/g,"").replace(/\]/g,"").replace(/\}/g,"").replace(/\//g,""); _alertValMsg(comp,"不能输入单引号双引号<>{}()[]/"); } } /** * MC版本:v1.0.13 * *单双 引号 转义*/ this.escapeHTML=function (str) { if(str!=null&&str.length>0) { return str.replace(/"/g, """).replace(/'/g, "'"); }else { return str; } } /** * MC版本:v1.0.12 (初始) * * 带图标的弹出确认窗口,入参:(弹窗类型(1:警告;2:成功;3:失败;4:疑问;5:锁定),提示窗标题,回调函数,回调函数参数,要显示的字符串,是否显示取消按钮,为1时显示) ,宽度,高度,页面组件对象,是否回设焦点并选中内容传1为是*/ this.confirmIcon = function(type,title,callBackFun,callBackFunPara, msg,showCancel,widthPara,heightPara,thisObj,isFocus,callBackClFun,clFunPara){ this.mcConfirmIcon({type:type,title:title, msg:msg, showCancel:showCancel,thisObj:thisObj, isFocus:0, callBackFun:callBackFun, callBackFunPara:callBackFunPara,callBackClFun:callBackClFun,clFunPara:clFunPara }); return; //所有进入的方法都调用新方法 tangws 20181130 //var title = "";//"%{getText('摩尔提示')}"; if (null == title || "" == title) { title = _GLO_CONFIRM_ICON_TITLE; } UtilsDivFor++;//cjd 2017-12-11 16:14 var divId = "confirmIconId0"+UtilsDivFor; var msgLength = msg.length; var tempPopupDivId = divId+"pop"; var shadowPopupDivId = divId+"shadow"; var temp = top.document; var height = 155; var width = 360; if(widthPara != null && widthPara != "" && widthPara != undefined){ width = setWidthAndHeight(msgLength,parseInt(widthPara)); } if(heightPara != null && heightPara != "" && heightPara != undefined){ height = setWidthAndHeight(msgLength,parseInt(heightPara)); } if(height>$(temp).height()){ height=$(temp).height(); } if(width>$(temp).width()){ width=$(temp).width(); } var iTop=($(temp).height()-height)/2-20; var iLeft=($(temp).width()-width)/2; var marginLeft = 5; //两个按钮 if(showCancel == 1 || showCancel == "1"){ if(width > 210){ marginLeft = (width - 210)/2; } }else{ if(width > 93){ marginLeft = (width - 93)/2; } } var iconType = " ico-warning"; if(type == "2" || type == 2){ iconType = " ico-success"; }else if(type == "3" || type == 3){ iconType = " ico-error"; }else if(type == "4" || type == 4){ iconType = " ico-question"; }else if(type == "5" || type == 5){ iconType = " ico-lock"; } //alert("screenWidth"+window.screen.availWidth+"screenHeight"+window.screen.availHeight+"docWidth:"+$(temp).width()+"docHeight:"+$(temp).height()+"iTop"+iTop // +"iLeft:"+iLeft+"height:"+height+"width:"+width); var divStr = "
" +"
" +"

"+title+"

" +"
" +" " +"
" +" " +"
"+_GLO_CONFIRM_ICON_NOTICE+":" + msg +"
" +"
" +" "; if(showCancel == 1 || showCancel == "1"){ //cjd 2017-12-11 16:26 divStr +=" "; } divStr +="
" +"
" +"
"; //+"
"; //if($(".dialog-mask").length == 0){ divStr += "
"; top.zcount++; //} var tmpDiv = temp.createElement("div"); tmpDiv.innerHTML = divStr; var body = temp.getElementsByTagName("body")[0]; body.appendChild(tmpDiv); top.$("#"+shadowPopupDivId).show(); top.$("#"+tempPopupDivId).draggable(); var confirmId0 = topDocument.getElementById(tempPopupDivId); /*var confirmOkBtn0 = topDocument.getElementById("confirmIcoOkBtn0"); //var maskId0 = topDocument.getElementById(".dialog-mask"); confirmOkBtn0.focus(); confirmOkBtn0.onclick = function () { closePopIcoFp(""+tempPopupDivId+""); if(callBackFun != null && callBackFun != "" && callBackFun != undefined){ window[callBackFun](callBackFunPara); } };*/ top.$(".confirmIcoOkBtn").each(function(i,e){ this.focus(); this.onclick = function() { closePopIcoFp(tempPopupDivId,thisObj,isFocus); if(callBackFun != null && callBackFun != "" && callBackFun != undefined){ window[callBackFun](callBackFunPara); } } }); top.$("#confirmIcoCancelBtn0").click(function(){ closePopIcoFp(tempPopupDivId,thisObj,isFocus); }) top.$("#closeTop").click(function(){ closePopIcoFp(tempPopupDivId,thisObj,isFocus); }) //cjd 2017-12-11 16:26 begin // top.$("#confirmIcoCancelBtn0").click(function () { // closePopIcoFp(""+tempPopupDivId+""); // }); //cjd 2017-12-11 16:26 end $("#"+tempPopupDivId+"").keyup(function (event) { // 获取键值 var keyEvent = event || window.event; var key = keyEvent.keyCode; //获得当前对象 var input_blur = $(this); switch (key) { case 27://按下esc键,取消 closePopIcoFp(""+tempPopupDivId+""); break; } }); } /** * MC版本:v2.1.0 * * 带图标的弹出确认窗口改造 * by tangws 20181120 * @argument type - 1:警告;2:成功;3:失败;4:疑问;5:锁定 * @argument title - 提示窗标题 * @argument msg - 显示的提示内容 * @argument showCancel - 是否显示取消按钮 1: 表显示/ 0或者任意值不显示(默认值) * @argument isFocus - 是否显示回显焦点 1: 表要回显/ 0或者任意值不显示(默认值) * @argument thisObj - 回显示聚焦的目标对象 null(默认值) 注意和isFocus参数配合使用。 * @argument callBackFun - 点击确定执行的回调函数名称 * @argument callBackFunPara - 回调函数参数 * {type:1/2/3/4/5,title:"", msg:"",showCancel:1/...,thisObj:null, isFocus:0/1, callBackFun:null, callBackFunPara:null } */ this._mcConfirmIcon = function(obj){ var originStr = ""; //用于保存弹窗obj.msg去左右两边空格后的字符串。 if (null == obj.title || "" == obj.title) { //平台客户定制化功能 //obj.title = _GLO_CONFIRM_ICON_TITLE; if(obj.showCancel == 1 || obj.showCancel == "1"){ obj.title = _GLO_CONFIRM_ICON_TITLE_CONFIRM; }else{ obj.title = _GLO_CONFIRM_ICON_TITLE_TIP; } if(obj.title ==null || obj.title ==''){ obj.title =_GLO_CONFIRM_ICON_TITLE; } } //UtilsDivFor++;//cjd 2017-12-11 16:14 UtilsDivFor+=top.zcount; var divId = "confirmIconId0"+UtilsDivFor; //var msgLength = obj.msg.length; var tempPopupDivId = divId+"pop"; var shadowPopupDivId = divId+"shadow"; var temp = top.document; /** * 暂不支持宽高自定义,默认宽度是300px,高度是200px,用户点击详情以后,宽度变为600px,高度变为400px; * */ obj.height = 200; obj.width = 300; /* if(widthPara != null && widthPara != "" && widthPara != undefined){ width = 300; } if(heightPara != null && heightPara != "" && heightPara != undefined){ height = setWidthAndHeight(msgLength,parseInt(heightPara)); if(parseInt(height) < 200) { height = 200; } } */ if(obj.height>$(temp).height()){ obj.height=$(temp).height(); } if(obj.width>$(temp).width()){ obj.width=$(temp).width(); } var iTop=($(temp).height()-obj.height)/2-20; var iLeft=($(temp).width()-obj.width)/2; var marginLeft = 5; //两个按钮 /* if(obj.showCancel == 1 || obj.showCancel == "1"){ if(obj.width > 210){ marginLeft = (obj.width - 210)/2; } }else{ if(obj.width > 93){ marginLeft = (obj.width - 93)/2; } } */ var iconType = " ico-warning"; if(obj.type == "2" || obj.type == 2){ iconType = " ico-success"; }else if(obj.type == "3" || obj.type == 3){ iconType = " ico-error"; }else if(obj.type == "4" || obj.type == 4){ iconType = " ico-question"; }else if(obj.type == "5" || obj.type == 5){ iconType = " ico-lock"; } var divStr = "
" +"
" +"

"+obj.title+"

" +"
" +" " +"
" +" " +"
"+_GLO_CONFIRM_ICON_NOTICE+":" + obj.msg +"
" +"
" +" 详情" +"
" +" "; if(obj.showCancel == 1 || obj.showCancel == "1"){ //cjd 2017-12-11 16:26 divStr +=""; } divStr +="
" //+"
" +""; //+"
"; //if($(".dialog-mask").length == 0){ divStr += "
"; top.zcount++; //top.zcount+=1000; //by tangws //} var tmpDiv = temp.createElement("div"); tmpDiv.innerHTML = divStr; var body = temp.getElementsByTagName("body")[0]; body.appendChild(tmpDiv); //插入以后判断 var spanHeight = top.$(".mc-dialog .dialog-txt").height(); if(spanHeight > 40) { originStr =top.$(".mc-dialog .dialog-txt").text(); var result = this.returnStr(originStr,22); top.$(".mc-dialog .dialog-txt").html(result+"..."); top.$(".dialog-more").show(); } //显示提示窗 top.$("#"+shadowPopupDivId).show(); top.$("#"+tempPopupDivId).draggable({ cancel: "div.dialog-content" }); var confirmId0 = topDocument.getElementById(tempPopupDivId); top.$(".confirmIcoOkBtn").each(function(i,e){ this.focus(); this.onclick = function() { closePopIcoFp(tempPopupDivId,obj.thisObj,obj.isFocus); if(obj.callBackFun != null && obj.callBackFun != "" && obj.callBackFun != undefined){ window[obj.callBackFun](obj.callBackFunPara); } } }); top.$("#confirmIcoCancelBtn0").click(function(){ closePopIcoFp(tempPopupDivId,obj.thisObj,obj.isFocus); }) /*top.$("#closeTop").click(function(){ closePopIcoFp(tempPopupDivId,obj.thisObj,obj.isFocus); })*/ top.$("#"+tempPopupDivId).find(".dialog-close").each(function(){ $(this).on("click",function(){ closePopIcoFp(tempPopupDivId,obj.thisObj,obj.isFocus); }) }) top.$("#"+tempPopupDivId).keyup(function (event) { // 获取键值 var keyEvent = event || window.event; var key = keyEvent.keyCode; //获得当前对象 var input_blur = $(this); switch (key) { case 27://按下esc键,取消 closePopIcoFp(""+tempPopupDivId+""); break; } }); //详情绑定click top.$(".dialog-more").one("click",function(){ top.$(".mc-dialog").css({"width":"600px","height":"400px"}); top.$(".dialog-content").css("max-width","380px"); top.$(".ico-confirm").css("vertical-align","top"); top.$(".dialog .dialog-txt").html(originStr); //mc-dialog var _top = parseInt(top.$(".mc-dialog").css("top")); var _left = parseInt(top.$(".mc-dialog").css("left")); top.$(".mc-dialog").css("top",_top-100+"px" ); top.$(".mc-dialog").css("left",_left-150+"px" ); //隐藏详情 $(this).hide(); }) //滚动条 top.$(".mc-dialog .dialog-content").mCustomScrollbar({ axis:"y", snapAmount:80, theme:"minimal-dark", autoExpandScrollbar:true,//鼠标移到滚动条的位置,滚动条的宽度变为原来的2倍 } ); // top.$(".dialog-txt").on("click",function(){ top.$("#"+tempPopupDivId) }) } /** * MC版本:v3.1.0 * * 新弹窗下的优化 和 function _mcConfirmIcon 方法一样功能 by tangws */ this.mcConfirmIcon = function(obj){ var originStr = ""; //用于保存弹窗obj.msg去左右两边空格后的字符串。 if (null == obj.title || "" == obj.title) { //平台客户定制化功能 //obj.title = _GLO_CONFIRM_ICON_TITLE; if(obj.showCancel == 1 || obj.showCancel == "1"){ obj.title = _GLO_CONFIRM_ICON_TITLE_CONFIRM; }else{ obj.title = _GLO_CONFIRM_ICON_TITLE_TIP; } if(obj.title ==null || obj.title ==''){ obj.title =_GLO_CONFIRM_ICON_TITLE; } } var divId = "confirmIconId0"+UtilsDivFor; //var msgLength = obj.msg.length; var tempPopupDivId = divId+"pop"; var shadowPopupDivId = divId+"shadow"; var temp = top.document; /** * 暂不支持宽高自定义,默认宽度是300px,高度是200px,用户点击详情以后,宽度变为600px,高度变为400px; * */ obj.height = 200; obj.width = 300; /* if(widthPara != null && widthPara != "" && widthPara != undefined){ width = 300; } if(heightPara != null && heightPara != "" && heightPara != undefined){ height = setWidthAndHeight(msgLength,parseInt(heightPara)); if(parseInt(height) < 200) { height = 200; } } */ if(obj.height>$(temp).height()){ obj.height=$(temp).height(); } if(obj.width>$(temp).width()){ obj.width=$(temp).width(); } var iTop=($(temp).height()-obj.height)/2-20; var iLeft=($(temp).width()-obj.width)/2; var marginLeft = 5; //两个按钮 /* if(obj.showCancel == 1 || obj.showCancel == "1"){ if(obj.width > 210){ marginLeft = (obj.width - 210)/2; } }else{ if(obj.width > 93){ marginLeft = (obj.width - 93)/2; } } */ var iconType = " ico-warning"; if(obj.type == "2" || obj.type == 2){ iconType = " ico-success"; }else if(obj.type == "3" || obj.type == 3){ iconType = " ico-error"; }else if(obj.type == "4" || obj.type == 4){ iconType = " ico-question"; }else if(obj.type == "5" || obj.type == 5){ iconType = " ico-lock"; } var divStr = ""; divStr += "
"; divStr += "
" +"
" +"

"+obj.title+"

" +"
" +" " +"
" +" " +"
"+_GLO_CONFIRM_ICON_NOTICE+":" + obj.msg +"
" +"
" +" 详情" +"
" +" "; if(obj.showCancel == 1 || obj.showCancel == "1"){ //cjd 2017-12-11 16:26 divStr +=""; } divStr +="
" +"
"; var tmpDiv = temp.createElement("div"); tmpDiv.innerHTML = divStr; var body = temp.getElementsByTagName("body")[0]; body.appendChild(tmpDiv); //插入以后判断 var spanHeight = top.$(".mc-dialog .dialog-txt").height(); if(spanHeight > 40) { originStr =top.$(".mc-dialog .dialog-txt").text(); var result = this.returnStr(originStr,22); top.$(".mc-dialog .dialog-txt").html(result+"..."); top.$(".dialog-more").show(); } //显示提示窗 top.$("#"+shadowPopupDivId).show(); top.$("#"+tempPopupDivId).draggable({ cancel: "div.dialog-content" }); var confirmId0 = topDocument.getElementById(tempPopupDivId); top.$(".confirmIcoOkBtn").each(function(i,e){ this.focus(); this.onclick = function() { closePopIcoFp(tempPopupDivId,obj.thisObj,obj.isFocus); if(obj.callBackFun != null && obj.callBackFun != "" && obj.callBackFun != undefined){ window[obj.callBackFun](obj.callBackFunPara); } } }); top.$("#confirmIcoCancelBtn0").click(function(){ closePopIcoFp(tempPopupDivId,obj.thisObj,obj.isFocus); if(obj.callBackClFun != null && obj.callBackClFun != "" && obj.callBackClFun != undefined){ window[obj.callBackClFun](obj.clFunPara); } }) /*top.$("#closeTop").click(function(){ closePopIcoFp(tempPopupDivId,obj.thisObj,obj.isFocus); })*/ top.$("#"+tempPopupDivId).find(".dialog-close").each(function(){ $(this).on("click",function(){ closePopIcoFp(tempPopupDivId,obj.thisObj,obj.isFocus); }) }) top.$("#"+tempPopupDivId).keyup(function (event) { // 获取键值 var keyEvent = event || window.event; var key = keyEvent.keyCode; //获得当前对象 var input_blur = $(this); switch (key) { case 27://按下esc键,取消 closePopIcoFp(""+tempPopupDivId+""); break; } }); //详情绑定click top.$(".dialog-more").one("click",function(){ top.$(".mc-dialog").css({"width":"600px","height":"400px"}); top.$(".dialog-content").css("max-width","380px"); top.$(".ico-confirm").css("vertical-align","top"); top.$(".dialog .dialog-txt").html(originStr); //mc-dialog var _top = parseInt(top.$(".mc-dialog").css("top")); var _left = parseInt(top.$(".mc-dialog").css("left")); top.$(".mc-dialog").css("top",_top-100+"px" ); top.$(".mc-dialog").css("left",_left-150+"px" ); //隐藏详情 $(this).hide(); }) //滚动条 top.$(".mc-dialog .dialog-content").mCustomScrollbar({ axis:"y", snapAmount:80, theme:"minimal-dark", autoExpandScrollbar:true,//鼠标移到滚动条的位置,滚动条的宽度变为原来的2倍 } ); // top.$(".dialog-txt").on("click",function(){ top.$("#"+tempPopupDivId) }) } /** * MC版本:v1.0.12 (初始) * * 弹出提示信息,入参:要显示的字符串 */ this.alert = function (msg,backFun,paramObj) { if (null == msg || "" == msg) { msg = "\u63D0\u793A\u4FE1\u606F info ";//提示信息 } var divStr = "
\n" +"\n" +"\n" +"
\n" +"
"+msg+"
\n" +"
" +""//确定 +"
" +"
" +"
"; //+"
"; if($(".dialog-mask").length == 0){ divStr += "
"; } var tmpDiv = topDocument.createElement("div"); tmpDiv.innerHTML = divStr; var body = topDocument.getElementsByTagName("body")[0]; body.appendChild(tmpDiv); top.$(".dialog-mask#shadow0").show(); top.$("#alertId0").draggable(); var alertId0 = topDocument.getElementById("alertId0"); var alertOkBtn0 = topDocument.getElementById("alertOkBtn0"); //var alertMaskId0 = topDocument.getElementById("alertMaskId0"); alertOkBtn0.focus();//默认选中确定按钮 alertOkBtn0.onclick = function () { //confirmId0.style.display = "none"; //maskId0.style.display = "none"; if(null!=backFun && backFun != ""){ backFun(paramObj); } $(alertId0).remove(); top.$(".dialog-mask#shadow0").hide(); top.$(".dialog-mask#shadow0").remove(); //top.$(".dialog-close").click(); //$(alertMaskId0).remove(); }; $("#alertOkBtn0").keyup(function (event) { // 获取键值 var keyEvent = event || window.event; var key = keyEvent.keyCode; //获得当前对象 var input_blur = $(this); switch (key) { case 27://按下esc键,取消 $(alertId0).remove(); top.$(".dialog-mask#shadow0").hide(); top.$(".dialog-mask#shadow0").remove(); //top.$(".dialog-close").click(); if(null!=backFun){ backFun(paramObj); } break; } }); }; /** * MC版本:v1.0.12 (初始) * * 列表过长字段弹窗显示更多 */ this.popRemark = function(callBackFun, msg,paramObj,title){ var temp = top.document; var width = 400; var height = 200; var iTop=($(temp).height()-height)/6; var iLeft=($(temp).width()-width)/2; var divStr = "
" +"
"; if(title != null && title != "" && title != undefined){ divStr += "

"+title+"

"; } divStr +="
" +" " +"
" //+ msg +"
" +"\n" +"
" +"
" +"
"; divStr += "
"; var tmpDiv = topDocument.createElement("div"); tmpDiv.innerHTML = divStr; var body = topDocument.getElementsByTagName("body")[0]; body.appendChild(tmpDiv); top.$(".dialog-mask#shadowConfirmId0").show(); top.$("#confirmId0").draggable(); }; /** * MC版本:v1.0.12 (初始) * * 替换所有的回车换行 */ this.transferString = function (content) { var string = content; try{ if(string != "" && string != null){ string = string.replace(/\r\n/g,"
") string = string.replace(/\n/g,"
"); } }catch(e){ //alert(e.message); } return string; } /** * MC版本:v2.1.0 * * 获取当前组织权限 */ this.getCurrentAuth = function(){ var _getAuth = _currentAuth;//此变量定义在两个pub_head页面中 return _getAuth; } /** * MC版本:v2.1.0 * * 字符串过滤掉前后空格 by tangws */ this.trimSpace = function (str){ return (str||"").replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g,""); } /** * MC版本:v2.1.0 * * 字符串截取 by tangws */ this.returnStr = function (str,len){ var num = 0; var patt = /[\u4e00-\u9fa5]/i; var s = this.trimSpace(str); originStr = s; //去空格后的原始值并且保存一份到全局 for(var i=0; i len){ return str.substr(0,i); } } } /** * MC版本:v2.2.0 * * 调试按钮处理 * create by hzp 2019.4.9 * param:className(类全名称) * param:codeId(类Id) * param:tableName(关联表id) * param:tableName(关联表id) */ this.debugPageDetail=function(classNameValue,codeId,codeType){ localStorage.codeType=codeType; var classNameclassLength=classNameValue.lastIndexOf(".");//获取类全名长度 var packageName=classNameValue.substring(0,classNameclassLength);//包名称 var className=classNameValue.substring(classNameclassLength+1,classNameValue.length);//类名 localStorage.packageName=packageName;//包名存储本地 localStorage.className=className;//类名存储本地 localStorage.currentClassName=classNameValue;//类全面存储 localStorage.codeId=codeId;//获取codeId $.ajax({ type : "POST", dataType : "text", async:false, url : "sys/pageDebugAction_checkOpen.ms", data:{ "paraMap.codeType":codeType, "paraMap.callClassName":classNameValue }, success : function(data) { data=JSON.parse(data); if(data.ajaxMap!=null&&data.ajaxMap.result=="true"){ window.open("sys/pageDebugAction_pageDebug.ms"); }else{ if(data.ajaxMap.message=="otherOpen"){ utilsFp.alert("其他用户调试中"); }else{ utilsFp.alert("断点界面已打开,请切换断点界面"); } } }, error : function(msg) { alert(); } }); } /** * MC版本:v2.2.0 * * iframe控制弹窗的帮助信息是否显示 * params: {ifShow: true/false, url:"xxx"} */ this.setHelp = function(obj){ //获取弹窗的id var iframeId = window.frameElement.id; var popId = iframeId+'pop'; var helpDom; if(obj.ifShow && popId){ helpDom = top.$("#"+popId).find(".dialog-help")[0]; $(helpDom).css("display","block"); } //给帮助设置方法 if(obj.url){ $(helpDom).on('click',function(){ window.open(obj.url); }) } } /** * MC版本:v3.0.1 * * 消息功能 */ this.showHelpMsgMc = function(obj){ var scrollTop = $(document).scrollTop(); //top var _top = $(obj._this).offset().top-scrollTop; //left var _left = $(obj._this).offset().left; //bottom //var _bottom = $(obj._this).parents("body").height() - _top - 15; //15修正bottom的值 var _bottom = $(window).height() - _top - 15; //15修正bottom的值 //right var _right = $(obj._this).parents("body").width() - _left; //position var positionObj = { left: _left, right: _right, top: _top, bottom: _bottom, scrollTop: scrollTop } //console.log("_left"+_left,"_right"+_right,"_top"+_top,"_bottom"+_bottom); //console.log(utilsFp.getContextPath()); //请求数据 $.ajax({ url:utilsFp.getContextPath() +'/sys/BussModelAction_ajaxuihelpinfo.ms', data: {UI_COMP:obj.id}, dataType:'json', success: function(data){ if(data.ajaxMap){ if(data.ajaxMap.status == '00'){ //判断该对象中是否有该属性 if(helpMsgObj.hasOwnProperty(obj.id)){ if( $('div').hasClass('helpMsg') ){ utilsFp.removeHelpMsgDom(); } utilsFp.showHelpMsgDom(helpMsgObj[obj.id],positionObj,obj._this); } else { //消息存储进helpMsgObj helpMsgObj[obj.id] = data.ajaxMap['help_info']; if( $('div').hasClass('helpMsg') ){ utilsFp.removeHelpMsgDom(); } utilsFp.showHelpMsgDom(data.ajaxMap['help_info'],positionObj,obj._this); } } if(data.ajaxMap.status == '03' || data.ajaxMap.status == '04' || data.ajaxMap.status == '05') { //消息有误 utilsFp.confirmIcon(1,"","","","未配置帮助信息",0,"300",""); } } else { //消息有误 utilsFp.confirmIcon(1,"","","", "请求消息失败",0,"300",""); } }, error: function(){ //消息有误 utilsFp.confirmIcon(1,"","","", "请求消息失败",0,"300",""); } }); } /** * MC版本:v3.0.1 * * 消息功能 N2扩展页面手动配置帮助 调用解析 */ this.showHelpMsg = function(obj){ var scrollTop = $(document).scrollTop(); //top var _top = $(obj._this).offset().top-scrollTop; //left var _left = $(obj._this).offset().left; //bottom //var _bottom = $(obj._this).parents("body").height() - _top - 15; //15修正bottom的值 var _bottom = $(window).height() - _top - 15; //15修正bottom的值 //right var _right = $(obj._this).parents("body").width() - _left; //position var positionObj = { left: _left, right: _right, top: _top, bottom: _bottom, scrollTop: scrollTop } //console.log("_left"+_left,"_right"+_right,"_top"+_top,"_bottom"+_bottom); //请求数据 $.ajax({ url:utilsFp.getContextPath() +'/sys/BussModelAction_ajaxuihelpinfo.ms', data: {UI_COMP_TYPE:obj.ui_comp_type,FORM_COL_ID:obj.form_col_id}, dataType:'json', success: function(data){ if(data.ajaxMap){ if(data.ajaxMap.status == '00'){ //判断该对象中是否有该属性 if(helpMsgObj.hasOwnProperty(obj.form_col_id)){ if( $('div').hasClass('helpMsg') ){ utilsFp.removeHelpMsgDom(); } utilsFp.showHelpMsgDom(helpMsgObj[obj.form_col_id],positionObj,obj._this); } else { //消息存储进helpMsgObj helpMsgObj[obj.form_col_id] = data.ajaxMap['help_info']; if( $('div').hasClass('helpMsg') ){ utilsFp.removeHelpMsgDom(); } utilsFp.showHelpMsgDom(data.ajaxMap['help_info'],positionObj,obj._this); } } if(data.ajaxMap.status == '03' || data.ajaxMap.status == '04' || data.ajaxMap.status == '05') { //消息有误 utilsFp.confirmIcon(1,"","","","未配置帮助信息",0,"300",""); } } else { //消息有误 utilsFp.confirmIcon(1,"","","", "请求消息失败",0,"300",""); } }, error: function(){ //消息有误 utilsFp.confirmIcon(1,"","","", "请求消息失败",0,"300",""); } }); } /** * MC版本:v3.0.1 * 显示帮助消息 * */ this.showHelpMsgDom = function(msg,pos,obj){ //console.log(pos); $("body").append("
"+msg+"
"); var msgHeight = $(".helpMsg").innerHeight(); //判断是否显示在上方 10是边距要留10px if(msgHeight < pos.bottom-10){ //显示在下面 if( pos.left < 135 ){ $(".helpMsg").css("left","5px").css("top",pos.top+pos.scrollTop+20+"px"); $(".helpArrow").css("left",pos.left-5+"px").css("top","-6px"); } else{ if( pos.right > (272 - 20) ){ //消息还是正常向右边显示 $(".helpMsg").css("left",pos.left-20+"px").css("top",pos.top+pos.scrollTop+20+"px"); $(".helpArrow").css("left","20px").css("top","-6px"); } else { //消息要往左边显示 $(".helpMsg").css("right","5px").css("top",pos.top+pos.scrollTop+20+"px"); $(".helpArrow").css("right",pos.right-5-12+"px").css("top","-6px"); } } } else if( msgHeight < pos.top-10 ){ //显示在上面 if( pos.left < 135 ){ $(".helpMsg").css("left","5px").css("bottom",pos.bottom-pos.scrollTop+20+"px"); //debugger $(".helpArrow").css("transform","rotateZ(180deg)").css("top",msgHeight+"px").css("left",pos.left-5+"px"); } else { if( pos.right > (272 - 20) ){ $(".helpMsg").css("left",pos.left-20+"px").css("bottom",pos.bottom-pos.scrollTop+20+"px"); $(".helpArrow").css("transform","rotateZ(180deg)").css("top",msgHeight+"px").css("left","20px"); } else { $(".helpMsg").css("right","5px").css("bottom",pos.bottom-pos.scrollTop+20+"px"); $(".helpArrow").css("transform","rotateZ(180deg)").css("top",msgHeight+"px").css("right",pos.right-5-12+"px"); } } } else { //出现滚动条 if( pos.top < pos.bottom ){ //显示在下面 if( pos.left < 135 ){ $(".helpMsg").css("left","5px").css("top",pos.top+pos.scrollTop+20+"px"); $(".helpMsg").css("height",$(window).height()-pos.top-25+'px'); $(".helpMsg .helpMsgCon").css("overflow-y","auto"); $(".helpArrow").css("left",pos.left-5+"px").css("top","-6px"); } else { if( pos.right > (272 - 20) ){ $(".helpMsg").css("left",pos.left-20+"px").css("top",pos.top+pos.scrollTop+20+"px"); $(".helpMsg").css("height",$(window).height()-pos.top-25+'px'); $(".helpMsg .helpMsgCon").css("overflow-y","auto"); //$(".helpArrow").css("left",pos.left-10+"px").css("top","-6px"); $(".helpArrow").css("left","20px").css("top","-6px"); } else { $(".helpMsg").css("right","5px").css("top",pos.top+pos.scrollTop+20+"px"); $(".helpMsg").css("height",$(window).height()-pos.top-25+'px'); $(".helpMsg .helpMsgCon").css("overflow-y","auto"); //$(".helpArrow").css("left",pos.left-10+"px").css("top","-6px"); $(".helpArrow").css("right",pos.right-5-12+"px").css("top","-6px"); } } } else { //显示在上面 if( pos.left < 135 ){ $(".helpMsg").css("left","5px").css("bottom",pos.bottom-pos.scrollTop+20+"px").css("height",pos.top-10+"px"); $(".helpMsg .helpMsgCon").css("overflow-y","auto"); $(".helpArrow").css("transform","rotateZ(180deg)").css("top",pos.top-10+"px").css("left",pos.left-5+"px"); } else { if( pos.right > (272 - 20) ){ $(".helpMsg").css("left",pos.left-20+"px").css("bottom",pos.bottom-pos.scrollTop+20+"px").css("height",pos.top-10+"px");; $(".helpMsg .helpMsgCon").css("overflow-y","auto"); $(".helpArrow").css("transform","rotateZ(180deg)").css("top",pos.top-10+"px").css("left","20px"); } else { $(".helpMsg").css("right","5px").css("bottom",pos.bottom-pos.scrollTop+20+"px").css("height",pos.top-10+"px");; $(".helpMsg .helpMsgCon").css("overflow-y","auto"); $(".helpArrow").css("transform","rotateZ(180deg)").css("top",pos.top-10+"px").css("right",pos.right-5-12+"px"); } } } } $(obj).addClass("active"); //去除冒泡 $(".helpMsg").on("mousedown",function(){ return false; }) //绑定body $("body").on("mousedown",function(){ utilsFp.removeHelpMsgDom(); }) //解决如果有表格的情况下拖动表格里的滚动条让帮助提示信息消失 try{ if($(obj).parents(".datagrid-header-inner").length > 0){ $(obj).parents(".datagrid-header-inner").on("scroll",function(){ utilsFp.removeHelpMsgDom(); }) } } catch(err){ console.log(err); } } /** * MC版本:v3.0.1 * * 移除提示窗 */ this.removeHelpMsgDom = function (){ $(".helpMsg").remove(); $(".msgQes").removeClass("active"); } /** * MC版本:v3.0.1 * MC版本:v3.1.0 (修改) * * 选中行数量 */ this.getCheckedCount = function(formId){ var selCount = 0; $("#tbody_"+formId).find("tr").each(function(seq) { if($(this).find(":checkbox._selectdata").prop("checked")){ selCount++; } }); return selCount; } /** * MC版本:v3.0.1 * MC版本:v3.1.0 (修改) * * 选中行记录集 */ this.getCheckedTrs = function(formId){ var _selectedEditTrs=[]; var index=0; $("#tbody_"+formId).find("tr").each(function(seq) { if($(this).find(":checkbox._selectdata").prop("checked")){ _selectedEditTrs[index++] = $(this); } }); return _selectedEditTrs; } /** * MC版本:v3.0.1 * * 加一个页面上所有控件加载完成的回调事件(2.2) */ this.addKjPromiseListener = function(obj,callBackFun){ //控件异步加载监听 var type=obj.type;//all:监听所有控件异步加载完成 other:监听kj_name所指定控件的异步加载完成 var kj_names=obj.kj_name.toUpperCase(); //console.log('type->'+type); if(type=='all'){ //all 监听所有控件异步加载完成 //获取当前页面所有的控件名称 $('.kj_name_class').each(function(){ var kj_name_value=$(this).attr('kj_name_value'); if(kj_names==''){ kj_names=kj_name_value; }else{ kj_names=kj_names+","+kj_name_value; } }) kj_names=kj_names.toUpperCase(); } if(type=='other'){ //other 监听kj_name所指定控件的异步加载完成 } //console.log('kj_names->'+kj_names); //console.log(_GLO_SELECT_PROMISE);//mc已经完成了所有下拉框控件异步加载的监听注入 并且存放在该变量 if(kj_names!=null && kj_names!=''){ var select_promise_arr= kj_names.split(","); for(var i=0;i'+select_promise); if(select_promise!=null){ select_promise_arr[i]=select_promise; }else{ //console.log('error-01:找不到控件名称是'+kj_name+'的监听...'); return "error-01";//obj.kj_name找不到该控件 } } } if(select_promise_arr!=null && select_promise_arr.length>0){ //Promise.all([select_promise]).then(function(resolve, reject){//通过控件字段名称数组方式注入要监听的控件 Promise.all(select_promise_arr).then(function(resolve, reject){//通过控件字段名称数组方式注入要监听的控件 //console.log('在这里下拉框控件'+kj_names+'已经完成了异步加载...'); // console.log('resolve->'+resolve); callBackFun();//执行监听控件异步加载完成以后的函数 //console.log('成功执行了监听控件异步加载完成以后的函数...'); }) } } /** * MC版本:v3.1.0 * * 动态设置列表固定列(已有固定列的表格才能使用该功能,没有固定列的表格使用无效) * fixedColList:冻结的列信息,对象格式为{name:字段名称,sort:排序} * formId:页面表单id */ this.mcSetFixedCol = function(fixedColList,formId){ var listType='ajax'; if($('#datagrid-htable'+formId).length>0){ listType='ajax'; }else if($('#datagrid-htable-kz').length>0){ listType='kz'; }else if($('#datagrid-htable').length>0){ listType='syn'; } if(!$("#left-datagrid-view"+(listType=='ajax'?'-ajax'+formId:(listType=='kz'?'-kz':''))) || $("#left-datagrid-view"+(listType=='ajax'?'-ajax'+formId:(listType=='kz'?'-kz':''))).length==0){ return; } var matchReg =/.*width\s*:\s*(\d*\.?\d*)px/; var widthDisplay =/.*display\s*:\s*(\d+)e/; var allTdWidth = 0; var colNum = 0; var tdNoWidthNum = 0; var tdNoWidth = false; for(var i=0;itd'); var tbody = $("#datagrid-btable"+(listType=='ajax'?'-ajax'+formId:(listType=='kz'?'-kz':''))).find('tr'); var leftThead = $("#left-datagrid-htable"+(listType=='ajax'?formId:(listType=='kz'?'-kz':''))).find('tr.datagrid-header-row>td'); var leftTbody = $("#left-datagrid-btable"+(listType=='ajax'?'-ajax'+formId:(listType=='kz'?'-kz':''))).find('tr'); var td = getElementByName('noprintset_'+fixedColList[i].name,thead); if(td){ var styleTd = $(td).attr("style"); if(styleTd && styleTd.indexOf("display")>-1&&styleTd.match(widthDisplay)!=null&&(styleTd.match(widthDisplay)[1])=="non"){ break; } if(styleTd && styleTd.indexOf("width")>-1){ allTdWidth+=parseFloat(styleTd.match(matchReg)[1]); colNum++; } if(typeof(styleTd) == "undefined" || styleTd.indexOf("width")<0){ tdNoWidth = true; } var index = fixedColList[i].sort; if(index<0){ index = 0; } var index = index+2; if(index>leftThead.length-1){ leftThead[leftThead.length-1].after(td); }else{ leftThead[index].before(td); } for(var j=0;jleftThead.length-1){ $($(leftTbody[j]).find('td')[leftThead.length-1]).after(td); }else{ $($(leftTbody[j]).find('td')[index]).before(td); } } } } } //左侧表格宽度更新 var leftTableWidth = $('#leftTable'+(listType=='ajax'?'-ajax'+formId:(listType=='kz'?'-kz':''))).width()+allTdWidth; $('#leftTable'+(listType=='ajax'?'-ajax'+formId:(listType=='kz'?'-kz':''))).width(leftTableWidth); //右侧表格宽度更新 $('#contentTable'+(listType=='ajax'?formId:(listType=='kz'?'-kz':''))).css('width','calc(100% - '+(leftTableWidth+2)+'px)'); var leftHeaderWidth = $("#left-datagrid-htable"+(listType=='ajax'?formId:(listType=='kz'?'-kz':''))).length>0?$("#left-datagrid-htable"+(listType=='ajax'?formId:(listType=='kz'?'-kz':''))).width():0; $(".dlist .datagrid-header").not(".left-datagrid-header-ajax,.left-datagrid-header,.left-datagrid-header-kz").width($(window).width() - 4 -leftHeaderWidth); $(".dlist .datagrid-body").not(".left-datagrid-body-ajax,.left-datagrid-body,.left-datagrid-body-kz").width($(window).width() - 4 -leftHeaderWidth); //滚动条更新 var mc=$('#contentTable'+(listType=='ajax'?formId:(listType=='kz'?'-kz':''))).find('.mCSB_container'); if(allTdWidth<0){ mc.width(mc.children().outerWidth()+(allTdWidth)); }else{ mc.width(mc.width()-allTdWidth-4); } $('#contentTable'+(listType=='ajax'?formId:(listType=='kz'?'-kz':''))).find('mCustomScrollbar').mCustomScrollbar('update'); //对表头拖拉改变列宽重新监听 if(listType=='ajax'){ _addDragTableEvent(formId,'ajax'); }else if(listType=='kz'){ _addDragTableEvent(formId,'kz'); }else if(listType=='syn'){ _addDragTableEvent(formId,'syn'); } //通过字段名称获取对应td元素 function getElementByName(name,list){ if(name == undefined || name == null){ return null; } for(var i=0;i" // ; var lay1 = "
" + iframeLay + "
"; var divHtml = "
" + "" + ""; var tmpDiv = document.createElement("div"); tmpDiv.innerHTML = lay1 + divHtml; body.appendChild(tmpDiv); } else { document.getElementById("_loading_div").style.display = ""; document.getElementById("_loading_img").src = imgUrl; } var divObj = document.getElementById("_loading_div"); var divLayObj = document.getElementById("_loading_lay_div"); divObj.style.display = ""; divLayObj.style.display = ""; var iWidth = divObj.offsetWidth; // 弹出窗口的宽度; var iHeight = divObj.offsetHeight; // 弹出窗口的高度; divObj.style.display = "none"; divLayObj.style.width = fullWidth + "px"; divLayObj.style.height = viewHeight + "px"; if (self.pageYOffset) { scLeft = self.pageXOffset; scTop = self.pageYOffset; } else { if (document.documentElement && document.documentElement.scrollTop) { scLeft = document.documentElement.scrollLeft; scTop = document.documentElement.scrollTop; } else { if (document.body) { scLeft = document.body.scrollLeft; scTop = document.body.scrollTop; } } } var topMargin = scTop + ((fullHeight - iHeight) / 2); if (topMargin < 0) { topMargin = 0; } divObj.style.top = topMargin + "px"; divObj.style.left = (scLeft + ((fullWidth - iWidth) / 2)) + "px"; if (gHideSelects) { hideSelectBoxes(); } divObj.style.display = ""; _isShowLoading = true; resizeTimer_showLoading = null; }; /* 关闭loading背景图片,入参:空 */ this.closeLoading = function () { _isShowLoading = false; if (gHideSelects) { displaySelectBoxes(); } var divObj = document.getElementById("_loading_div"); if (null != divObj) { divObj.style.display = "none"; } var _loading_lay_div = document.getElementById("_loading_lay_div"); if (null != _loading_lay_div) { _loading_lay_div.style.display = "none"; } window.setTimeout("utilsFp._closeLoadingTimeOut()", 60); }; this._closeLoadingTimeOut = function () { _isShowLoading = false; if (gHideSelects) { displaySelectBoxes(); } var divObj = document.getElementById("_loading_div"); if (null != divObj) { divObj.style.display = "none"; } var _loading_lay_div = document.getElementById("_loading_lay_div"); if (null != _loading_lay_div) { _loading_lay_div.style.display = "none"; } }; /* 在顶层窗口显示loading背景图片,入参:显示提示信息,若为空则显示默认信息 */ this.showTopLoading = function (msg) { try { if (window.top._topIframe != null) { // this.showTopLoading(); } else { this.showLoading(); return; } } catch (e) { } var ieop = this.isIE(); var xDom; var xBody; try { xDom = (window.top.document == document) ? document : (window.top.document.body.tagName != "BODY") ? document : window.top.document; xBody = (window.top.document == document) ? document.body : (window.top.document.body.tagName == "BODY") ? window.top.document.body : (ieop) ? document.body : window.top.document.documentElement; } catch (e) { try { xDom = (window.parent.document == document) ? document : (window.parent.document.body.tagName != "BODY") ? document : window.parent.document; xBody = (window.parent.document == document) ? document.body : (window.parent.document.body.tagName == "BODY") ? window.parent.document.body : (ieop) ? document.body : window.parent.document.documentElement; xDom = (window.parent.parent.document == document) ? document : (window.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.document; xBody = (window.parent.parent.document == document) ? document.body : (window.parent.parent.document.body.tagName == "BODY") ? window.parent.parent.document.body : (ieop) ? document.body : window.parent.parent.document.documentElement; xDom = (window.parent.parent.parent.document == document) ? document : (window.parent.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.parent.document; xBody = (window.parent.parent.parent.document == document) ? document.body : (window.parent.parent.parent.document.body.tagName == "BODY") ? window.parent.parent.parent.document.body : (ieop) ? document.body : window.parent.parent.parent.document.documentElement; xDom = (window.parent.parent.parent.parent.document == document) ? document : (window.parent.parent.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.parent.parent.document; xBody = (window.parent.parent.parent.parent.document == document) ? document.body : (window.parent.parent.parent.parent.document.body.tagName == "BODY") ? window.parent.parent.parent.parent.document.body : (ieop) ? document.body : window.parent.parent.parent.parent.document.documentElement; xDom = (window.parent.parent.parent.parent.parent.document == document) ? document : (window.parent.parent.parent.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.parent.parent.parent.document; xBody = (window.parent.parent.parent.parent.parent.document == document) ? document.body : (window.parent.parent.parent.parent.parent.document.body.tagName == "BODY") ? window.parent.parent.parent.parent.parent.document.body : (ieop) ? document.body : window.parent.parent.parent.parent.parent.document.documentElement; } catch (e) { if (null == xDom) { xDom = (window.document == document) ? document : (window.document.body.tagName != "BODY") ? document : window.document; xBody = (window.document == document) ? document.body : (window.document.body.tagName == "BODY") ? window.document.body : (ieop) ? document.body : window.document.documentElement; } } } var body = xBody; if (null == body) { return; } var fullHeight = body.scrollHeight; var fullWidth = getViewportWidth(); var viewHeight = getViewportHeight(); if (fullHeight < viewHeight) { fullHeight = viewHeight; } var scLeft, scTop; if (null == msg || "" == msg) { msg = this.submit_default_info; utilsFp.initLangMap('["数据加载中 请稍后"]'); msg = utilsFp.getLangShow("数据加载中 请稍后")+"..."; } _showTopLoadingMsg = msg; var imgUrl = this.getContextPath() + "/plf/images/loading_h1.gif"; if (null == xDom.getElementById("_top_loading_div")) { var xdoc = xDom.createDocumentFragment(); body.appendChild(xdoc); var lay1 = "
"; var divHtml = "
" + "
" + msg + "
" + ""; var tmpDiv = xDom.createElement("div"); tmpDiv.innerHTML = lay1 + divHtml; body.appendChild(tmpDiv); } else { xDom.getElementById("_top_loading_div").style.display = ""; xDom.getElementById("_top_loading_lay_div").style.display = ""; xDom.getElementById("_top_loading_img").src = imgUrl; } var divObj = xDom.getElementById("_top_loading_div"); var divLayObj = xDom.getElementById("_top_loading_lay_div"); var iWidth = divObj.offsetWidth; // 弹出窗口的宽度; var iHeight = divObj.offsetHeight; // 弹出窗口的高度; divObj.style.top = body.scrollTop + body.offsetHeight / 2 - (iHeight / 2) + "px"; divObj.style.left = body.scrollLeft + body.offsetWidth / 2 - (iWidth / 2) + "px"; if (gHideSelects) { hideSelectBoxes(); } _isShowTopLoading = true; }; /* 关闭top loading背景图片,入参:空 */ this.closeTopLoading = function () { _isShowTopLoading = false; var xDom; try { xDom = (window.top.document == document) ? document : (window.top.document.body.tagName != "BODY") ? document : window.top.document; xBody = (window.top.document == document) ? document.body : (window.top.document.body.tagName == "BODY") ? window.top.document.body : (ieop) ? document.body : window.top.document.documentElement; } catch (e) { try {// 如果页面被iframe跨域嵌套时,查找顶层页面时最多向上查找5层 xDom = (window.parent.document == document) ? document : (window.parent.document.body.tagName != "BODY") ? document : window.parent.document; xDom = (window.parent.parent.document == document) ? document : (window.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.document; xDom = (window.parent.parent.parent.document == document) ? document : (window.parent.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.parent.document; xDom = (window.parent.parent.parent.parent.document == document) ? document : (window.parent.parent.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.parent.parent.document; xDom = (window.parent.parent.parent.parent.parent.document == document) ? document : (window.parent.parent.parent.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.parent.parent.parent.document; } catch (e) { if (null == xDom) { xDom = (window.document == document) ? document : (window.document.body.tagName != "BODY") ? document : window.document; } } } var loadingDiv = xDom.getElementById("_top_loading_div"); var loadingLayDiv = xDom.getElementById("_top_loading_lay_div"); if (null != loadingDiv) { if (gHideSelects) { displaySelectBoxes(); } loadingDiv.style.display = "none"; loadingLayDiv.style.display = "none"; } }; this._closeTopLoadingTimeOut = function () { _isShowTopLoading = false; var xDom; try { xDom = (window.top.document == document) ? document : (window.top.document.body.tagName != "BODY") ? document : window.top.document; xBody = (window.top.document == document) ? document.body : (window.top.document.body.tagName == "BODY") ? window.top.document.body : (ieop) ? document.body : window.top.document.documentElement; } catch (e) { try {// 如果页面被iframe跨域嵌套时,查找顶层页面时最多向上查找5层 xDom = (window.parent.document == document) ? document : (window.parent.document.body.tagName != "BODY") ? document : window.parent.document; xDom = (window.parent.parent.document == document) ? document : (window.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.document; xDom = (window.parent.parent.parent.document == document) ? document : (window.parent.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.parent.document; xDom = (window.parent.parent.parent.parent.document == document) ? document : (window.parent.parent.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.parent.parent.document; xDom = (window.parent.parent.parent.parent.parent.document == document) ? document : (window.parent.parent.parent.parent.parent.document.body.tagName != "BODY") ? document : window.parent.parent.parent.parent.parent.document; } catch (e) { if (null == xDom) { xDom = (window.document == document) ? document : (window.document.body.tagName != "BODY") ? document : window.document; } } } var loadingDiv = xDom.getElementById("_top_loading_div"); var loadingLayDiv = xDom.getElementById("_top_loading_lay_div"); if (null != loadingDiv) { if (gHideSelects) { displaySelectBoxes(); } loadingDiv.style.display = "none"; loadingLayDiv.style.display = "none"; } window.setTimeout("utilsFp._closeTopLoadingTimeOut()", 60); }; /* 初始化多语言 */ //langs 要翻译的文字,传数组 '["中文"]'或者'["中文","英文"]' //moName 模块标识 'mc_plf' this.initLangMap = function (langs, moName) { langs = _mcBase64JsToJava.getMcDealBase64Encode(langs); jQuery.ajax({type:"POST", dataType:"json",async:false , cache:false , url:this.getContextPath() + "/comm/CacheAction_getLangMap.ms", data:{"paraMap.langs":langs, "paraMap.moName":moName}, success:function (data) { // alert(JSON.stringify(data)); // util.alert(data.ajaxMap.nextselectId); if (null == data) { return; } if (null == data.ajaxMap) { return; } if(data.ajaxMap.RES == false){ alert(data.ajaxMap.RES_MSG); return; } for (var key in data.ajaxMap) { if (null == _LANG_MAP_GOL[key]) { _LANG_MAP_GOL[key] = data.ajaxMap[key]; } } }, error:function (msg) { utilFp.closeLoading(); utilFp.alert("error:" + msg); }}); }; /* 多语言翻译 */ this.getLangShow = function (key) { if (null == key) { return ""; } var lang = _LANG_MAP_GOL[key]; if(null==lang || ""==lang){ lang=key; } for(var i=1; i this.setTextAreaWidth = function (divId, areaId) { var tdWh = $("#" + divId).width(); var docWh = $(document).width(); var winWh = $(window).width(); if (docWh > (winWh + 21)) { $("#" + areaId).css({width:tdWh - (docWh - winWh + 7)}); } else { $("#" + areaId).css({width:tdWh - 2}); } }; // <%-- 设置textarea 自适应高度 --%> this.setTextAreaHeight = function (areaId, divHeadH) { var docWh = $(document).height(); var winWh = $(window).height(); $("#" + areaId).css({height:winWh - divHeadH - 21}); }; /*------selection operations-------*/ /** *********************以下为编辑器优化设置**************************** */ /* * //截获了Tab按键,其他的textarea框不进行此配置 //下面的代码就是为了实现这个功能,原理很简单,采用上一行的缩进就行 * //只要在html中插入脚本调用reloadTabKey()函数就可以了 * //注1:需要jQuery支持,如果不喜欢jQuery改成javascript也很方便的 //兼容firefox和IE! */ this.reloadTabKey = function (jqObj) { /* set all the tab indent for all the text areas */ jqObj.each(function () { $(this).keydown(function (eve) { if (eve.target != this) { return; } if (eve.keyCode == 13) { last_blanks = UtilsFp.getCurrentLineBlanks(this); } else { if (eve.keyCode == 9) { eve.preventDefault(); UtilsFp.insertAtCursor(this, "\t"); this.returnValue = false; } } }).keyup(function (eve) { if (eve.target == this && eve.keyCode == 13) { UtilsFp.insertAtCursor(this, last_blanks); } }); }); }; this.insertAtCursor = function (obj, txt) { obj.focus(); // IE support if (document.selection) { sel = document.selection.createRange(); sel.text = txt; } else { var startPos = obj.selectionStart; var scrollTop = obj.scrollTop; var endPos = obj.selectionEnd; obj.value = obj.value.substring(0, startPos) + txt + obj.value.substring(endPos, obj.value.length); startPos += txt.length; obj.setSelectionRange(startPos, startPos); obj.scrollTop = scrollTop; } }; this.getCurrentLineBlanks = function (obj) { var pos = this.getCaretPos(obj); var str = obj.value; var i = pos - 1; while (i >= 0) { if (str.charAt(i) == "\n") { break; } i--; } i++; var blanks = ""; while (i < str.length) { var c = str.charAt(i); if (c == " " || c == "\t") { blanks += c; } else { break; } i++; } return blanks; }; this.getCaretPos = function (ctrl) { var caretPos = 0; if (document.selection) { // IE Support var range = document.selection.createRange(); // We'll use this as a 'dummy' var stored_range = range.duplicate(); // Select all text stored_range.moveToElementText(ctrl); // Now move 'dummy' end point to end point of original range stored_range.setEndPoint("EndToEnd", range); // Now we can calculate start and end points ctrl.selectionStart = stored_range.text.length - range.text.length; ctrl.selectionEnd = ctrl.selectionStart + range.text.length; caretPos = ctrl.selectionStart; } else { if (ctrl.selectionStart || ctrl.selectionStart == "0") { // Firefox support } } caretPos = ctrl.selectionStart; return (caretPos); }; // 新增个获取UUID方法 this.getUUID = function(){ return ('xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); })); }; /* 获取页面url的参数值 */ /* var urlStr = window.location.href; //获取完整URL var viewId = getUrlParameter("viewId",urlStr);*/ this.getUrlParameter = function (queryName, url) { if(url){ var str=url.split("?")[1]; var vars = str.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == queryName) { return pair[1]; } } } return ""; }; //用于2.0模板查询列表 点击更多的时候执行的回调 this.mcQueryMoreCallRun = null; this.mcQueryMoreCall = function(callbackFn){ if(callbackFn && typeof callbackFn == 'function') { return this.mcQueryMoreCallRun = callbackFn; } } } var utilsFp = new UtilsFp(); var util=new UtilsFp(); /** * MC版本:v3.0.1 * * 取平台参数 */ function getMemoryMcPara(pname) { var mcPara; $.ajax({ type: "POST", dataType: "json", async:false, url: utilsFp.getContextPath() +"/buss/bussModel_getMemoryMcPara.ms", data: { 'pname' : pname }, success: function(data){ mcPara= data.ajaxMap.mcPara; }, error: function(msg){ if(msg.readyState!=0){ util.closeLoading(); utilsFp.confirmIcon(3,"","","", "error:"+msg,0,"",""); } } }); return mcPara; } /** * MC版本:v3.0.1 * * 取平台参数VAL */ function getMemoryMcParaVal(pname) { var mcPara =getMemoryMcPara(pname); if(mcPara!=null) { return mcPara.PVALUE; } return null; } /** * MC版本:v3.1.0 * * 获取div的高度=height+margin+padding */ function getHeight(className) { if(className){ var divHeigth; var divHeigth= $("."+className).outerHeight(true); return divHeigth; } else { //获取 top.getHeight return $(window).height(); } } /** * 当MC被别的系统嵌入的时候 top的获取 */ function mcGetTop(){ try{ if(top.EXTSYS_INCLUDE_MC == 'EXTSYS_INCLUDE_MC'){ if(top.document.getElementById("mcIncludeByIframe").contentWindow){ return top.document.getElementById("mcIncludeByIframe").contentWindow; } } else { //没有被嵌套 mainFrame.jsp return top; } } catch(err){ return top; } } /** * 获取当前tab中打开的iframe 中的弹层 zIndex */ function getIframePopZIndex(showPosition){ //判断top是否有 top.popConfig 没有的话top创建一个 适配window.open场景 if( !top.popConfig ){ top.popConfig={ "mainFrame":{"zIndex":10000,"popIframe":[]} }; } if(showPosition == "main-top" || showPosition == "tab-top"){ //return ++top.popConfig["mainFrame"]["zIndex"]; return ++top.zcount; //统一走 showPopWinFp()的层级 } if(showPosition == "tab-in") { var cur_iframe_name = getCurTabIfameName(); for(var key in top.popConfig){ if(cur_iframe_name == key){ return ++top.popConfig[cur_iframe_name]["zIndex"]; } } } } function getViewportHeight() { if (window.innerHeight != window.undefined) { return window.innerHeight; } if (document.compatMode == "CSS1Compat") { return document.documentElement.clientHeight; } if (document.body) { return document.body.clientHeight; } return window.undefined; } function getViewportWidth() { if (window.innerWidth != window.undefined) { return window.innerWidth; } if (document.compatMode == "CSS1Compat") { return document.documentElement.clientWidth; } if (document.body) { return document.body.clientWidth; } return window.undefined; } var gHideSelects = false; function _canClose(){ $(window).unbind('beforeunload'); window.onbeforeunload = null; } // 全局的AJAX访问,处理AJAX清求时SESSION超时及无权限提示(这个有ajax加载的页面才需要用到) try { jQuery.ajaxSetup({contentType:"application/x-www-form-urlencoded;charset=utf-8", complete:function (XMLHttpRequest, textStatus) { _mcAjaxBack(XMLHttpRequest); } }); //对返回数据进行处理,mc session超时处理 jQuery.ajaxSetup({contentType:"application/x-www-form-urlencoded;charset=utf-8", dataFilter:function(mcResult,type,xml ) { if(mcResult.indexOf("_sessionTimeOutGoToUrl")==-1){ return mcResult; }else{ mcResult=JSON.parse(mcResult); if("1"==mcResult._urlType){ window.top.location = utilsFp.getContextPath() + "/sys/LoginAction_mainFrame.ms?loadMark=10";// 有指定时,跳转到后台登录页 }else{ window.top.location = mcResult._sessionTimeOutGoToUrl;// 跳转之前请求的页面,让过滤器去判断跳转到前台或者是后台 } } } }); } catch (e) { } /** * ajax请求时没有权限的处理方法 * * @param XMLHttpRequest * @returns {Boolean} */ function _mcAjaxBack(XMLHttpRequest){ // 通过XMLHttpRequest取得响应头,sessionstatus var sessionstatus = XMLHttpRequest.getResponseHeader("sessionstatus"); var isPlatform = XMLHttpRequest.getResponseHeader("isPlatform"); if (null != sessionstatus ) { if(sessionstatus == "timeout"){ _canClose(); var _urlType = XMLHttpRequest.getResponseHeader("_urlType"); var _sessionTimeOutGoToUrl = XMLHttpRequest.getResponseHeader("_sessionTimeOutGoToUrl"); if("1"==_urlType){ window.top.location = utilsFp.getContextPath() + "/sys/LoginAction_mainFrame.ms?loadMark=10";// 有指定时,跳转到后台登录页 }else{ window.top.location = _sessionTimeOutGoToUrl;// 跳转之前请求的页面,让过滤器去判断跳转到前台或者是后台 } }else if (sessionstatus == "noAuthority") { utilsFp.initLangMap('["权限认证"]'); var msgStr= utilsFp.getLangShow("权限认证"); if (isPlatform=="1"){ var config = { type: 2, skin: 'layui-layer-molv', title: msgStr, area: ['500px', '350px'], min: function(index, layero){ }, success: function(){ } }; var mcIframeName = window.frameElement.name; var type = "1"; if(mcIframeName=="leftFrame"){ mcIframeName = window.parent.name; type = "2"; }else if(window.frameElement.name=="mainFrame"){ mcIframeName = window.parent.name; type = "3"; } config.content = utilsFp.getContextPath()+"/fp/FpAction_forPlatFormLogin.ms?mcIframeName="+mcIframeName+"&type="+type; top.layer.open(config); return false; }else{ if (!_isAlertAuthMsg) { alert(_GLO_NO_AUTHORITY_MSG); } _isAlertAuthMsg = true; //utilsFp.closeLoading(); isQuery = false; } } } return true; } // check to see if this is IE version 6 or lower. hide select boxes if so // maybe they'll fix this in version 7? var ieVerIndex = window.navigator.userAgent.indexOf("MSIE"); if (ieVerIndex > -1 && getInternetExplorerVersion() < 8) { gHideSelects = true; } //根据iframe name返回对应document / window /* * @argument mcIframeName:'xxx'。 @argument type:document/window 如果调用的是对象,方法,属性 * type:window; 如果调用的是DOM type:document {mcIframeName:'xxx', type: * document/window} */ function getSrcByIframeName(jsonObject){ if(jsonObject.type == 'document'){ return top.window.frames[jsonObject.mcIframeName].document; } return top.window.frames[jsonObject.mcIframeName]; } function _canClose(){ $(window).unbind('beforeunload'); window.onbeforeunload = null; } /** * 特殊字符反转义 */ function decodeHtml(str){ if (str==null || str==undefined) { return str; } var result = str.replace(/</g, "<").replace(/>/g, ">").replace(/[/g, "\[").replace( /]/g, "\]").replace(/(/g, "\(").replace(/)/g, "\)").replace(/+/g, "\\+").replace(/'/g, "'").replace(/"/g, "\""); return result; } /** * 特殊字符转义 */ function encodeHtml(str){ if (str==null || str==undefined) { return str; } var result = str.replace(//g, ">").replace(/\[/g, "[").replace(/\]/g, "]").replace(/\(/g, "(").replace(/\)/g, ")").replace(/\+/g,"+").replace(/'/g, "'").replace(/"/g, """); return result; } //**************************下面为扩展原有对象的方法*********************************************/ //对Date的扩展,将 Date 转化为指定格式的String //月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, //年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) //例子: //(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 //(new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 Date.prototype.Format = function(fmt) { // author: meizz var o = { "M+" : this.getMonth()+1, // 月份 "d+" : this.getDate(), // 日 "h+" : this.getHours(), // 小时 "m+" : this.getMinutes(), // 分 "s+" : this.getSeconds(), // 秒 "q+" : Math.floor((this.getMonth()+3)/3), // 季度 "S" : this.getMilliseconds() // 毫秒 }; if(/(y+)/.test(fmt)) fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); for(var k in o) if(new RegExp("("+ k +")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length))); return fmt; } Array.prototype.remove = function (dx) { if(isNaN(dx)||dx>this.length){return false;} this.splice(dx,1); } /** * Simple Map * * * var m = new Map(); m.put('key','value'); ... var s = ""; * m.each(function(key,value,index){ s += index+":"+ key+"="+value+"n"; }); * alert(s); * * @author dewitt * @date 2008-05-24 */ function Map() { /** 存放键的数组(遍历用到) */ this.keys = new Array(); /** 存放数据 */ this.data = new Object(); /** * 放入一个键值对 * * @param {String} * key * @param {Object} * value */ this.put = function (key, value) { if (this.data[key] == null) { this.keys.push(key); } this.data[key] = value; }; /** * 获取某键对应的值 * * @param {String} * key * @return {Object} value */ this.get = function (key) { return this.data[key]; }; /** * 删除一个键值对 * * @param {String} * key */ this.remove = function (key) { this.keys.remove(key); this.data[key] = null; }; /** * 遍历Map,执行处理函数 * * @param {Function} * 回调函数 function(key,value,index){..} */ this.each = function (fn) { if (typeof fn != "function") { return; } var len = this.keys.length; for (var i = 0; i < len; i++) { var k = this.keys[i]; fn(k, this.data[k], i); } }; /** * 获取键值数组(类似Java的entrySet()) * * @return 键值对象{key,value}的数组 */ this.entrys = function () { var len = this.keys.length; var entrys = new Array(len); for (var i = 0; i < len; i++) { entrys[i] = {key:this.keys[i], value:this.data[i]}; } return entrys; }; /** * 判断Map是否为空 */ this.isEmpty = function () { return this.keys.length == 0; }; /** * 获取键值对数量 */ this.size = function () { return this.keys.length; }; /** * 重写toString */ this.toString = function () { var s = "{"; for (var i = 0; i < this.keys.length; i++, s += ",") { var k = this.keys[i]; s += k + "=" + this.data[k]; } s += "}"; return s; }; } /* js map 测试 */ function testMap() { var m = new Map(); m.put("key1", "Comtop"); m.put("key2", "\u5357\u65b9\u7535\u7f51"); m.put("key3", "\u666f\u65b0\u82b1\u56ed"); alert("init:" + m); m.put("key1", "\u5eb7\u62d3\u666e"); alert("set key1:" + m); m.remove("key2"); alert("remove key2: " + m); var s = ""; m.each(function (key, value, index) { s += index + ":" + key + "=" + value + "\n"; }); alert(s); } //获取uuid function getUuid() { var s = []; var hexDigits = "0123456789abcdef"; for (var i = 0; i < 36; i++) { s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); } s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the // clock_seq_hi_and_reserved // to 01 s[8] = s[13] = s[18] = s[23] = "-"; var uuid = s.join(""); return uuid; } /** * ***********************END************************ * ************************************************** */
" + msg + "