Ext.namespace('DsTruck'); DsTruck.MsWlBulkPcQueryIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.MsWlBulkPcQueryIndex.superclass.constructor.call(this); }; Ext.extend(DsTruck.MsWlBulkPcQueryIndex, Ext.Panel, { OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { //定义数据集 this.storeList = Ext.create('Ext.data.Store', { model: 'MsWlBulkQuery', remoteSort: true, proxy: { type: 'ajax', url: '/TruckMng/MsWlBulkPc/GetDataQueryList', reader: { id: 'BillNo', root: 'data', totalProperty: 'totalCount' } } }); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, features: [{ ftype: 'summary' }], columns: [{ sortable: true, dataIndex: 'BillNo', header: '单据号', width: 150 }, { sortable: true, dataIndex: 'UserCode', header: '用户编码', width: 60 }, { sortable: true, dataIndex: 'UserName', header: '用户姓名', width: 80 }, { sortable: true, dataIndex: 'TruckNo', header: '车牌号', width: 130 }, { sortable: true, dataIndex: 'DrvName', header: '司机姓名', width: 130 }, { sortable: true, dataIndex: 'ExpDate', header: '派车日期', width: 80 }, { sortable: true, dataIndex: 'CustName', header: '委托单位', width: 80 }, { sortable: true, dataIndex: 'ClsName', header: '品名', width: 100 }, { sortable: true, dataIndex: 'Vessel', header: '船名', width: 150 }, { sortable: true, dataIndex: 'DepartureDate', header: '起运日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), width: 80 }, { sortable: true, dataIndex: 'DepartureTime', header: '起运时间', width: 80 }, { sortable: true, dataIndex: 'LoadPlace', header: '装货地点', width: 100 }, { sortable: true, dataIndex: 'UnLoadPlace', header: '卸货地点', width: 100 }, { sortable: true, dataIndex: 'LoadCount', header: '实际运行次数', summaryType: 'sum', width: 76 }, { sortable: true, dataIndex: 'OverLoadMil', header: '实际重驶里程', summaryType: 'sum', width: 76 }, { sortable: true, dataIndex: 'NoLoadMil', header: '实际空驶里程', summaryType: 'sum', width: 76 }, { sortable: true, dataIndex: 'UnLoadCount', header: '实际倾斜次数', summaryType: 'sum', width: 76 }, { sortable: true, dataIndex: 'Weight', header: '实际运输总重量', summaryType: 'sum', width: 76 }, { sortable: true, dataIndex: 'TonMil', header: '吨公里', summaryType: 'sum', width: 76 }, { sortable: true, dataIndex: 'RatedFuel', header: '额定油耗', summaryType: 'sum', width: 80 }, { sortable: true, dataIndex: 'TransPrice', header: '费率', width: 85 }, { sortable: true, dataIndex: 'TransTotal', header: '运费', summaryType: 'sum', width: 160 } ] }); //#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: 'BillNo' }, { fieldLabel: '从派车日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateBgn' }, { fieldLabel: '到派车日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateEnd' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '车牌号', name: 'TruckNo' }, { fieldLabel: '委托单位代码', name: 'CustCode' }, { fieldLabel: '委托单位', name: 'CustName' } ] } ]//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: "重置条件", iconCls: "btnreset", handler: function (button, event) { this.onResetClick(button, event); }, scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 105, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); }, //end initUIComponents onRefreshClick: function (button, event) { var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: 500, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var billNo = form.findField('BillNo').getValue(); sql = sql + getAndConSql(sql, billNo, "b.BillNo = '" + billNo + "'"); var expDateBgn = form.findField('ExpDateBgn').getValue(); if (expDateBgn != null) { var expDateBgnValue = DateToStr(expDateBgn); sql = sql + getAndConSql(sql, expDateBgnValue, "p.ExpDate >='" + expDateBgnValue + "'"); } var expDateEnd = form.findField('ExpDateEnd').getValue(); if (expDateBgn != null) { var expDateEndValue = DateToStr(expDateEnd); sql = sql + getAndConSql(sql, expDateEndValue, "p.ExpDate <='" + expDateEndValue + "'"); } var truckNo = form.findField('TruckNo').getValue(); sql = sql + getAndConSql(sql, truckNo, "p.TruckNo = '" + truckNo + "'"); var custCode = form.findField('CustCode').getValue(); sql = sql + getAndConSql(sql, custCode, " b.CustCode = '" + custCode + "'"); var custName = form.findField('CustName').getValue(); sql = sql + getAndConSql(sql, custName, " b.CustName = '" + custName + "'"); return sql; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; }, onResetClick: function (button, event) { this.formSearch.getForm().reset(); } });