Ext.namespace('DsTruckRpt'); DsTruckRpt.MsRptTruckMaterialIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruckRpt.MsRptTruckMaterialIndex.superclass.constructor.call(this); }; Ext.extend(DsTruckRpt.MsRptTruckMaterialIndex, Ext.Panel, { PageSize: 30, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { //定义数据集 this.storeList = Ext.create('Ext.data.Store', { fields: [ { name: 'TRUCKNO', type: 'string' }, { name: 'LYTOTALTYRE', type: 'number' }, { name: 'LYTOTALOIL', type: 'number' }, { name: 'LYTOTALMATERIAL', type: 'number' }, { name: 'TOTALFUEL', type: 'number' }, { name: 'REALHOURS', type: 'number' }, { name: 'REMARK', type: 'string' } ], // pageSize: this.PageSize, remoteSort: true, proxy: { type: 'ajax', url: '/RptMng/MsRptTruckMaterial/QryData', reader: { id: '', root: 'data', totalProperty: 'totalCount' } } }); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, features: [{ ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 }], disableSelection: false, columns: [{ sortable: true, dataIndex: 'TRUCKNO', header: '车牌号', summaryType: 'count', width: 200 }, { sortable: true, dataIndex: 'LYTOTALTYRE', header: '轮胎', summaryType: 'sum', width: 160 }, { sortable: true, dataIndex: 'LYTOTALOIL', header: '润滑油', summaryType: 'sum', width: 160 }, { sortable: true, dataIndex: 'LYTOTALMATERIAL', header: '材料', summaryType: 'sum', width: 160 }, { sortable: true, dataIndex: 'TOTALFUEL', header: '燃料', summaryType: 'sum', width: 160 }, { sortable: true, dataIndex: 'REALHOURS', header: '工时数', summaryType: 'sum', width: 160 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 500 } ] /* , // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) */ }); //#region formSearch //#region formSearch枚举参照相关 //#endregion this.formSearch = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '组织编码', name: 'PS_ORGCODE' }, { fieldLabel: '车牌号', name: 'PS_TRUCKNO' }, { fieldLabel: '月份', format: 'Y-m', xtype: 'datefield', name: 'PS_MONTH' } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //#endregion formSearch //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 80, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.storeList.on('beforeload', function (store) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); }, //end initUIComponents onRefreshClick: function (button, event) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: 500, condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, getCondition: function () { var form = this.formSearch.getForm(); var sql = ''; /* var drvName = form.findField('PS_TRUCKNO').getValue(); sql = sql + getAndConSql(sql, drvName, " TRUCKNO='" + drvName + "'"); var orgcode = form.findField('PS_ORGCODE').getValue(); sql = sql + getAndConSql(sql, orgcode, " OrgCode='" + orgcode + "'"); var yearmonth = form.findField('PS_MONTH').getRawValue(); sql = sql + getAndConSql(sql, yearmonth, " SUBSTRING(NSDQDATE, 1, 7)='" + yearmonth + "'"); */ var sqldata = form.getValues(); sql = Ext.JSON.encode(sqldata); return sql; }, checkSearchCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return false; } return true; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; } , onExportClick: function (button, event) { GridExportExcelPage(this.gridList); } });