Extjs form提交時間段,監聽時間控制元件的select事件
阿新 • • 發佈:2018-12-30
DateForm = Ext.extend(Ext.ux.Form,{ taskIds:[], //存放批量任務 constructor: function(){ this.dateStart = this.createDateField('<font color="red">*</font>開始日期', 'dateStart','Ymd', '95%'); this.dateEnd = this.createDateField('<font color="red">*</font>結束日期','dateEnd','Ymd', '95%'); // var paramPk =[{'id':'0', 'name':'0'},{'id':'1', 'name':'1'}]; this.paramPk = this.createMemoryCombo('PK值','id','name','95%',paramPk, 'paramPk');//自定義下拉框值 this.paramPk.allowBlank = false; this.paramPk.store.load(); this.dateStart.setMaxValue(new Date()); this.dateEnd.setMaxValue(new Date()); this.dateStart.on('select',function(e){ var beginTime = taskGrid.dateWindow.dateForm.dateStart.getValue().format("Y-m-d"); taskGrid.dateWindow.dateForm.dateEnd.setMinValue(beginTime); }); this.dateEnd.on('select',function(e){ var endTime = taskGrid.dateWindow.dateForm.dateEnd.getValue().format("Y-m-d"); taskGrid.dateWindow.dateForm.dateStart.setMaxValue(endTime); }); this.dateStart.allowBlank = false; this.dateEnd.allowBlank = false; DateForm.superclass.constructor.call(this, { anchor: '90%', autoHeight:true, labelWidth: 60, labelAlign :'right', frame: true, bodyStyle:"padding: 3px 3px 0", layout: 'tableform', layoutConfig: {columns:3}, items:[ this.dateStart,this.dateEnd,this.paramPk ], buttonAlign :'center', buttons: [ {text: '確定', width: 20,iconCls: 'save', hidden: false,handler:this.DateFormClick,scope:this}, {text: '關閉', width: 20,iconCls:'delete', handler: this.onCloseClick, scope: this} ] }); }, DateFormClick:function(){ // var taskId = this.taskId.getValue(); // var dateStr = this.date_.getValue(); var paramPk = this.paramPk.getValue(); if(this.getForm().isValid()){ this.getForm().submit({ waitMsg: '正在提交資料...', url: '/etl/task/doEtlTaskSched', method: 'POST', params:{taskIds:this.taskIds,paramPk:paramPk}, success: function(form,action){ Ext.MessageBox.alert("系統提示:",BLANKSTR+"新增成功!"+BLANKSTR); // this.dateWindow().ownerCt.hide(); }, failure: function(form,action){ Ext.MessageBox.alert("系統提示:",BLANKSTR+"新增失敗!"+BLANKSTR); this.getForm().ownerCt.hide(); } }); } }, onCloseClick:function(){ this.ownerCt.hide(); } });
/******************Java後臺接收*************************/
@RequestMapping(value = "/doEtlTaskSched", method = RequestMethod.POST) @ResponseBody public ResponseData doEtlTaskSched(Integer[] taskIds, String dateStart,String dateEnd,Integer paramPk) { taskSchedService.doEtlTaskSched(taskIds, dateStart,dateEnd,paramPk); return ResponseData.SUCCESS_NO_DATA; }