var tracywindyObject = {}; var isEnableTracywindyRandomUrl = false; function getTracywindyRandomUrl(url){ var tempUrl; if(!isEnableTracywindyRandomUrl){ tempUrl = "tracywindyRandom=1"; }else{ tempUrl = "tracywindyRandom=" + Math.random(); } /* * 资源URL 添加标志符 */ if(url.indexOf('?')>-1){ url += ("&" + tempUrl); }else { url += ("?" + tempUrl); } return url; } //格式化数字为千分位 function formatNumberThousand(s) { if(isNaN(s)){ return s; } s += ""; s = s.replace(/,/g,""); var re=/(\d{1,3})(?=(\d{3})+(?:$|\D))/g; //肖遥云指点 var n1=s.replace(re,"$1,"); return n1; } //判断parentObj是否是obj的上级元素 function isParent(obj,parentObj){ while (obj != undefined && obj != null && obj.tagName.toUpperCase() != 'BODY'){ if (obj == parentObj){ return true; } obj = obj.parentNode; } return false; } function clearForm(form) { var elements = form.elements; for(var i=0;i -1, //IE内核 presto : userAgent.indexOf('presto') > -1, //opera内核 webKit : userAgent.indexOf('applewebkit') > -1, //苹果、谷歌内核 gecko : userAgent.indexOf('gecko') > -1 && userAgent.indexOf('khtml') == -1, //火狐内核 mobile : !!userAgent.match(/applewebkit.*mobile.*/)|| !!userAgent.match(/applewebkit/), //是否为移动终端 ios : !!userAgent.match(/\(i[^;]+;( u;)? cpu.+mac os x/), //ios终端 android : userAgent.indexOf('android') > -1 || userAgent.indexOf('linux') > -1, //android终端或者uc浏览器 iPhone : userAgent.indexOf('iphone') > -1 /*|| userAgent.indexOf('mac') > -1*/, //是否为iPhone或者QQHD浏览器 iPad: userAgent.indexOf('ipad') > -1, //是否iPad webApp : userAgent.indexOf('safari') == -1,//是否web应该程序,没有头部与底部 google:userAgent.indexOf('chrome')>-1, getBrowser:function(){ if(SysBrowser.msie) return "IE"; else if(SysBrowser.firefox) return "Firefox"; else if(SysBrowser.chrome) return "Chrome"; else if(SysBrowser.opera) return "Opera"; else if(SysBrowser.safari) return "Safari"; else return "IE"; }, getVersion:function(){ return SysBrowser.version; }, getLanguage:function(){ return SysBrowser.language; } }; function getEvent(e) { return window.event||e; } function getTarget(e) { var e = getEvent(e); return e.srcElement||e.target||e.currentTarget; } function cancelBubble(e) { var e = getEvent(e); try{ e.cancelBubble = true; e.stopPropagation(); }catch(e){ e.cancelBubble = true; } } function stopDefault(e){ try { getEvent(e).returnValue=false; getEvent(e).preventDefault(); getEvent(e).stopPropagation(); }catch(e) { getEvent(e).returnValue=false; } } //强制加n个小数30->30.00 function forcePreciseDecimal(x,scale) { scale = scale||2; var f_x = parseFloat(x); if (isNaN(f_x)) { alert('function:forcePreciseDecimal->parameter error'); return false; } var f_x = Math.round(x*100)/100; var s_x = f_x.toString(); var pos_decimal = s_x.indexOf('.'); if (pos_decimal < 0) { pos_decimal = s_x.length; s_x += '.'; } while (s_x.length <= pos_decimal + scale) { s_x += '0'; } return s_x; } function decimalReal(num,v) { var dight =(num*Math.pow(10,v)/Math.pow(10,v)).toFixed(v); return parseFloat(dight); } //四舍五入 function decimal(num,v) { //num表示要四舍五入的数,v表示要保留的小数位数。 if(0 == v) { return decimalReal(decimalReal(num,2),0); } return decimalReal(num,v); } function getTracywindyObject(id) { return tracywindyObject[id]; } //function 处理css String.prototype.trim=function(){ return this.replace(/(^\s{1,})|(\s{1,}$)/gim,""); }; Array.prototype.contains = function(item){ for(i=0;i=48)&&(keyCode<=57))||(keyCode==8)||(keyCode==190)) { pass = true; } //小键盘 if(((keyCode>=96)&&(keyCode<=105))||(keyCode==110)) { pass = true; } e.returnValue = pass;*/ } //弹出一个全屏窗口 function openFullScreenWindow(strURL,attachmentParams,winRef) { if(-1==strURL.indexOf("systemMathRandom")) { if(strURL.indexOf("?")>-1) { strURL+="&systemMathRandom=systemMathRandom"; } else { strURL+="?systemMathRandom=systemMathRandom"; } } if(attachmentParams) { if('string' == typeof(attachmentParams)) { strURL += ("&"+attachmentParams.replace(/(^&)|(^\?)/,"")); } else if('object' == typeof(attachmentParams)) { for(var p in attachmentParams) { strURL+=("&"+p+"="+attachmentParams[p]); } } } /*strURL=encodeURI(encodeURI(strURL)); var params = {}; if(attachmentParams){ if("object" == typeof(attachmentParams)){ for(var p in attachmentParams){ params[p] = attachmentParams[p];//escape(encodeURIComponent(attachmentParams[p])); } } else if("string" == typeof(attachmentParams)){ var paramsArr = attachmentParams.split("&"); for(var i=0;i=1){ key = keyValueArr[0]; if(key){ key = key.trim(); } } if(keyValueArrLen>=2){ value = keyValueArr[1]; if(value){ value = value;//escape(encodeURIComponent(value)).trim(); } } if(key){ params[key]=value; } } } } }*/ var sheight = window.screen.availHeight-30; var swidth = window.screen.availWidth-10; var winoption ="left=0px,top=0px,height="+sheight+"px,width="+swidth+"px,toolbar=yes,menubar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes"; if(winRef){ window.loc = function(){ winRef.location.href = strURL;//改变页面的 location }; setTimeout("window.loc();",800);//这个等待很重要,如果不等待的话将无法实现 }else{ window.open(strURL,'_blank',winoption); } /*var tempSubmitForm = document.getElementById("id_tempSubmitForm"); if(!tempSubmitForm){ tempSubmitForm = document.createElement("form"); document.body.appendChild(tempSubmitForm); } with(tempSubmitForm){ style.display="none"; innerHTML = ""; action = strURL; target = "temSubmitFormTargetWindow"; method = "post"; } for(p in params){ var hiddenInput = document.createElement("input"); with(hiddenInput){ type = "hidden"; name = p; value = params[p]; } tempSubmitForm.appendChild(hiddenInput); } tempSubmitForm.submit();*/ return false; } function setCookie(name,value)//两个参数,一个是cookie的名子,一个是值 { var Days = 30; //此 cookie 将被保存 30 天 var exp = new Date(); //new Date("December 31, 9998"); exp.setTime(exp.getTime() + Days*24*60*60*1000); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); } function getCookie(name)//取cookies函数 { var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); if(arr != null) return unescape(arr[2]); return ""; } //删除数字多余的0 function nullToString(value) { if((typeof(value)=='undefined')||(value==null)) { return ""; } return value; } function trimZero(numberStr) { if(!numberStr) return numberStr; var floatValue = parseFloat(numberStr); var intVar = parseInt(numberStr); var resultStr = ""; if(intVar==floatValue) { resultStr= intVar+""; } else { resultStr=(floatValue+"").replace(/(^0+)|(0+$)/gi,""); } return resultStr; } function empty2Other(sourceStr,replaceStr) { return !sourceStr ? replaceStr : sourceStr; } //说明:设置某个table中的输入框为只读/可编辑 //参数1:操作table的ID //参数2:table那个域是不操作的以“,”分隔 //参数3:操作类型 0为只读 1为编辑 function formJSPInputHideOrShow(id,exceptFfield,stype){ if(document.getElementById(id)){ var inputs=jQuery("#"+id+" input[type='text'],#"+id+" textarea"); var d=0; var vfield=[]; var cflag=true; if(exceptFfield!=""){vfield=exceptFfield.split(",");} for(;d0){ for(var i=0;i0){ //inputs[d].setAttribute("onClick","WdatePicker(inputs[d],{readOnly:true})"); inputs[d].onclick=""; removeClass( inputs[d],"Wdate"); } } else{ inputs[d].readOnly = false; var pnode=inputs[d].parentNode; removeClass( inputs[d],"element-readonly"); if(inputs[d].getAttribute("dataType")=="Date"){ inputs[d].readOnly = true; inputs[d].onclick=function(){WdatePicker(this,{readOnly:true})}; inputs[d].className=inputs[d].className+" Wdate "; } } }} } } //查询多行控件中必填项 function checkTracywindyTableData(talbeid,title){ var sourceTable= getTracywindyObject(talbeid); var sourceData=sourceTable.getRowsJsonData(); if(sourceData.length<=0){ jQuery.messager.alert('提示',"
请填写"+title+"
",'error'); return false; } var sourceColumn=sourceTable.columns; var columndata; var onecolumn; for(var i=0;i