Ext.namespace('DsTruck'); DsTruck.MsWlTruckEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.MsWlTruckEdit.superclass.constructor.call(this); }; var TruckNo; Ext.extend(DsTruck.MsWlTruckEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, initUIComponents: function () { this.serialNo = 0; this.bodyDel = []; this.cardDel = []; this.carduseDel = []; this.TruckMonthDel = []; this.CARDGID = ""; //枚举参照相关 this.storeTruckType = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeTruckType.load({ params: { enumTypeId: 99019} }); this.comboxTruckType = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '车辆类型', store: this.storeTruckType, name: 'TruckType' }); this.storeNowStatus = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeNowStatus.load({ params: { enumTypeId: 99018} }); this.comboxNowStatus = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '当前状态', store: this.storeNowStatus, name: 'NowStatus' }); this.storeVerifiType = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeVerifiType.load({ params: { enumTypeId: 99016} }); this.comboxVerifiType = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '年审类型', store: this.storeVerifiType, name: 'VerifiType' }); this.storeInsureType = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeInsureType.load({ params: { enumTypeId: 99021} }); this.comboxInsureType = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '保险类型', store: this.storeInsureType, name: 'InsureType' }); this.storeEmissions = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeEmissions.load({ params: { enumTypeId: 99031} }); this.comboxEmissions = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '车辆尾气排放', store: this.storeEmissions, name: 'Emissions' }); this.storeBizProperty = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeBizProperty.load({ params: { enumTypeId: 99032} }); this.comboxBizProperty = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '营运性质', store: this.storeBizProperty, name: 'BizProperty' }); 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' }); this.storeFuelType = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeFuelType.load({ params: { enumTypeId: 99034} }); this.comboxFuelType = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '燃油类型', store: this.storeFuelType, name: 'FuelType' }); this.storeYouLiaoType = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeYouLiaoType.load({ params: { enumTypeId: 99049} }); this.comboxYouLiaoType = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '油料类型', store: this.storeYouLiaoType, name: 'YouLiaoType', valueField: 'EnumValueName', displayField: 'EnumValueName' }); this.storeCompany = Ext.create('DsExt.ux.RefTableStore', { model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' } }); this.storeCompany.load({ params: { condition: ""} }); this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '所属分公司', forceSelection: true, allowBlank: false, store: this.storeCompany, name: 'OrgCode', valueField: 'code', displayField: 'name' }); //表参照相关 this.storeDrvCode = Ext.create('DsExt.ux.RefTableStore', { model: 'MsWlTruckRefMsWlDriver', proxy: { url: '/TruckMng/MsWlTruck/GetDrvCodeList' } }); this.storeDrvCode.load(); this.comboxDrvCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '驾驶员编码', store: this.storeDrvCode, name: 'DrvCode', valueField: 'DrvCode', displayField: 'CodeAndName' }); this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustomerNameRef.load({ params: { condition: ""} }); this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeCustomerNameRef, fieldLabel: '所有者', //forceSelection: true, allowBlank: true, name: 'OWNER', valueField: 'GId', displayField: 'CodeAndName' }); //编辑form this.formEdit = Ext.widget('form', { region: 'center', frame: true, bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 100, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '驾驶员姓名', name: 'DrvName', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '所属车队', name: 'TruncClass', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '车牌号', allowBlank: false, name: 'TruckNo' }, { fieldLabel: '车辆型号', allowBlank: false, name: 'TruckSpec' }, this.comboxTruckType , { labelWidth: 120, fieldLabel: '关联车辆(车头)号', //allowBlank: false, name: 'LINKTRUCKNO' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '车辆颜色', allowBlank: false, name: 'TrunkColor' }, { fieldLabel: '车辆品牌', allowBlank: false, name: 'TrunkBrand' }, { fieldLabel: '载重量', xtype: 'numberfield', allowBlank: false, name: 'LoadCount' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '车架号', name: 'CjNo' }, { fieldLabel: '发动机号', name: 'FdjNo' }, { fieldLabel: '购置日期', format: 'Y-m-d', xtype: 'datefield', name: 'GzDate' }, { fieldLabel: '报废日期', format: 'Y-m-d', xtype: 'datefield', name: 'BfDate' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxDrvCode, this.comboxNowStatus, { fieldLabel: '二期维护日期', format: 'Y-m-d', xtype: 'datefield', name: 'Level2Date' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '年审到期日', format: 'Y-m-d', xtype: 'datefield', name: 'NsDqDate' }, this.comboxVerifiType, this.comboxEmissions ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxBizProperty, { fieldLabel: '车籍', name: 'NativeAddr' }, this.comboxProperty ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxFuelType, { fieldLabel: '管理单位', name: 'MngOrg' }, this.comboxCompany/*,{ fieldLabel: '组织编码', name: 'OrgCode', flex: 0, hidden: true, margins: '0' }*/ ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '吊车百吨油耗', name: 'CraneFuel' }, { fieldLabel: '自卸车倾斜油耗', name: 'UnloadFuel' }, { fieldLabel: '自卸车基础油耗', name: 'BasisFuel' }, { fieldLabel: '自卸车吨公里油耗', name: 'TonMilFuel' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxYouLiaoType,{ fieldLabel: '备注', name: 'Remark', flex: 1 }, { fieldLabel: '工作地编号', name: 'WORKNO' }, this.comboxCustomerNameRef ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //end this.formEdit //按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, { text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, '-', { text: "保存并新建", handler: function (button, event) { this.Save('2'); }, scope: this } ] }); //end 按钮Toolbar //#region 明细表 //明细表表格相关 this.storeLoadTypeRef = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeLoadTypeRef.load({ params: { enumTypeId: 99030} }); this.comboxLoadTypeRef = Ext.create('DsExt.ux.RefEnumCombox', { store: this.storeLoadTypeRef, name: 'LoadType' }); //#region 明细表 空驶/重驶 this.storeBodyList = Ext.create('Ext.data.Store', { model: 'MsWlTruckFuel', remoteSort: false, proxy: { type: 'ajax', url: '/TruckMng/MsWlTruck/GetBodyList', reader: { id: 'TruckNo,SerialNo', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.gridList = new Ext.grid.GridPanel({ store: this.storeBodyList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.gridListCellEditing], selType: 'cellmodel', tbar: [{ text: '增加明细', tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { this.onAddDetailClick(button, event); }, scope: this }, '-', { text: '删除明细', tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelDetailClick(button, event); }, scope: this }/*, { xtype: 'labelfield', fieldLabel:'注意,重量区间必须首尾相连(上一个的结束重量应当是下一个的开始重量)' }*/], columns: [{ sortable: true, dataIndex: 'TruckNo', hidden: true, header: '车牌号', // hidden: true, editor: { xtype: 'textfield', allowBlank: false, selectOnFocus: true }, width: 160 }, { sortable: true, dataIndex: 'SerialNo', header: '录入序号', width: 60 }, { sortable: true, dataIndex: 'LoadType', header: '空驶/重驶方式', renderer: function (value, p, record) { if (value == null || value == '') return ''; else return value + '-' + record.data.LoadType_Ref; }, editor: this.comboxLoadTypeRef, width: 100 }, { sortable: true, dataIndex: 'Condition1', header: '条件1', hidden: true, width: 60 }, { sortable: true, dataIndex: 'Ton1', header: '吨位区间(从)<含此重量>', editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true }, width: 160 }, { sortable: true, dataIndex: 'Condition2', header: '条件2', hidden: true, width: 60 }, { sortable: true, dataIndex: 'Ton2', header: '吨位区间(至)<不含此重量>', editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true }, width: 160 }, { sortable: true, dataIndex: 'FuelTotal', header: '耗油量(百公里)', editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true }, width: 90 }, { sortable: true, dataIndex: 'FuelPrice', header: '耗油量2(千吨公里)', editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true }, width: 110 }, { sortable: true, dataIndex: 'Remark', header: '备注', editor: { xtype: 'textfield', selectOnFocus: true }, width: 200 } ] }); //#endregion //#region 明细表 其他费用 this.storeTruckFee = Ext.create('Ext.data.Store', { pageSize: 50, model: 'MsWlTruckFeemb', remoteSort: false, proxy: { type: 'ajax', url: '/TruckMng/MsWlTruckFee/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.gridTruckFee = new Ext.grid.GridPanel({ store: this.storeTruckFee, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, features: [{ ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 }], //selModel: this.PCCB, //plugins: [this.cellEditing], columns: [new Ext.grid.RowNumberer(), { sortable: true, dataIndex: 'GID', hidden: true, header: 'GID', width: 130 }, { sortable: true, dataIndex: 'TruckNo', header: '车号', width: 85 }, { sortable: true, dataIndex: 'FeeDate', header: '费用日期', width: 85, renderer: Ext.util.Format.dateRenderer('Y-m-d') }, { sortable: true, dataIndex: 'FeeName', header: '费用名称', editor: this.comboxFeeName, width: 80 }, { sortable: true, dataIndex: 'Amount', header: '金额', summaryType: 'sum', width: 70 }, { sortable: true, dataIndex: 'Remark', header: '备注', width: 120 }, { sortable: true, hidden: true, dataIndex: 'Inserted', header: 'Inserted', width: 80 }], // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); //#endregion 明细表 //#region 充值卡 this.storeCardType = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeCardType.load({ params: { enumTypeId: 99045} }); this.comboxCardType = Ext.create('DsExt.ux.RefTableCombox', { //fieldLabel: '充值卡类型', forceSelection: true, store: this.storeCardType, name: 'CARDTYPE', valueField: 'EnumValueName', displayField: 'EnumValueName', //triggerAction: 'all', selectOnFocus: true }); this.storeCard = Ext.create('Ext.data.Store', { model: 'DsTruckMng.ux.CardModel', remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/TruckMng/Card/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //表格 this.CardColumns = [ { sortable: true, hidden: true, dataIndex: 'GID', header: 'GID', width: 80 }, { sortable: true, dataIndex: 'CARDNO', header: '卡号', editor: { xtype: 'textfield', allowBlank: false, selectOnFocus: true }, width: 170 }, { sortable: true, dataIndex: 'CARDTYPE', header: '卡类型', editor: this.comboxCardType /* xtype: 'textfield', allowBlank: false, selectOnFocus: true }*/, width: 70 }, { sortable: true, hidden: true, dataIndex: 'OP', header: '所有者', width: 80 }, { sortable: true, hidden: true, dataIndex: 'OWNGID', header: 'OWNGID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'ISDELETE', header: 'ISDELETE', width: 80 }, { sortable: true, dataIndex: 'REMAIN', header: '剩余金额', width: 80 } ]; this.cellEditingCard = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.cardCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); var _this = this; this.formCard = new Ext.grid.GridPanel({ store: this.storeCard, enableHdMenu: false, layout: 'border', region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingCard], selModel: this.cardCheckBoxModel, multiSelect: false, selType: 'cellmodel', tbar: [{ text: '增加明细', tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { this.onAddCardClick(button, event); }, scope: this }, '-', { text: '删除明细', tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelCardClick(button, event); }, scope: this }, '-', { text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }], columns: this.CardColumns }); //#endregion //选择load this.formCard.getSelectionModel().on('select', function (model, record, index) { var CARDGID = record.data.GID; this.CARDGID = CARDGID; this.storeCardUse.load({ params: { CARDGID: CARDGID} }); }, this); //#region 充值卡使用 this.storeCardUse = Ext.create('Ext.data.Store', { model: 'DsTruckMng.ux.CardUseModel', remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/TruckMng/Card/GetUseList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //表格 this.CardUseColumns = [ { sortable: true, hidden: true, dataIndex: 'GID', header: 'GID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'CARDNO', header: 'CARDNO', width: 80 }, { sortable: true, hidden: true, dataIndex: 'CARDGID', header: 'CARDGID', width: 80 }, { sortable: true, dataIndex: 'BILLNO', header: '业务编号', width: 150 }, { sortable: true, dataIndex: 'OPERATE', header: '业务操作', width: 80, editor: { xtype: 'textfield', allowBlank: false, selectOnFocus: true } }, { sortable: true, dataIndex: 'INNUM', header: '充入', width: 80, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { sortable: true, dataIndex: 'OUTNUM', header: '支出', width: 80, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { sortable: true, dataIndex: 'OPTIME', header: '操作时间', width: 140, renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'), editor: { xtype: 'datetimefield', selectOnFocus: true } }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 80, editor: { xtype: 'textfield', allowBlank: false, selectOnFocus: true } }]; this.cellEditingCardUse = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.CardUseCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); var _this = this; this.formCardUse = new Ext.grid.GridPanel({ store: this.storeCardUse, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingCardUse], selModel: this.CardUseCheckBoxModel, selType: 'cellmodel', tbar: [{ text: '增加明细', tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { var CARDGID = ""; var records = this.formCard.selModel.getSelection(); if (records.length == 0) { alert("请先选中一个充值卡"); return; } OWNGID = records[0].data.OWNGID; if (OWNGID == "") { alert("请先保存充值卡信息"); return; } this.onAddCardUseClick(records[0].data.GID); }, scope: this }, { text: '删除明细', tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { var records = this.formCard.selModel.getSelection(); var OWNGID = records[0].data.OWNGID; var CARDGID = records[0].data.GID; this.onDelCardUseClick(CARDGID, OWNGID); }, scope: this }, '-', { text: '保存充值卡使用信息', tooltip: '仅可保存修改充值卡的充值信息。', iconCls: "btnsave", handler: function (button, event) { var CARDGID = ""; var records = this.formCard.selModel.getSelection(); var CARDGID = records[0].data.GID; var OWNGID = records[0].data.OWNGID; if (OWNGID == "") { alert("请先保存充值卡信息"); return; } this.onSaveCardUseClick(CARDGID, OWNGID); }, scope: this }], columns: this.CardUseColumns }); //#endregion //#region 车辆月度信息 this.storeTruckMonth = Ext.create('Ext.data.Store', { model: 'TruckMonthmb', remoteSort: false, proxy: { type: 'ajax', url: '/TruckMng/MsWlTruck/GetTruckMonthList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //表格 this.TruckMonthColumns = [ { sortable: true, hidden: true, dataIndex: 'GID', readOnly: true, header: 'GID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'TRUCKNO', readOnly: true, header: 'TRUCKNO', width: 80 }, { sortable: true, dataIndex: 'ACCDATE', header: '会计期间', width: 80, renderer: Ext.util.Format.dateRenderer('Y-m'), editor: { xtype: 'monthfield', selectOnFocus: true, renderer: Ext.util.Format.dateRenderer('Y-m') } }, { sortable: true, dataIndex: 'ZJF', header: '折旧费', width: 80, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true, minValue: 0 } }, { sortable: true, dataIndex: 'BXF', header: '车辆保险', width: 80, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true, minValue: 0 } }, { sortable: true, dataIndex: 'GZCR', hidden: true, header: '工作车日', width: 80, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true, minValue: 0 } }, { sortable: true, hidden: true, dataIndex: 'XLCR', header: '修理车日', width: 80 }, { sortable: true, hidden: true, dataIndex: 'ZCR', header: '总车日', width: 80, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true, minValue: 0 } } ]; this.cellEditingTruckMonth = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.TruckMonthCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); var _this = this; this.formTruckMonth = new Ext.grid.GridPanel({ store: this.storeTruckMonth, enableHdMenu: false, layout: 'border', region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingTruckMonth], selModel: this.TruckMonthCheckBoxModel, multiSelect: false, selType: 'cellmodel', tbar: [{ text: '增加明细', tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { this.onAddTruckMonthClick(button, event); }, scope: this }, '-', { text: '删除明细', tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelTruckMonthClick(button, event); }, scope: this }, '-', { text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }], columns: this.TruckMonthColumns }); //车辆证件上传 //var billno = this.editRecord.get('TruckNo'); this.storeTruckCert = Ext.create('Ext.data.Store', { model: 'TruckCert', remoteSort: false, proxy: { type: 'ajax', url: '/TruckMng/MsWlTruck/GetTruckCertList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //this.storeTruckCert.load({ params: { start: 0, limit: 9999, TruckNo: TruckNo} }); //表格 this.TruckMonthColumns = [ { sortable: true, hidden: true, dataIndex: 'GID', readOnly: true, header: 'GID', width: 80 }, { sortable: true, hidden: false, dataIndex: 'CertTypeName', readOnly: true, header: '证件类型', width: 80 }, { sortable: true, hidden: false, dataIndex: 'Pic_Name', readOnly: true, header: '文件名称', width: 80 }, { sortable: true, hidden: true, dataIndex: 'Pic_Type', readOnly: true, header: 'Pic_Type', width: 80 }, { sortable: true, hidden: false, dataIndex: 'UpdateTime', readOnly: true, header: '上传日期', width: 80 }, { sortable: true, hidden: false, dataIndex: 'Operator', readOnly: true, header: '上传者', width: 80 }, { sortable: true, hidden: true, dataIndex: 'Pic_Path', header: 'Pic_Path', width: 80 }, { xtype: 'actioncolumn', width: 50, text: "操作", items: [{ icon: '/images/icons/btnSearch.gif', // Use a URL in the icon config tooltip: '预览', handler: function (grid, rowIndex, colIndex) { var rec = grid.getStore().getAt(rowIndex); var filePath = "/Areas/TruckMng/CertImages/" + rec.get('TruckNo') + '/' + rec.get('Pic_Name'); var imgView = new DsTruck.CertView({ filePath: filePath }); imgView.show(); } }] } ]; var selCertModel = Ext.create('Ext.selection.CheckboxModel'); this.formTruckCert = new Ext.grid.GridPanel({ store: this.storeTruckCert, enableHdMenu: false, layout: 'border', region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selModel: selCertModel, singleSelect: true, selType: 'rowmodel', tbar: [{ text: '上传证件图片', tooltip: '上传证件图片', iconCls: "btnadddetail", handler: function (button, event) { this.onAddTruckCertClick(button, event); }, scope: this }, '-', { text: '删除', tooltip: '删除证件图片', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelTruckCertClick(button, event); }, scope: this }], columns: this.TruckMonthColumns }); //#endregion //#region 布局 //控件布局 this.panelTop = new Ext.Panel({ layout: "border", region: 'north', margin: '1 1', height: 310, split: true, items: [this.panelBtn, this.formEdit] }); this.panelCardList = new Ext.Panel({ // title: '货物信息和许可证使用', layout: "border", region: 'west', margin: '0 0', //height: 450, width: 330, split: true, items: [this.formCard] }); this.panelCardUse = new Ext.Panel({ // title: '货物信息和许可证使用', layout: "border", region: 'center', margin: '0 0', //height: 450, width: 450, split: true, items: [this.formCardUse] }); this.panelCard = new Ext.Panel({ // layout: "border", region: 'center', margin: '0 0', //height: 260, //width: 450, split: true, items: [this.panelCardList, this.panelCardUse] }); this.page_1 = new Ext.Panel({ id: "page_1", title: "油耗信息", autoScroll: true, layout: "border", region: 'center', //closable:true, items: [this.gridList] }); this.page_2 = new Ext.Panel({ id: "page_2", title: "其他费用查询", layout: "border", region: 'center', items: [this.gridTruckFee] }); this.page_3 = new Ext.Panel({ id: "page_3", title: "充值卡管理", layout: "border", region: 'center', items: [this.panelCard] }); this.page_4 = new Ext.Panel({ id: "page_4", title: "车辆月度费用管理", layout: "border", region: 'center', items: [this.formTruckMonth] }); this.page_5 = new Ext.Panel({ id: "page_5", title: "车辆证件上传", layout: "border", region: 'center', items: [this.formTruckCert] }); this.MainTab = new Ext.tab.Panel({ layout: "border", region: "center", split: true, items: [ this.page_1, this.page_2, this.page_3, this.page_4, this.page_5 ] }); Ext.apply(this, { items: [this.panelTop, this.MainTab] }); //#endregion //绑定查询窗体 this.ParentWin = window.parent.opener; //初始化数据 this.InitData(); //绑定事件 this.gridList.on('edit', function (editor, e, eOpts) { this.gridAfterEdit(editor, e, eOpts); }, this); this.cellEditingCardUse.on('beforeedit', function (editor, e) { return this.CardUseBeforeEdit(editor, e); }, this); }, //end initUIComponents InitData: function () { this.opStatus = 'add'; var condition = ''; if (this.ParentWin) { var ret = this.ParentWin.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; } if (this.opStatus == 'edit') condition = " TruckNo='" + this.editRecord.get('TruckNo') + "'"; this.LoadData(this.opStatus, condition); }, //end InitData LoadData: function (opstatus, condition) { this.serialNo = 0; this.bodyDel = []; this.opStatus = opstatus; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/TruckMng/MsWlTruck/GetData', params: { handle: opstatus, condition: condition }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } var data = result.data; TruckNo = data.TruckNo; this.storeTruckCert.load({ params: { start: 0, limit: 9999, TruckNo: TruckNo} }); this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(data); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); var billno = '*'; if (this.opStatus == 'edit') { TruckNo = this.editRecord.get('TruckNo'); billno = this.editRecord.get('TruckNo'); this.formEdit.getForm().findField('TruckNo').setDisabled(true); this.storeTruckFee.load({ params: { start: 0, limit: 50, sort: '', condition: "TruckNo='" + this.editRecord.get('TruckNo') + "'" }, waitMsg: "正在查询数据...", scope: this }); this.storeTruckMonth.load({ params: { condition: "TruckNo='" + this.editRecord.get('TruckNo') + "'" }, waitMsg: "正在查询数据...", scope: this }); } this.storeBodyList.load({ params: { billno: billno} }); this.storeCard.load({ params: { OWNGID: billno} }); //显示充值卡剩余数量 }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } basicForm.findField('TruckNo').setDisabled(false); var data = basicForm.getValues(); basicForm.findField('TruckNo').setDisabled(true); var bodydatas = []; for (var i = 0; i < this.storeBodyList.getCount(); i += 1) { var member = this.storeBodyList.getAt(i); bodydatas.push(member); } var jsonBody = ConvertRecordsToJson(bodydatas); var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel); var Carddatas = []; for (var i = 0; i < this.storeCard.getCount(); i += 1) { var member = this.storeCard.getAt(i); Carddatas.push(member); } var CardjsonBody = ConvertRecordsToJson(Carddatas); var CardjsonDelBody = ConvertRecordsToJsonAll(this.cardDel); var TruckMonthdatas = []; for (var i = 0; i < this.storeTruckMonth.getCount(); i += 1) { var member = this.storeTruckMonth.getAt(i); var Y = member.data.ACCDATE.getFullYear(); var M = member.data.ACCDATE.getMonth() + 1; var _M = ""; if (M < 10) { _M = "0" + M; } else { _M = "" + M; } member.data.ACCDATE = Y + '-' + _M; TruckMonthdatas.push(member); } var TruckMonthjsonBody = ConvertRecordsToJson(TruckMonthdatas); var TruckMonthjsonDelBody = ConvertRecordsToJsonAll(this.TruckMonthDel); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/TruckMng/MsWlTruck/Save', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), body: jsonBody, delbody: jsonDelBody, Cardbody: CardjsonBody, Carddelbody: CardjsonDelBody, TruckMonthbody: TruckMonthjsonBody, TruckMonthdelbody: TruckMonthjsonDelBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); TruckNo = jsonresult.Data.TruckNo; if (jsonresult.Success) { var returnData = jsonresult.Data; this.formEdit.getForm().setValues(returnData); if (this.opStatus == 'add') { var arrNewRecords = this.StoreList.add(returnData); this.editRecord = arrNewRecords[0]; } else if (this.opStatus == 'edit') { var editp = Ext.create('MsWlTruck', returnData); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'id') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); } if (type == '0') { this.opStatus = 'edit'; basicForm.findField('TruckNo').setDisabled(true); for (var j = 0; j < this.storeBodyList.getCount(); j += 1) { var memberbody = this.storeBodyList.getAt(j); memberbody.set("TruckNo", this.editRecord.get('TruckNo')); memberbody.commit(); }; } else if (type == '1') { window.close(); } else { this.LoadData('add', ''); basicForm.findField('TruckNo').setDisabled(false); } this.storeCard.load({ params: { OWNGID: returnData.TruckNo} }); this.storeTruckMonth.load({ params: { condition: "TruckNo='" + returnData.TruckNo + "'" }, waitMsg: "正在查询数据...", scope: this }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save onAddDetailClick: function (button, event) { this.addDetail(); }, //end onAddDetailClick onDelDetailClick: function (button, event) { this.deleteDetail(); }, //onDelDetailClick gridAfterEdit: function (editor, e, eOpts) { //需要自己实现里面的事件 if (e.field == 'LoadType') { var records = DsStoreQueryBy(this.storeLoadTypeRef, 'EnumValueId', e.value); if (records.getCount() > 0) { var data = records.getAt(0).data; e.record.set('LoadType_Ref', data.EnumValueName); } else { e.record.set('LoadType_Ref', ''); } } }, addDetail: function () { var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo); this.serialNo = newSerialno; var loadType = "1"; var loadTypeRef = "重驶"; var records = DsStoreQueryBy(this.storeLoadTypeRef, 'EnumValueId', loadType); if (records.getCount() > 0) { var data = records.getAt(0).data; loadTypeRef = data.EnumValueName; } var record = Ext.create('MsWlTruckFuel', { TruckNo: '', SerialNo: newSerialno, LoadType: loadType, LoadType_Ref: loadTypeRef, Condition1: ">=", Ton1: 0, Condition2: "<", Ton2: 0, FuelTotal: 0, Remark: '' }); this.storeBodyList.add(record); var n = this.storeBodyList.getCount(); this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 }); }, deleteDetail: function () { this.serialNo = DsGetCurSerialNo(this.storeBodyList, this.serialNo); var selectedRecords = this.gridList.selModel.getSelection(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台 { this.bodyDel.push(rec); } this.storeBodyList.remove(selectedRecords[i]); } }, onAddCardClick: function () { var record = Ext.create('DsTruckMng.ux.CardModel', { GID: NewGuid(), CARDNO: "", CARDTYPE: "", OP: "", OWNGID: "", ISDELETE: "0" }); this.storeCard.add(record); var n = this.storeCard.getCount(); this.cellEditingCard.startEditByPosition({ row: n - 1, column: 2 }); }, onDelCardClick: function () { /* var selectedRecords = this.formCard.selModel.getSelection(); if (this.storeCardUse.getCount()>0){ alert("包含充值或使用明细的卡片不能删除"); return; } */ var selections = this.formCard.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择卡片!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var _L = selections.length; var UseCount = "0"; var OWNGID = this.editRecord.get('TruckNo'); Ext.MessageBox.confirm('提示', '确定删除这' + _L + '条记录吗?', function (btn) { if (btn == 'yes') { //var record = selections[0]; for (var i = 0; i < _L; i++) { var record = selections[i]; var GID = record.data.GID; Ext.Ajax.request({ waitMsg: '正在查询数据...', url: '/TruckMng/Card/SearchCardUse', scope: this, async: false, params: { GID: GID }, waitMsg: "正在查询数据...", callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); var returnData = jsonresult.data; //alert(returnData); UseCount = returnData; } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } } }); if (UseCount != "0") { alert("该卡片下包含未删除的使用/充值明细,不能删除"); return; } else { //Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/TruckMng/Card/DeleteCard', params: { GID: GID }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { //this.storeCard.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.storeList.remove(record); //if (i >= _L ) { // Ext.Msg.show({ title: '提示', msg: "数据删除结束", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); //} this.storeCard.load({ params: { OWNGID: OWNGID} }); }; //Ext.Msg.show({ title: '提示', msg: "数据删除结束", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); //this.onRefreshClick(button, event); }, this); } , onAddCardUseClick: function (CARDGID) { function GetDateStr(AddDayCount) { var dd = new Date(); dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期 var y = dd.getFullYear(); var m = dd.getMonth() + 1; //获取当前月份的日期 var d = dd.getDate(); return y + "-" + m + "-" + d; } var EnterDate = GetDateStr(0); var record = Ext.create('DsTruckMng.ux.CardUseModel', { GID: NewGuid(), CARDNO: "", CARDGID: "", BILLNO: "", OPERATE: "充值", INNUM: "0", OUTNUM: "0", OPTIME: EnterDate, REMARK: "" }); this.storeCardUse.add(record); var n = this.storeCardUse.getCount(); this.cellEditingCardUse.startEditByPosition({ row: n - 1, column: 2 }); }, onDelCardUseClick: function (CARDGID, OWNGID) { var selectedRecords = this.formCardUse.selModel.getSelection(); var selections = this.formCardUse.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择充值卡使用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var _L = selections.length; for (var i = 0; i < _L; i++) { var record = selections[i]; if (record.data.OPERATE == "路单使用") { alert("不能删除由路单生成的充值卡使用明细"); return; } } Ext.MessageBox.confirm('提示', '确定删除这' + _L + '条记录吗?', function (btn) { if (btn == 'yes') { //var record = selections[0]; for (var i = 0; i < _L; i++) { var record = selections[i]; var GID = record.data.GID; //Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', async: false, url: '/TruckMng/Card/DeleteCardUse', params: { GID: GID }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeCardUse.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 } }; //Ext.Msg.show({ title: '提示', msg: "数据删除结束", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); var _this = this; this.storeCard.load({ async: false, params: { OWNGID: OWNGID }, callback: function (options, success, response) { for (var i = 0; i < _this.storeCard.getCount(); i += 1) { var member = _this.storeCard.getAt(i); if (member.data.GID == CARDGID) { _this.formCard.getSelectionModel().select(member); } } } }); }, this); }, onSaveCardUseClick: function (CARDGID, OWNGID) { var bodyCardUse = []; for (i = 0; i < this.storeCardUse.getCount(); i += 1) { var memberyf = this.storeCardUse.getAt(i); bodyCardUse.push(memberyf); }; var jsonCardUseBody = ConvertRecordsToJson(bodyCardUse); var jsonCardUseDelBody = ConvertRecordsToJsonAll(this.carduseDel); if (jsonCardUseBody == "" && jsonCardUseDelBody == "") { return; } Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/TruckMng/Card/SaveCardUse', scope: this, params: { CARDGID: CARDGID , CardUsebody: jsonCardUseBody , CardUseDelbody: jsonCardUseDelBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { //alert("保存成功"); var returnData = jsonresult.Data; this.storeCardUse.commitChanges(); var _this = this; this.storeCard.load({ async: false, params: { OWNGID: OWNGID }, callback: function (options, success, response) { for (var i = 0; i < _this.storeCard.getCount(); i += 1) { var member = _this.storeCard.getAt(i); if (member.data.GID == CARDGID) { _this.formCard.getSelectionModel().select(member); } } } }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } //alert('03'); } }); }, CardUseBeforeEdit: function (editor, e) { var OPERATE = e.record.get('OPERATE'); var canedit = true; if (OPERATE == "路单使用") { canedit = false; } return canedit; } , onAddTruckMonthClick: function () { var record = Ext.create('TruckMonthmb', { GID: NewGuid(), TRUCKNO: "", ACCDATE: "", ZJF: "0", BXF: "0", GZCR: "0", XLCR: "0", ZCR: "0" }); this.storeTruckMonth.add(record); var n = this.storeTruckMonth.getCount(); this.cellEditingTruckMonth.startEditByPosition({ row: n - 1, column: 2 }); }, onDelTruckMonthClick: function () { var selectedRecords = this.formTruckMonth.selModel.getSelection(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.TRUCKNO != "" || rec.TRUCKNO != "*") //如果是新增但没有保存的数据,没有必要提交到后台 { this.TruckMonthDel.push(rec); } this.storeTruckMonth.remove(selectedRecords[i]); } }, onAddTruckCertClick: function () { if (TruckNo == '') { Ext.MessageBox.alert('提示', '请先保存车辆基本信息!'); return; } var winAccess = new DsTruck.CertUpload({}); winAccess.TruckNo = TruckNo; winAccess.show(); }, ReflashEdt: function () { this.storeTruckCert.load({ params: { start: 0, limit: 9999, TruckNo: TruckNo} }); }, onDelTruckCertClick: function () { var selections = this.formTruckCert.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要删除的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = new Array(); for (var i = 0; i < selections.length; i++) { record.push(selections[i].data); } Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/TruckMng/MsWlTruck/CertDel', params: { data: Ext.JSON.encode(record) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.ReflashEdt(); 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); } });