Index: ssts-web/src/main/webapp/disinfectsystem/reportforms/tousseDeliverStatisticsView.js =================================================================== diff -u -r12331 -r14535 --- ssts-web/src/main/webapp/disinfectsystem/reportforms/tousseDeliverStatisticsView.js (.../tousseDeliverStatisticsView.js) (revision 12331) +++ ssts-web/src/main/webapp/disinfectsystem/reportforms/tousseDeliverStatisticsView.js (.../tousseDeliverStatisticsView.js) (revision 14535) @@ -24,9 +24,6 @@ window.open(WWWROOT+"/jasperreports/jasperreportsAction!createJasperPrint.do?jasperreportName=tousseDeliverStatistics.jasper&startDay="+startTime+"&endDay="+endTime+"&reportName=tousseDeliverStatistics",'thisIframe','_self'); } - var dt = new Date(); - var startDayofMonth = dt.getFullYear() + "/" + (dt.getMonth() + 1) + "/01"; - var form = new Ext.form.FormPanel({ title : '器械包发货统计报表', region : 'north', @@ -62,7 +59,7 @@ altFormats:'Y-m-d|Y-n-j|y-n-j|y-m-j|y-m-d|y-n-d|Y-n-d|Y-m-j|Ymd|Ynj|ynj|ymj|ymd|ynd|Ynd|Ymj|Y/m/d|Y/n/j|y/n/j|y/m/j|y/m/d|y/n/d|Y/n/d|Y/m/j', allowBlank : false, anchor : '95%', - value: new Date(startDayofMonth), + value: new Date(), listeners : { specialkey : function(field, e) { if (e.getKey() == Ext.EventObject.ENTER) { @@ -149,7 +146,7 @@ autoScroll:true,//自动显示滚动条 collapsible:true,//允许展开和收缩 bodyPadding:5, - html:'' + html:'' }); @@ -162,5 +159,20 @@ items : reportForm }] }); - + + Ext.Ajax.request({ + url : WWWROOT + '/system/serverTimeAction!getServerDateTime.do', + params:{dateformat:"yyyy/MM/dd"}, + success : function(response, options) { + var result = Ext.decode(response.responseText); + if(result.success){ + var servertime = result.serverTime; + Ext.getCmp('startTime').setValue(new Date(servertime)); + Ext.getCmp('endTime').setValue(new Date(servertime)); + reloadReport(); + } + }, + failure : function(response, options) { + } + }); }); \ No newline at end of file Index: forgon-core/src/main/java/com/forgon/servertime/action/ServerTimeAction.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/servertime/action/ServerTimeAction.java (revision 0) +++ forgon-core/src/main/java/com/forgon/servertime/action/ServerTimeAction.java (revision 14535) @@ -0,0 +1,47 @@ +package com.forgon.servertime.action; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; + +import net.sf.json.JSONObject; + +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.ParentPackage; + +import com.forgon.Constants; +import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.json.JSONUtil; + +/** + * 服务器时间的action + * @author kzh + * + */ +@ParentPackage(value = "default") +@Namespace(value = "/system") +@Action(value = "serverTimeAction") +public class ServerTimeAction { + public void getServerDateTime(){ + try{ + String dateformat = StrutsParamUtils.getPraramValue("dateformat", Constants.DATEFORMAT_YYYYMMDDHHMMSS); + DateFormat df = null; + try{ + df = new SimpleDateFormat(dateformat); + }catch(Exception e){ + dateformat = Constants.DATEFORMAT_YYYYMMDDHHMMSS; + df = Constants.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS; + } + String serverTime = df.format(Calendar.getInstance().getTime()); + JSONObject json = JSONUtil.buildJsonObject(true); + JSONUtil.addProperty(json, "serverTime",serverTime); + JSONUtil.addProperty(json, "timeFormat",dateformat); + StrutsResponseUtils.output(json); + }catch(Exception ex){ + ex.printStackTrace(); + } + StrutsResponseUtils.output(false); + } +} Index: forgon-core/src/main/java/com/forgon/Constants.java =================================================================== diff -u -r14519 -r14535 --- forgon-core/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 14519) +++ forgon-core/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 14535) @@ -30,6 +30,8 @@ public final static String DATEFORMAT_YYYYMMDD = "yyyy-MM-dd"; + public final static String DATEFORMAT_YYYYMMDDHHMMSS = "yyyy-MM-dd HH:mm:ss"; + public final static SimpleDateFormat SIMPLEDATEFORMAT_YYYYMMDDHHMMSS = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); public final static SimpleDateFormat SIMPLEDATEFORMAT_YYYYMMDDHHMM = new SimpleDateFormat(