//集运管理-路单查询 Ext.namespace('DsTruck'); DsTruck.MsWl_HaierMainIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.MsWl_HaierMainIndex.superclass.constructor.call(this); }; //#region 当前时间 Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.getSeconds(), //second "q+": Math.floor((this.getMonth() + 3) / 3), //quarter "S": this.getMilliseconds() //millisecond } if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); return format; } var xhr = new XMLHttpRequest(); var currdate = new Date(); if (!xhr) { //...其他生成xmlhttprequest方法 } xhr.open("HEAD", location.href, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var datestr = xhr.getResponseHeader("Date"); currdate = new Date(datestr); // alert(currdate.format('yyyy-MM-dd')); } } xhr.send(null); //#endregion Ext.extend(DsTruck.MsWl_HaierMainIndex, Ext.Panel, { PageSize: 100, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'HaierMainmb', remoteSort: false, proxy: { type: 'ajax', url: '/TruckMng/MsWl_HaierMain/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.formname = "MsWl_HaierMain"; //#region 表参照 this.storeTruckNo = Ext.create('DsExt.ux.RefTableStore', { model: 'MsWlBsHeadRefMsWlTruck', proxy: { url: '/TruckMng/MsWlPc/GetTruckNoList' } }); this.storeTruckNo.load({ params: { condition: ""} }); this.comboxTruckNo = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '车牌号', store: this.storeTruckNo, name: 'TruckNo', valueField: 'TruckNo', displayField: 'TruckNo', listeners: { change: function (field, newValue, oldValue) { //this.tonAndTruckNoChange(field, newValue, oldValue); }, scope: this } }); this.storeDrvName = Ext.create('DsExt.ux.RefTableStore', { model: 'MsWlBsHeadRefMsWlDriver', proxy: { url: '/TruckMng/MsWlPc/GetDrvNameList' } }); this.storeDrvName.load({ params: { condition: ""} }); this.comboxDrvName = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '司机', store: this.storeDrvName, name: 'DrvCode', valueField: 'DrvCode', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { //this.setDrvName(records[0].data.DrvCode); } } } }); //#endregion this.column = [ { sortable: true, hidden: true, dataIndex: 'GID', header: 'GID', width: 80 }, { sortable: true, dataIndex: 'ACCDATE', header: '月份', width: 80 }, { sortable: true, dataIndex: 'TruckNo', header: '车号', width: 80 }, { sortable: true, hidden: true, dataIndex: 'DrvCode', header: 'DrvCode', width: 80 }, { sortable: true, dataIndex: 'DrvName', header: '驾驶员', width: 80 }, { sortable: true, dataIndex: 'TotalMil', header: '总行程(公里)', width: 80,align:'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'FuelPrice', header: '油耗单价', width: 80 }, { sortable: true, dataIndex: 'FuelAmount', header: '油费(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'XXF', header: '小修费(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'EBF', header: '二保费(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true,hidden:true, dataIndex: 'DZXF', header: '大中修费(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'LTSH', header: '轮胎损耗(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'LQF', header: '路桥费、条码费等代垫付费用(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'LTKF', header: '鲁通卡服务费(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'RGF', header: '人工成本费(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'YLS', header: '人工养老税金(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'LCJL', header: '超里程激励(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'Amount_1', header: '费用小计(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'Tax', header: '税金(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'ZFJL', header: '正负激励(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'ZCGL', header: '资产管理费(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'YXCB', header: '运行成本合计(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'YSSR', header: '运输收入(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'CLBX', header: '车辆保险费(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'CLZJ', header: '车辆折旧费(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'Amount_2', header: '超收入小计(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'CLJL', header: '超利激励(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'CLSJ', header: '超利税金(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'AQKH', header: '安全事故考核(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } }, { sortable: true, dataIndex: 'Amount_3', header: '应挂金额(元)', width: 80, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; } } ]; this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.PCCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true }); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 45 }); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, 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(), ], // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); /////////////以下部分为获取存储的gridpanel显示样式 this.column = DsTruck.GetGridPanel(GID, this.formname, this.column); this.column.unshift(new Ext.grid.RowNumberer()); this.gridList.reconfigure(this.storeList, this.column); //////////////////////////// //#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: [{ xtype: 'monthfield', name: 'ACCDATE', fieldLabel: '月份', labelWidth: 80, anchor: '100%' }, this.comboxTruckNo , this.comboxDrvName, { xtype: 'hiddenfield',flex:2 } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //#endregion formSearch //菜单 var menu_SetFee = new Ext.menu.Menu({ id: 'PriceMenu', items: [{ text: '设定超重费用', handler: clickHandler_1 }, { text: '超重费用取消', handler: clickHandler_2 }, { text: '设定重回额外费用', handler: clickHandler_3 }, { text: '重回额外费用取消', handler: clickHandler_4 }] }); me = this; function clickHandler_1() { me.SetFee("超重费", "150", "1"); }; function clickHandler_2() { me.SetFee("超重费", "150", "0"); }; function clickHandler_3() { me.SetFee("双背附加费", "600", "1"); }; function clickHandler_4() { me.SetFee("双背附加费", "600", "0"); }; //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, '-', { text: '新建路单',hidden:true, tooltip: '新建路单', iconCls: "btnadddetail", handler: function (button, event) { this.onAddPCClick(button, event); }, scope: this }, { text: '删除', tooltip: '删除', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelPCClick(button, event); }, scope: this }, { text: "保存修改", iconCls: "btnsave", handler: function (button, event) { this.onSaveClick(button, event); }, scope: this }, '-', { text: "导入海尔月度汇总", iconCls: "btnexportexcel", handler: function (button, event) { var winAccess = new DsTruck.FileImport({}); winAccess.StoreList = this.storeList; winAccess.show(); }, scope: this }, '-', { text: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this }, '-', { text: "保存列表样式", id: "btntest", handler: function (button, event) { DsTruck.SaveGridPanel(GID, this.formname, this.gridList.columns, this.column, 1, false); }, scope: this } ] }); //#region 布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 70, 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); //#endregion }, //end initUIComponents onAuditRefuseClick: function (button, event) { var sql = " A.GID in (select bsno from ch_fee where FEESTATUS=6)"; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: "", condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onRefreshClick: function (button, event) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); this.storeList.load({ //GetDataList(int start, int limit, string sort, string condition) params: { start: 0, limit: this.PageSize, sort: "", condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, getCondition: function () { var form = this.formSearch.getForm(); var sql = ""; /* var sqldata = form.getValues(); sql = Ext.JSON.encode(sqldata); */ //var mblNo = form.findField('PS_MBLNO').getValue(); //sql = sql + getAndConSql(sql, mblNo, "A.MblNo like '%" + mblNo + "%'"); var ACCDATE = form.findField('ACCDATE').getRawValue(); sql = sql + getAndConSql(sql, ACCDATE, " M.ACCDATE='" + ACCDATE + "'"); var TruckNo = form.findField('TruckNo').getValue(); sql = sql + getAndConSql(sql, TruckNo, " M.TruckNo='" + TruckNo + "'"); var DrvCode = form.findField('DrvCode').getValue(); sql = sql + getAndConSql(sql, DrvCode, " M.DrvCode = '" + DrvCode + "'"); /*var billNo = form.findField('PS_REFBILLNO').getValue(); sql = sql + getAndConSql(sql, billNo, " A.RefBillNo like '%" + billNo + "%'"); var expDate_Min = form.findField('PS_EXPDATEBGN').getRawValue(); sql = sql + getAndConSql(sql, expDate_Min, " A.ExpDate>='" + expDate_Min + "'"); var expDate_Max = form.findField('PS_EXPDATEEND').getRawValue(); sql = sql + getAndConSql(sql, expDate_Max, " A.ExpDate<='" + expDate_Max + " 23:59:59'"); var orgCode = form.findField('OrgCode').getValue(); sql = sql + getAndConSql(sql, orgCode, "OrgCode like '%" + orgCode + "%'"); */ 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; ret[3] = this.SelectedRecord.data.REFBILLNO; ret[4] = "MsRptPcHeadQryIndex"; return ret; }, onExportClick: function (button, event) { GridExportExcelPage(this.gridList); }, SetFee: function (FeeName, Amount, Type) { var _condition = this.getCondition(); var GIDList = []; var selectedRecords = this.gridList.selModel.getSelection(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; GIDList.push(rec.get('GID')); } var _GIDList = ConvertStringListToJson(GIDList); Ext.Ajax.request({// waitMsg: '正在初始化库存数据...', url: '/TruckMng/MsRptPcHeadQry/SetFee', params: { GIDList: _GIDList, FeeName: FeeName, Amount: Amount, Type: Type }, callback: function (_count) { //alert('初始化完成'); //重新load库存表的store this.storeList.load({ params: { condition: _condition} }); }, scope: this }); //request over }, onAddPCClick: function (button, event, type) { var store = null; store = this.storeList; //var truckno = Ext.getCmp('S_TRUCKNO').getValue(); record = Ext.create('PCmb', { TRUCKNO: "", DRVCODE: "", DRVNAME: "", GId: newGuid(), BillNo: "", DdCode: usercode, DdCode_Ref: SHOWNAME, DDNAME: "", ArriveDate: currdate.format('yyyy-MM-dd'), CustCode: "QDHE", CustName: "海尔", TRUCKNO: "", MBLNO: "", DRVNAME: "", DRVNAME_REF: "", MOBILE: "", CONTAINERTYPE: "", CONTAINERTYPE_REF: "", CONTAINERQTY: "", YARDCODE_REF: "", VOYVEG_REF: "", DSTAREA: "", NOLOADMIL: "", OVERLOADMIL: "", RATEDFUEL: "", REALFUEL: "", LRDATE: "", USERCODE: "", USERNAME: "", REFBILLNO: "", DETINATION: "", CONTAINERNO: "", SEALNO: "", Ton: "", ActualWeight: "", IsDoubleREF: "", IsDoubleREF: "", TimeMark: 0 }); var _this = this; var data = record.data; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/TruckMng/MsWl_Haier/CreatePC', scope: this, async: true, params: { data: Ext.JSON.encode(data) }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { record = jsonresult.Data; store.add(record); cellediting = this.cellEditing; var n = store.getCount(); cellediting.startEditByPosition({ row: n - 1, column: 2 }); } 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'); } }); }, onDelPCClick: 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 selectedRecords = []; selectedRecords = this.gridList.selModel.getSelection(); /* var candelete = DsTruck.CheckBaoxiaoDelete(selectedRecords); if (candelete == false) { return; }*/ var record = selections[0]; Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/TruckMng/MsWl_Haier/DeleteYDHZ', 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); //InitData(); } //onDeleteClick , onSaveClick: function (button, event) { for (var i = 0; i < this.storeList.getCount(); i += 1) { var record = this.storeList.getAt(i); if (record.dirty) { Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/TruckMng/MsWl_Haier/SaveYDHZ', scope: this, async: false, params: { data: Ext.JSON.encode(record.data) }, callback: function (options, success, response) { if (success) { //Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnData = jsonresult.Data; var editp = Ext.create('PCmb', returnData); this.storeList.getAt(i).fields.each(function (field) { if (field.persist) { name = field.name; //alert(name + ' -- ' + editp.get(name)); if (name != 'BillNo') this.storeList.getAt(i).set(name, editp.get(name)); } }, this); this.storeList.getAt(i).commit(); } 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 }); } } }); } } } });