Ext.namespace('Shipping'); Shipping.MsRptCtnVesselIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsRptCtnVesselIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsRptCtnVesselIndex, Ext.Panel, { PageSize: 1000, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, EditRecord: null, initUIComponents: function () { //定义数据集 var myfield = [ { name: 'vessel', type: 'string' }, { name: 'voyage', type: 'string' } ] this.girdcolums = [{ sortable: true, dataIndex: 'vessel', header: '船名', width: 150 }, { sortable: true, dataIndex: 'voyage', header: '航次', width: 120 } ]; this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); //定义Grid this.gridList = new Ext.grid.GridPanel({ // store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.gridListCellEditing], selModel: this.CheckBoxModel, selType: 'cellmodel', columns: this.girdcolums, bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; }, this); //#region formSearch 查询面板 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: 'Vessel' }, { fieldLabel: '航次', name: 'Voy' }, { fieldLabel: 'ETD', format: 'Y-m-d', xtype: 'datefield', name: 'ETDDateBgn' }, { fieldLabel: '至', format: 'Y-m-d', xtype: 'datefield', name: 'ETDDateEnd' }] }]//end items(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) { }, 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.panelBtn, this.formSearch] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeCtnModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' } }); _this = this; this.storeCodeCtn.load({ params: { condition: "" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { for (i = 0; i < this.storeCodeCtn.getCount(); i += 1) { var itemindex = i + 1; var memberyf = this.storeCodeCtn.getAt(i); myfield.push({ name: 'C' + memberyf.data.CTN, type: 'string' }); _this.girdcolums.push({ sortable: true, dataIndex: 'C' + memberyf.data.CTN, header: memberyf.data.CTN, width: 80 }); }; } Ext.define('CtnVessel', { extend: 'Ext.data.Model', fields: myfield }); this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'CtnVessel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpCtnStatus/GetRptCtnVesselData', reader: { root: 'data', totalProperty: 'totalCount' } } }); this.gridList.reconfigure(this.storeList, _this.girdcolums); this.onRefreshClick(); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); } }, scope: this }); }, onRefreshClick: function (button, event) { var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); }, //onDeleteClick getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var Vessel = form.findField('Vessel').getValue(); sql = sql + getAndConSql(sql, Vessel, "(b.Vessel like '%" + Vessel + "%' )"); var Voy = form.findField('Voy').getValue(); sql = sql + getAndConSql(sql, Voy, "(b.voyage like '%" + Voy + "%' )"); var ETDDateBgn = form.findField('ETDDateBgn').getRawValue(); sql = sql + getAndConSql(sql, ETDDateBgn, "b.ETD>='" + ETDDateBgn + "'"); var ETDDateEnd = form.findField('ETDDateEnd').getRawValue(); sql = sql + getAndConSql(sql, ETDDateEnd, "b.ETD <='" + ETDDateEnd + "'"); return sql; }, 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); }, onImportBsClick: function (button, event) { var winAccess = new Shipping.CtnFileImport({ }); winAccess.StoreList = this.storeList; winAccess.show(); return; } });