`

ExtJs含高级查询的Window

 
阅读更多
Ext.ns("CompositeTestGradeCollectView");
var expMode = 0;// 导出模式 0用模糊搜索条件 1用高级查询条件
CompositeTestGradeCollectView = Ext.extend(Ext.Viewport, {
			searchPanel : null,
			advSearchPanel : null,
			gridPanel : null,
			store : null,
			topbar : null,
			constructor : function(a) {
				Ext.applyIf(this, a);
				this.initUIComponents();
				CompositeTestGradeCollectView.superclass.constructor.call(this, {
							id : "CompositeTestGradeCollectView", 
							title : "",
							iconCls : "menu-employee",
							layout : "border",
							items : [this.searchPanel, this.gridPanel]
						});
			},
			initUIComponents : function() {
				this.advSearchPanel = new Ext.Window({
							id : "CompositeTestGradeCollectSearchWin",
							title : '高级查询',
							width : 300,
							autoHeight : true,
							closeAction : 'hide',
							listeners : {
								show : function(w) {// 添加淡出效果
									w.getEl().fadeIn({
												endOpacity : 1,
												easing : 'easeOut',
												duration : .4
											})
								}
							},
							items : new Ext.FormPanel({
										id : 'AdvanceSearchForm',
										layout : 'form',
										items : [{
													xtype : "numberfield",
													fieldLabel : '年度',
													name : "filter_LIKES_label"
												}, {
													xtype : "textfield",
													fieldLabel : '合格分数线',
													name : "filter_LIKES_satisfactoryGrade"
												},{
													xtype : "datefield",
													fieldLabel : '首考日期',
													format : 'Y-m-d',
													width : 128,
													name : "filter_LIKES_skDate1"
												},{
													xtype : "datefield",
													fieldLabel : '补考1日期',
													format : 'Y-m-d',
													width : 128,
													name : "filter_LIKES_bkDate1"
												},{
													xtype : "datefield",
													fieldLabel : '补考2日期',
													format : 'Y-m-d',
													width : 128,
													name : "filter_LIKES_bkDate2"
												}],
										buttons : [{
													xtype : "button",
													split : true,
													text : "查询",
													iconCls : "btn-search",
													handler : function() {
														expMode = 1;
														var c = Ext.getCmp("AdvanceSearchForm");
														var d = Ext.getCmp("TrainingRecGrid");
														if (c.getForm().isValid()) {
															$search({
																		searchPanel : c,
																		gridPanel : d
																	});
														}
													}
												}, {
													xtype : "button",
													split : true,
													text : "重置",
													iconCls : "btn-reset",
													handler : function() {
														var c = Ext.getCmp("AdvanceSearchForm");
														c.getForm().reset();
													}
												}, {
													xtype : "button",
													split : true,
													text : "导出",
													iconCls : "btn-xls",
													handler : function() {
														var c = Ext.getCmp("AdvanceSearchForm");
														var d = Ext.getCmp("TrainingRecGrid");
														var expnum = Ext.getCmp("expnum");
														if (c.getForm().isValid() && expnum.isValid()) {
															$export({
																		expnum : expnum.getValue(),
																		searchPanel : c,
																		gridPanel : d,
																		url : _ctxPath + "exam/composite-test-grade!exportXLS.action"
																	});
														}
													}
												}]
									})

						});
				this.searchPanel = new Ext.FormPanel({
							height : 35,
							region : "north",
							frame : false,
							layoutConfig : {
								padding : "5",
								align : "middle"
							},
							id : "AdvanceSearchForm",
							layout : "hbox",
							defaults : {
								xtype : "label",
								border : false,
								margins : {
									top : 2,
									right : 4,
									bottom : 2,
									left : 4
								}
							},
							items : [{
										xtype : "textfield",
										emptyText : '请输入年度或首考日期',
										name : "filter_LIKES_nDyear_OR_skDate1",
										cls : 'sech_pane',
										width: 160
									}, {
										xtype : "splitbutton",
										split : true,
										text : "查询",
										iconCls : "btn-search",
										arrowTooltip : '高级查询',
										handler : function() {
											var c = Ext.getCmp("AdvanceSearchForm");
											var d = Ext.getCmp("CompositeTestGradeCollectGrid");
											if (c.getForm().isValid()) {
												$search({
															searchPanel : c,
															gridPanel : d
														});
											}
										},
										arrowHandler : function(b, e) {
											var win = Ext.getCmp("CompositeTestItemSearchWin");
											win.setPagePosition(e.xy[0], e.xy[1] + 15);// 设置窗口显示的位置为当前按钮出位置
											if (!win.isVisible()) {
												win.show();
											} else {
												win.hide();
											}

										}
									}]
						});

				this.store = new Ext.data.Store({
							proxy : new Ext.data.HttpProxy({
										url : __ctxPath + "exam/composite-test-grade-collect!list.action?op=ajax"
									}),
							reader : new Ext.data.JsonReader({
										//root : "result",
										totalProperty : "totalCount",
										id : "id",
										fields : [{
													name : "id",
													type : "int"
												}, "ndyear","label","policeName","sex","birth","police_no","deptName","kcOrder","khDate","unit","score","grade","passed"]
									}),
							remoteSort : true
						});
				this.store.setDefaultSort("id", "ASC");
				this.store.load({
							params : {
								start : 0,
								limit : 25
							}
						});
				var b = new Ext.grid.CheckboxSelectionModel();
				var a = new Ext.grid.ColumnModel({
							columns : [b, new Ext.grid.RowNumberer(), {
										header : "体能技能达标测试成绩汇总id",
										dataIndex : "id",
										hidden : true
									}, 										
									{
										header : "年度",
										dataIndex : "ndyear",
										width : 100
									}, {
										header : "测试项目名称",
										dataIndex : "label",
										width : 150,
										renderer : function(v) {
											if(v == 'null') {
												return '';
											}else {
												return v;
											}
										}
									},{
										header : "参加测试人",
										dataIndex : "policeName",
										width : 100
									},{
										header : "性别",
										dataIndex : "sex",
										width : 50,
										renderer : function(v) {
											if(v != 'null') {
												if(v == '0') {
													return '男';
												}else if(v == '1') {
												    return '女';
												}
											}else {
												return '';
											}
										}
									},{
										header : "年龄",
										dataIndex : "birth",
										width : 50,
										renderer : function(v) {
											if(v != null) {
												 return parseInt(new Date().format('Y').toString()) - parseInt(v.substr(0, 4));
											}else {
												return '';
											}
										}
									}, {
										header : "警号",
										dataIndex : "police_no",
										width : 150
									}, {
										header : "所在单位",
										dataIndex : "deptName",
										width : 180
									}, {
										header : "考次",
										dataIndex : "kcOrder",
										width : 50,
										renderer : function(v) {
											if(v == '0') {
												return '首考';
											}else if(v == '1') {
												return '补考1';
											}else if(v == '2') {
												return '补考2';											
											}
										}
									},{
										header : "考核日期",
										dataIndex : "khDate",
										width : 80
									},{
										header : "计分单位",
										dataIndex : "unit",
										width : 80,
										renderer : function(v) {
											if(v == 'null') {
												return '';
											}else {
												return v;
											}
										}
									},{
										header : "计分",
										dataIndex : "score",
										width : 50,
										renderer : function(v) {
											if(v == 'null') {
												return '';
											}else {
												return v;
											}
										}
									},{
										header : "换算分值",
										dataIndex : "grade",
										width : 80,
										renderer : function(v) {
											if(v == 'null') {
												return '';
											}else {
												return v;
											}
										}
									},{
										header : "是否合格",
										dataIndex : "passed",
										width : 80,
										renderer : function(v) {
											if(v != 'null') {
												if(v == '0') {
													return '不合格';
												}else if(v == '1') {
													return '合格';
												}
											}
										} 
									},{
										header : "总分",
										dataIndex : "",
										width : 200
									},{
										header : "最终结果",
										dataIndex : "",
										width : 200
									}
									],
							defaults : {
								sortable : true,
								menuDisabled : false,
								width : 100
							}
						});

				this.gridPanel = new Ext.grid.EditorGridPanel({
							id : "CompositeTestItemGrid",
							region : "center",
							title : "",
							tbar : this.topbar(),
							store : this.store,
							trackMouseOver : true,
							disableSelection : false,
							loadMask : true,
							cm : a,
							sm : b,
							viewConfig : {
								forceFit : false,
								enableRowBody : false,
								showPreview : false
							},
							bbar : new HT.PagingBar({
										id : 'pagebar',
										store : this.store
									})
						});
			}
		});

CompositeTestGradeCollectView.prototype.topbar = function() {
	var a = new Ext.Toolbar({
				id : "CompositeTestItemFootBar",
				height : 30,
				bodyStyle : "text-align:left",
				items : []
			});
	if (isGranted("_CompositeTestItemExp")) {
		a.add(new Ext.Button({
					iconCls : "btn-xls",
					text : "导出excel",
					handler : function() {
						if (expMode == 0) {
							var c = Ext.getCmp("CompositeTestItemForm");
						} else {
							var c = Ext.getCmp("CompositeTestItemForm");

						}
						var d = Ext.getCmp("TrainingRecGrid");
						var expnum = Ext.getCmp("expnum");
						if (c.getForm().isValid() && expnum.isValid()) {
							$export({
										expnum : expnum.getValue(),
										searchPanel : c,
										gridPanel : d,
										url : _ctxPath + "exam/composite-test-item!exportXLS.action"
									});
						}
					}
				}));
		a.add({
					xtype : 'tbtext',
					text : "条数"
				}, {
					xtype : "numberfield",
					id : 'expnum',
					name : "expnum",
					value : 100,
					width : 35
				});
	}
	return a;
};
CompositeTestGradeCollectView.remove = function(b) {
	var b = [b];
	var a = Ext.getCmp("CompositeTestItemGrid");
	Ext.Msg.confirm("信息确认", "您确认要删除该记录吗?", function(c) {
				if (c == "yes") {
					Ext.Ajax.request({
								url : __ctxPath + "exam/composite-test-item!delete.action",
								params : {
									op : 'ajax',
									ids : b.join()
								},
								method : "post",
								success : function(response, options) {
									var res = Ext.util.JSON.decode(response.responseText);
									if (res.success) {
										Ext.Msg.alert('操作信息', res.message);
										a.getStore().reload();
									} else {
										Ext.Msg.alert('操作信息', '删除失败' + res.message);
									}
								},
								failure : function(response, options) {
									Ext.Msg.alert('操作信息', res.message);
								}
							});
				}
			});
};
CompositeTestGradeCollectView.edit = function(a) {
	new AbilityTestItemForm({
				trainingRecId : a
			}).show();
};
CompositeTestGradeCollectView.Skan = function(a) {
	new AbilityTestItemForm({
				compositeTestItemId : a,
				compositeTestItemSkanFlag: 1
			}).show();
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics