Index: ssts-web/src/main/webapp/js/common.js =================================================================== diff -u -r14689 -r14777 --- ssts-web/src/main/webapp/js/common.js (.../common.js) (revision 14689) +++ ssts-web/src/main/webapp/js/common.js (.../common.js) (revision 14777) @@ -54,7 +54,40 @@ } }); } +/** + * 获取服务器时间 + * @param format 时间格式 + * @param extObj Ext对象,暂时有top.Ext,top.Ext4,Ext + * @param fieldId 要设置时间区域的id + * @param myFn 自定义的方法(可选) + */ +function getServerTime(format,extObj,fieldId,myFn) { + extObj.Ajax.request({ + url : WWWROOT + '/system/serverTimeAction!getServerDateTime.do', + params : {dateformat : format}, + success : function(response, options) { + var result = extObj.decode(response.responseText); + if(result.success){ + var serverTime = result.serverTime; + // 如果有自定义的方法则执行自定义方法,否则执行默认的方法 + myFn ? myFn(serverTime) : setFieldTime(extObj,fieldId,serverTime); + } + }, + failure : function(response, options) { + alert('获取服务器时间失败'); + } + }); +} +/** + * 对应的区域设置时间 + * @param extObj Ext对象 + * @param fieldId 要设置时间区域的id + * @param time 要设定的时间 + */ +function setFieldTime(extObj,fieldId,time) { + extObj.getCmp(fieldId).setValue(time); +} function uniteTwoStringBySemicolon(targetString,addString,separator) { if(typeof(separator) == "undefined" || separator == "" ){