Ext.namespace('DsTruck'); DsTruck.MsWlTruckIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.MsWlTruckIndex.superclass.constructor.call(this); }; Ext.extend(DsTruck.MsWlTruckIndex, Ext.Panel, { PageSize: 100, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { /* this.storeProperty = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeProperty.load({ params: { enumTypeId: 99033} }); this.comboxProperty = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '车辆性质', store: this.storeProperty, name: 'Property' });*/ //#region 参照相关 this.storeProperty = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeProperty.load({ params: { enumTypeId: 99033} }); this.comboxProperty = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '车辆性质', autosize: true, bodyPadding: 5, flex: 4, width: 500, labelWidth: 90, store: this.storeProperty, queryMode: 'local', triggerOnClick: false, name:'Property', valueField: 'EnumValueId', displayField: 'EnumValueName' }); var _this = this; this.storeCompany = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.CompanyModel', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' } }); this.storeCompany.load({ params: { condition: "" } , callback: function (options, success, response) { if (success) { var record = Ext.create('DsTruckMng.ux.CompanyModel', { 'gid': '', 'code': '', 'name': '' }); _this.storeCompany.add(record); // Ext.getCmp("PS_ORGCODE").setValue(""); } } }); this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '分公司', store: this.storeCompany, name: 'ORGCODE', valueField: 'code', displayField: 'name' }); //#endregion //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsWlTruck', remoteSort: true, proxy: { type: 'ajax', url: '/TruckMng/MsWlTruck/GetDataList', reader: { id: 'TruckNo', root: 'data', totalProperty: 'totalCount' } } }); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: [{ sortable: true, dataIndex: 'RowNumber', header: '序号', width: 60 }, { sortable: true, dataIndex: 'OrgCode', header: '组织编码', width: 60 }, { sortable: true, dataIndex: 'TruckNo', header: '车牌号', width: 100 }, { sortable: true, dataIndex: 'TruckSpec', header: '车辆型号', width: 160 }, { sortable: true, dataIndex: 'TruckType', header: '车辆类型', renderer: function (value, p, record) { return value + '-' + record.data.TruckType_Ref; }, width: 80 }, { sortable: true, dataIndex: 'TrunkColor', header: '车辆颜色', width: 120 }, { sortable: true, dataIndex: 'TrunkBrand', header: '车辆品牌', width: 160 }, { sortable: true, dataIndex: 'LoadCount', header: '载重量', width: 60 }, { sortable: true, dataIndex: 'CjNo', header: '车架号', width: 140 }, { sortable: true, dataIndex: 'FdjNo', header: '发动机号', width: 120 }, { sortable: true, dataIndex: 'GzDate', header: '购置日期', width: 80 }, { sortable: true, dataIndex: 'DrvCode', header: '驾驶员编码', renderer: function (value, p, record) { return value + '-' + record.data.DrvCode_Ref; }, width: 80 }, { sortable: true, dataIndex: 'NowStatus', header: '当前状态', renderer: function (value, p, record) { return value + '-' + record.data.NowStatus_Ref; }, width: 40 }, { sortable: true, dataIndex: 'NsDqDate', header: '年审到期日', width: 80 }, { sortable: true, dataIndex: 'VerifiType', header: '年审类型', renderer: function (value, p, record) { return value + '-' + record.data.VerifiType_Ref; }, width: 20 }, { sortable: true, dataIndex: 'InsureType', header: '保险类型', renderer: function (value, p, record) { return value + '-' + record.data.InsureType_Ref; }, width: 20 }, { sortable: true, dataIndex: 'InsureDate', header: '投保日期', width: 80 }, { sortable: true, dataIndex: 'AcciDate', header: '事故日期', width: 80 }, { sortable: true, dataIndex: 'AcciExplain', header: '事故说明', width: 200 }, { sortable: true, dataIndex: 'DealResult', header: '处理结果', width: 200 }, { sortable: true, dataIndex: 'RepairDate', header: '送修日期', width: 80 }, { sortable: true, dataIndex: 'IsRotine', header: '是否例行保养', width: 20 }, { sortable: true, dataIndex: 'OWNER_REF', header: '拥有者', width: 20 }, { sortable: true, dataIndex: 'Remark', header: '备注', width: 200 }, { sortable: true, dataIndex: 'WORKNO', header: '工作地编号', width: 80 } ], // paging bar on the bottom 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'; DsOpenEditWin('/TruckMng/MsWlTruck/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: [this.comboxCompany ,{ fieldLabel: '车牌号', name: 'TruckNo' }, { fieldLabel: '车辆品牌', name: 'TrunkBrand' }, this.comboxProperty ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //#endregion formSearch //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "新建", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/TruckMng/MsWlTruck/Edit'); }, scope: this }, { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (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) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.storeList.on('edit', function (editor, e, eOpts) { this.TruckAfterEdit(editor, e, eOpts); }, this); }, //end initUIComponents onRefreshClick: function (button, event) { var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onDeleteClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/TruckMng/MsWlTruck/Delete', params: { data: Ext.JSON.encode(record.data) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeList.remove(record); Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); }, //onDeleteClick TruckAfterEdit: function (editor, e, eOpts) { if (e.field == 'Foreign') { var _r = DsStoreQueryBy(this.storeForeign, 'Foreign', e.value); if (_r.getCount() > 0) { var _d = _r.getAt(0).data; e.record.set('Foreign_REF', _d.Foreign_REF); } else { e.record.set('Foreign_REF', ''); } } }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var ORGCODE = form.findField('ORGCODE').getValue(); sql = sql + getAndConSql(sql, ORGCODE, " ORGCODE = '" + ORGCODE + "'"); var truckNo = form.findField('TruckNo').getValue(); sql = sql + getAndConSql(sql, truckNo, " (TruckNo like '%" + truckNo + "%' or WORKNO like '%" + truckNo + "%')"); var trunkBrand = form.findField('TrunkBrand').getValue(); sql = sql + getAndConSql(sql, trunkBrand, "TrunkBrand like '%" + trunkBrand + "%'"); var Property = this.comboxProperty.getValue(); if (Property != "") { sql = sql + getAndConSql(sql, Property, "Property in (" + Property + ")"); } return sql; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; } });