/// Ext.namespace('DsTruck'); DsTruck.ROEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.ROEdit.superclass.constructor.call(this); }; 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); function getSaved() { var feedirty = DsTruck.GetDirty(panelEdit.storeBodyChfee, panelEdit.storeBodyChfeeDel); if (panelEdit.formEdit.getForm().isDirty()== true ) { return true; } else return false; } Ext.extend(DsTruck.ROEdit, Ext.Panel, { parentWin: null, OpStatus: 'add', StoreList: null, editRecord: null, BXSTATUS: 1, // parentfunction: null, _First: true, VISIBLERANGE: 0, OPERATERANGE: 0, WorkFlowName: "", WorkFlowID: "", initUIComponents: function () { //this.feeSerialNo = 0; this.RODel = []; //this.PayBodyDel = []; //枚举参照相关(编辑form) WorkFlowName = 'BaoxiaoMod'; Ext.define('BodyTypeMd', { extend: 'Ext.data.Model', fields: [ { name: 'BODYTYPE', type: 'string' }, { name: 'BODYTYPE_REF', type: 'string' } ] }); var BodyTypeData = [{ "BODYTYPE": "Ctn", "BODYTYPE_REF": "集装箱" }, { "BODYTYPE": "Other", "BODYTYPE_REF": "杂项" }, { "BODYTYPE": "RO", "BODYTYPE_REF": "滚装" }, { "BODYTYPE": "MovCtn", "BODYTYPE_REF": "外部拖箱"}]; this.storeBodyType = Ext.create('Ext.data.Store', { model: 'BodyTypeMd', data: BodyTypeData }); this.comboxBodyType = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '业务类型', forceSelection: true, store: this.storeBodyType, name: 'BODYTYPE', valueField: 'BODYTYPE', displayField: 'BODYTYPE_REF', readOnly: true }); 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); } } } }); ////////////////// //编辑form:formEdit this.formEdit = Ext.widget('form', { // layout: "border", region: 'north', frame: true, bodyPadding: 1, trackResetOnLoad: true, fieldDefaults: { margins: '1 1 1 1', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' //,split:true }, //bodyStyle: 'background:#FFF', items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{//container_1 xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '业务序列号', // allowBlank: false, //disabled: true, name: 'GID' }, this.comboxBodyType, { fieldLabel: '制单时间', format: 'Y-m-d', id: "EXPDATE", xtype: 'datefield', renderer: Ext.util.Format.dateRenderer('Y-m-d'), name: 'EXPDATE' }, { xtype: 'hiddenfield', flex: 1 } ] }, //container_1 end { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '会计月份', // allowBlank: false, //disabled: true, name: 'ACCDATE' }, { fieldLabel: '应收', name: 'Amount_1', id: "Amount_1", flex: 1 }, { fieldLabel: '应付', name: 'Amount_2', id: "Amount_2", flex: 1 }/*, { xtype: 'hiddenfield', flex: 1 }*/, { fieldLabel: '时间戳', name: 'TimeMark', flex: 1, hidden: true, margins: '0' }, { xtype: 'checkbox', flex: 1, fieldLabel: '业务锁定', name: 'Locked', readOnly: true } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '备注', name: 'REMARK', flex: 2 } ] } ] } ] }); ////////////////////////////////// //明细 <<<< 收支费用明细 >>>> // /* this.storeAccitems = Ext.create('DsExt.ux.RefTableStore', { model: 'Accitemsmb', proxy: { url: '/CommMng/BasicDataRef/GetAccitems' } }); this.storeAccitems.load({ params: { condition: ""} }); */ //数据集 this.storeRO = Ext.create('Ext.data.Store', { model: 'PortROmb', remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/TruckMng/MsWl_Port/GetRO', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //表格 this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.CBModel = Ext.create('Ext.selection.CheckboxModel'); this.formRO = new Ext.grid.GridPanel({ store: this.storeRO, enableHdMenu: false, region: 'center', title: '集装箱', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditing], selModel: this.CBModel, selType: 'cellmodel', tbar: [{ text: '增加明细', id: "add1", tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { this.onAddROClick(button, event); }, scope: this }, '-', { text: '删除明细', id: "del1", tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelROClick(button, event); }, scope: this }], columns: [ { sortable: true, hidden: true, dataIndex: 'GID', header: 'GID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'LINKID', header: 'LINKID', width: 80 }, { sortable: true, dataIndex: 'DRVCODE', header: '驾驶员姓名', width: 80, renderer: function (value, p, record) { if (value == null || value == '') return ''; else return record.data.DRVNAME; }, width: 80, editor: this.comboxDrvName }, { sortable: true, hidden: true, dataIndex: 'DRVNAME', header: 'DRVNAME' }, { sortable: true, dataIndex: 'Mobile', header: '电话', width: 80, editor: { xtype: 'textfield', //numberfield textfield selectOnFocus: true } }, { sortable: true, dataIndex: 'TRUCKNO', header: '车号', width: 80, editor: this.comboxTruckNo }, { sortable: true, dataIndex: 'Trans', header: '转运', width: 50, editor: { xtype: 'numberfield', //numberfield textfield selectOnFocus: true } }, { sortable: true, dataIndex: 'Dock', header: '倒车', width: 50, editor: { xtype: 'textfield', //numberfield selectOnFocus: true } }, { sortable: true, dataIndex: 'Mov', header: '车次数', width: 50/*, editor: { xtype: 'numberfield', //numberfield textfield selectOnFocus: true }*/ }, { sortable: true, dataIndex: 'Trans_Price', header: '转运费率', width: 50, editor: { xtype: 'numberfield', //numberfield textfield selectOnFocus: true } }, { sortable: true, dataIndex: 'Dock_Price', header: '倒车费率', width: 50, editor: { xtype: 'textfield', //numberfield selectOnFocus: true } }, { sortable: true, dataIndex: 'Mov_Price', header: '车次收费费率', width: 50, editor: { xtype: 'numberfield', //numberfield textfield selectOnFocus: true } }, { sortable: true, hidden: true, dataIndex: 'AvrOil', header: '平均油价', width: 80, editor: { xtype: 'numberfield', //numberfield textfield selectOnFocus: true } }, { sortable: true, hidden: true, dataIndex: 'Factor', header: '系数', width: 80, editor: { xtype: 'numberfield', //numberfield textfield selectOnFocus: true } }, { sortable: true, hidden: true, dataIndex: 'Plus', header: '尾数', width: 80, editor: { xtype: 'numberfield', //numberfield textfield selectOnFocus: true } }, { sortable: true, dataIndex: 'Amount_1', header: '应收(结算)', width: 80, editor: { xtype: 'numberfield', //numberfield textfield selectOnFocus: true } }, { sortable: true, dataIndex: 'Amount_2', header: '应付(核算)', width: 80, editor: { xtype: 'numberfield', //numberfield textfield selectOnFocus: true } }] }); //////////////////////////////////////////////明细<<<< 集装箱信息 >>>>结束 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { // id: "saveandclose", text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, { // id: "saveandclose", text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, '-', { // id: "saveandclose", text: "关闭", handler: function (button, event) { window.close(); }, scope: this } ] }); //end 按钮Toolbar //布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 30, items: [this.panelBtn] }); this.panelRO = new Ext.Panel({ layout: "border", region: 'center', margin: '1 1', height: 230, split: true, items: [this.formEdit, this.formRO] }); Ext.apply(this, { items: [this.panelTop, this.panelRO] }); parentWin = window.parent.opener; this.InitData(); //集中绑定事件 this.formRO.on('edit', function (editor, e, eOpts) { this.ROAfterEdit(editor, e, eOpts); }, this); this.cellEditing.on('beforeedit', function (editor, e) { //Ext.getCmp("zongshu").setText("1234"); return this.ROBeforeEdit(editor, e); }, this); }, //end initUIComponents parentfunction: function (button, event) { var ret1 = window.parent.opener.OprationSwap(); // alert(this.First); ret1[3](); }, onAddROClick: function (button, event, type) { //var allow = this.getAllowOperationDetail(); //if (allow == false) { // return; //} var store = null; store = this.storeRO; //var newSerialno = this.GetHandleSerialNo(store, type); var record = null; var Trans_Price = "0"; var Dock_Price = "0"; var Mov_Price = "0"; if (store.getCount() > 0) { Trans_Price = store.getAt(0).get("Trans_Price").toString(); Dock_Price =store.getAt(0).get("Dock_Price").toString(); Mov_Price = store.getAt(0).get("Mov_Price").toString(); } record = Ext.create('PortROmb', { GID: newGuid(), LINKID: "", DRVCODE: "", DRVNAME: "", Mobile: "", TRUCKNO: "", Trans: "0", Dock: "0", Mov: "0", Trans_Price: Trans_Price, Dock_Price: Dock_Price, Mov_Price: Mov_Price, AvrOil: "6", Factor: "0.7", Plus: "11.5", Amount_1: "0", Amount_2: "0" }); store.add(record); cellediting = this.cellEditing; var n = store.getCount(); cellediting.startEditByPosition({ row: n - 1, column: 2 }); }, onDelROClick: function (button, event) { var selectedRecords = this.formRO.selModel.getSelection(); Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) { if (btn == 'yes') { for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.GID != "" || rec.GID != "*") //如果是新增但没有保存的数据,没有必要提交到后台 { this.RODel.push(rec); } this.storeRO.remove(selectedRecords[i]); } } }, this); //aftereditform(); var Amount_ALL = 0; for (var i = 0; i < this.storeRO.getCount(); i += 1) { Amount_ALL = Add(Amount_ALL, parseFloat(this.storeRO.getAt(i).get("Amount"))); } Ext.getCmp("AMOUNT_ALL").setValue(Amount_ALL + ""); }, ROAfterEdit: function (editor, e, eOpts) { //需要自己实现里面的事件 if (COMPANYID == "") { alert("登录信息不全,请退出重新登录"); returen; } if (e.field == 'DRVCODE') { var BSrecords = DsStoreQueryBy(this.storeDrvName, 'DrvCode', e.value); if (BSrecords.getCount() > 0) { var BSdata = BSrecords.getAt(0).data; e.record.set('DRVNAME', BSdata.DrvName); e.record.set('Mobile', BSdata.Mobile); } else { e.record.set('DRVNAME', ''); } } if (e.field == 'Trans' || e.field == 'Dock' || e.field == 'Trans_Price' || e.field == 'Dock_Price' || e.field == 'Mov_Price' ) { var Trans = parseFloat(e.record.get('Trans')); var Trans_Price = parseFloat(e.record.get('Trans_Price')); var Dock = parseFloat(e.record.get('Dock')); var Dock_Price = parseFloat(e.record.get('Dock_Price')); var Mov_Price = parseFloat(e.record.get('Mov_Price')); var Mov = Add(Div(Trans, 2), Div(Dock, 2)); var Amount_1 = Mul(Mov, Mov_Price); var Amount_2 = Add(Mul(Trans, Trans_Price), Mul(Dock, Dock_Price)); e.record.set('Amount_1', Amount_1); e.record.set('Amount_2', Amount_2); e.record.set('Mov', Mov); }/* if ( e.field == 'Mov') { var Trans = parseFloat(e.record.get('Trans')); var Trans_Price = parseFloat(e.record.get('Trans_Price')); var Dock = parseFloat(e.record.get('Dock')); var Dock_Price = parseFloat(e.record.get('Dock_Price')); var Mov_Price = parseFloat(e.record.get('Mov_Price')); var Mov = parseFloat(e.record.get('Mov')); //var AvrOil = parseFloat(e.record.get('AvrOil')); var Amount_1 = Mul(Mov, Mov_Price); var Amount_2 = Add(Mul(Trans, Trans_Price), Mul(Dock, Dock_Price)); //var Mov = Add(Add(_20, _40), _45); //e.record.set('TEU', TEU); e.record.set('Amount_1', Amount_1); e.record.set('Amount_2', Amount_2); //e.record.set('Mov', Mov); }*/ }, ROBeforeEdit: function (editor, e) { }, InitData: function () { this.OpStatus = 'add'; var condition = ''; if (parentWin) { var ret = parentWin.OprationSwap(); this.OpStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; // this.parentfunction = ret[3]; } if (this.OpStatus == 'edit') { condition = " P.GID='" + this.editRecord.get('GID') + "'"; } this.LoadData(this.OpStatus, condition); }, //end InitData //载入数据 LoadData: function (OpStatus, condition) { if (COMPANYID == "") { alert("登录信息不全,请退出重新登录"); return; } this.OpStatus = OpStatus; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/TruckMng/MsWl_Port/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; // this.formEdit.getForm().reset(); if (data.EXPDATE == "") { data.EXPDATE = currdate.format('yyyy-MM-dd') }; data.BODYTYPE = "RO"; this.formEdit.getForm().setValues(data); //alert(data.TimeMark); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); //request over if (this.OpStatus == 'edit') { //this.formEdit.getForm().findField('BXGID').setDisabled(false); var GID = this.editRecord.get('GID'); this.storeRO.load({ params: { GID: GID} }); } }, // end LoadDate Save: function (type) { var Amount_1 = 0; var Amount_2 = 0; for (var i = 0; i < this.storeRO.getCount(); i += 1) { Amount_1 = Add(Amount_1, parseFloat(this.storeRO.getAt(i).get("Amount_1"))); Amount_2 = Add(Amount_2, parseFloat(this.storeRO.getAt(i).get("Amount_2"))); } Ext.getCmp("Amount_1").setValue(Amount_1 + ""); Ext.getCmp("Amount_2").setValue(Amount_2 + ""); var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var data = this.formEdit.getForm().getValues(); var GID = data.GID; if (data.Locked == "on") { alert("请先解除锁定"); return false; } data.Locked = this.formEdit.getForm().findField('Locked').getValue() ? 1 : 0; if (COMPANYID == "") { alert("登录信息不全,请退出重新登录"); return; } var ROs = []; for (var i = 0; i < this.storeRO.getCount(); i += 1) { var member = this.storeRO.getAt(i); ROs.push(member); /* var Amount = member.data.Amount_1; if (Amount == 0 || NOTAXAMOUNT == 0) { Ext.Msg.show({ title: '警告', msg: '不含税价格和价税合计金额均不允许为0,请修改后再保存', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; }*/ } var RO = ConvertRecordsToJson(ROs); var RODel = ConvertRecordsToJsonAll(this.RODel); var _this = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/TruckMng/MsWl_Port/SaveRO', scope: this, async: false, params: { OpStatus: this.OpStatus, data: Ext.JSON.encode(data), RO: RO, RODel: RODel }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); 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]; // alert(editRecord.get('ContractNo')); } else if (this.OpStatus == 'edit') { var editp = Ext.create('MsWl_Portmb', returnData); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; //alert(name + ' -- ' + editp.get(name)); if (name != 'GID') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); } this.storeRO.commitChanges(); if (type == '0') { this.OpStatus = 'edit'; //basicForm.findField('Feeid').setDisabled(false); //this.storeApp.load({ params: { condition: this.editRecord.get('ContractNo')} }); //this.storeCargo.load({ params: { condition: this.editRecord.get('ContractNo')} }); //basicForm.findField('Feeid').setDisabled(true); var GID = this.editRecord.get('GID'); this.storeRO.load({ params: { GID: GID} }); } else if (type == '1') {//保存并关闭 window.close(); } else if (type == '2') {//保存并全部新建 this.LoadData('add', ''); } } 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'); } }); } //end save , DoPrint: function () { var basicForm = this.formEdit.getForm(); var GID = this.editRecord.get('GID') /* if (ContractNo == '*' || ContractNo == '') { Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; }*/ 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; } //alert(GetDateStr(+5)); var needdate = GetDateStr(+5); var printdate = GetDateStr(0); var _date = Ext.getCmp("CREATEDATE").getRawValue(); var printType = 'Baoxiao'; //客户对账_KC // var sql1 = " select OA_Baoxiao.*,sd.deptname DN "; var sql1 = sql1 + " from OA_Baoxiao left join [user] U on U.showname=OA_Baoxiao.createuser "; var sql1 = sql1 + " left join [user_baseinfo] ub on ub.userid=u.gid "; var sql1 = sql1 + " left join sys_dept sd on sd.gid=OA_Baoxiao.DEPTNAME "; var sql1 = sql1 + " where BXGID='" + BXGID + "' "; var sql2 = " select vs.mblno,vs.CUSTNO, c.* from ch_fee c "; var sql2 = sql2 + " left join vw_settlement vs on vs.bsno=c.bsno "; var sql2 = sql2 + " where BXGID ='" + BXGID + "' order by c.CHEQUENUM,c.remark"; var sql3 = "select createuser from oa_baoxiao where bxgid ='" + BXGID + "' "; var sql4 = "select dbo.GetRemain_ZWC ('" + DEPTGID + "','" + _date + "')"; //获取该部门剩余资金 var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } });