Ext.define('Ext.ux.YearComboBox', { extend: 'Ext.form.ComboBox',
alias: 'widget.yearComboBox', addCode: 1,//显示栏是否显示区域编码 1:显示;0:不显示 initComponent: function(){ function initData(yearFrom, Length) { var arr = new Array(); for (var j = 0; j <= Length; j++) { arr[j] = { key : (yearFrom + j).toString(), value: (yearFrom + j).toString() } } return arr; } var dataStore = Ext.create('Ext.data.JsonStore', { fields : ['key', 'value'], data : initData(2013, 20) }); Ext.apply(this, { listConfig : { emptyText : '未找到匹配值', maxHeight : 120 }, triggerAction : 'all', store : dataStore, displayField : 'value',// 定义要显示的字段 valueField : 'key', queryMode : 'local', forceSelection : true, typeAhead : true }); this.superclass.initComponent.apply(this, arguments); } });
/**
* 单位信息列表 * 过滤条件:登录用户相关信息 * 1、S:管理员 --> 区域编码 * 2、E:企业用户 --> 所属企业编码 */ Ext.define('Ext.ux.unitCombo', { extend: 'Ext.form.ComboBox', alias: 'widget.unitCombo', userType: UserDetails.type,//用户类别 attrCoding: UserDetails.attrCoding,//单位所属区域 dataStore: null, initComponent: function(){ this.dataStore = new Ext.data.JsonStore({// 根据id,name动态读取 fields : ['key', 'value'], proxy : { type : 'ajax', url : '../dc/Dc04Action!getUnitData.action?userType='+this.userType, method : 'post', reader : { root : 'data' } }, method : 'post' }); this.dataStore.load({ params: { attrCoding: this.attrCoding } }); Ext.apply(this, { listConfig : { emptyText : '未找到匹配值', maxHeight : 120 }, triggerAction : 'all', store : this.dataStore, displayField : 'value',// 定义要显示的字段 valueField : 'key', queryMode : 'local', forceSelection : true, typeAhead : true }); this.superclass.initComponent.apply(this, arguments); } });//打印报表:【src:action路径】【 params:参数】 //【frameHeight:Iframe高度】【frameWidth:Iframe宽度】 function CommPrintReport(src, params, frameHeight, frameWidth) { var paramStr = src; if (null != params) { Ext.each(params, function(items, index) { if (index > 0) { paramStr += '&'; } else if (index == 0) { paramStr += '?'; } paramStr += items.key + '=' + items.value; }); } var StrPrint = '<Iframe height = ' + frameHeight + ' width = ' + frameWidth + ' src="' + paramStr + '"></iframe>';
return StrPrint;
};// 3.产生报表页面
var RptHtml = CommPrintReport( '../rpt/Rp_dv01Action!PrintReportData.action',params, reportHeight, reportWidth); // 4.通过模板映射到web页面的div var TptTpl = new Ext.XTemplate(RptHtml); TptTpl.overwrite('id_rpt_dv01');
//报表导出:【src:action路径】【 params:参数】
function CommExportReport(src, params) { var paramStr = src; if (null != params) { Ext.each(params, function(items, index) { if (index > 0) { paramStr += '&'; } else if (index == 0) { paramStr += '?'; } paramStr += items.key + '=' + items.value; }); } window.open(paramStr); };Ext中给控件添加属性listeners
listeners : { 'afterrender' : { fn : function() { tpl.overwrite('cb01Tree', []); } } }
给控件添加on事件
Ext.getCmp(id).on("事件名",function(){
});
var unitEnergyAuditStore = new Ext.data.Store({
pageSize : 40,// 每页显示的记录值 groupField:'UNIT_DESC1', fields : ['UNIT_CODE', 'UNIT_DESC1', 'ACC_DATE','EN_CODE','EN_NAME','TSBA01','TDCB01','STATUS'], proxy : { type : 'ajax', url : '../sh/Sh01Action.action', reader : { totalProperty : 'totalCount',// 分页时候使用 type : 'json', root : 'items' } }, sorters : [{ property : 'UNIT_CODE', // 排序字段 direction : 'ASC'// 默认ASC }] }); unitEnergyAuditStore.load();
var unitEnergyAuditGrid = Ext.create('Ext.grid.Panel', {
id : 'unitEnergyAuditGrid', columnLines : true, selType : 'rowmodel',// 设置单元格选择模型 store :unitEnergyAuditStore, features: [unitGroupingFeature], border:false, columns : [{ header : "单位编码", autoWidth : true, width : 140, dataIndex : "UNIT_CODE" }, { header : "单位名称", autoWidth : true, width : 150, dataIndex : "UNIT_DESC1" }, { header : "上报月份 ", width:170, dataIndex : "ACC_DATE", renderer : function(value) { if(value!=''&& value!=null){ return value.substring(0,7); } } }, { header : "能耗类别", width : 100, dataIndex : "EN_NAME" }, { header : "能耗数值", width : 100, align:'right', dataIndex : "TSBA01" },{ header : "计量类型", width : 100, dataIndex : "TDCB01" },{ header : "状态", dataIndex : "STATUS", autoWidth : true, xtype : 'booleancolumn', trueText : '<font size="2" color="green">生效</font>',// 1 falseText : '<font size="2" color="red">申请作废</font>'// 0 },{ xtype: 'actioncolumn', text:'操作', width: 50, items: [{ icon : '../images/delete.gif', // Use a URL in the icon config accept.gif tooltip: '作废', handler: function(grid, rowIndex, colIndex) { var rec = unitEnergyAuditStore.getAt(rowIndex); Ext.MessageBox.confirm("作废提示", "您是否确认作废该笔数据", function(btnId) { if (btnId == "yes") { var msgTip = Ext.Msg.show({ title : '提示', width : 250, msg : '正在删除中...' }); Ext.Ajax.request({ url : '../sh/Sh01Action!deleteUnitData.action', params : { // 此处可以另外加参数 unit_code:rec.get('UNIT_CODE'), acc_date:rec.get('ACC_DATE'), en_code:rec.get('EN_CODE') }, method : 'POST', success : function() { msgTip.hide(); Ext.Msg.alert("提示", "作废成功"); unitEnergyAuditStore.load(); }, failure : function() { msgTip.hide(); Ext.Msg.alert("提示", "作废失败"); } }); } }); } }, { icon : '../images/accept.gif', // Use a URL in the icon config accept.gif tooltip: '生效', handler: function(grid, rowIndex, colIndex) { var rec = unitEnergyAuditStore.getAt(rowIndex); Ext.MessageBox.confirm("生效提示", "您是否确认生效该笔数据", function(btnId) { if (btnId == "yes") { Ext.Ajax.request({ url : '../sh/Sh01Action!updateUnitData.action', params : { // 此处可以另外加参数 unit_code:rec.get('UNIT_CODE'), acc_date:rec.get('ACC_DATE'), en_code:rec.get('EN_CODE') }, method : 'POST', success : function() { Ext.Msg.alert("提示", "生效成功"); unitEnergyAuditStore.load(); }, failure : function() { Ext.Msg.alert("提示", "生效失败"); } }); } }); } }] }], bbar : new Ext.PagingToolbar({ store : unitEnergyAuditStore, displayInfo : true, displayMsg : '显示{0}-{1}条记录,共 {2}条记录', emptyMsg : "没有记录", beforePageText : '第', afterPageText : '页/共{0}页' }) });