Index: ssts-web/src/main/webapp/js/common.js =================================================================== diff -u -r27885 -r28522 --- ssts-web/src/main/webapp/js/common.js (.../common.js) (revision 27885) +++ ssts-web/src/main/webapp/js/common.js (.../common.js) (revision 28522) @@ -1,7 +1,7 @@ -var bPageModified=false; -var wheight=window.screen.height-60; -var wwidth=window.screen.width; -var openReturnValue=""; +var bPageModified = false; +var wheight = window.screen.height - 60; +var wwidth = window.screen.width; +var openReturnValue = ""; var webCtxRoot = ''; @@ -13,50 +13,51 @@ * @param callback 回调函数 * */ -function setStartDate(extObject, format, datefieldId , callback) { - - extObject.Ajax.request({ - url : WWWROOT + '/system/serverTimeAction!getServerDateTime.do', - params : {dateformat : format}, - success : function(response, options) { - var result = extObject.decode(response.responseText); - if(result.success){ - var serverTime = result.serverTime; - extObject.getCmp(datefieldId).setValue(new Date(serverTime)); - if(callback){ - try{ - callback(); - }catch(e){ - - } - } - } - }, - failure : function(response, options) { +function setStartDate(extObject, format, datefieldId, callback) { + + extObject.Ajax.request({ + url: WWWROOT + '/system/serverTimeAction!getServerDateTime.do', + params: { dateformat: format }, + success: function(response, options) { + var result = extObject.decode(response.responseText); + if (result.success) { + var serverTime = result.serverTime; + extObject.getCmp(datefieldId).setValue(new Date(serverTime)); + if (callback) { + try { + callback(); + } catch (e) { + + } + } + } + }, + failure: function(response, options) { alert('获取服务器时间失败'); } - }); - + }); + } + function setStartDate2(extObject, datefieldId) { - - extObject.Ajax.request({ - url : WWWROOT + '/system/serverTimeAction!getServerDateTime2.do', -// params : {dateformat : format}, - success : function(response, options) { - var result = extObject.decode(response.responseText); - if(result.success){ - var timeInMillis = result.timeInMillis; - var date = new Date(0); - date.setUTCMilliseconds(timeInMillis); - extObject.getCmp(datefieldId).setValue(date); - } - }, - failure : function(response, options) { + + extObject.Ajax.request({ + url: WWWROOT + '/system/serverTimeAction!getServerDateTime2.do', + // params : {dateformat : format}, + success: function(response, options) { + var result = extObject.decode(response.responseText); + if (result.success) { + var timeInMillis = result.timeInMillis; + var date = new Date(0); + date.setUTCMilliseconds(timeInMillis); + extObject.getCmp(datefieldId).setValue(date); + } + }, + failure: function(response, options) { alert('获取服务器时间失败'); } - }); - + }); + } /** @@ -69,69 +70,69 @@ * */ function synchronizationSetDateField(extObject, format, datefieldId, datefieldValue, refreshFrequency) { - - if (!datefieldValue) { //如果没传时间的值,就取服务器的当前时间 - DWREngine.setAsync(false); - ServerTimeTableManager.getServerDateTime(format, function(config) { - datefieldValue = config; - }); - DWREngine.setAsync(true); - } - - extObject.getCmp(datefieldId).setValue(new Date(datefieldValue)); - - if (refreshFrequency && !isNaN(refreshFrequency)) { //需要定时刷新时间 - var lastTime = extObject.getCmp(datefieldId).getValue().getTime(); - var timerHandle = setInterval(function() { - var time = extObject.getCmp(datefieldId).getValue().getTime(); - if (time == lastTime) { - lastTime = time + refreshFrequency; - extObject.getCmp(datefieldId).setValue(new Date(lastTime)); - } else { //如果上一秒或者分钟和下一秒或者分钟的时间戳不一样,清除定时器 - clearInterval(timerHandle); - } - }, refreshFrequency); - return timerHandle; - } - + + if (!datefieldValue) { //如果没传时间的值,就取服务器的当前时间 + DWREngine.setAsync(false); + ServerTimeTableManager.getServerDateTime(format, function(config) { + datefieldValue = config; + }); + DWREngine.setAsync(true); + } + + extObject.getCmp(datefieldId).setValue(new Date(datefieldValue)); + + if (refreshFrequency && !isNaN(refreshFrequency)) { //需要定时刷新时间 + var lastTime = extObject.getCmp(datefieldId).getValue().getTime(); + var timerHandle = setInterval(function() { + var time = extObject.getCmp(datefieldId).getValue().getTime(); + if (time == lastTime) { + lastTime = time + refreshFrequency; + extObject.getCmp(datefieldId).setValue(new Date(lastTime)); + } else { //如果上一秒或者分钟和下一秒或者分钟的时间戳不一样,清除定时器 + clearInterval(timerHandle); + } + }, refreshFrequency); + return timerHandle; + } + } /* -*报表查询封装函数 -*/ -function seachReport(url,params){ + *报表查询封装函数 + */ +function seachReport(url, params) { var html = ''; - setTimeout(function(){ + setTimeout(function() { document.getElementById('thisIframe').contentWindow.document.body.innerHTML = html; document.getElementById('thisIframe').contentWindow.document.getElementById("reportHiddenForm").action = url; document.getElementById('thisIframe').contentWindow.document.getElementById("reportHiddenForm").submit(); - },1000); + }, 1000); } /* -*IE8以下兼容document.getElementsByClassName -*/ + *IE8以下兼容document.getElementsByClassName + */ function documentGetElementsByClassName(className) { - if(!document.getElementsByClassName){ - document.getElementsByClassName = function(className){ + if (!document.getElementsByClassName) { + document.getElementsByClassName = function(className) { var children = document.getElementsByTagName('*'); var elements = new Array(); - for (var i=0; i=0 ){ - notice("谢谢使用,您已经成功退出系统!"); - window.close(); //ensure to clear SSL cache after x509 logout +function logout(contextPath) { + var springSecurityLogoutUrl = contextPath + "/j_spring_security_logout"; + top.document.location.href = springSecurityLogoutUrl; + if (top.document.location.href.indexOf("https") >= 0) { + notice("谢谢使用,您已经成功退出系统!"); + window.close(); //ensure to clear SSL cache after x509 logout } } -function replaceToNewLine(toReplaceStr){ - return toReplaceStr.replace(/(\(\*\#\*\))/g,"\n"); +function replaceToNewLine(toReplaceStr) { + return toReplaceStr.replace(/(\(\*\#\*\))/g, "\n"); } -function stringToInteger(s){ - if (isNaN(s) || s.Trim() == "" ){ +function stringToInteger(s) { + if (isNaN(s) || s.Trim() == "") { return 0; } return parseInt(s); } -function stringToFloat(s){ - if (isNaN(s) || s.Trim() == "" ){ + +function stringToFloat(s) { + if (isNaN(s) || s.Trim() == "") { return 0; } return parseFloat(s); } -function keyOnclick(e) -{ +function keyOnclick(e) { var keyNum; - try{ - if(bPageModified==true){ + try { + if (bPageModified == true) { return; } - if (window.Event){ //for other + if (window.Event) { //for other keyNum = e.which; - } - else{ //for IE5+ + } else { //for IE5+ keyNum = event.keyCode; - } + } //ignore 'Enter' and 'Tab' key - if(keyNum !=13 && keyNum !=9){ - bPageModified=true; + if (keyNum != 13 && keyNum != 9) { + bPageModified = true; } - } - catch(e) - { - } + } catch (e) {} } -function closeSelf(){ +function closeSelf() { window.close(); } -function canCloseSelf(confirmMsg,bNotRefreshOpener){ - if(bPageModified==true){ - if(!confirm(confirmMsg)){ +function canCloseSelf(confirmMsg, bNotRefreshOpener) { + if (bPageModified == true) { + if (!confirm(confirmMsg)) { return; } } - var iNotRefresh=0; + var iNotRefresh = 0; - try{ - iNotRefresh=parseInt(bNotRefreshOpener); - }catch(e){} + try { + iNotRefresh = parseInt(bNotRefreshOpener); + } catch (e) {} - if(iNotRefresh>0){ + if (iNotRefresh > 0) { closeSelf(); - }else{ + } else { closeAndReloadOpener(); } } -function removeLastSharp(source){ - var dest=source; +function removeLastSharp(source) { + var dest = source; - if(source.substr(source.length-1,1)=='#'){ - dest=source.substring(0,source.length-1); + if (source.substr(source.length - 1, 1) == '#') { + dest = source.substring(0, source.length - 1); } return dest; } -function closeAndReloadOpener(){ - try{ +function closeAndReloadOpener() { + try { window.close(); window.opener.focus(); - window.opener.location=window.opener.location; - }catch(e){} + window.opener.location = window.opener.location; + } catch (e) {} } -function openNewWindow(pageUrl) -{ +function openNewWindow(pageUrl) { //remove last sharp - pageUrl=removeLastSharp(pageUrl); + pageUrl = removeLastSharp(pageUrl); - var style='menubar=no,location=no,directories=no,toolbar=no,statusbar=no,' - +'scrollbars=yes,resizable=yes'; + var style = 'menubar=no,location=no,directories=no,toolbar=no,statusbar=no,' + + 'scrollbars=yes,resizable=yes'; - var popwin=window.open(pageUrl,'_blank',style); + var popwin = window.open(pageUrl, '_blank', style); popwin.focus(); } -function openNewSizeWindow(pageUrl,windowName,width,height,scrollbars) -{ +function openNewSizeWindow(pageUrl, windowName, width, height, scrollbars) { //remove last sharp - pageUrl=removeLastSharp(pageUrl); - var style="menubar=no,location=no,directories=no,toolbar=no,statusbar=no,resizable=no,"+getCenterWindowPos(width,height)+",scrollbars="+scrollbars; - var popwin=window.open(pageUrl,windowName,style); - if(popwin != null ){ - popwin.focus(); + pageUrl = removeLastSharp(pageUrl); + var style = "menubar=no,location=no,directories=no,toolbar=no,statusbar=no,resizable=no," + getCenterWindowPos(width, height) + ",scrollbars=" + scrollbars; + var popwin = window.open(pageUrl, windowName, style); + if (popwin != null) { + popwin.focus(); } - - + + } -function getCenterWindowPos(pWidth,pHeight){ - var width=parseInt(''+pWidth); - var height=parseInt(''+pHeight); - var top=parseInt((parent.screen.height*0.88-height)*0.5, 10); - var left=parseInt((parent.screen.width*0.985-width)*0.5, 10); +function getCenterWindowPos(pWidth, pHeight) { + var width = parseInt('' + pWidth); + var height = parseInt('' + pHeight); + var top = parseInt((parent.screen.height * 0.88 - height) * 0.5, 10); + var left = parseInt((parent.screen.width * 0.985 - width) * 0.5, 10); - if(top<0){ - top=0; + if (top < 0) { + top = 0; } - if(left<0){ - left=0; + if (left < 0) { + left = 0; } - var posStatement="top="+top+",left="+left+",width="+width+",height="+height; + var posStatement = "top=" + top + ",left=" + left + ",width=" + width + ",height=" + height; return posStatement; } -function openModalWindow(pageUrl,varArgIn,width,height) -{ - width = parseInt(width,10); - height = parseInt(height,10); +function openModalWindow(pageUrl, varArgIn, width, height) { + width = parseInt(width, 10); + height = parseInt(height, 10); - if(!!window.ActiveXObject || "ActiveXObject" in window){ - var style="dialogHeight: "+height+"px; dialogWidth: "+width+"px; center: Yes; help: No; resizable: No; status: No;"; - var retval = window.showModalDialog(pageUrl,varArgIn,style); + if (!!window.ActiveXObject || "ActiveXObject" in window) { + var style = "dialogHeight: " + height + "px; dialogWidth: " + width + "px; center: Yes; help: No; resizable: No; status: No;"; + var retval = window.showModalDialog(pageUrl, varArgIn, style); return retval; - }else { - var style="height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no"; - - if(typeof varArgIn == 'object'){ + } else { + var style = "height=" + height + ",width=" + width + ",status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no"; + + if (typeof varArgIn == 'object') { var html = ''; - for(var k in varArgIn){ - html += k+'='+varArgIn[k]+'&'; + for (var k in varArgIn) { + html += k + '=' + varArgIn[k] + '&'; } - html = html.slice(0,html.length-1); + html = html.slice(0, html.length - 1); - var recyclingWindow = window.open(pageUrl+'?'+html,"_blank",style); + var recyclingWindow = window.open(pageUrl + '?' + html, "_blank", style); return recyclingWindow; - }else { - var recyclingWindow = window.open(pageUrl,"_blank",style); + } else { + var recyclingWindow = window.open(pageUrl, "_blank", style); return recyclingWindow; } } } -function openModalWindowForExt(pageUrl,varArgIn,title,width,height) -{ - width = parseInt(width,10) || parseInt((window.screen.width-250),10); - height = parseInt(height,10) || parseInt((window.screen.height-200),10); +function openModalWindowForExt(pageUrl, varArgIn, title, width, height) { + width = parseInt(width, 10) || parseInt((window.screen.width - 250), 10); + height = parseInt(height, 10) || parseInt((window.screen.height - 200), 10); var url = ''; var tab1GroupMgr = new Ext.WindowGroup(); - tab1GroupMgr.zseed=999999; + tab1GroupMgr.zseed = 999999; - if(typeof varArgIn == 'object'){ + if (typeof varArgIn == 'object') { var html = ''; - for(var k in varArgIn){ - html += k+'='+varArgIn[k]+'&'; + for (var k in varArgIn) { + html += k + '=' + varArgIn[k] + '&'; } - html = html.slice(0,html.length-1); - url = pageUrl+'?'+html; - }else { + html = html.slice(0, html.length - 1); + url = pageUrl + '?' + html; + } else { url = pageUrl; } var win = new top.Ext.Window({ - title : title, - id:'extWindow', - width : width+50, - height : height+40, - autoScroll : false, - isTopContainer : true, - modal : true, - resizable : false, + title: title, + id: 'extWindow', + width: width + 50, + height: height + 40, + autoScroll: false, + isTopContainer: true, + modal: true, + resizable: false, manager: tab1GroupMgr, - items:[{ - xtype:"panel", - id:"index", - html:"" + items: [{ + xtype: "panel", + id: "index", + html: "" }] }) @@ -430,49 +423,49 @@ return win; } -function getURLParameter(paramName, defaultValue){ - if(defaultValue == 'undefined' || defaultValue == null){ - defaultValue = ""; - } - - var args = getURLParameters(); - var paramValue = args[paramName]; - if(paramValue == 'undefined' || paramValue == null || paramValue == ''){ +function getURLParameter(paramName, defaultValue) { + if (defaultValue == 'undefined' || defaultValue == null) { + defaultValue = ""; + } + + var args = getURLParameters(); + var paramValue = args[paramName]; + if (paramValue == 'undefined' || paramValue == null || paramValue == '') { paramValue = defaultValue; } - + return paramValue; } function getURLParameters() { - var args = new Object(); - var query = location.search.substring(1); // Get query string - var pairs = query.split("&"); // Break at ampersand - for(var i = 0; i < pairs.length; i++) { - var pos = pairs[i].indexOf('='); // Look for "name=value" - if (pos == -1) continue; // If not found, skip - var argname = pairs[i].substring(0,pos); // Extract the name - var value = pairs[i].substring(pos+1); // Extract the value - value = decodeURIComponent(value); // Decode it, if needed - args[argname] = value; // Store as a property - } - return args; // Return the object + var args = new Object(); + var query = location.search.substring(1); // Get query string + var pairs = query.split("&"); // Break at ampersand + for (var i = 0; i < pairs.length; i++) { + var pos = pairs[i].indexOf('='); // Look for "name=value" + if (pos == -1) continue; // If not found, skip + var argname = pairs[i].substring(0, pos); // Extract the name + var value = pairs[i].substring(pos + 1); // Extract the value + value = decodeURIComponent(value); // Decode it, if needed + args[argname] = value; // Store as a property + } + return args; // Return the object } function parseUrlParameter(parameter) { - if (parameter.substring(0,1)=="?") { - parameter=parameter.substring(1); + if (parameter.substring(0, 1) == "?") { + parameter = parameter.substring(1); } - if (parameter.substring(parameter.length-1)=="#") { - parameter=parameter.substring(0,parameter.length-1); + if (parameter.substring(parameter.length - 1) == "#") { + parameter = parameter.substring(0, parameter.length - 1); } return parameter; } -function ReplaceAllSubString(str,strOld,strNew){ - while (str.indexOf(strOld)>-1){ - str = str.replace(strOld,strNew); +function ReplaceAllSubString(str, strOld, strNew) { + while (str.indexOf(strOld) > -1) { + str = str.replace(strOld, strNew); } return str; } @@ -482,21 +475,27 @@ else return false; } -function isFieldNotNull(objField , alertMsg){ - if (typeof(objField[0])=="object"){ - objField = objField[0]; +function isFieldNotNull(objField, alertMsg) { + if (objField !== null && objField !== '') { + if (typeof(objField[0]) == "object") { + objField = objField[0]; + } } - if (typeof(objField)=="object"){ - if (objField.value.Trim()==""){ - - if(alertMsg != ""){ - alert(alertMsg); + if (typeof(objField) == "object") { + if (objField !== null && objField !== '') { + if (objField.value.Trim() == "") { + + if (alertMsg != "") { + alert(alertMsg); + } + + setFieldFocus(objField); + return false; + } else { + return true; } - - setFieldFocus(objField); - return false; - }else{ + } else { return true; } } @@ -505,378 +504,376 @@ } -function isFieldIsMoney(objField , alertMsg){ - if (!isNumeric(objField.value)){ +function isFieldIsMoney(objField, alertMsg) { + if (!isNumeric(objField.value)) { alert(alertMsg); setFieldFocus(objField); return false; - }else{ + } else { return true; } } -function isFieldIsInteger(objField , alertMsg){ - if (!isAmount(objField.value)){ +function isFieldIsInteger(objField, alertMsg) { + if (!isAmount(objField.value)) { alert(alertMsg); setFieldFocus(objField); return false; - }else{ + } else { return true; } } -function isAmount(s){ - if(typeof(s) == 'undefined'){ - return false; - } - if(s == null){ - return false; - } - s = s+''; - if (s.Trim()=="") return false; - if (s.Trim()!=s) return false; - while (s.length > 1 && s.substring(0,1) == "0"){ +function isAmount(s) { + if (typeof(s) == 'undefined') { + return false; + } + if (s == null) { + return false; + } + s = s + ''; + if (s.Trim() == "") return false; + if (s.Trim() != s) return false; + while (s.length > 1 && s.substring(0, 1) == "0") { s = s.substr(1); } - if (isNaN(s)) return false; - if (parseInt(s).toString()!=s) return false; - if (parseInt(s)<0) return false; - else return true; + if (isNaN(s)) return false; + if (parseInt(s).toString() != s) return false; + if (parseInt(s) < 0) return false; + else return true; } -function isFieldIsAnyInteger(objField , alertMsg){ - if (!isInteger(objField.value)){ +function isFieldIsAnyInteger(objField, alertMsg) { + if (!isInteger(objField.value)) { alert(alertMsg); setFieldFocus(objField); return false; - }else{ + } else { return true; } } -function isFieldIsDate(objField , alertMsg){ - if (CheckTimeTH(objField.value)==-1){ +function isFieldIsDate(objField, alertMsg) { + if (CheckTimeTH(objField.value) == -1) { alert(alertMsg); setFieldFocus(objField); return false; - }else{ + } else { return true; } } -function isDate(str){ - var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/; - var r = str.match(reg); +function isDate(str) { + var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/; + var r = str.match(reg); - if(r==null)return false; - var d= new Date(r[1], r[3]-1,r[4]); - var newStr=d.getFullYear()+r[2]+(d.getMonth()+1)+r[2]+d.getDate(); - return true; + if (r == null) return false; + var d = new Date(r[1], r[3] - 1, r[4]); + var newStr = d.getFullYear() + r[2] + (d.getMonth() + 1) + r[2] + d.getDate(); + return true; } -function compareDate(beginDate, endDate){ - var d1 = beginDate; - if(!(beginDate instanceof Date)){ - d1 = new Date(beginDate.replace(/-/g, "/")); - } - var d2 = endDate; - if(!(endDate instanceof Date)){ - d2 = new Date(endDate.replace(/-/g, "/")); - } - if( (d1 - d2) >0 ) - return false; - return true; +function compareDate(beginDate, endDate) { + var d1 = beginDate; + if (!(beginDate instanceof Date)) { + d1 = new Date(beginDate.replace(/-/g, "/")); + } + var d2 = endDate; + if (!(endDate instanceof Date)) { + d2 = new Date(endDate.replace(/-/g, "/")); + } + if ((d1 - d2) > 0) + return false; + return true; } /** * 判断两个日期是否相等 * @param date1 * @param date2 */ -function dateEquals(date1, date2){ - if(date1 == date2){ - //引用相等,那就相等了 - return true; - } - if(date1 == null || date2 == null){ - //到这里,说明引用不相等,并且其中有一个为null,那另一个一定不为null(如果另一个也为null,那上面的判断就已经确定了),所以不相等 - return false; - } - //到这里,两个肯定都不为null - var d1 = date1; - if(!(date1 instanceof Date)){ - d1 = new Date(date1.replace(/-/g, "/")); - } - var d2 = date2; - if(!(date2 instanceof Date)){ - d2 = new Date(date2.replace(/-/g, "/")); - } - return (d1 - d2 == 0); +function dateEquals(date1, date2) { + if (date1 == date2) { + //引用相等,那就相等了 + return true; + } + if (date1 == null || date2 == null) { + //到这里,说明引用不相等,并且其中有一个为null,那另一个一定不为null(如果另一个也为null,那上面的判断就已经确定了),所以不相等 + return false; + } + //到这里,两个肯定都不为null + var d1 = date1; + if (!(date1 instanceof Date)) { + d1 = new Date(date1.replace(/-/g, "/")); + } + var d2 = date2; + if (!(date2 instanceof Date)) { + d2 = new Date(date2.replace(/-/g, "/")); + } + return (d1 - d2 == 0); } -String.prototype.Trim=function(){ - return this.replace(/(^\s*)|(\s*$)/g,""); +String.prototype.Trim = function() { + return this.replace(/(^\s*)|(\s*$)/g, ""); }; -String.prototype.lenB=function(){ - return this.replace(/[^\x00-\xff]/g,"**").length; -}; +String.prototype.lenB = function() { + return this.replace(/[^\x00-\xff]/g, "**").length; +}; function setFieldFocus(objField) { - try - { + try { objField.focus(); - }catch (e){} + } catch (e) {} } function defaultFieldFocus(objFieldId) { - try - { + try { var objField = document.getElementById(objFieldId); - if (objField.className.indexOf("readonly") == -1){ + if (objField.className.indexOf("readonly") == -1) { objField.focus(); } - } catch(e) { + } catch (e) { } } function defaultFieldFocusAndSelect(objFieldId) { - try - { + try { var objField = document.getElementById(objFieldId); - if (objField.className.indexOf("readonly") == -1){ + if (objField.className.indexOf("readonly") == -1) { objField.focus(); - if(objField.type == "text" || objField.type == "textarea"){ + if (objField.type == "text" || objField.type == "textarea") { objField.select(); } } - } catch(e) { - + } catch (e) { + } } -function openFullSizeWindowWithName(pageUrl,scrollbars,windowName){ - var width=screen.availWidth; - var height=document.body.scrollHeight; - var top=0; - var left=0; - var posStatement="top="+top+",left="+left+",width="+width+",height="+height; - var style='menubar=no,location=yes,directories=no,toolbar=no,statusbar=no,resizable=yes,' - +posStatement+",scrollbars="+scrollbars; +function openFullSizeWindowWithName(pageUrl, scrollbars, windowName) { + var width = screen.availWidth; + var height = document.body.scrollHeight; + var top = 0; + var left = 0; + var posStatement = "top=" + top + ",left=" + left + ",width=" + width + ",height=" + height; + var style = 'menubar=no,location=yes,directories=no,toolbar=no,statusbar=no,resizable=yes,' + + posStatement + ",scrollbars=" + scrollbars; var popwin; - if(pageUrl.indexOf('?') > -1){ - var popwin=window.open(pageUrl+'&source=portalPage',windowName,style); - }else { - var popwin=window.open(pageUrl,windowName,style); + if (pageUrl.indexOf('?') > -1) { + pageUrl = encodeURI(pageUrl); + var popwin = window.open(pageUrl + '&source=portalPage', windowName, style); + } else { + pageUrl = encodeURI(pageUrl); + var popwin = window.open(pageUrl, windowName, style); } - - if(popwin == null){ - return false; + + if (popwin == null) { + return false; } - try{ - popwin.moveTo(0,0); - popwin.resizeTo(screen.availWidth,screen.availHeight); - popwin.focus(); - } - catch(e) - {} - return popwin; + try { + popwin.moveTo(0, 0); + popwin.resizeTo(screen.availWidth, screen.availHeight); + popwin.focus(); + } catch (e) {} + return popwin; } -function openFullSizeWindow(pageUrl,scrollbars){ - openFullSizeWindowWithName(pageUrl, scrollbars, "_blank"); +function openFullSizeWindow(pageUrl, scrollbars) { + openFullSizeWindowWithName(pageUrl, scrollbars, "_blank"); } -function autoMaxSize(){ - self.moveTo(0,0); - self.resizeTo(screen.availWidth,screen.availHeight); +function autoMaxSize() { + self.moveTo(0, 0); + self.resizeTo(screen.availWidth, screen.availHeight); } -function showWaitingMessage(){ +function showWaitingMessage() { var waitingMsgStyle = ''; var waitingMsgDiv = '
正在加载,请稍候...
'; document.write(waitingMsgStyle + waitingMsgDiv); obj = document.getElementById("waiting"); - if (obj != null){ + if (obj != null) { obj.style.display = "block"; } } -function hideWaitingMessage(){ + +function hideWaitingMessage() { obj = document.getElementById("waiting"); - if (obj != null){ + if (obj != null) { obj.style.display = "none"; } } -function moveUp(selectFieldId){ - var selectElement = document.getElementById(selectFieldId); - var intIndex = selectElement.selectedIndex; - - if (intIndex>0){ - var temText = selectElement.options[intIndex-1].text; - var temValue = selectElement.options[intIndex-1].value; - - selectElement.options[intIndex-1].text = selectElement.options[intIndex].text; - selectElement.options[intIndex-1].value = selectElement.options[intIndex].value; - - selectElement.options[intIndex].text = temText; - selectElement.options[intIndex].value = temValue ; - - selectElement.options[intIndex-1].selected = true; - selectElement.options[intIndex].selected = false; - } +function moveUp(selectFieldId) { + var selectElement = document.getElementById(selectFieldId); + var intIndex = selectElement.selectedIndex; + + if (intIndex > 0) { + var temText = selectElement.options[intIndex - 1].text; + var temValue = selectElement.options[intIndex - 1].value; + + selectElement.options[intIndex - 1].text = selectElement.options[intIndex].text; + selectElement.options[intIndex - 1].value = selectElement.options[intIndex].value; + + selectElement.options[intIndex].text = temText; + selectElement.options[intIndex].value = temValue; + + selectElement.options[intIndex - 1].selected = true; + selectElement.options[intIndex].selected = false; + } } -function moveDown(selectFieldId){ +function moveDown(selectFieldId) { - var selectElement = document.getElementById(selectFieldId); - var intIndex = selectElement.selectedIndex ; + var selectElement = document.getElementById(selectFieldId); + var intIndex = selectElement.selectedIndex; - if (selectElement.options.length>1 && intIndex=0){ - var temText = selectElement.options[intIndex+1].text; - var temValue = selectElement.options[intIndex+1].value; - - selectElement.options[intIndex+1].text = selectElement.options[intIndex].text; - selectElement.options[intIndex+1].value = selectElement.options[intIndex].value; - - selectElement.options[intIndex].text = temText; - selectElement.options[intIndex].value = temValue; - - selectElement.options[intIndex+1].selected = true; - selectElement.options[intIndex].selected = false; - } + if (selectElement.options.length > 1 && intIndex < selectElement.options.length - 1 && intIndex >= 0) { + var temText = selectElement.options[intIndex + 1].text; + var temValue = selectElement.options[intIndex + 1].value; + + selectElement.options[intIndex + 1].text = selectElement.options[intIndex].text; + selectElement.options[intIndex + 1].value = selectElement.options[intIndex].value; + + selectElement.options[intIndex].text = temText; + selectElement.options[intIndex].value = temValue; + + selectElement.options[intIndex + 1].selected = true; + selectElement.options[intIndex].selected = false; + } } -function addItemToOptions(addItemFieldId, selectFieldId){ +function addItemToOptions(addItemFieldId, selectFieldId) { var addValue = $F(addItemFieldId).Trim(); var selectElement = document.getElementById(selectFieldId); - - if (addValue == ""){ + + if (addValue == "") { alert("新增加值不能为空!"); return false; } - - for(var i=0; i 1 ){ - alert("只能选择一个"+msg+"!"); + if (selAmount > 1) { + alert("只能选择一个" + msg + "!"); return false; } return true; } -function getSelectedTreeNodeId(msg, selectedField){ - var id = document.getElementById(selectedField).value.Trim(); - if(id.Trim()==""){ +function getSelectedTreeNodeId(msg, selectedField) { + var id = document.getElementById(selectedField).value.Trim(); + if (id.Trim() == "") { alert(msg); return ""; } return id; } function inputOnkeyDownEvent(btnId) { - try{ + try { if (event.keyCode == 13) { document.getElementById(btnId).onclick(); return false; } - }catch(e){ + } catch (e) { return false; } return true; } -function isSelectedItem(item, items , sparator){ +function isSelectedItem(item, items, sparator) { - if(items.Trim() == "") return false; - - if( typeof(sparator) == "undefined"){ + if (items.Trim() == "") return false; + + if (typeof(sparator) == "undefined") { sparator = ";"; } var itemsArray = items.split(sparator); - - if( typeof(itemsArray) == "undefined" || typeof(itemsArray.length) == "undefined" ){ - return false; + + if (typeof(itemsArray) == "undefined" || typeof(itemsArray.length) == "undefined") { + return false; } - - for(var i=0; i'); - } catch (e) { - // Probably failed because we’re not running on IE - } - if (!element) { - element = document.createElement(type); - element.name = name; - } - return element; +function createFormElement(type, name) { + var element = null; + + try { + // First try the IE way; if this fails then use the standard way + element = document.createElement('<' + type + ' name="' + name + '">'); + } catch (e) { + // Probably failed because we’re not running on IE + } + if (!element) { + element = document.createElement(type); + element.name = name; + } + return element; } -function createInputElement(id, type, value){ +function createInputElement(id, type, value) { var inputObj = createFormElement("input", id); - if (inputObj != null){ + if (inputObj != null) { inputObj.type = type; inputObj.id = id; inputObj.value = value; - inputObj.style.width="90%"; - inputObj.style.height="20px"; + inputObj.style.width = "90%"; + inputObj.style.height = "20px"; } return inputObj; } -function createReadOnlyInputElement(id, type, value){ +function createReadOnlyInputElement(id, type, value) { var inputObj = createFormElement("input", id); - if (inputObj != null){ + if (inputObj != null) { inputObj.type = type; inputObj.id = id; - inputObj.className="readonly"; + inputObj.className = "readonly"; inputObj.value = value; - inputObj.style.width="90%"; - inputObj.style.height="20px"; + inputObj.style.width = "90%"; + inputObj.style.height = "20px"; } return inputObj; } -function escapeSpecialChar(string){ - if(string) { +function escapeSpecialChar(string) { + if (string) { return string.replace('<', '<').replace('>', '>'); - } - else { + } else { return ""; } } -function createDisplayTextNode(textStr){ - textStr = getDefaultString(textStr, ""); - text = document.createTextNode(textStr); - return text; +function createDisplayTextNode(textStr) { + textStr = getDefaultString(textStr, ""); + text = document.createTextNode(textStr); + return text; } -function getDefaultString(textStr, defaultString){ - if(textStr == null || textStr == "null"){ +function getDefaultString(textStr, defaultString) { + if (textStr == null || textStr == "null") { textStr = defaultString; } return textStr; } -function isBlank(string){ - return string.replace(/(^\s*)(\s*$)/g, ""); - } - - function addSelectedOptionByOne(sourceBoxName, destinationBoxName){ +function isBlank(string) { + return string.replace(/(^\s*)(\s*$)/g, ""); +} + +function addSelectedOptionByOne(sourceBoxName, destinationBoxName) { var items = $Id(destinationBoxName).length; - if(items == 0){ + if (items == 0) { addSelectedOption(sourceBoxName, destinationBoxName); - }else { + } else { alert("只能添加一个"); return false; } } // 拦截聚焦后的聚焦事件 -function feildOnFocus(selfObj){ +function feildOnFocus(selfObj) { var focusCssName = selfObj.className; var selfObjType = selfObj.type; - if((selfObjType=="input" || selfObjType=="text" || selfObjType=="textarea")&& focusCssName.indexOf('form_textfieldonfocus') == -1){ - selfObj.className +=' form_textfieldonfocus'; + if ((selfObjType == "input" || selfObjType == "text" || selfObjType == "textarea") && focusCssName.indexOf('form_textfieldonfocus') == -1) { + selfObj.className += ' form_textfieldonfocus'; selfObj.select(); } } // 拦截聚焦后的离开事件 -function reconvertFieldCss(obj){ - obj.className=obj.className.replace(new RegExp(" form_textfieldonfocus\\b"), ""); +function reconvertFieldCss(obj) { + obj.className = obj.className.replace(new RegExp(" form_textfieldonfocus\\b"), ""); obj.value = obj.value; } // 初始化select -function selectInObj(selectObj,sVal){ - if(selectObj != null){ - for(var i=0;i= 5.5) && (document.body.filters)) - { - for(var j=0; j" ; - img.outerHTML = strNewHTML; - j = j-1; - } - } - } + var arVersion = navigator.appVersion.split("MSIE"); + var version = parseFloat(arVersion[1]); + if ((version >= 5.5) && (document.body.filters)) { + for (var j = 0; j < document.images.length; j++) { + var img = document.images[j]; + var imgName = img.src.toUpperCase(); + if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") { + var imgID = (img.id) ? "id='" + img.id + "' " : ""; + var imgClass = (img.className) ? "class='" + img.className + "' " : ""; + var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "; + var imgStyle = "display:inline-block;" + img.style.cssText; + if (img.align == "left") imgStyle = "float:left;" + imgStyle; + if (img.align == "right") imgStyle = "float:right;" + imgStyle; + if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle; + var strNewHTML = ""; + img.outerHTML = strNewHTML; + j = j - 1; + } + } + } } @@ -1568,265 +1557,269 @@ //str_1 是否大写字母 //str_2 是否小写字母 //str_3 是否数字 -function randomStr(str_0,str_1,str_2,str_3){ - var seed_array=new Array(); - var seedary; - var i; - - seed_array[0]=""; - seed_array[1]= "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; - seed_array[2]= "a b c d e f g h i j k l m n o p q r s t u v w x y z"; - seed_array[3]= "0 1 2 3 4 5 6 7 8 9"; - - if (!str_1&&!str_2&&!str_3){str_1=true;str_2=true;str_3=true;} - - if (str_1){seed_array[0]+=seed_array[1];} - if (str_2){seed_array[0]+=" "+seed_array[2];} - if (str_3){seed_array[0]+=" "+seed_array[3];} - - seed_array[0]= seed_array[0].split(" "); - seedary=""; - for (i=0;i0){ - return ; +function displayElement(idArray, displayOrHidden) { + for (var i = 0; i < idArray.length; i++) { + var currentElement = $Id(idArray[i]); + if (displayOrHidden) { + currentElement.style.display = "inline"; + } else { + currentElement.style.display = "none"; + } } - for(var i=0;i 0) { + return; } + for (var i = 0; i < factArgumentsLength; i++) { + var currentSelectId = arguments[i][0]; + var currentValue = arguments[i][1]; + var currentSelect = $Id(currentSelectId); + for (var j = 0; j < currentSelect.options.length; j++) { + if (currentValue == currentSelect.options[j].value) { + currentSelect.options[j].selected = true; + break; + } + } + } } -function setSelectByText(){ - var factArgumentsLength = arguments.length; - if(!factArgumentsLength>0){ - return ; +function setSelectByText() { + var factArgumentsLength = arguments.length; + if (!factArgumentsLength > 0) { + return; } - for(var i=0;ithis.length){ - return false; - } - if(this.substr(0,str.length)==str){ - return true; - }else { - return false; - } - return true; +String.prototype.startWith = function(str) { + if (str == null || str == "" || this.length == 0 || str.length > this.length) { + return false; + } + if (this.substr(0, str.length) == str) { + return true; + } else { + return false; + } + return true; }; -function setElementStyle(elementToSet,styleObj){ - for(styleName in styleObj ){ - elementToSet.style[styleName] = styleObj[styleName]; - } - } - +function setElementStyle(elementToSet, styleObj) { + for (styleName in styleObj) { + elementToSet.style[styleName] = styleObj[styleName]; + } +} + //创建DOM对象。参数标签名。属性对象,格式为{proName:proValue[,proName:proValue]}。样式对象,格式为{styleName:value[,styleName:value]} -function createCommonElement(tagName,proObj,styleObj){ - if(tagName==null){ - return null; +function createCommonElement(tagName, proObj, styleObj) { + if (tagName == null) { + return null; } - var commonElement = document.createElement(tagName); - if(proObj!=null){ - for(proName in proObj){ - commonElement[proName] = proObj[proName]; - } - } - if(styleObj!=null){ - for(styleName in styleObj ){ - commonElement.style[styleName] = styleObj[styleName]; - } - } - return commonElement; + var commonElement = document.createElement(tagName); + if (proObj != null) { + for (proName in proObj) { + commonElement[proName] = proObj[proName]; + } + } + if (styleObj != null) { + for (styleName in styleObj) { + commonElement.style[styleName] = styleObj[styleName]; + } + } + return commonElement; } -function setElementProperty(elementToSet,proObj){ - for(proName in proObj ){ - elementToSet[proName] = proObj[proName]; - } +function setElementProperty(elementToSet, proObj) { + for (proName in proObj) { + elementToSet[proName] = proObj[proName]; + } } -function createSelectElementByNumber(numberMin,numberMax,proObj,styleObj){ - var selectElement = document.createElement('select'); - for(var i=parseInt(numberMin);i<=numberMax;i++){ - var value = i+''; - var newOption = document.createElement('option'); - var textNode = document.createTextNode(value); - newOption.value = value; - newOption.appendChild(textNode); - selectElement.appendChild(newOption); - } - if(proObj!=null){ - setElementProperty(selectElement,proObj); - } - - if(styleObj!=null){ - setElementStyle(selectElement,styleObj); - } - return selectElement; +function createSelectElementByNumber(numberMin, numberMax, proObj, styleObj) { + var selectElement = document.createElement('select'); + for (var i = parseInt(numberMin); i <= numberMax; i++) { + var value = i + ''; + var newOption = document.createElement('option'); + var textNode = document.createTextNode(value); + newOption.value = value; + newOption.appendChild(textNode); + selectElement.appendChild(newOption); + } + if (proObj != null) { + setElementProperty(selectElement, proObj); + } + + if (styleObj != null) { + setElementStyle(selectElement, styleObj); + } + return selectElement; } -function transform(value){ - var num; - var dig; - if(value.indexOf(".") == -1){num = value;dig = "";} - else{ - num = value.substr(0,value.indexOf("."));dig = value.substr( value.indexOf(".")+1, value.length); - } - var i=1; - var len = num.length; - var dw2 = new Array("","万","亿"); - var dw1 = new Array("拾","佰","千"); - var dw = new Array("","壹","贰","叁","肆","伍","陆","柒","捌","玖"); - var dws = new Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖"); - var k1=0; - var k2=0; - var str=""; - for(i=1;i<=len;i++){ - var n = num.charAt(len-i); - if(n=="0"){ - if(k1!=0) - str = str.substr( 1, str.length-1); - } - str = dw[Number(n)].concat(str); - if(len-i-1>=0){ - if(k1!=3){ - str = dw1[k1].concat(str); - k1++;} - else{ - k1=0; - var temp = str.charAt(0); - if(temp=="万" || temp=="亿") str = str.substr( 1, str.length-1); - str = dw2[k2].concat(str);} - }; - if(k1==3){k2++;} - }; - var strdig=""; - for(i=0;i<2;i++){ - var n=dig.charAt(i); - strdig+=dws[Number(n)];} - if(strdig!='零零')str += " 点 "+strdig; - return str; - } - -function StringUtils(){ +function transform(value) { + var num; + var dig; + if (value.indexOf(".") == -1) { num = value; + dig = ""; } else { + num = value.substr(0, value.indexOf(".")); + dig = value.substr(value.indexOf(".") + 1, value.length); + } + var i = 1; + var len = num.length; + var dw2 = new Array("", "万", "亿"); + var dw1 = new Array("拾", "佰", "千"); + var dw = new Array("", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); + var dws = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); + var k1 = 0; + var k2 = 0; + var str = ""; + for (i = 1; i <= len; i++) { + var n = num.charAt(len - i); + if (n == "0") { + if (k1 != 0) + str = str.substr(1, str.length - 1); + } + str = dw[Number(n)].concat(str); + if (len - i - 1 >= 0) { + if (k1 != 3) { + str = dw1[k1].concat(str); + k1++; + } else { + k1 = 0; + var temp = str.charAt(0); + if (temp == "万" || temp == "亿") str = str.substr(1, str.length - 1); + str = dw2[k2].concat(str); + } + }; + if (k1 == 3) { k2++; } + }; + var strdig = ""; + for (i = 0; i < 2; i++) { + var n = dig.charAt(i); + strdig += dws[Number(n)]; + } + if (strdig != '零零') str += " 点 " + strdig; + return str; } -StringUtils.isNotBlank = function (stringValue){ - if(stringValue!=null&&((stringValue+'').Trim()!='')){ - return true; - } - return false; +function StringUtils() {} + +StringUtils.isNotBlank = function(stringValue) { + if (stringValue != null && ((stringValue + '').Trim() != '')) { + return true; + } + return false; }; -StringUtils.isBlank = function (stringValue){ - if(stringValue!=null&&((stringValue+'').Trim()!='')){ - return false; - } - return true; +StringUtils.isBlank = function(stringValue) { + if (stringValue != null && ((stringValue + '').Trim() != '')) { + return false; + } + return true; }; -StringUtils.defaultIfEmpty = function (str, defaultStr){ - if(StringUtils.isBlank(str)){ - return defaultStr; - } - return str; +StringUtils.defaultIfEmpty = function(str, defaultStr) { + if (StringUtils.isBlank(str)) { + return defaultStr; + } + return str; }; -String.prototype.startWith = function (str){ - if(StringUtils.isBlank(str)){ - return true; - } - if(this.indexOf(str)==0){ - return true; - } - return false; +String.prototype.startWith = function(str) { + if (StringUtils.isBlank(str)) { + return true; + } + if (this.indexOf(str) == 0) { + return true; + } + return false; }; -Date.getDateByString = function (dateStr){ - if(StringUtils.isBlank(dateStr)){ - return null; - } - dateStr +=''; - var year = dateStr.substring(0,4); - var month = dateStr.substring(5,7); - var day = dateStr.substring(8,10); - if(month.startWith('0')){ - month = month.substring(1,2); - } - if(day.startWith('0')){ - day = day.substring(1,2); - } - month = parseInt(month)-1; - - if(dateStr.length == 16){ - var hour = dateStr.substring(11,13); - if(hour.startWith('0')){ - hour = hour.substring(1,2); - } - - var minute = dateStr.substring(14,16); - if(minute.startWith('0')){ - minute = minute.substring(1,2); - } - var dateObj = new Date(year,month,day,hour,minute); - return dateObj; - }else{ - var dateObj = new Date(year,month,day); - return dateObj; - } +Date.getDateByString = function(dateStr) { + if (StringUtils.isBlank(dateStr)) { + return null; + } + dateStr += ''; + var year = dateStr.substring(0, 4); + var month = dateStr.substring(5, 7); + var day = dateStr.substring(8, 10); + if (month.startWith('0')) { + month = month.substring(1, 2); + } + if (day.startWith('0')) { + day = day.substring(1, 2); + } + month = parseInt(month) - 1; + + if (dateStr.length == 16) { + var hour = dateStr.substring(11, 13); + if (hour.startWith('0')) { + hour = hour.substring(1, 2); + } + + var minute = dateStr.substring(14, 16); + if (minute.startWith('0')) { + minute = minute.substring(1, 2); + } + var dateObj = new Date(year, month, day, hour, minute); + return dateObj; + } else { + var dateObj = new Date(year, month, day); + return dateObj; + } }; -Date.prototype.toCommonStr = function (){ - var returnStr = ''; - var year = this.getFullYear(); - var month = this.getMonth(); - var day = this.getDate(); - month = parseInt(month)+1; - if(parseInt(month)<10){ - month = '0'+month; - } - if(parseInt(day)<10){ - day = '0'+day; - } - returnStr = year+'-'+month+'-'+day; - return returnStr; +Date.prototype.toCommonStr = function() { + var returnStr = ''; + var year = this.getFullYear(); + var month = this.getMonth(); + var day = this.getDate(); + month = parseInt(month) + 1; + if (parseInt(month) < 10) { + month = '0' + month; + } + if (parseInt(day) < 10) { + day = '0' + day; + } + returnStr = year + '-' + month + '-' + day; + return returnStr; }; //对Date的扩展,将 Date 转化为指定格式的String @@ -1835,193 +1828,198 @@ //例子: //(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; +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; } -Date.prototype.addMonth = function (m){ - if(StringUtils.isBlank(m)){ - return ; - } - this.setMonth(this.getMonth()+parseInt(m)); +Date.prototype.addMonth = function(m) { + if (StringUtils.isBlank(m)) { + return; + } + this.setMonth(this.getMonth() + parseInt(m)); }; -function getFlowViewTitleByProcessStatus(processStatus){ - var tableTile = ""; - if(!processStatus || processStatus == 'auditing'){ +function getFlowViewTitleByProcessStatus(processStatus) { + var tableTile = ""; + if (!processStatus || processStatus == 'auditing') { tableTile = "审批中"; - } else if(processStatus == 'passed'){ + } else if (processStatus == 'passed') { tableTile = "已批准"; - } else if(processStatus=='denied'){ + } else if (processStatus == 'denied') { tableTile = "已否决"; - } else if (processStatus =='ended'){ + } else if (processStatus == 'ended') { tableTile = "已结束"; - } else if (processStatus == 'onGoing'){ - tableTile = "进行中"; - } else if(processStatus == 'all'){ - tableTile = "全部列表"; + } else if (processStatus == 'onGoing') { + tableTile = "进行中"; + } else if (processStatus == 'all') { + tableTile = "全部列表"; } - + return tableTile; } -function viewObject(o){ - if(o!=null){ - var alertStr = ''; - for(var pn in o){ - alertStr+='\n'+pn+' = '+o[pn]; - } - alert(alertStr); - } +function viewObject(o) { + if (o != null) { + var alertStr = ''; + for (var pn in o) { + alertStr += '\n' + pn + ' = ' + o[pn]; + } + alert(alertStr); + } } -function autoSaveFormSerialNumber(fileName,formName) -{ - formSerialNumber=fileName.value.Trim(); +function autoSaveFormSerialNumber(fileName, formName) { + formSerialNumber = fileName.value.Trim(); - EAMSerialNumberManager.saveFormSerialNumber(formName,formSerialNumber); + EAMSerialNumberManager.saveFormSerialNumber(formName, formSerialNumber); } -function formatExtFieldMoney(f){ - var v = f.getValue(); - if(StringUtils.isNotBlank(v)){ - alert(v); - v= formatMoneyByComma(v); - alert(v); - f.setValue(v); - } - +function formatExtFieldMoney(f) { + var v = f.getValue(); + if (StringUtils.isNotBlank(v)) { + alert(v); + v = formatMoneyByComma(v); + alert(v); + f.setValue(v); + } + } //Ext 屏蔽引号,逗号,句号等特殊符号 function screenSpecialKeyByExt(key, fieldId) { - if(key.getKey() == 222 || key.getKey() == 190 || key.getKey() == 188 || key.getKey() == 192 || key.getKey() == 186 || key.getKey() == 220 || key.getKey() == 191 || key.getKey() == 219 || key.getKey() == 221){ - var nameText = Ext.getCmp(fieldId).getValue(); - nameText = nameText.substring(0, nameText.length-1); - Ext.getCmp(fieldId).setValue(nameText); - } + if (key.getKey() == 222 || key.getKey() == 190 || key.getKey() == 188 || key.getKey() == 192 || key.getKey() == 186 || key.getKey() == 220 || key.getKey() == 191 || key.getKey() == 219 || key.getKey() == 221) { + var nameText = Ext.getCmp(fieldId).getValue(); + nameText = nameText.substring(0, nameText.length - 1); + Ext.getCmp(fieldId).setValue(nameText); + } } //普通页面 屏蔽引号,逗号,句号等特殊符号 function screenSpecialKey() { - try{ - var keyNum = event.keyCode; + try { + var keyNum = event.keyCode; if (keyNum == 222 || keyNum == 190 || keyNum == 188 || keyNum == 192 || keyNum == 186 || keyNum == 220 || keyNum == 191 || keyNum == 219 || keyNum == 221) { return false; } - }catch(e){ + } catch (e) { return false; } return true; } //获取一个cookies的值 -function getCookie(cookie_name){ - var allcookies = document.cookie; - var cookie_pos = allcookies.indexOf(cookie_name); - // 如果找到了索引,就代表cookie存在, - // 反之,就说明不存在。 - if (cookie_pos != -1){ - // 把cookie_pos放在值的开始,只要给值加1即可。 - cookie_pos += cookie_name.length + 1; - var cookie_end = allcookies.indexOf(";", cookie_pos); - if (cookie_end == -1){ - cookie_end = allcookies.length; - } - var value = unescape(allcookies.substring(cookie_pos, cookie_end)); - return value; - } - return null; -} +function getCookie(cookie_name) { + var allcookies = document.cookie; + var cookie_pos = allcookies.indexOf(cookie_name); + // 如果找到了索引,就代表cookie存在, + // 反之,就说明不存在。 + if (cookie_pos != -1) { + // 把cookie_pos放在值的开始,只要给值加1即可。 + cookie_pos += cookie_name.length + 1; + var cookie_end = allcookies.indexOf(";", cookie_pos); + if (cookie_end == -1) { + cookie_end = allcookies.length; + } + var value = unescape(allcookies.substring(cookie_pos, cookie_end)); + return value; + } + return null; +} //写并保存cookies -function setCookie(c_name,value,expiredays){ +function setCookie(c_name, value, expiredays) { //document.cookie = c_name+ "=" + escape(value); - var Days = expiredays ? expiredays : 60; //cookie 将被保存两个月 - var exp = new Date(); //获得当前时间 - exp.setTime(exp.getTime() + Days*24*60*60*1000); //换成毫秒 + var Days = expiredays ? expiredays : 60; //cookie 将被保存两个月 + var exp = new Date(); //获得当前时间 + exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000); //换成毫秒 //document.cookie = c_name+ "=" +escape(value)+ ";expires="+expiredays; document.cookie = c_name + "=" + escape(value) + ";expires=" + exp.toGMTString(); } -function iframeLoad(iframeId,loadUrl){ +function iframeLoad(iframeId, loadUrl) { $Id(iframeId).src = loadUrl; } -function getQueryString(name) -{ - var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i"); - if (reg.test(location.href)) return RegExp.$2.replace(/\+/g, " "); return ""; + +function getQueryString(name) { + var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i"); + if (reg.test(location.href)) return RegExp.$2.replace(/\+/g, " "); + return ""; } -function addZero(str){ - if(str<10){ - return "0"+str; - }else{ +function addZero(str) { + if (str < 10) { + return "0" + str; + } else { return str; } } -function dateObj2String(date){ - if(date == null){ - return ""; - } else { - return (parseInt(date.year) + 1900)+ "-" +addZero(parseInt(date.month,10) + 1) + "-" + addZero(date.date); - } +function dateObj2String(date) { + if (date == null) { + return ""; + } else { + return (parseInt(date.year) + 1900) + "-" + addZero(parseInt(date.month, 10) + 1) + "-" + addZero(date.date); + } } -function myDateFormat(v, p, record){ - if(v == null){ - return ""; - } else { - return v.substring(0,10); - } +function myDateFormat(v, p, record) { + if (v == null) { + return ""; + } else { + return v.substring(0, 10); + } } -function myDateFormatBySecond(v, p, record){ - return v; - if(v == null){ - return ""; - } else { - return v.substring(0,19); - } +function myDateFormatBySecond(v, p, record) { + return v; + if (v == null) { + return ""; + } else { + return v.substring(0, 19); + } } -function myDateFormatByMinute(v, p, record){ - if(v == null){ - return ""; - } else { - return v.substring(0,16); - } +function myDateFormatByMinute(v, p, record) { + if (v == null) { + return ""; + } else { + return v.substring(0, 16); + } } /** * title 默认值 '提示' * pauseTime 默认值 5秒 (自动隐藏时间) */ -function showResult(message,title,pauseTime) { - showResultWithoutSpeak(message,title,pauseTime) - speaker.speak(message); +function showResult(message, title, pauseTime) { + try { + showResultWithoutSpeak(message, title, pauseTime) + speaker.speak(message); + } catch (error) { + + } } // 当前页显示提示信息 -function showResultCurPage(message,title,pauseTime) { - showResultWithoutSpeakCurPage(message,title,pauseTime) +function showResultCurPage(message, title, pauseTime) { + showResultWithoutSpeakCurPage(message, title, pauseTime) speaker.speak(message); } + function showResultExt(result) { - var message = result.message; - top.MsgTip.msgExt(result); + var message = result.message; + top.MsgTip.msgExt(result); speaker.speak(message); } /** @@ -2030,132 +2028,136 @@ * @param title 标题,默认值为'提示' * @param pauseTime 默认值 5秒 (自动隐藏时间) */ -function showResultWithoutSpeak(message,title,pauseTime){ - var tipMsg = ''+message+''; - var tempPauseTime = 5, tempTitle = '提示'; - if(pauseTime){ - tempPauseTime = pauseTime; - } - if(title){ - tempTitle = title; - } - top.MsgTip.msg(tempTitle,tipMsg,true,tempPauseTime); +function showResultWithoutSpeak(message, title, pauseTime) { + var tipMsg = '' + message + ''; + var tempPauseTime = 5, + tempTitle = '提示'; + if (pauseTime) { + tempPauseTime = pauseTime; + } + if (title) { + tempTitle = title; + } + top.MsgTip.msg(tempTitle, tipMsg, true, tempPauseTime); } /** * 语音播报消息 * @param message */ -function speakMessage(message){ +function speakMessage(message) { speaker.speak(message); } // 在当前页信息 -function showResultWithoutSpeakCurPage(message,title,pauseTime){ - var tipMsg = ''+message+''; - var tempPauseTime = 5, tempTitle = '提示'; - if(pauseTime){ - tempPauseTime = pauseTime; - } - if(title){ - tempTitle = title; - } - MsgTip.msg(tempTitle,tipMsg,true,tempPauseTime); +function showResultWithoutSpeakCurPage(message, title, pauseTime) { + var tipMsg = '' + message + ''; + var tempPauseTime = 5, + tempTitle = '提示'; + if (pauseTime) { + tempPauseTime = pauseTime; + } + if (title) { + tempTitle = title; + } + MsgTip.msg(tempTitle, tipMsg, true, tempPauseTime); } -function showWarningDialog(message){ - top.Ext.MessageBox.show({ - title: '警告', - msg: message, - width: 300, - buttons: Ext.MessageBox.OK, - icon: Ext.MessageBox.WARNING - }); + +function showWarningDialog(message) { + top.Ext.MessageBox.show({ + title: '警告', + msg: message, + width: 300, + buttons: Ext.MessageBox.OK, + icon: Ext.MessageBox.WARNING + }); } /** * 用于绑定grid视图某列的onclick事件,则会触发modify函数调用,并传入当前列的值以及record.data对象 * 页面中需要定义 modify(v,data) 函数 */ -function modifyRecord(v, p, record){ - var dataArrStr= Ext.util.JSON.encode(record.data); - -// dataArrStr=dataArrStr.replace(/\"/g,"'");//替换半角双引号为单引号 - dataArrStr = dataArrStr.replace(/\"/g,""");// 双引号转义处理 -// dataArrStr = dataArrStr.replace(/\'/g,"'");// 单引号转义处理 - if (v == '总价' && !record.data.id) { //如果这是最后一行(汇计总金额的)就不给他加修改的链接(陈家儒改) - return v; - } - return "" + v + ""; +function modifyRecord(v, p, record) { + var dataArrStr = Ext.util.JSON.encode(record.data); + + // dataArrStr=dataArrStr.replace(/\"/g,"'");//替换半角双引号为单引号 + dataArrStr = dataArrStr.replace(/\"/g, """); // 双引号转义处理 + // dataArrStr = dataArrStr.replace(/\'/g,"'");// 单引号转义处理 + if (v == '总价' && !record.data.id) { //如果这是最后一行(汇计总金额的)就不给他加修改的链接(陈家儒改) + return v; + } + return "" + v + ""; } -function callModifyFun(v,data){ - if(typeof(isShowPrintBtn) != "undefined"){ - isShowPrintBtn = false; - } - //var record = Ext.util.JSON.decode(r); - modify(v,data); +function callModifyFun(v, data) { + if (typeof(isShowPrintBtn) != "undefined") { + isShowPrintBtn = false; + } + //var record = Ext.util.JSON.decode(r); + modify(v, data); } /** * 是否为正整数 * @param param * @return */ -function isPositiveInteger(param){ - var re = /^[1-9]+[0-9]*$/; - if(!re.test(param)){ - return false; - } - return true; +function isPositiveInteger(param) { + var re = /^[1-9]+[0-9]*$/; + if (!re.test(param)) { + return false; + } + return true; } /** * 密码必须是数字与字母组合,长度不小于8,可有特殊字符 * @param pwd * @return */ -function testPasswordReg(pwd){ - /*simon:update needBeStrongPwdWhenModifyPwd当修改密码时,密码是否一定为强密码*/ - if(sstsConfig.needBeStrongPwdWhenModifyPwd){ - if(pwd.length<6||!/[0-9]+/.test(pwd)||!/[a-zA-Z]+/.test(pwd)){ - return true; - }else{ - return false; - } - }else{ - return false; - } +function testPasswordReg(pwd) { + /*simon:update needBeStrongPwdWhenModifyPwd当修改密码时,密码是否一定为强密码*/ + if (sstsConfig.needBeStrongPwdWhenModifyPwd) { + if (pwd.length < 6 || !/[0-9]+/.test(pwd) || !/[a-zA-Z]+/.test(pwd)) { + return true; + } else { + return false; + } + } else { + return false; + } } -function isfloat(oNum){ - if(!oNum) return false; - var strP=/^\d+(\.\d+)?$/; - if(!strP.test(oNum)) return false; - try{ - if(parseFloat(oNum)!=oNum) return false; - }catch(ex){ - return false; - } - return true; +function isfloat(oNum) { + if (!oNum) return false; + var strP = /^\d+(\.\d+)?$/; + if (!strP.test(oNum)) return false; + try { + if (parseFloat(oNum) != oNum) return false; + } catch (ex) { + return false; + } + return true; } // 不足两位,前面补零 -function timeformat(t){ - if (t < 10){ - t = "0" + t; - } - return t; +function timeformat(t) { + if (t < 10) { + t = "0" + t; + } + return t; } //Speed up calls to hasOwnProperty var hasOwnProperty = Object.prototype.hasOwnProperty; + function isObjEmpty(obj) { // null and undefined are "empty" if (obj == null) return true; // Assume if it has a length property with a non-zero value // that that property is correct. - if (obj.length > 0) return false; - if (obj.length === 0) return true; + if (obj.length > 0) return false; + if (obj.length === 0) return true; // Otherwise, does it have any properties of its own? // Note that this doesn't handle @@ -2209,59 +2211,51 @@ var FileIOModeForAppending = 8; //var enableFileSystemObject = false; // 初始化文件操作对象 -function initFileSystemObject() -{ - if(fso) - { - return; - } - try - { - //enableFileSystemObject在includeExtJsAndCss.jsp中根据session中的值定义 - //这里如果没有引入includeExtJsAndCss.jsp的页面,则会异常,然后进入catch中 - if(enableFileSystemObject == true){ - fso = new ActiveXObject("Scripting.FileSystemObject"); - } - }catch(e) - { - //alert(e.name + ": " + e.message); - // 一般是未添加信任站点,或者安全设置有问题 - fso = null; - //alert('文件系统对象初始化失败,请设置信任站点或调整安全设置!'); - } +function initFileSystemObject() { + if (fso) { + return; + } + try { + //enableFileSystemObject在includeExtJsAndCss.jsp中根据session中的值定义 + //这里如果没有引入includeExtJsAndCss.jsp的页面,则会异常,然后进入catch中 + if (enableFileSystemObject == true) { + fso = new ActiveXObject("Scripting.FileSystemObject"); + } + } catch (e) { + //alert(e.name + ": " + e.message); + // 一般是未添加信任站点,或者安全设置有问题 + fso = null; + //alert('文件系统对象初始化失败,请设置信任站点或调整安全设置!'); + } } //文件操作对象是否初始化成功 -function isFileSystemObjectInitSuccessful() -{ - if(fso != null) - { - return true; - } - return false; +function isFileSystemObjectInitSuccessful() { + if (fso != null) { + return true; + } + return false; } // 文件是否存在 -function isFileExist(fileName){ - initFileSystemObject(); - if(!isFileSystemObjectInitSuccessful()){ - return false; - } - if(fso.FileExists(fileName)){ - return true; - } - return false; +function isFileExist(fileName) { + initFileSystemObject(); + if (!isFileSystemObjectInitSuccessful()) { + return false; + } + if (fso.FileExists(fileName)) { + return true; + } + return false; } // 打开文本文件 -function OpenTextFile(fileName, iomode, create,format) -{ - if(!isFileSystemObjectInitSuccessful()) - { - return null; - } - if(!fso.FileExists(fileName)){ - return null; - } - //alert('OpenTextFile,fileName='+fileName); - return fso.OpenTextFile(fileName, iomode, create,format); +function OpenTextFile(fileName, iomode, create, format) { + if (!isFileSystemObjectInitSuccessful()) { + return null; + } + if (!fso.FileExists(fileName)) { + return null; + } + //alert('OpenTextFile,fileName='+fileName); + return fso.OpenTextFile(fileName, iomode, create, format); } // 读取一行文本 @@ -2270,388 +2264,364 @@ /////////////////////////// 文件操作API /////////////////////////// /////////////////////////// key-value配置API /////////////////////////// //keyValue的map, -function ForgonKeyValueSettings() -{ +function ForgonKeyValueSettings() { } -ForgonKeyValueSettings.prototype.addkeyValueFromLocalFile = function (type,fileName,overWriteExistingItem){ - if(!type || !fileName) - { - return ; - } - var forgonKeyValueMap = this[type]; - if(!forgonKeyValueMap){ - forgonKeyValueMap = this[type] = new ForgonKeyValueMap(); - } - forgonKeyValueMap.addkeyValueFromLocalFile(fileName,overWriteExistingItem); -} -//根据key获取字符串值 -ForgonKeyValueSettings.prototype.getStringValue = function (type,key,defaultValue) -{ - if(!type || !key) - { - return defaultValue; - } - var forgonKeyValueMap = this[type]; - if(forgonKeyValueMap){ - return forgonKeyValueMap.getStringValue(key,defaultValue); - } - - return defaultValue; -} -// key-value形式的参数配置对象,支持从本地ini加载。 +ForgonKeyValueSettings.prototype.addkeyValueFromLocalFile = function(type, fileName, overWriteExistingItem) { + if (!type || !fileName) { + return; + } + var forgonKeyValueMap = this[type]; + if (!forgonKeyValueMap) { + forgonKeyValueMap = this[type] = new ForgonKeyValueMap(); + } + forgonKeyValueMap.addkeyValueFromLocalFile(fileName, overWriteExistingItem); + } + //根据key获取字符串值 +ForgonKeyValueSettings.prototype.getStringValue = function(type, key, defaultValue) { + if (!type || !key) { + return defaultValue; + } + var forgonKeyValueMap = this[type]; + if (forgonKeyValueMap) { + return forgonKeyValueMap.getStringValue(key, defaultValue); + } + + return defaultValue; + } + // key-value形式的参数配置对象,支持从本地ini加载。 var forgonKeyValueSettings = forgonKeyValueSettings || new ForgonKeyValueSettings(); // 从本地加载文件,并解析为key-value形式 // keyValue的map, -function ForgonKeyValueMap() -{ - this.values = new Object(); +function ForgonKeyValueMap() { + this.values = new Object(); } // 从本地文件添加keyValue -ForgonKeyValueMap.prototype.addkeyValueFromLocalFile = function (fileName,overWriteExistingItem) -{ - if(fileName == undefined || fileName == null) - { - return undefined; - } - if(overWriteExistingItem == undefined) - { - overWriteExistingItem = false; - } - var fileHandle = null; - try - { - // 打开文件 - fileHandle = OpenTextFile(fileName, FileIOModeForReading); - if(!fileHandle){ - throw new Error("OpenTextFile Failed!("+fileName+')'); - } - var lineLength = 0; - // 等于号 - var firstEqualSignIndex = -1; - // 分号 - var firstSemicolonIndex = -1; - var keyLength = 0; - var key,value; - // 逐行读取 - while (!fileHandle.AtEndOfStream) - { - key = ''; - value = ''; - var line = fileHandle.ReadLine(); - line = line || ''; - //忽略注释行和空行 - if(line.length == 0 || line.charAt(0) == ';') - { - continue; - } - // 将第一个分号(注释符)后面的内容删除,这样可支持行尾注释 - firstSemicolonIndex = line.indexOf(';'); - if(firstSemicolonIndex != -1) - { - line = line.substring(0,firstSemicolonIndex); - } - lineLength = line.length; +ForgonKeyValueMap.prototype.addkeyValueFromLocalFile = function(fileName, overWriteExistingItem) { + if (fileName == undefined || fileName == null) { + return undefined; + } + if (overWriteExistingItem == undefined) { + overWriteExistingItem = false; + } + var fileHandle = null; + try { + // 打开文件 + fileHandle = OpenTextFile(fileName, FileIOModeForReading); + if (!fileHandle) { + throw new Error("OpenTextFile Failed!(" + fileName + ')'); + } + var lineLength = 0; + // 等于号 + var firstEqualSignIndex = -1; + // 分号 + var firstSemicolonIndex = -1; + var keyLength = 0; + var key, value; + // 逐行读取 + while (!fileHandle.AtEndOfStream) { + key = ''; + value = ''; + var line = fileHandle.ReadLine(); + line = line || ''; + //忽略注释行和空行 + if (line.length == 0 || line.charAt(0) == ';') { + continue; + } + // 将第一个分号(注释符)后面的内容删除,这样可支持行尾注释 + firstSemicolonIndex = line.indexOf(';'); + if (firstSemicolonIndex != -1) { + line = line.substring(0, firstSemicolonIndex); + } + lineLength = line.length; - // 第一个等于号位置 - firstEqualSignIndex = line.indexOf('='); - - // 如果没有等于号,跳过此行 - if(firstEqualSignIndex == -1) - { - continue; - } - // 获取key - key = line.substring(0,firstEqualSignIndex); - // 获取value - if(firstEqualSignIndex < lineLength - 1) - { - value = line.substring(firstEqualSignIndex+1); - } - if(key == ''){ - continue; - } - if(this.values[key] && !overWriteExistingItem){ - // 是否已经存在key - continue; - } - - this.values[key] = value; - //alert('key='+key+',value='+value); - } - }catch(e) - { - //alert(e.message); - }finally - { - if(fileHandle) - { - fileHandle.Close(); - //alert('file closed'); - } - } + // 第一个等于号位置 + firstEqualSignIndex = line.indexOf('='); + + // 如果没有等于号,跳过此行 + if (firstEqualSignIndex == -1) { + continue; + } + // 获取key + key = line.substring(0, firstEqualSignIndex); + // 获取value + if (firstEqualSignIndex < lineLength - 1) { + value = line.substring(firstEqualSignIndex + 1); + } + if (key == '') { + continue; + } + if (this.values[key] && !overWriteExistingItem) { + // 是否已经存在key + continue; + } + + this.values[key] = value; + //alert('key='+key+',value='+value); + } + } catch (e) { + //alert(e.message); + } finally { + if (fileHandle) { + fileHandle.Close(); + //alert('file closed'); + } + } } // 根据key获取值 -ForgonKeyValueMap.prototype.getValue = function (key) -{ - if(key == undefined || key == null) - { - return undefined; - } - return this.values[key]; -} -//根据key获取字符串值 -ForgonKeyValueMap.prototype.getStringValue = function (key,defaultValue) -{ - if(key == undefined || key == null) - { - return defaultValue; - } - var value = this.values[key]; - if(value != undefined) - { - return value; - } - return defaultValue; -} -// 初始化ini配置 +ForgonKeyValueMap.prototype.getValue = function(key) { + if (key == undefined || key == null) { + return undefined; + } + return this.values[key]; + } + //根据key获取字符串值 +ForgonKeyValueMap.prototype.getStringValue = function(key, defaultValue) { + if (key == undefined || key == null) { + return defaultValue; + } + var value = this.values[key]; + if (value != undefined) { + return value; + } + return defaultValue; + } + // 初始化ini配置 var InikeyValueConfig = { - types:[ - { - typeName:'print', - filePath:'C:\\forgon\\config\\printConfig.ini' - } - ] + types: [{ + typeName: 'print', + filePath: 'C:\\forgon\\config\\printConfig.ini' + }] }; -function initKeyValueSettings() -{ - initFileSystemObject(); - // ini - if(InikeyValueConfig && InikeyValueConfig.types){ - for(var i=0;i 0){ - for(var i = 0;i 0) { + for (var i = 0; i < selectedUsersArray.length; i++) { var userStr = selectedUsersArray[i]; - if(userIds == ''){ + if (userIds == '') { userIds = userStr.split('#*')[0]; - }else{ - userIds += ';'+userStr.split('#*')[0]; + } else { + userIds += ';' + userStr.split('#*')[0]; } - if(userNames == ''){ + if (userNames == '') { userNames = userStr.split('#*')[1]; - }else{ - userNames += ';'+userStr.split('#*')[1]; + } else { + userNames += ';' + userStr.split('#*')[1]; } } - userIdsElement.setValue(userIds) ; - userNamesElement.setValue(userNames) ; + userIdsElement.setValue(userIds); + userNamesElement.setValue(userNames); } - }else { + } else { var loop = setInterval(function() { - if(selectedUsersArray.closed) { + if (selectedUsersArray.closed) { clearInterval(loop); var returnValue = selectedUsersArray.returnValue || []; - if (returnValue.length > 0){ - for(var i = 0;i 0) { + for (var i = 0; i < returnValue.length; i++) { var userStr = returnValue[i]; - if(userIds == ''){ + if (userIds == '') { userIds = userStr.split('#*')[0]; - }else{ - userIds += ';'+userStr.split('#*')[0]; + } else { + userIds += ';' + userStr.split('#*')[0]; } - if(userNames == ''){ + if (userNames == '') { userNames = userStr.split('#*')[1]; - }else{ - userNames += ';'+userStr.split('#*')[1]; + } else { + userNames += ';' + userStr.split('#*')[1]; } } - userIdsElement.setValue(userIds) ; - userNamesElement.setValue(userNames) ; + userIdsElement.setValue(userIds); + userNamesElement.setValue(userNames); } - } - },500); + } + }, 500); } } -function dumpObj(obj){ - var msg = ''; - for(var p in obj){ - if(obj.hasOwnProperty(p)){ - var pv = p+'='+obj[p]; - if(msg == ''){ - msg = pv; - }else{ - msg +=','+ pv; - } - } - } - alert(msg); + +function dumpObj(obj) { + var msg = ''; + for (var p in obj) { + if (obj.hasOwnProperty(p)) { + var pv = p + '=' + obj[p]; + if (msg == '') { + msg = pv; + } else { + msg += ',' + pv; + } + } + } + alert(msg); } // string格式:"2010-08-09 01:02:03" -function string2Date(dateString){ - var reggie = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/; - var dateArray = reggie.exec(dateString); - var dateObject = new Date( - (+dateArray[1]), - (+dateArray[2])-1, // Careful, month starts at 0! - (+dateArray[3]), - (+dateArray[4]), - (+dateArray[5]), - (+dateArray[6]) - ); - return dateObject; +function string2Date(dateString) { + var reggie = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/; + var dateArray = reggie.exec(dateString); + var dateObject = new Date( + (+dateArray[1]), + (+dateArray[2]) - 1, // Careful, month starts at 0! + (+dateArray[3]), + (+dateArray[4]), + (+dateArray[5]), + (+dateArray[6]) + ); + return dateObject; } function date2string(date) { var dateStr = padStr(date.getFullYear()) + "-" + - padStr(1 + date.getMonth()) + "-" + - padStr(date.getDate()) + " " + - padStr(date.getHours()) + ":" + - padStr(date.getMinutes()) + ":" + - padStr(date.getSeconds()); + padStr(1 + date.getMonth()) + "-" + + padStr(date.getDate()) + " " + + padStr(date.getHours()) + ":" + + padStr(date.getMinutes()) + ":" + + padStr(date.getSeconds()); return dateStr; } function padStr(i) { return (i < 10) ? "0" + i : "" + i; } // 判断字符串内容看起来是否相等 -function stringLooksEquals(s1,s2){ - if(isUndefinedOrNullOrEmpty(s1) && isUndefinedOrNullOrEmpty(s2)){ -// alert(1) - return true - } - if(s1+'' == s2+''){ -// alert(2) - return true; - } -// alert(3) - return false; +function stringLooksEquals(s1, s2) { + if (isUndefinedOrNullOrEmpty(s1) && isUndefinedOrNullOrEmpty(s2)) { + // alert(1) + return true + } + if (s1 + '' == s2 + '') { + // alert(2) + return true; + } + // alert(3) + return false; } -function emptyStringIfUndefinedOrNull(s){ - if(isUndefinedOrNull(s)){ - return ''; - } - return s; + +function emptyStringIfUndefinedOrNull(s) { + if (isUndefinedOrNull(s)) { + return ''; + } + return s; } /** @@ -2660,11 +2630,10 @@ * @param startTime 开始时间 * @returns {boolean} */ -function checkEtGreaterThanSt(endTime,startTime) { - if (Ext.isIE){ - return Date.parse(endTime.replace(/-/g,'/')) < Date.parse(startTime.replace(/-/g,'/')); - } - else{ +function checkEtGreaterThanSt(endTime, startTime) { + if (Ext.isIE) { + return Date.parse(endTime.replace(/-/g, '/')) < Date.parse(startTime.replace(/-/g, '/')); + } else { return Date.parse(endTime) < Date.parse(startTime); } } @@ -2678,8 +2647,7 @@ var extObj; try { extObj = top.Ext || Ext; - } - catch (error) { + } catch (error) { // 如果Ext2不存在则用Ext4 extObj = top.Ext4 || Ext4; } @@ -2704,11 +2672,11 @@ * @param removeMask */ -function createMask(maskName,msg,target,removeMask) { - if (isUndefinedOrNullOrEmpty(this[maskName])){ +function createMask(maskName, msg, target, removeMask) { + if (isUndefinedOrNullOrEmpty(this[maskName])) { this[maskName] = new Ext.LoadMask(target, { - msg : msg, - removeMask : removeMask ? removeMask : true + msg: msg, + removeMask: removeMask ? removeMask : true }); } } @@ -2719,9 +2687,9 @@ * @param msg 遮罩层显示的提示 * @param target 遮罩层显示的地方 */ -function createExt4Mask(maskName,msg,target) { - if (isUndefinedOrNullOrEmpty(this[maskName]) || this[maskName].isDestroyed || this[maskName].getBubbleTarget() != target){ - this[maskName] = new Ext4.LoadMask({msg:msg,target:target}); +function createExt4Mask(maskName, msg, target) { + if (isUndefinedOrNullOrEmpty(this[maskName]) || this[maskName].isDestroyed || this[maskName].getBubbleTarget() != target) { + this[maskName] = new Ext4.LoadMask({ msg: msg, target: target }); } } @@ -2732,12 +2700,12 @@ * @param separator 分隔符(可选,默认用逗号) * @returns {string} */ -function getRowsPropertiesWithComma(rows,property,separator) { +function getRowsPropertiesWithComma(rows, property, separator) { var properties = ""; separator = separator || ','; - for (i = 0, rowLen = rows.length;i < rowLen ; i++){ + for (i = 0, rowLen = rows.length; i < rowLen; i++) { properties += rows[i].get(property); - if (i != rowLen - 1){ + if (i != rowLen - 1) { properties += separator; } } @@ -2751,12 +2719,12 @@ */ function setFocus(id, delayTime) { var dt = delayTime || 300; - setTimeout(function(){ - try{ + setTimeout(function() { + try { var ipt = document.getElementById(id); ipt.focus(); - }catch(e){} - },dt); + } catch (e) {} + }, dt); } /** @@ -2769,20 +2737,20 @@ function resetComboData(recordConfig, store, setValueObj, extObj) { var data = store.findRecord(recordConfig.property, recordConfig.val); var ext = extObj || top.Ext4; - if (!ext.isEmpty(data)){ + if (!ext.isEmpty(data)) { //注:(这个方法只支持Ext4Js) ext.Object.each(setValueObj, function(id, value) { ext.getCmp(id).setValue(data.get(value)); }); } } -function formartToFixedFloat(v,vfractionDigits) { - if(!isUndefinedOrNullOrEmpty(v)){ - var temp = parseFloat(v); - return temp.toFixed(vfractionDigits); - } - return v; +function formartToFixedFloat(v, vfractionDigits) { + if (!isUndefinedOrNullOrEmpty(v)) { + var temp = parseFloat(v); + return temp.toFixed(vfractionDigits); + } + return v; } //两个数字相加(参数不能为空) @@ -2854,56 +2822,57 @@ /** * 阻止浏览器backspace按钮返回 */ -function banBackSpace(e){ - var ev = e || window.event; - //各种浏览器下获取事件对象 - var obj = ev.relatedTarget || ev.srcElement || ev.target ||ev.currentTarget; - //按下Backspace键 - if(ev.keyCode == 8){ - var tagName = obj.nodeName //标签名称 - //如果标签不是input或者textarea则阻止Backspace - if(tagName!='INPUT' && tagName!='TEXTAREA'){ - return stopIt(ev); - } - var tagType = obj.type.toUpperCase();//标签类型 - //input标签除了下面几种类型,全部阻止Backspace - if(tagName=='INPUT' && (tagType!='TEXT' && tagType!='TEXTAREA' && tagType!='PASSWORD')){ - return stopIt(ev); - } - //input或者textarea输入框如果不可编辑则阻止Backspace - if((tagName=='INPUT' || tagName=='TEXTAREA') && (obj.readOnly==true || obj.disabled ==true)){ - return stopIt(ev); - } - } +function banBackSpace(e) { + var ev = e || window.event; + //各种浏览器下获取事件对象 + var obj = ev.relatedTarget || ev.srcElement || ev.target || ev.currentTarget; + //按下Backspace键 + if (ev.keyCode == 8) { + var tagName = obj.nodeName //标签名称 + //如果标签不是input或者textarea则阻止Backspace + if (tagName != 'INPUT' && tagName != 'TEXTAREA') { + return stopIt(ev); + } + var tagType = obj.type.toUpperCase(); //标签类型 + //input标签除了下面几种类型,全部阻止Backspace + if (tagName == 'INPUT' && (tagType != 'TEXT' && tagType != 'TEXTAREA' && tagType != 'PASSWORD')) { + return stopIt(ev); + } + //input或者textarea输入框如果不可编辑则阻止Backspace + if ((tagName == 'INPUT' || tagName == 'TEXTAREA') && (obj.readOnly == true || obj.disabled == true)) { + return stopIt(ev); + } + } } -function stopIt(ev){ - if(ev.preventDefault ){ - //preventDefault()方法阻止元素发生默认的行为 - ev.preventDefault(); - } - if(ev.returnValue){ - //IE浏览器下用window.event.returnValue = false;实现阻止元素发生默认的行为 - ev.returnValue = false; - } - return false; + +function stopIt(ev) { + if (ev.preventDefault) { + //preventDefault()方法阻止元素发生默认的行为 + ev.preventDefault(); + } + if (ev.returnValue) { + //IE浏览器下用window.event.returnValue = false;实现阻止元素发生默认的行为 + ev.returnValue = false; + } + return false; } /** * 判断某模块是否不在config.js配置的白名单之内,不在返回true,否则返回false * @param sstsConfig sstsConfig对象(即:config.js文件的sstsConfig对象) * @param moduleCode 模块编码 */ function notInWhiteList(sstsConfig, moduleCode) { - var moduleWhiteList = sstsConfig.moduleWhiteList; - var temp = ''; - if (moduleWhiteList && moduleWhiteList.join(';')) { - temp = ';' + moduleWhiteList.join(';') + ';'; - } - - if (temp && temp.indexOf(';' + moduleCode + ';') == -1) { - return true; - } else { - return false; - } + var moduleWhiteList = sstsConfig.moduleWhiteList; + var temp = ''; + if (moduleWhiteList && moduleWhiteList.join(';')) { + temp = ';' + moduleWhiteList.join(';') + ';'; + } + + if (temp && temp.indexOf(';' + moduleCode + ';') == -1) { + return true; + } else { + return false; + } } /** @@ -2912,38 +2881,38 @@ * @param array 元素 */ function existsObjInArray(obj, array) { - if(!obj || !array || array.length == 0){ - return false; - } - for(var i = 0;i < array.length;i++){ - if(array[i] == obj){ - return true; - } - } - return false; + if (!obj || !array || array.length == 0) { + return false; + } + for (var i = 0; i < array.length; i++) { + if (array[i] == obj) { + return true; + } + } + return false; } /** * 验证ext的form表单(暂时没有地方调用) * 仅验证表单内的可见元素(文本框、数字筐、文本域、日历控件、下拉筐等)是否有效(是否符合不允许为空、是否超出最小值与最大值的范围内) * @param formPanel */ -function validateExtFormPanel(formPanel){ - +function validateExtFormPanel(formPanel) { + } /** * 自动补零的函数(先封装好,有需要时再进行调用) * @param value */ -function paddingZero(value,totalLength){ - if(value != null && value.Trim().length >0){ - var lengthOfZero = value.Trim().length; - for(var i = 0; i < totalLength - lengthOfZero ; i++){ - value = '0' + value; - } - } - return value; +function paddingZero(value, totalLength) { + if (value != null && value.Trim().length > 0) { + var lengthOfZero = value.Trim().length; + for (var i = 0; i < totalLength - lengthOfZero; i++) { + value = '0' + value; + } + } + return value; } /** @@ -2952,11 +2921,11 @@ * @returns */ function transformRecords(records) { - var record = records; - if (records && records.length > 0){ - record = records[0]; - } - return record; + var record = records; + if (records && records.length > 0) { + record = records[0]; + } + return record; } function dingxiang_applyIf(object, config) { @@ -2974,45 +2943,45 @@ } //获取颜色的类名 -function getClassNameForColor(rgbVal,info){ +function getClassNameForColor(rgbVal, info) { var rowClassName = ""; var infos = info || ''; - if(rgbVal == "#ff0000"){ - rowClassName = "urgent_red_color"+infos; - }else if(rgbVal == "#ff3300"){ - rowClassName = "urgent_orange_red_color"+infos; - }else if(rgbVal == "#ff6600"){ - rowClassName = "urgent_orange_color"+infos; - }else if(rgbVal == "#ff9900"){ - rowClassName = "urgent_orange_yellow_color"+infos; - }else if(rgbVal == "#ffff00"){ - rowClassName = "urgent_yellow_color"+infos; - }else if(rgbVal == "#99ff00"){ - rowClassName = "urgent_yellow_green_color"+infos; - }else if(rgbVal == "#00ff00"){ - rowClassName = "urgent_green_color"+infos; - }else if(rgbVal == "#00ffff"){ - rowClassName = "urgent_blue_green_color"+infos; - }else if(rgbVal == "#0000ff"){ - rowClassName = "urgent_blue_color"+infos; - }else if(rgbVal == "#6600ff"){ - rowClassName = "urgent_blue_purple_color"+infos; - }else if(rgbVal == "#ff00ff"){ - rowClassName = "urgent_purple_color"+infos; - }else if(rgbVal == "#ff0066"){ - rowClassName = "urgent_purple_red_color"+infos; - }else{ - rowClassName = "my_row_white"; - } - return rowClassName; + if (rgbVal == "#ff0000") { + rowClassName = "urgent_red_color" + infos; + } else if (rgbVal == "#ff3300") { + rowClassName = "urgent_orange_red_color" + infos; + } else if (rgbVal == "#ff6600") { + rowClassName = "urgent_orange_color" + infos; + } else if (rgbVal == "#ff9900") { + rowClassName = "urgent_orange_yellow_color" + infos; + } else if (rgbVal == "#ffff00") { + rowClassName = "urgent_yellow_color" + infos; + } else if (rgbVal == "#99ff00") { + rowClassName = "urgent_yellow_green_color" + infos; + } else if (rgbVal == "#00ff00") { + rowClassName = "urgent_green_color" + infos; + } else if (rgbVal == "#00ffff") { + rowClassName = "urgent_blue_green_color" + infos; + } else if (rgbVal == "#0000ff") { + rowClassName = "urgent_blue_color" + infos; + } else if (rgbVal == "#6600ff") { + rowClassName = "urgent_blue_purple_color" + infos; + } else if (rgbVal == "#ff00ff") { + rowClassName = "urgent_purple_color" + infos; + } else if (rgbVal == "#ff0066") { + rowClassName = "urgent_purple_red_color" + infos; + } else { + rowClassName = "my_row_white"; + } + return rowClassName; } /** * 处理url参数部分特殊符号 * @param param * @returns */ -function deocdeUrlParam(param){ - return param.replace(/\%/g,'%25').replace(/\#/g,'%23').replace(/\+/g,'%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F').replace(' ','+').replace(/\?/g,'%3F').replace(/\&/g,'%26').replace(/\=/g,'%3D') +function deocdeUrlParam(param) { + return param.replace(/\%/g, '%25').replace(/\#/g, '%23').replace(/\+/g, '%2B').replace(/\"/g, '%22').replace(/\'/g, '%27').replace(/\//g, '%2F').replace(' ', '+').replace(/\?/g, '%3F').replace(/\&/g, '%26').replace(/\=/g, '%3D') } /** * 多选下拉框全选处理 @@ -3021,31 +2990,30 @@ * @param index 值下标 * @param nameOfFiled 显示值字段名 */ -function onAllChoosedOrNotCom(combo, record,index,nameOfFiled){ - var choose = record.get(combo.checkField); - var fristRecord = combo.store.getAt(0); - if(index != 0){ - if(!choose) { - fristRecord.set(combo.checkField, false); - combo.setValue(combo.getCheckedValue()); - }else{ - var isAllChoosed = true; - combo.store.each(function (thisRecord) - { - if(thisRecord.get(nameOfFiled) != ('全部') && !thisRecord.get(combo.checkField)){ - isAllChoosed = false; - } - }); - if(isAllChoosed){ - fristRecord.set(combo.checkField, true); - combo.setValue(combo.getCheckedValue()); - } - } - return; - } - if(choose){ - combo.selectAll(); - }else{ - combo.deselectAll(); - } +function onAllChoosedOrNotCom(combo, record, index, nameOfFiled) { + var choose = record.get(combo.checkField); + var fristRecord = combo.store.getAt(0); + if (index != 0) { + if (!choose) { + fristRecord.set(combo.checkField, false); + combo.setValue(combo.getCheckedValue()); + } else { + var isAllChoosed = true; + combo.store.each(function(thisRecord) { + if (thisRecord.get(nameOfFiled) != ('全部') && !thisRecord.get(combo.checkField)) { + isAllChoosed = false; + } + }); + if (isAllChoosed) { + fristRecord.set(combo.checkField, true); + combo.setValue(combo.getCheckedValue()); + } + } + return; + } + if (choose) { + combo.selectAll(); + } else { + combo.deselectAll(); + } } \ No newline at end of file