/// Ext.namespace('DsTruck'); var C_cargoinfo_id=""; var HTHCount=0; DsTruck.JiekuanEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.JiekuanEdit.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.storeJieKuan2, panelEdit.storeJieKuan2Del); if (panelEdit.formEdit.getForm().isDirty()== true ) { return true; } else return false; } Ext.extend(DsTruck.JiekuanEdit, Ext.Panel, { parentWin: null, OpStatus: 'add', StoreList: null, editRecord: null, // parentfunction: null, _First: true, initUIComponents: function () { this.feeSerialNo = 0; this.JieKuan2Del = []; //枚举参照相关(编辑form) Ext.define('PayTypeMd', { extend: 'Ext.data.Model', fields: [ { name: 'PayTypeID', type: 'string' }, { name: 'PayTypeName', type: 'string' } ] }); var PayTypeData = [{ "PayTypeID": "1", "PayTypeName": "成本" }, { "PayTypeID": "2", "PayTypeName": "费用"}]; var storePayType = Ext.create('Ext.data.Store', { model: 'PayTypeMd', data: PayTypeData }); this.comboxPayType = Ext.create('DsExt.ux.RefEnumCombox', { //fieldLabel: '收付类型', forceSelection: true, store: storePayType, name: 'Reason', valueField: 'PayTypeName', displayField: 'PayTypeName' }); Ext.define('TFmb', { extend: 'Ext.data.Model', fields: [ { name: 'TFID', type: 'string' }, { name: 'TFName', type: 'string' } ] }); var TFData = [{ "TFID": "0", "TFName": "未借出" }, { "TFID": "1", "TFName": "已借出"}/*, { "PayTypeID": "2", "PayTypeName": "原单原转"}*/]; this.storeTF = Ext.create('Ext.data.Store', { model: 'TFmb', data: TFData }); this.comboxTF = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '借款状态', forceSelection: true, store: this.storeTF, name: 'ISOVER', valueField: 'TFID', displayField: 'TFName' }); this.storeUser = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeUser.load({ params: { condition: " 1=1 "} }); this.comboxCreator = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '制单人', forceSelection: true, store: this.storeUser, name: 'ENTEROPERATOR', id: "ENTEROPERATOR", valueField: 'GID', displayField: 'CodeAndName', allowBlank: false, readOnly: true }); this.comboxAuditor = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '审核人', forceSelection: true, store: this.storeUser, name: 'AUDITOR', id: "AUDITOR", valueField: 'UserCode', displayField: 'CodeAndName' }); this.storecurr = Ext.create('DsExt.ux.RefTableStore', { model: 'currRef', proxy: { url: '/CommMng/BasicDataRef/GetcurrRefList' } }); this.storecurr.load({ params: { condition: ""} }); this.comboxcurr = Ext.create('DsExt.ux.RefTableCombox', { forceSelection: true, //fieldLabel: '币别', store: this.storecurr, name: 'CURRENCY', valueField: 'codename', displayField: 'codename', value: "RMB" }); this.storeJKSTATUS = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeJKSTATUS.load({ params: { enumTypeId: 99024} }); this.comboxJKSTATUS = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '借款单状态', //forceSelection :true, store: this.storeJKSTATUS, name: 'JKSTATUS', readOnly: true, id: "JKSTATUS" }); this.storeJKTYPE = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeJKTYPE.load({ params: { enumTypeId: 36} }); this.comboxJKTYPE = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '借款方式', forceSelection: true, store: this.storeJKTYPE, name: 'JKTYPE', //readOnly: true, id: "JKTYPE" }); this.storeFEESTATUS = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeFEESTATUS.load({ params: { enumTypeId: 99024} }); this.comboxFEESTATUS = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '费用状态', forceSelection: true, store: this.storeFEESTATUS, name: 'FEESTATUS', readOnly: true, id: "STATUS" }); this.storeAccitems = Ext.create('DsExt.ux.RefTableStore', { model: 'Accitemsmb', proxy: { url: '/CommMng/BasicDataRef/GetAccitems' } }); this.storeAccitems.load({ params: { condition: ""} }); //通过mblno获取bsno this.storeBS = Ext.create('DsExt.ux.RefTableStore', { model: 'BSmb', proxy: { url: '/OA/Baoxiao/GetBSNO' } }); this.storeBS.load({ params: { COMPANYID: COMPANYID} }); this.comboxMAKETIMEUPPER = Ext.create('DsExt.ux.RefTableCombox', { //fieldLabel: '业务编号', // forceSelection: true, store: this.storeBS, name: 'MAKETIMEUPPER', valueField: 'BSNO', displayField: 'MBLNO' }); this.comboxBANK = Ext.create('DsExt.ux.RefTableCombox', { //fieldLabel: '收支方式', //收支的银行账户 store: this.storeAccitems, forceSelection: true, name: 'OPERATORSIDE', valueField: 'ACCID', displayField: 'ACCIDNAME', flex: 1 }); ////////////////// //编辑form:formEdit this.formEdit = Ext.widget('form', { // layout: "border", region: 'north', frame: true, bodyPadding: 3, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', 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, readOnly: true, name: 'GID' }, { fieldLabel: 'COMPANYID', hidden: true, id: "COMPANYID", name: 'COMPANYID', flex: 1 }, { fieldLabel: 'TimeMark', hidden: true, id: "TimeMark", name: 'TimeMark', flex: 1 }, { fieldLabel: '制单时间', format: 'Y-m-d H:i:s', id: "ENTERDATE", xtype: 'datefield', renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'), name: 'ENTERDATE' }, this.comboxCreator, { fieldLabel: 'DEPTID', hidden: true, id: "DEPTID", name: 'DEPTID', flex: 1 }] }, //container_1 end { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxJKTYPE , { fieldLabel: '支票号', name: 'CHEQUENO', flex: 1 }, this.comboxJKSTATUS] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'COMPANY', name: 'COMPANY', hidden: true, flex: 1 }, { fieldLabel: 'DEPTNAME', name: 'DEPTNAME', hidden: true, flex: 1 }, { fieldLabel: 'BSNO', id: "BSNO", name: 'BSNO', hidden: true, flex: 1 }, { fieldLabel: '备注', name: 'REMARK', flex: 2 }, { fieldLabel: '预计还款日', format: 'Y-m-d', xtype: 'datefield', renderer: Ext.util.Format.dateRenderer('Y-m-d'), name: 'EXREPAYDATE' } ] } ] } ] }); ////////////////////////////////// //明细 <<<< 收支费用明细 >>>> // this.comboxAccitems = Ext.create('DsExt.ux.RefTableCombox', { //fieldLabel: '费用科目', store: this.storeAccitems, name: 'FEENAME', valueField: 'ACCID', displayField: 'ACCIDNAME' }); this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.FeeTypeRefModel', proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' } }); this.storeFeeNameRef.load({ params: { condition: ""} }); this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeFeeNameRef, name: 'FeeName', valueField: 'Name', 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, name: 'CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName' }); /* this.storecurr = Ext.create('DsExt.ux.RefTableStore', { model: 'currRef', proxy: { url: '/CommMng/BasicDataRef/GetcurrRefList' } }); this.storecurr.load({ params: { condition: ""} }); this.comboxcurr = Ext.create('DsExt.ux.RefTableCombox', { store: this.storecurr, name: 'currid', valueField: 'gid', displayField: 'codename' //币别 });*/ this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.FeeTypeRefModel', proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' } }); this.storeFeeNameRef.load({ params: { condition: ""} }); this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeFeeNameRef, forceSelection: true, name: 'FeeName', valueField: 'Name', displayField: 'CodeAndName' }); //数据集 this.storeJieKuan2 = Ext.create('Ext.data.Store', { model: 'JieKuan2Bodymb', remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/OA/Jiekuan2/GetJieKuan2Body', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.storeBS = Ext.create('DsExt.ux.RefTableStore', { model: 'BSmb', proxy: { url: '/OA/Baoxiao/GetBSNO' } }); this.storeBS.load({ params: { COMPANYID: COMPANYID } }); this.comboxMAKETIMEUPPER = Ext.create('DsExt.ux.RefTableCombox', { //fieldLabel: '业务编号', forceSelection: true, store: this.storeBS, name: 'BSNO', valueField: 'BSNO', displayField: 'MBLNO' }); //表格 this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); this.formJieKuan2 = new Ext.grid.GridPanel({ store: this.storeJieKuan2, enableHdMenu: false, region: 'center', //layout: "border", bodyStyle: 'background:#FFF', trackResetOnLoad: true, //height: 160, title: '借款明细', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditing], selModel: this.CheckBoxModel, selType: 'cellmodel', tbar: [{ text: '增加明细', tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { this.onAddFeeClick(button, event); }, scope: this }, '-', { text: '删除明细', tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelFeeClick(button, event); }, scope: this }], columns: [ new Ext.grid.RowNumberer() , { sortable: true, hidden: true, dataIndex: 'GID', header: 'GID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'JKGID', header: 'JKGID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'FEETYPE', header: 'FEETYPE', width: 80 }, { sortable: true, hidden: true, dataIndex: 'FEETYPE_REF', header: '收付类型', width: 80 }, { sortable: true, hidden: true, dataIndex: 'FEESTATUS', header: 'FEESTATUS', width: 80 }, { sortable: true, dataIndex: 'FEESTATUS_REF', header: '费用状态', width: 80 }, { sortable: true, dataIndex: 'FEENAME', header: '费用名称', width: 80, editor: this.comboxFeeNameRef }, { sortable: true, dataIndex: 'CURRENCY', header: '币别', width: 80, editor: this.comboxcurr }, { sortable: true, dataIndex: 'Remark', header: '借款理由', width: 200, editor: { xtype: 'textfield', //numberfield selectOnFocus: true } }, { sortable: true, dataIndex: 'AMOUNT', header: '金额', width: 100, editor: { xtype: 'numberfield', //numberfield selectOnFocus: true }, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'SETTLEMENT', header: '已核销金额', width: 100, editor: { xtype: 'numberfield', //numberfield selectOnFocus: true }, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, hidden: true, dataIndex: 'MODIFIEDUSER', header: 'MODIFIEDUSER', width: 80 }, { sortable: true, hidden: true, dataIndex: 'MODIFIEDTIME', header: 'MODIFIEDTIME', width: 80 }, { sortable: true, dataIndex: 'BXGID', header: '报销单号', width: 80 }, { sortable: true, dataIndex: 'SALESNO', header: '相关编号', width: 120, editor: { xtype: 'textfield', //numberfield selectOnFocus: true } }, { sortable: true, dataIndex: 'F_NO', header: '业务编号(提单号)', //hidden: true, width: 150, renderer: function (value, p, record) { if (value == null || value == '') return ''; else return record.data.MBLNO; }, editor: this.comboxMAKETIMEUPPER } ] }); //////////////////////////////////////////////明细<<<< 收支费用明细 >>>>结束 this.formSum = Ext.widget('form', { // layout: "border", region: 'south', frame: true, bodyPadding: 3, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', 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: '合计RMB', // allowBlank: false, readOnly: true, flex: 1, name: 'RMBAMOUNT', id: "RMBAMOUNT" }, { fieldLabel: '金额大写', // allowBlank: false, readOnly: true, flex: 2, name: 'HJRMBDX', id: "HJRMBDX" }] }, //container_1 end { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '合计USD', // allowBlank: false, readOnly: true, flex: 1, name: 'USDAMOUNT', id: "USDAMOUNT" }, { fieldLabel: '金额大写', // allowBlank: false, readOnly: true, flex: 2, name: 'HJUSDDX', id: "HJUSDDX" }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '合计其他币别', // allowBlank: false, readOnly: true, flex: 1, name: 'OTHERAMOUNT', id: "OTHERAMOUNT" }, { fieldLabel: '金额大写', // allowBlank: false, readOnly: true, flex: 2, name: 'HJOTHERDX', id: "HJOTHERDX" } ] } ] } , {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{//container_1 xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '审核人', // allowBlank: false, readOnly: true, flex: 1, name: 'AUDITOR' }, { fieldLabel: '审核时间', // allowBlank: false, readOnly: true, flex: 1, name: 'AUDITTIME' }, { fieldLabel: '审核人',hidden:true, // allowBlank: false, readOnly: true, flex: 0.5, name: 'Auditor2' }, { fieldLabel: '审核时间', hidden: true, // allowBlank: false, readOnly: true, flex: 0.5, name: 'AuditTime2' }, { xtype: 'hiddenfield', flex: 3}] }, //container_1 end { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ ] } ] } ] }); //公共按钮Toolbar:panelBtn this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { id: "savebtn", text: "保存", handler: function (button, event) { this.Save('0'); }, scope: this }, { id: "saveandclosebtn", text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, { id: "saveandnewbtn", text: "保存并新建", handler: function (button, event) { this.Save('2'); }, scope: this }, '-', { // id: "saveandclose", text: "关闭", handler: function (button, event) { window.close(); }, scope: this }, '-', { // id: "saveandclose", text: "打印", handler: function (button, event) { this.DoPrint(); }, scope: this } ] }); //end 按钮Toolbar //布局 /* 3 */ this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 32, //bodyStyle: 'background:#FFF', items: [this.panelBtn]//, this.formEdit] }); this.panelBody = new Ext.Panel({ layout: "border", region: "center", height: 260, split: true, items: [this.formJieKuan2] }); this.page_1 = new Ext.Panel({ layout: "border", title: "借款单", // bodyStyle: 'background:#FFF', items: [this.formEdit, this.panelBody, this.formSum] }); /* this.page_2 = new Ext.Panel({ title: "库存管理", items: [this.formKC] }); this.page_3 = new Ext.Panel({ title: "票据管理", items: [this.gridListReceipt] }); this.page_4 = new Ext.Panel({ title: "应收应付录入", items: [this.gridListChFee] }); this.panelReceipt = new Ext.Panel({ layout: "border", region: "center", items: [this.panelBodyReceipt] });*/ this.MainTab = new Ext.tab.Panel({ layout: "border", region: "center", bodyStyle: 'background:#FFF', items: [ this.page_1 //, this.page_2 //, this.page_3 //, this.page_4 ] }) Ext.apply(this, { items: [this.panelTop, this.MainTab] }); parentWin = window.parent.opener; this.InitData(); //集中绑定事件 this.formJieKuan2.on('edit', function (editor, e, eOpts) { this.JieKuan2AfterEdit(editor, e, eOpts); }, this); this.cellEditing.on('beforeedit', function (editor, e) { //Ext.getCmp("zongshu").setText("1234"); return this.cellEditingBeforeEdit(editor, e); }, this); }, //end initUIComponents parentfunction: function (button, event) { var ret1 = window.parent.opener.OprationSwap(); // alert(this.First); ret1[3](); }, SetAmount: function () { var RMBAMOUNT = 0; var USDAMOUNT = 0; var OTHERAMOUNT = 0; for (var i = 0; i < this.storeJieKuan2.getCount(); i += 1) { var Amount = this.storeJieKuan2.getAt(i).get("AMOUNT"); var CURRENCY = this.storeJieKuan2.getAt(i).get("CURRENCY"); if (CURRENCY == "RMB") { RMBAMOUNT = Add(RMBAMOUNT, Amount); } else if (CURRENCY == "USD") { USDAMOUNT = Add(USDAMOUNT, Amount); } else { OTHERAMOUNT = Add(OTHERAMOUNT, Amount); } } //this.editRecord.set('AMOUNT', Amount + ''); //this.formEdit.getForm().setValues(this.editRecord.data); Ext.getCmp("RMBAMOUNT").setValue(RMBAMOUNT + ""); Ext.getCmp("USDAMOUNT").setValue(USDAMOUNT + ""); Ext.getCmp("OTHERAMOUNT").setValue(OTHERAMOUNT + ""); }, SetDX: function () { var data = this.formSum.getForm().getValues(); Ext.getCmp("HJRMBDX").setValue(formatRMB(data.RMBAMOUNT)); Ext.getCmp("HJUSDDX").setValue(formatUSD(data.USDAMOUNT)); Ext.getCmp("HJOTHERDX").setValue(formatRMB(data.OTHERAMOUNT)); }, onAddFeeClick: function (button, event, type) { /* if (this.OpStatus == 'add') { this.Save('0'); this.onAddFeeClick(button, event); }*/ function newID() { var guid = ""; for (var i = 1; i <= 32; i++) { var n = Math.floor(Math.random() * 16.0).toString(16); guid += n; if ((i == 8) || (i == 12) || (i == 16) || (i == 20)) guid += "-"; } return guid.toUpperCase(); } var store = null; store = this.storeJieKuan2; //var newSerialno = this.GetHandleSerialNo(store, type); var record = null; record = Ext.create('JieKuan2Bodymb', { GID: newID(), JKGID: '', BXGID: '', FEETYPE: '2', FEETYPE_REF: '', FEESTATUS: '1', FEESTATUS_REF: '', BSNO: '', FEENAME: '', CURRENCY: '', AMOUNT: '0', SETTLEMENT: '0', MODIFIEDUSER: USERID, MODIFIEDTIME: currdate.format('yyyy-MM-dd hh:mm:ss'), Remark: '' }); //alert(Ext.getCmp("CREATEDATE").getRawValue()); store.add(record); cellediting = this.cellEditing; var n = store.getCount(); cellediting.startEditByPosition({ row: n - 1, column: 2 }); }, onDelFeeClick: function (button, event) { var selectedRecords = this.formJieKuan2.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.JieKuan2Del.push(rec); } this.storeJieKuan2.remove(selectedRecords[i]); } } }, this); //aftereditform(); }, JieKuan2AfterEdit: function (editor, e, eOpts) { //需要自己实现里面的事件 if (e.field == 'F_NO') { var BSrecords = DsStoreQueryBy(this.storeBS, 'BSNO', e.value); if (BSrecords.getCount() > 0) { var BSdata = BSrecords.getAt(0).data; e.record.set('MAKETIMEUPPER', BSdata.BSNO); e.record.set('MBLNO', BSdata.MBLNO); } else { e.record.set('MAKETIMEUPPER', ''); e.record.set('MBLNO', ''); } } this.SetAmount(); this.SetDX(); }, cellEditingBeforeEdit: function (editor, e) { if (this.OpStatus == "add") { var JKStatus = "1"; } else { var JKStatus = this.editRecord.get('JKSTATUS'); } /* this.VISIBLERANGE 可视 this.OPERATERANGE 可操作;*/ //可操作为0则全都可见,3为可提交/驳回,2为可审核/驳回,1为只能看 var canedit = true; if (this.OPERATERANGE == 1) { canedit = false; } //chfeefeeStatus == 1 || chfeefeeStatus == 2 || chfeefeeStatus == 6 if (this.OPERATERANGE == 2) { canedit = JKStatus == 0 || JKStatus == 2; } if (this.OPERATERANGE == 3) { canedit = JKStatus == 1 || JKStatus == 6; } //alert(canedit); if (e.record.get("FEESTATUS") == "1" || e.record.get("FEESTATUS") == "6") { } else { canedit = false; } return canedit; }, 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 = " jk.GID='" + this.editRecord.get('GID') + "'"; } else { //Ext.getCmp("AMOUNT_ALL").setValue("0"); //Ext.getCmp("JieKuan2AMOUNT").setValue("0"); } var me = this; Ext.Ajax.request({ waitMsg: '正在查询用户权限...', url: '/CommMng/BasicDataRef/GetAuthorityRange', params: { modName: "mod_Baoxiao", USERID: USERID }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); rec = result.data; //alert(rec.VISIBLERANGE); //alert(rec.OPERATERANGE); //可操作为0则全都可见,3为可提交/驳回,2为可审核/驳回,1为只能看 this.VISIBLERANGE = rec.VISIBLERANGE; this.OPERATERANGE = rec.OPERATERANGE; if (this.OPERATERANGE == '0') { //me.formPayBody.show(); } else if (this.OPERATERANGE == '1') { //me.formPayBody.hide(); } else if (this.OPERATERANGE == '2') { //me.formPayBody.show(); } else {//3 //me.formPayBody.hide(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); //request over this.LoadData(this.OpStatus, condition); //Ext.getCmp("JieKuan2NO").disable(); }, //end InitData //载入数据 LoadData: function (OpStatus, condition) { this.OpStatus = OpStatus; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/OA/Jiekuan2/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 basicForm = this.formEdit.getForm(); var data = result.data; if (data.JKSTATUS == "1" || data.JKSTATUS == "6" || this.OpStatus == "add") { //可以编辑 Ext.getCmp('savebtn').enable(); Ext.getCmp('saveandclosebtn').enable(); Ext.getCmp('saveandnewbtn').enable(); } else { Ext.getCmp('savebtn').disable(); Ext.getCmp('saveandclosebtn').disable(); Ext.getCmp('saveandnewbtn').disable(); } // this.formEdit.getForm().reset(); if (data.ENTERDATE == "") { data.ENTERDATE = currdate.format('yyyy-MM-dd hh:mm:ss') }; if (data.ENTEROPERATOR == "") { //basicForm.findField('ENTEROPERATOR').setDisabled(false); data.ENTEROPERATOR = USERID; //basicForm.findField('ENTEROPERATOR').setDisabled(true); }; if (data.DEPTID == "") { data.DEPTID = DEPTID }; if (DEPTID == "") { alert("登陆信息不完整,请重新登陆"); return; } if (data.AMOUNT == "") { data.AMOUNT = 0 }; //if (data.JieKuan2AMOUNT == "") { data.JieKuan2AMOUNT = 0 }; //if (data.BXSTATUS_REF == "") { data.BXSTATUS_REF = "录入状态" }; //if (data.BXSTATUS == "") { data.BXSTATUS = 1 }; if (this.OpStatus == 'add') { data.COMPANYID = COMPANYID; data.DEPTID = DEPTGID; data.JKSTATUS = "1"; data.JKTYPE = "2"; } if (data.DEPTID == "" || data.ENTEROPERATOR == "" || data.COMPANYID == "") { alert("登陆信息不完整,请重新登陆"); return; } this.formEdit.getForm().setValues(data); this.formSum.getForm().setValues(data); this.SetDX(); if (data.BSNO != '') { Ext.getCmp("MBLNO").setRawValue(data.MBLNO); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); //request over if (this.OpStatus == 'edit') { //this.formEdit.getForm().findField('GID').setDisabled(false); var bsno = this.editRecord.get('GID'); var _this = this; this.storeJieKuan2.load({ params: { condition: " JKGID='" + this.editRecord.get('GID') + "' " } , callback: function (options, success, response) { _this.SetDX(); } }); //this.formEdit.getForm().findField('GID').setDisabled(true); } }, // end LoadDate checkedit: function (status) { /* if (status != 1 && status != 2 && status != 6) { alert("只有 录入状态/提交审核/驳回提交 的费用才能保存"); return false; } else { return true; }*/ }, Save: function (type) { this.SetAmount(); var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var data = this.formEdit.getForm().getValues(); var GID = data.GID; var data2 = this.formSum.getForm().getValues(); var JieKuan2datas = []; for (var i = 0; i < this.storeJieKuan2.getCount(); i += 1) { var member = this.storeJieKuan2.getAt(i); JieKuan2datas.push(member); } //明细 var JieKuan2Body = ConvertRecordsToJson(JieKuan2datas); var JieKuan2DelBody = ConvertRecordsToJsonAll(this.JieKuan2Del); var _this = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/OA/Jiekuan2/Save', scope: this, async: false, params: { OpStatus: this.OpStatus, data: Ext.JSON.encode(data), data2: Ext.JSON.encode(data2), JieKuan2Body: JieKuan2Body, JieKuan2DelBody: JieKuan2DelBody }, 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]; this.OpStatus = 'edit'; } else if (this.OpStatus == 'edit') { var editp = Ext.create('Jiekuanmb', 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.storeJieKuan2.commitChanges(); if (type == '0') { this.OpStatus = 'edit'; //this.storeJieKuan2.load({ params: { condition: " BILLNO='" + this.editRecord.get('GID') + "' "} }); this.storeJieKuan2.each(function (record) { var BILLNO = _this.editRecord.get('GID'); record.set('BILLNO', BILLNO); }); this.storeJieKuan2.commitChanges(); } 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(); /* 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("ENTERDATE").getRawValue(); var printType = 'Jiekuan2'; //打印借款单 // var data = this.formEdit.getForm().getValues(); var JKUSERID = data.USERID; var GID = data.GID; var sql1 = " select jk.GID 借款单号,jk.ENTEROPERATOR,u.showname 借款人,dbo.trimdate(jk.ENTERDATE) 借款日期 "; sql1 = sql1 + " ,jk.RMBAMOUNT RMB金额 ,'" + Ext.getCmp("HJRMBDX").getValue() + "' RMB大写 "; sql1 = sql1 + " ,jk.USDAMOUNT USD金额 ,'" + Ext.getCmp("HJUSDDX").getValue() + "' USD大写 "; sql1 = sql1 + " ,jk.OTHERAMOUNT 其他金额 ,'" + Ext.getCmp("HJOTHERDX").getValue() + "' 其他大写 "; sql1 = sql1 + " ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=36 and EnumValueID=jk.JKTYPE) as 借款方式 "; sql1 = sql1 + " ,jk.chequeno 支票号 "; sql1 = sql1 + " ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=jk.JKSTATUS) as 借款状态 "; sql1 = sql1 + " ,(select showname from vw_user where userid=(select top 1 auditor from workflow_do where billno=jk.GID order by AUDITTIME DESC )) auditor"; sql1 = sql1 + " ,(select top 1 dbo.trimtime(AUDITTIME) from workflow_do where billno=jk.GID order by AUDITTIME DESC ) audittime"; sql1 = sql1 + " FROM vw_Jiekuan jk "; sql1 = sql1 + " left join sys_dept sd on sd.gid=jk.deptid "; sql1 = sql1 + " left join [user] u on u.gid=jk.ENTEROPERATOR "; sql1 = sql1 + " where jk.GID='" + GID + "' "; var sql2 = " select C.gid,C.feename 费用名称,C.SALESNO 相关编号,C.currency 币别,c.Amount 金额,c.remark 用途 "; sql2 = sql2 + " from ch_fee c where c.JKGID='" + GID + "' "; var sql3 = ""; var sql4 = ""; //获取该部门剩余资金 var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } });