Index: ssts-web/src/main/webapp/js/common.js =================================================================== diff -u -r14650 -r14689 --- ssts-web/src/main/webapp/js/common.js (.../common.js) (revision 14650) +++ ssts-web/src/main/webapp/js/common.js (.../common.js) (revision 14689) @@ -1,8 +1,61 @@ +$refreshStartDateHandle = null; //定时器的句柄(陈家儒改) +$lastTime = 0; //定时器的上一分钟的时间戳 var bPageModified=false; var wheight=window.screen.height-60; var wwidth=window.screen.width; var openReturnValue=""; var webCtxRoot = ''; + +/** + * 实现刷新时间的方法,并且判断了用户是否手动修改了时间,如果是,则清除定时器(陈家儒改) + * @param datefieldWithMinId: 时间选项框的id + * @param refreshFrequency: 时间刷新的频率 + * + */ +function refreshTime(datefieldWithMinId, refreshFrequency) { + var time = top.Ext.getCmp(datefieldWithMinId).getValue().getTime(); + if (time == $lastTime) { +// if (refreshFrequency) { //测试用的 +// $lastTime = time + 60000; +// } + $lastTime = time + refreshFrequency; + top.Ext.getCmp(datefieldWithMinId).setValue(new Date($lastTime)); + } else { //如果上一分钟和下一分钟的时间戳不一样,清除定时器 + clearInterval($refreshStartDateHandle); + } +} + + +/** + * 设置"开始时间"的方法,以服务器的时间为准(陈家儒改) + * @param format: 时间的格式 + * @param datefieldWithMinId: 时间选项框的id + * @param refreshFrequency: 时间刷新的频率 + * @param refresh: 是否需要刷新 + * + */ +function setStartDate(format, datefieldWithMinId, refreshFrequency, refresh) { + Ext.Ajax.request({ + url : WWWROOT + '/system/serverTimeAction!getServerDateTime.do', + params : {dateformat : format}, + success : function(response, options) { + var result = Ext.decode(response.responseText); + if(result.success){ + var serverTime = result.serverTime; + top.Ext.getCmp(datefieldWithMinId).setValue(new Date(serverTime)); + $lastTime = top.Ext.getCmp(datefieldWithMinId).getValue().getTime(); + if (refresh) { + $refreshStartDateHandle = setInterval("refreshTime('" + datefieldWithMinId + "', " + refreshFrequency + ")", refreshFrequency); + } + } + }, + failure : function(response, options) { + alert('获取服务器时间失败'); + } + }); +} + + function uniteTwoStringBySemicolon(targetString,addString,separator) { if(typeof(separator) == "undefined" || separator == "" ){ separator = ";" ;