Ext.namespace('Shipping'); Shipping.MsChInvoiceAppEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsChInvoiceAppEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsChInvoiceAppEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, addstore: false, PageSize: 30, initUIComponents: function () { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.FeeSql = ''; this.BillSql = ''; this.DuiBillSql = ''; this.IsDebit = '0'; this.canedit = false; this.AddMblNo = 1; this.firsttemplate = 1; this.sqlcontext = ''; parentWin = window.parent.opener; mainWin = getMainForm(parentWin); this.formname = "MsChInvoiceAppEdit"; //页面名称 this.formname_Applist = "MsChInvoiceAppEdit_Applist"; this.StoreLockOp = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } }); this.StoreLockOp.load({ params: { optype: "modInvLock"} }); this.StoreUnLockOp = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } }); this.StoreUnLockOp.load({ params: { optype: "modInvUnLock"} }); this.storeMustBe = Ext.create('Ext.data.Store', { model: 'DsShipping.ux.OpDefValue', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsCodeOpMustField/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //#region 编辑form //枚举参照相关(编辑form) //表参照相关(编辑form) this.storeCurrExrate = Ext.create('Ext.data.Store', { fields: ['CURR', 'EXRATE'] }); this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomInvRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomInvRefList' } }); //this.storeCustCode.loadData(mainWin.GetPubStore("PubStore_CustomerAll").data.items); this.storeCustCode.load({ params: { condition: ""} }); this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '开票单位', store: this.storeCustCode, forceSelection: true, matchFieldWidth: false, flex: 1.5, labelWidth: 60, allowBlank: false, name: 'CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName' , listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var recs = DsStoreQueryBy(this.storeCustCode, 'CustName', records[0].data.CustName); var INVOICECUSTNAME = this.formEdit.getForm().findField('INVOICECUSTNAME'); var CUSTRATENO = this.formEdit.getForm().findField('CUSTRATENO'); var CUSTADDRTEL = this.formEdit.getForm().findField('CUSTADDRTEL'); var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK'); var CURR = this.formEdit.getForm().findField('RECVCURR').getValue(); if (recs.getCount() > 0) { var data = recs.getAt(0).data; INVOICECUSTNAME.setValue(data.BillRises1); CUSTRATENO.setValue(data.TaxNo); if (data.INVADDRTEL == '') CUSTADDRTEL.setValue(data.Addr + ' ' + data.Tel); else CUSTADDRTEL.setValue(data.INVADDRTEL); if (CURR == 'RMB') { this.storecustbank.load({ params: { condition: " CURRENCY='RMB' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + records[0].data.CustName + "')" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); } } }, scope: this }); } else if (CURR == 'USD') { this.storecustbank.load({ params: { condition: " CURRENCY='USD' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + records[0].data.CustName + "')" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); } } }, scope: this }); } } else { INVOICECUSTNAME.setValue(''); CUSTRATENO.setValue(''); CUSTADDRTEL.setValue(''); CUSTBANK.setValue(''); } var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue(); if (CUSTOMERNAME == '') return; var CUSTNAME = this.formSearch.getForm().findField('CUSTNAME'); var tmpcust = CUSTNAME.getValue(); if (tmpcust == '' || tmpcust == null || tmpcust == undefined) { CUSTNAME.setValue(CUSTOMERNAME); } } } } }); this.storeInvCustCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomInvRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomInvRefList' } }); this.storeInvCustCode.load({ params: { condition: ""} }); this.comboxInvCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '代开客户', store: this.storeInvCustCode, forceSelection: true, labelWidth: 60, flex: 1.5, name: 'ACTUALCUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var recs = DsStoreQueryBy(this.storeInvCustCode, 'CustName', records[0].data.CustName); var INVOICECUSTNAME = this.formEdit.getForm().findField('INVOICECUSTNAME'); var CUSTRATENO = this.formEdit.getForm().findField('CUSTRATENO'); var CUSTADDRTEL = this.formEdit.getForm().findField('CUSTADDRTEL'); var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK'); var CURRFIELD = this.formEdit.getForm().findField('RECVCURR'); var CURR = CURRFIELD.getValue(); if (recs.getCount() > 0) { var data = recs.getAt(0).data; INVOICECUSTNAME.setValue(data.BillRises1); CUSTRATENO.setValue(data.TaxNo); if (data.INVADDRTEL == '') CUSTADDRTEL.setValue(data.Addr + ' ' + data.Tel); else CUSTADDRTEL.setValue(data.INVADDRTEL); if (CURR == 'RMB') { this.storecustbank.load({ params: { condition: " CURRENCY='RMB' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + records[0].data.CustName + "')" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); } } }, scope: this }); } else if (CURR == 'USD') { this.storecustbank.load({ params: { condition: " CURRENCY='USD' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + records[0].data.CustName + "')" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); } } }, scope: this }); } } else { INVOICECUSTNAME.setValue(''); CUSTRATENO.setValue(''); CUSTADDRTEL.setValue(''); CUSTBANK.setValue(''); } } } } }); this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } }); this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' } }); this.StoreCurr.load({ params: { condition: ""} }); this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '币别', store: this.StoreCurr, forceSelection: true, allowBlank: false, labelWidth: 60, name: 'CURRENCY', valueField: 'CURR', displayField: 'CURR' //, //listeners: { // scope: this, // 'select': function (combo, records, eOpts) { // if (records.length > 0) { // var CUSTOMERNAME = this.formEdit.getForm().findField('ACTUALCUSTOMERNAME').getValue(); // if (CUSTOMERNAME == '') { // CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue(); // } // if (CUSTOMERNAME == '') return; // var CURR = records[0].data.CURR; // var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK'); // var recs = DsStoreQueryBy(this.storeInvCustCode, 'CustName', CUSTOMERNAME); // if (recs.getCount() > 0) { // var data = recs.getAt(0).data; // if (CURR == 'RMB') { // this.storecustbank.load({ params: { condition: " CURRENCY='RMB' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + CUSTOMERNAME + "')" }, // callback: function (r, options, success) { // if (success) { // if (r.length != 0) { // CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); // } // } // }, // scope: this // }); // } else if (CURR == 'USD') { // this.storecustbank.load({ params: { condition: " CURRENCY='USD' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + CUSTOMERNAME + "')" }, // callback: function (r, options, success) { // if (success) { // if (r.length != 0) { // CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); // } // } // }, // scope: this // }); // } // } else { // CUSTBANK.setValue(''); // } // } // } //} }); this.StoreCurr2 = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' } }); this.StoreCurr2.load({ params: { condition: ""} }); this.comboxCurr2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '发票币别', store: this.StoreCurr2, forceSelection: true, labelWidth: 60, name: 'RECVCURR', valueField: 'CURR', displayField: 'CURR' , listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var CUSTOMERNAME = this.formEdit.getForm().findField('ACTUALCUSTOMERNAME').getValue(); if (CUSTOMERNAME == '') { CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue(); } if (CUSTOMERNAME == '') return; var CURR = records[0].data.CURR; var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK'); var recs = DsStoreQueryBy(this.storeInvCustCode, 'CustName', CUSTOMERNAME); if (recs.getCount() > 0) { var data = recs.getAt(0).data; if (CURR == 'RMB') { this.storecustbank.load({ params: { condition: " CURRENCY='RMB' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + CUSTOMERNAME + "')" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); } } }, scope: this }); } else if (CURR == 'USD') { this.storecustbank.load({ params: { condition: " CURRENCY='USD' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + CUSTOMERNAME + "')" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); } } }, scope: this }); } } else { CUSTBANK.setValue(''); } } } } }); this.storecustbank = Ext.create('DsExt.ux.RefTableStore', { model: 'MsInfoClientBankModel', proxy: { url: '/MvcShipping/MsInfoClient/GetBankList' } }); this.comboxCustBank = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '开户行及账号', store: this.storecustbank, forceSelection: true, name: 'CUSTBANK', valueField: 'BANKNAME_ACCOUNT', displayField: 'BANKNAME_ACCOUNT' }); this.storeInvCategory = Ext.create('DsExt.ux.RefTableStore', { model: 'DsExtEnumModel', proxy: { url: '/CommMng/PubSys/GetEnumValueList' } }); this.storeInvCategory.load({ params: { enumTypeId: 97008} }); this.comboxInvCategory = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '发票类型',//'类型' store: this.storeInvCategory, labelWidth: 60, forceSelection: true, name: 'INVOICECATEGORY', valueField: 'EnumValueId', displayField: 'EnumValueName' }); this.StoreInvNo = Ext.create('DsExt.ux.RefTableStore', { model: 'MsChInvoiceNo', proxy: { url: '/Account/Chfee_invoice/GetInvoiceNo' } }); this.StoreInvNo.load({ params: { condition: ""} }); this.comboxInvNo = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreInvNo, fieldLabel: '发票号', allowBlank: false, flex: 2, name: 'INVOICENO', valueField: 'INVNO', displayField: 'INVNO' }); this.storeSaleCompany = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCompanysEntity', proxy: { url: '/MvcShipping/MsCompanys/GetNoPicDataList' } }); this.storeSaleCompany.load({ params: { condition: ""} }); this.comboxSaleCompany = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '所属分部', //'委托分公司', store: this.storeSaleCompany, forceSelection: true, flex: 1.5, labelWidth: 60, name: 'SALECORPID', id: 'PAYCOMPANYID', valueField: 'GID', displayField: 'NAME', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { // var companyid = data.items[0].data.GID; // this.StoreBANK.load({ params: { condition: ""} }); } } } }); this.StoreBANK = Ext.create('DsExt.ux.RefTableStore', { model: 'BANK', proxy: { url: '/MvcShipping/MsBaseInfo/GetAllBANKList' } }); this.StoreBANK.load({ params: { condition: "" } }); this.comboxBANK = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '我司银行及账号', store: this.StoreBANK, flex: 2, labelWidth: 100, // forceSelection: true, name: 'ACCOUNT', valueField: 'BANKACCOUNT', displayField: 'BANKACCOUNT' }); //编辑form this.formEdit = Ext.widget('form', { region: 'center', frame: true, bodyPadding: 3, trackResetOnLoad: true, // autoScroll: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'GID', name: 'GID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'BILLSTATUS', name: 'BILLSTATUS', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'DZSTATUS', name: 'DZSTATUS', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'VOUCHERNO', name: 'VOUCHERNO', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'VOUNO', name: 'VOUNO', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'APPLICANT', name: 'APPLICANT', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'CREATEUSER', name: 'CREATEUSER', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'CREATETIME', name: 'CREATETIME', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'OPERATOR', name: 'OPERATOR', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'COMPANYID', name: 'COMPANYID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'INVOICETYPE', value: '2', name: 'INVOICETYPE', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '编号', readOnly: true, hidden: true, flex: 2, name: 'BILLNO' }, { fieldLabel: '发票类别', readOnly: true, flex: 2, name: 'INVOICETYPEREF' }, this.comboxInvNo, { fieldLabel: '开票日期', flex: 2, format: 'Y-m-d', xtype: 'datefield', name: 'INVOICEMAKETIME' }, { fieldLabel: '开票人', flex: 2, readOnly: true, name: 'OPERATORNAME' }, { fieldLabel: '是否锁定', flex: 1, readOnly: true, name: 'BILLSTATUSREF' }, { fieldLabel: '是否打印', flex: 1, readOnly: true, name: 'ISNEEDPRINT' }, { fieldLabel: '是否结算', flex: 1, readOnly: true, name: 'ISNEEDFEE' }, { fieldLabel: '是否作废', flex: 1, readOnly: true, name: 'ISDELETE' } ] } ]//end items(fieldset 1) }, //end fieldset 1 { xtype: 'fieldset', defaultType: 'textfield', layout: 'hbox', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'anchor', flex: 3, defaultType: 'textfield', items: [ { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '发票抬头', name: 'INVOICECUSTNAME' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '纳税人识别号', name: 'CUSTRATENO' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '地址、电话', name: 'CUSTADDRTEL' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '客户开户行及账号', labelWidth: 105, name: 'CUSTBANK' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxBANK] } ] }, { xtype: 'fieldset', defaultType: 'textfield', flex: 5, layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [this.comboxCurr, this.comboxInvCategory, this.comboxCurr2, this.comboxCustCode, this.comboxInvCustCode] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '实际金额', labelWidth: 60, 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; }, name: 'AMOUNT' }, { fieldLabel: '开票金额', labelWidth: 60, 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; }, name: 'INVAMOUNT' }, { fieldLabel: '开票税率', labelWidth: 60, name: 'EXCHANGERATE', listeners: { scope: this, blur: function (field, The, eOpts) { _this.ChangeInvRate(field.value); } } }, { fieldLabel: '外币金额', labelWidth: 60, flex: 1.5, 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; }, name: 'OTCURRAMOUNT' }, this.comboxSaleCompany] } , { xtype: 'container', layout: 'hbox', flex: 2, defaultType: 'textfield', items: [{ xtype: 'textareafield', grow: true, labelWidth: 60, name: 'REMARK', fieldLabel: '备注', anchor: '100%' }, { xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', region: 'east', width: 80, defaults: { anchor: '100%' }, items: [{ xtype: 'button', text: "提取备注", handler: function (button, event) { this.ImportRemarks(); }, scope: this }, { xtype: 'button', text: "模板设置", handler: function (button, event) { this.SetRemarksTemplate(); }, scope: this }] }] } ] } ]//end items(fieldset 2) } ]//end root items }); //end this.formEdit //#endregion //#region 按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { id: 'btnEPrev', text: "上一票", //"上一票", // iconCls: "btnsave", handler: function (button, event) { this.PrevRecord(); }, scope: this }, { id: 'btnENext', text: "下一票", //"下一票", // iconCls: "btnsave", handler: function (button, event) { this.NextRecord(); }, scope: this }, { id: 'btnESave', text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, '-', { text: "打印", handler: function (button, event) { this.Print(); }, scope: this }, '-', { id: 'btnESaveAndClose', text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, '-', { id: 'btnESaveAndNew', text: "保存并新建", handler: function (button, event) { this.Save('2'); this.GetEditStatus(); }, scope: this }, '-', { id: 'btnENew', text: "新建", handler: function (button, event) { this.LoadData('add', '*'); }, scope: this }, '-', { text: '锁定', tooltip: '锁定', id: 'btnSubmitAudit', handler: function (button, event) { this.onSubmitAuditClick(); }, scope: this }, '-', { text: '撤销锁定', tooltip: '撤销锁定', id: 'btnSubmitAuditBack', handler: function (button, event) { this.onSubmitAuditBackClick(); }, scope: this }, '-', { text: '导出发票', tooltip: '导出发票', handler: function (button, event) { this.onExpInvClick(); }, scope: this }, '-', { text: "电子开票", iconCls: 'btnexportexcel', handler: function (button, event) { _this.onExpDZInvClick(); }, scope: this }, '-', { text: "荣e通", iconCls: 'btnexportexcel', handler: function (button, event) { _this.onExpRYTInvClick(); }, scope: this } ] }); //end 按钮Toolbar //#endregion //#region发票明细 this.StoreCodeGoodInv = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeGoodInv', proxy: { url: '/MvcShipping/MsCodeGoodInv/GetDataList' } }); this.StoreCodeGoodInv.load({ params: { condition: "" } }); this.comboxCodeGoodInv = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreCodeGoodInv, forceSelection: true, valueField: 'GID', displayField: 'GOODCODENAME' }); this.GridDetailCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); //明细表-数据集 this.storeDetailList = Ext.create('Ext.data.Store', { model: 'MsChInvoiceDetail', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoice/GetDetailList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.gridDetailCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.gridDetailList = new Ext.grid.GridPanel({ store: this.storeDetailList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, viewConfig: { enableTextSelection: true, autoFill: true }, // columnLines: true, selModel: this.GridDetailCheckBoxModel, plugins: [this.gridDetailCellEditing], features: [{ ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 }], tbar: [{ text: '添加发票明细', tooltip: '添加发票明细', id: 'btnAddInvdetail', iconCls: "btnadddetail", handler: function (button, event) { this.onAddInvDetailClick(); }, scope: this }, { text: '删除发票明细', tooltip: '删除发票明细', id: 'btndelInvdetail', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelInvDetailClick(); }, scope: this }], columns: [{ sortable: true, dataIndex: 'GID', header: 'GID', hidden: true, width: 100 }, { sortable: true, dataIndex: 'PID', header: 'PID', hidden: true, width: 100 }, { sortable: true, dataIndex: 'SERIALNO', header: 'SERIALNO', hidden: true, width: 100 }, { sortable: false, dataIndex: 'GOODSNAME', header: '货物或应税劳务名称', editor: this.comboxCodeGoodInv, renderer: function (value, p, record) { return record.data.GOODSNAMEREF; }, summaryType: 'count', width: 120 }, { sortable: false, dataIndex: 'SPEC', header: '规格型号', editor: { xtype: 'textfield', allowBlank: false, selectOnFocus: true }, width: 100 }, { sortable: false, dataIndex: 'UNIT', header: '单位', editor: { xtype: 'textfield', allowBlank: false, selectOnFocus: true }, width: 100 }, { sortable: false, dataIndex: 'PKGS', header: '数量', editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true }, width: 80 }, { sortable: false, dataIndex: 'TAXPRICE', header: '含税单价', editor: { xtype: 'numberfield', allowBlank: false, 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; }, summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, width: 80 }, { sortable: false, dataIndex: 'PRICE', header: '单价', editor: { xtype: 'numberfield', allowBlank: false, 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; }, width: 80 }, { sortable: false, dataIndex: 'AMOUNT', editor: { xtype: 'numberfield', allowBlank: false, 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; }, summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, header: '金额', width: 80 }, { sortable: false, dataIndex: 'TAXRATE', editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true }, header: '税率', width: 80 }, { sortable: false, dataIndex: 'TAX', header: '税额', editor: { xtype: 'numberfield', allowBlank: false, 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; }, summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, width: 80 } ] }); this.gridDetailList.on('edit', function (editor, e, eOpts) { this.gridListDetailAfterEdit(editor, e, eOpts); }, this); //#endregion this.formAMT = Ext.widget('form', { region: 'south', frame: false, bodyPadding: 0, height: 35, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 0 0', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '金额合计(大写)', readOnly: true, name: 'AMOUNTCAPITAL' } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }] }); //end this.formEdit //#region 明细表 //明细表表格相关 //明细表-数据集 this.storeBodyList = Ext.create('Ext.data.Store', { model: 'Chfee_do_detail', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoice/GetBillList', reader: { id: 'BSNO,FEEDOID', root: 'data', totalProperty: 'totalCount' } } }); this.gridList = new Ext.grid.GridPanel({ store: this.storeBodyList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, viewConfig: { enableTextSelection: true }, columns: [{ sortable: true, dataIndex: 'BILLNO', header: 'BILL', hidden: true, width: 100 }, { sortable: true, dataIndex: 'BSNO', header: 'BSNO', hidden: true, width: 100 }, { sortable: true, dataIndex: 'FEEDOID', header: 'FEEDOID', hidden: true, width: 100 }, { sortable: true, dataIndex: 'CUSTNO', header: '委托编号', width: 120 }, { sortable: true, dataIndex: 'MBLNO', header: '主提单号', width: 120 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '委托单位', width: 100 }, { sortable: true, dataIndex: 'SettleCust', header: '结算对象', width: 100 }, { sortable: true, dataIndex: 'ETD', header: '开船日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), width: 100 }, { sortable: true, dataIndex: 'BSSOURCE', header: '业务来源', width: 80 }, { sortable: true, dataIndex: 'FEENAME', header: '费用名称', width: 80 }, { sortable: true, dataIndex: 'FEETYPEREF', header: '收付', width: 40 }, { sortable: true, dataIndex: 'AMOUNT', header: '申请金额', width: 80, 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: 'ORIGCURRENCY', header: '原始币别', width: 80 }, { sortable: true, dataIndex: 'ORIGEXCHANGERATE', header: '原始汇率', width: 80 }, { sortable: true, dataIndex: 'EXCHANGERATE', header: '折算汇率', width: 80 }, { sortable: true, dataIndex: 'ORIGAMOUNT', header: '原始金额', width: 80, 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: 'SALE', header: '揽货人', width: 80 }, { sortable: true, dataIndex: 'VESSEL', header: '船名航次', width: 150, renderer: function (value, p, record) { return record.data.VESSEL + '/' + record.data.VOYNO; } }, { sortable: true, dataIndex: 'PORTLOAD', header: '装货港', width: 120 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '卸货港', width: 120 }, { sortable: false, dataIndex: 'ACCDATE', header: '会计期间', width: 60 } ] }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2 var openType = "_blank"; var openUrl = ""; openUrl = "../../MvcShipping/MsOpBill/MsOpFeeView?handle=check&bsno=" + record.data.BSNO; window.open(openUrl, openType, openSet); }, this); this.storeBodySum = Ext.create('Ext.data.Store', { model: 'Chfee_do_sum', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoice/GetBillSum', reader: { root: 'data', totalProperty: 'totalCount' } } }); this.gridSum = new Ext.grid.GridPanel({ store: this.storeBodySum, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, tbar: [{ xtype: 'label', width: 120, height: 22, text: '开票金额合计' }], columns: [{ sortable: true, dataIndex: 'FEETYPEREF', header: '收付', width: 40 }, { sortable: true, dataIndex: 'CURRENCY', header: '币 别', width: 80 }, { sortable: true, dataIndex: 'AMOUNT', header: '金额', width: 80, 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; } } ] }); //#region 明细表 //明细表表格相关 this.GridCheckBoxAppModel = Ext.create('Ext.selection.CheckboxModel'); //明细表-数据集 this.storeBodyAppList = Ext.create('Ext.data.Store', { model: 'MsChInvoiceapplication', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoiceapplication/GetDataList', reader: { id: 'BILLNO', root: 'data', totalProperty: 'totalCount' } } }); this.initgirdcolums = [ { sortable: false, dataIndex: 'BILLNO', header: '申请单号', width: 120 }, { sortable: false, dataIndex: 'BILLSTATUSREF', header: '状态', width: 80 }, { sortable: false, dataIndex: 'CURRENCY', header: '币别', width: 60 }, { sortable: false, dataIndex: 'APPLYAMOUNT', header: '申请金额', 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; }, align: 'right', width: 100, 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: false, dataIndex: 'INVAMOUNT', header: '开票金额', 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; }, align: 'right', width: 100, 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: false, dataIndex: 'APPLYTIME', header: '申请开票日期', width: 100 }, { sortable: false, dataIndex: 'APPLICANTNAME', header: '申请人', width: 100 }, { sortable: false, dataIndex: 'APPLICANTEMAIL', header: '申请人邮箱', width: 100 }, { sortable: true, dataIndex: 'OPERATETIME', header: '申请时间', width: 100 }, { sortable: false, dataIndex: 'INVOICENO', header: '发票号', width: 120 }, { sortable: false, dataIndex: 'INVOICECUSTNAME', header: '发票抬头', width: 160 }, { sortable: false, dataIndex: 'REMARK', header: '备注', width: 260 } ]; this.girdcolums = this.initgirdcolums; this.gridAppList = new Ext.grid.GridPanel({ store: this.storeBodyAppList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selModel: this.GridCheckBoxAppModel, viewConfig: { enableTextSelection: true }, tbar: [{ text: '删除申请明细', tooltip: '删除申请明细', iconCls: "btndeletedetail", id: "btndeldetail", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "保存列表样式", id: "btnappformsave", menu: [ { text: "保存", handler: function (button, event) { this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname_Applist, _this.gridAppList.columns, _this.girdcolums, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname_Applist, _this.gridAppList.columns, _this.initgirdcolums, 1, true); } }], scope: this } ], columns: this.girdcolums }); this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname_Applist, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 //this.girdcolums.unshift(new Ext.grid.RowNumberer()); this.gridAppList.reconfigure(this.storeBodyAppList, this.girdcolums); this.storeAddFeeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsChInvoiceapplication', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoiceapplication/GetDataList', reader: { id: 'BILLNO', root: 'data', totalProperty: 'totalCount' } } }); this.AddFeeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.cellEditingFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, listeners: { 'edit': function (editor, e) { } } }); _this = this; this.initgirdbilladdcolums = [{ sortable: true, dataIndex: 'BILLNO', header: '申请单号', width: 120 }, { sortable: true, dataIndex: 'BILLSTATUSREF', header: '状态', width: 80 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '开票单位', width: 120 }, { sortable: true, dataIndex: 'CUSTOMERFULLNAME', header: '开票单位全称', width: 200 }, { sortable: true, dataIndex: 'INVOICECUSTNAME', header: '发票抬头', width: 160 }, { sortable: true, dataIndex: 'CURRENCY', header: '币别', width: 60 }, { sortable: true, dataIndex: 'APPLYAMOUNT', header: '申请金额', 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; }, align: 'right', width: 100 }, { sortable: true, dataIndex: 'INVAMOUNT', header: '开票金额', align: 'right', width: 100, 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: 'RECVCURR', header: '实收币别', width: 60 }, { sortable: true, dataIndex: 'FEEAMOUNT', header: '原币金额', width: 120, 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: 'RATE', header: '申请税率', width: 100 }, { sortable: true, dataIndex: 'INVOICECATEGORYREF', header: '发票类型',//申请类型 width: 100 }, { sortable: true, dataIndex: 'APPLYTIME', header: '申请开票日期', width: 100 }, { sortable: true, dataIndex: 'APPLICANTNAME', header: '申请人', width: 100 }, { sortable: true, dataIndex: 'OPERATETIME', header: '申请时间', width: 100 }, { sortable: true, dataIndex: 'APPLICANTDEPT', header: '所属部门', width: 100 }, { sortable: true, dataIndex: 'PAYCOMPANYREF', header: '所属分部', width: 100 }, { sortable: true, dataIndex: 'INVOICENO', header: '发票号', width: 120 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 160 }, { sortable: true, dataIndex: 'SHENREMARK', header: '开票要求', width: 160 } ]; this.girdbilladdcolums = this.initgirdbilladdcolums; //使用者id,表名,中间column数组,跳过一开始的几列 this.gridAddFeeList = new Ext.grid.GridPanel({ store: this.storeAddFeeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, viewConfig: { enableTextSelection: true }, plugins: [this.cellEditingFee], selModel: this.AddFeeGridCheckBoxModel, selType: 'cellmodel', tbar: [{ text: '添加申请明细', tooltip: '添加申请明细', iconCls: "btnadddetail", id: "btnadddetail", handler: function (button, event) { this.onAddDetailClick(button, event); }, scope: this }, '-', { text: "保存列表样式", id: "btntest", menu: [ { text: "保存", handler: function (button, event) { _this.girdbilladdcolums = DsTruck.SaveGridPanel(USERID, _this.formname + 'billadd', _this.gridAddFeeList.columns, _this.girdbilladdcolums, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.girdbilladdcolums = DsTruck.SaveGridPanel(USERID, _this.formname + 'billadd', _this.gridAddFeeList.columns, _this.initgirdbilladdcolums, 1, true); } }], scope: this }], columns: this.girdbilladdcolums, // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeAddFeeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.girdbilladdcolums = DsTruck.GetGridPanel(USERID, this.formname + 'billadd', this.girdbilladdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.girdbilladdcolums.unshift(new Ext.grid.RowNumberer()); this.gridAddFeeList.reconfigure(this.storeAddFeeList, this.girdbilladdcolums); //明细表-数据集 this.storeAddBodyList = Ext.create('Ext.data.Store', { model: 'Chfee_do_detail', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoiceapplication/GetBillList', reader: { id: 'BSNO,FEEDOID', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.gridAddBodyList = new Ext.grid.GridPanel({ store: this.storeAddBodyList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, viewConfig: { enableTextSelection: true }, disableSelection: false, columns: [{ sortable: true, dataIndex: 'BILLNO', header: 'BILL', hidden: true, width: 100 }, { sortable: true, dataIndex: 'BSNO', header: 'BSNO', hidden: true, width: 100 }, { sortable: true, dataIndex: 'FEEDOID', header: 'FEEDOID', hidden: true, width: 100 }, { sortable: true, dataIndex: 'CUSTNO', header: '委托编号', width: 120 }, { sortable: true, dataIndex: 'MBLNO', header: '主提单号', width: 120 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '委托单位', width: 100 }, { sortable: true, dataIndex: 'ETD', header: '开船日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), width: 100 }, { sortable: true, dataIndex: 'BSSOURCE', header: '业务来源', width: 80 }, { sortable: true, dataIndex: 'FEENAME', header: '费用名称', width: 80 }, { sortable: true, dataIndex: 'FEETYPEREF', header: '收付', width: 40 }, { sortable: true, dataIndex: 'AMOUNT', header: '申请金额', width: 80, 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: 'ORIGCURRENCY', header: '原始币别', width: 80 }, { sortable: true, dataIndex: 'ORIGAMOUNT', header: '原始金额', width: 80, 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: 'EXCHANGERATE', header: '折算汇率', width: 80 }, { sortable: true, dataIndex: 'AUDITDATE', header: '审核日期', width: 80 }, { sortable: true, dataIndex: 'SALE', header: '揽货人', width: 80 } ] }); _this = this; //#region formSearch this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeOpCode.load(); //客服 this.comboxAPPLICANT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '申请人', flex: 0.6, matchFieldWidth: false, store: this.storeOpCode, forceSelection: true, name: 'APPLICANT', valueField: 'GID', displayField: 'CodeAndName', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeInvCategory = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeInvCategory.load({ params: { enumTypeId: 97008 } }); this.comboxInvCategory2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '发票类型',//申请类型 flex: 0.6, matchFieldWidth: false, store: this.storeInvCategory, labelWidth: 60, forceSelection: true, name: 'INVOICECATEGORY', valueField: 'EnumValueId', displayField: 'EnumValueName', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeCustCodefee = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRmAll' } }); this.storeCustCodefee.load({ params: { condition: "1==2" } }); //this.storeCustCodefee.loadData(mainWin.GetPubStore("PubStore_CustomerAll").data.items); this.comboxAddCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '开票单位', store: this.storeCustCodefee, forceSelection: true, name: 'CustName', valueField: 'CustName', displayField: 'CodeAndName', queryMode: 'remote', minChars: 2, queryParam: 'CODENAME', enableKeyEvents: true, listeners: { beforequery: function (e) { return FilterCombox(e, 1); }, specialkey: function (combo, e) { //将回车13转义成tab9 GetComboxFirstValueOnTableClick_RefTable(combo, e, 'CustName'); if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.comboxSaleCompany2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '所属分部', //'委托分公司', store: this.storeSaleCompany, forceSelection: true, flex: 1, labelWidth: 60, name: 'PAYCOMPANYID', id: 'PAYCOMPANYID2', valueField: 'GID', displayField: 'NAME', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { // var companyid = data.items[0].data.GID; // this.StoreBANK.load({ params: { condition: ""} }); } } } }); _this = this; this.formSearch = Ext.widget('form', { frame: true, region: 'north', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 70, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '申请编号', name: 'BsNo', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '编号', name: 'MblNo', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxAddCustCode, { fieldLabel: '从申请日期', format: 'Y-m-d', labelWidth: 80, flex: 0.6, xtype: 'datefield', name: 'ExpDateBgn', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '到申请日期', format: 'Y-m-d', labelWidth: 80, flex:0.6, xtype: 'datefield', name: 'ExpDateEnd', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } } , this.comboxAPPLICANT , this.comboxInvCategory2 , this.comboxSaleCompany2 , { xtype: 'button', width: 60, text: "查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { xtype: 'button', width: 45, text: "", iconCls: "btnmore", handler: function (button, event) { var sql = this.getCondition(); var winAccess = new Shipping.DsQuery({ }); winAccess.StoreList = this.storeList; winAccess.formname = this.formname; winAccess.condition = sql; winAccess.show(); return; }, scope: this } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //#endregion formSearch this.panelInvDetail = new Ext.Panel({ layout: "border", title: "发票明细", // height: 220, region: 'west', width: 830, margin: '2 2', split: true, items: [this.gridDetailList] }); this.panelAppDetail = new Ext.Panel({ layout: "border", title: "申请明细", region: "center", margin: '2 2', items: [this.gridAppList] }); this.panelInvApp = new Ext.Panel({ layout: "border", // height: 220, region: "center", margin: '2 2', items: [this.panelInvDetail, this.panelAppDetail, this.formAMT] }); this.panelService = new Ext.Panel({ layout: "border", region: 'center', margin: '2 2', items: [this.gridList] }); this.panelSum = new Ext.Panel({ layout: "border", region: 'east', width: 260, split: true, margin: '2 2', items: [this.gridSum] }); this.paneldetail = new Ext.Panel({ title: '费用明细', layout: "border", height: 220, region: "north", items: [ this.panelService, this.panelSum ] }); this.panelAddBodyService = new Ext.Panel({ layout: "border", title: '发票申请明细', region: 'east', width: 380, split: true, margin: '2 2', items: [this.gridAddBodyList] }); this.panelAddService = new Ext.Panel({ layout: "border", region: 'center', margin: '2 2', items: [this.gridAddFeeList, this.panelAddBodyService] }); this.paneladd = new Ext.Panel({ title: '添加发票申请明细', layout: "border", // region: 'south', region: "center", // height: 420, items: [ this.formSearch, this.panelAddService ] }); //#endregion 明细表 //#region 布局 //控件布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 242, items: [this.panelBtn, this.formEdit] }); this.panelBody = new Ext.Panel({ title: "费用明细", layout: "border", region: "center", items: [this.paneldetail] }); this.panelInv = new Ext.Panel({ title: "发票详细内容", layout: "border", region: "center", // height: 220, items: [this.panelInvApp] }); this.tabpanel = new Ext.TabPanel ({ activeTab: 0, autoWidth: true, border: false, frame: false, height: 280, region: 'north', id: "TabPanelID", enableTabScroll: true, split: true, items: [ this.panelInv, this.panelBody ] }); Ext.apply(this, { items: [this.panelTop, this.tabpanel, this.paneladd] }); //#endregion //绑定查询窗体 this.ParentWin = window.parent.opener; //初始化数据 this.InitData(); //绑定事件 var billno = '*'; if (this.opStatus == 'edit') { billno = this.editRecord.get('BILLNO'); }; this.storeBodyList.on('beforeload', function (store) { var sql = " BILLNO='" + billno + "'"; Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.storeBodyList.on('load', function (store, records) { if (store.getCount() > 0) { //this.gridList.getSelectionModel().select(0); } }, this); this.storeAddFeeList.on('load', function (store, records) { if (store.getCount() > 0) { this.gridAddFeeList.getSelectionModel().select(0); var btnEAddDetail = Ext.getCmp('btnadddetail'); btnEAddDetail.enable(); } }, this); _this = this; this.storeAddFeeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: this.BillSql }); }, this); this.storeBodySum.on('beforeload', function (store) { billno = this.editRecord.get('BILLNO'); var sql = " BILLNO='" + billno + "'"; Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); var isloadfee = true; this.gridAddFeeList.getSelectionModel().on('select', function (model, record, index) { if (!isloadfee) return; var bsno = record.data.BILLNO; var sql = ""; sql = " BILLNO='" + bsno + "'"; isloadfee = false; this.storeAddBodyList.load({ params: { condition: sql }, callback: function (r, options, success) { if (success) { isloadfee = true; } } }); }, this); //#region 下载窗体 this.formDownloadShow = Ext.widget('form', { frame: true, region: 'center', height: 100, 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', id: 'downloadfile', defaults: { anchor: '100%' }, items: [{ xtype: 'label', html: '', width: 120, text: '' } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); me = this; this.winDownloadShow = Ext.create('Ext.window.Window', { title: "下载文件", width: 450, height: 120, //plain : true, iconCls: "addicon", resizable: false, // 是否可以拖动 // draggable:false, collapsible: true, // 允许缩放条 closeAction: 'close', closable: true, modal: 'true', buttonAlign: "center", bodyStyle: "padding:0 0 0 0", items: [this.formDownloadShow], buttons: [{ text: "关闭", minWidth: 70, handler: function () { me.winDownloadShow.close(); } }] }); //#endregion Ext.Ajax.request({ waitMsg: '', url: '/MvcShipping/MsSysParamSet/GetData', params: { condition: "PARAMNAME='INVADDMBL'" }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (result.Success != true) { } else { var data = result.data; if (data.PARAMVALUE == '1' || data.PARAMVALUE == 1) _this.AddMblNo = 1; else _this.AddMblNo = 0; } } else { } }, scope: 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' || this.opStatus == 'copyadd') condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'"; if (this.opStatus == 'edit') { document.title = "发票开出" + this.editRecord.get('INVOICENO').toString().trim(); } else { document.title = "发票开出-新增"; } this.LoadData(this.opStatus, condition); this.LoadMustBe(); }, //end InitData LoadData: function (opstatus, condition) { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.opStatus = opstatus; _this = this; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/GetData', params: { handle: opstatus, condition: condition, isapp: true }, 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().findField('BILLSTATUS').setDisabled(false); _this.formEdit.getForm().reset(); _this.formAMT.getForm().reset(); _this.formEdit.getForm().setValues(data); _this.formAMT.getForm().setValues(data); if (this.opStatus == 'copyadd') this.CopyNewData(); this.StoreInvNo.load({ params: { condition: "" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { if (_this.opStatus == 'add') { var basicForm = _this.formEdit.getForm(); field = basicForm.findField('INVOICENO'); var invno = field.getValue(); if (invno == '' || invno == null) { var datasetinv = _this.StoreInvNo.getAt(0); field.setValue(datasetinv.get('INVNO')); } } } } } }); // _this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true); _this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); var billno = '*'; var GID = '*'; if (this.opStatus == 'edit') { billno = this.editRecord.get('BILLNO'); GID = this.editRecord.get('GID'); }; this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" }, callback: function (r, options, success) { if (success) { if (this.storeBodyList.getCount() > 0) { this.comboxCurr.setReadOnly(true); this.comboxCustCode.setReadOnly(true); } else { this.comboxCurr.setReadOnly(false); this.comboxCustCode.setReadOnly(false); } } }, scope: this }); this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} }); this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} }); this.storeBodyAppList.load({ params: { condition: "INVBILLNO='" + billno + "'"} }); this.onRefreshClick(); }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } this.formEdit.getForm().findField('GID').setDisabled(false); // this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false); this.formEdit.getForm().findField('COMPANYID').setDisabled(false); var data = basicForm.getValues(); var GID = this.formEdit.getForm().findField('GID').getValue(); // this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true); this.formEdit.getForm().findField('COMPANYID').setDisabled(true); this.formEdit.getForm().findField('GID').setDisabled(true); var bodydatas = []; for (var i = 0; i < this.storeDetailList.getCount(); i += 1) { var member = this.storeDetailList.getAt(i); bodydatas.push(member); } var jsonBody = ConvertRecordsToJsonAll(bodydatas); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/Account/Chfee_invoice/Save', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), body: jsonBody }, 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); this.formAMT.getForm().setValues(data); if (this.opStatus == 'add') { var arrNewRecords = this.StoreList.insert(0, returnData); this.editRecord = this.StoreList.getAt(0); } else if (this.opStatus == 'edit') { var editp = Ext.create('MsChInvoice', 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'; this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} }); } else if (type == '1') { window.close(); } else { 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 }); } } }); }, //end save CopyNewData: function () { var basicForm = this.formEdit.getForm(); this.opStatus = 'add'; basicForm.findField('GID').setDisabled(false); var field = basicForm.findField('GID'); var BSNO = NewGuid(); field.setValue(BSNO); basicForm.findField('GID').setDisabled(true); field = basicForm.findField('VOUCHERNO'); field.setValue(''); field = basicForm.findField('VOUNO'); field.setValue(''); field = basicForm.findField('INVOICENO'); field.setValue(''); field = basicForm.findField('BILLNO'); field.setValue(''); field = basicForm.findField('BILLSTATUS'); field.setValue('0'); field = basicForm.findField('BILLSTATUSREF'); field.setValue('未锁定'); field = basicForm.findField('ISNEEDPRINT'); field.setValue(''); field = basicForm.findField('ISNEEDFEE'); field.setValue(''); field = basicForm.findField('ISDELETE'); field.setValue(''); field = basicForm.findField('OPERATOR'); field.setValue(USERID); field = basicForm.findField('OPERATORNAME'); field.setValue(SHOWNAME); field = basicForm.findField('APPLICANT'); field.setValue(''); field = basicForm.findField('AMOUNT'); field.setValue(0); field = basicForm.findField('INVAMOUNT'); field.setValue(0); field = basicForm.findField('OTCURRAMOUNT'); field.setValue(0); field = basicForm.findField('REMARK'); field.setValue(''); this.formAMT.getForm().findField('AMOUNTCAPITAL').setValue(''); var myDate = new Date(); var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d'); field = basicForm.findField('INVOICEMAKETIME'); field.setValue(mydatestr); this.storeBodyList.removeAll(); this.storeBodySum.removeAll(); this.storeDetailList.removeAll(); }, onAddDetailClick: function (button, event) { this.addstore = true; this.IsAddDetail(); }, //end onAddDetailClick onDelDetailClick: function (button, event, type) { this.deleteDetail(); }, //onDelDetailClick onAddClick: function (button, event) { this.addstore = true; this.addBill(); }, //end onAddDetailClick onDeleteClick: function (button, event) { this.deleteBill(); }, //end onAddDetailClick gridListDetailAfterEdit: function (editor, e, eOpts) { if (e.value == e.originalValue) return; if (e.field == 'PKGS' || e.field == 'PRICE') { var TaxUnitPrice = e.record.data['TAXPRICE']; var quantity = e.record.data['PKGS']; var taxrate = e.record.data['TAXRATE']; if (taxrate != null) { var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var unitPrice = (parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2); e.record.set('PRICE', unitPrice); } if (quantity == 1) { taxrate = parseFloat(taxrate) / 100; var tax = ((parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).mul(taxrate)).toFixed(2); e.record.set('TAX', tax); var amount = Add(TaxUnitPrice, -tax).toFixed(2); e.record.set('AMOUNT', amount); } else { var taxamount = (parseFloat(TaxUnitPrice).mul(quantity)).toFixed(2); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(taxamount).div(parseFloat(taxrateb))).mul(taxrate).toFixed(2); e.record.set('TAX', tax); var amount = Add(taxamount, -tax).toFixed(2); e.record.set('AMOUNT', amount); } this.calcDetailTotal(); } else if (e.field == 'TAXPRICE') { var TaxUnitPrice = e.record.data['TAXPRICE']; if (e.value != 0) { var quantity = e.record.data['PKGS']; var taxrate = e.record.data['TAXRATE']; var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var unitPrice = (parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2); e.record.set('PRICE', unitPrice); if (quantity != null) { if (quantity == 1) { taxrate = parseFloat(taxrate) / 100; var tax = ((parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).mul(taxrate)).toFixed(2); e.record.set('TAX', tax); var amount = Add(TaxUnitPrice, -tax).toFixed(2); e.record.set('AMOUNT', amount); } else { var taxamount = (parseFloat(TaxUnitPrice).mul(quantity)).toFixed(2); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat((parseFloat(TaxUnitPrice).mul(quantity))).div(parseFloat(taxrateb))).mul(taxrate).toFixed(2); e.record.set('TAX', tax); var amount = Add(taxamount, -tax).toFixed(2); e.record.set('AMOUNT', amount); } } this.calcDetailTotal(); } } else if (e.field == 'TAXRATE') { var taxrate = e.record.data['TAXRATE']; var TaxUnitPrice = e.record.data['TAXPRICE']; if (TaxUnitPrice != 0) { var quantity = e.record.data['PKGS']; var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var unitPrice = (parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2); e.record.set('PRICE', unitPrice); if (quantity != null) { if (quantity == 1) { taxrate = parseFloat(taxrate) / 100; var tax = ((parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).mul(taxrate)).toFixed(2); e.record.set('TAX', tax); var amount = Add(TaxUnitPrice, -tax).toFixed(2); e.record.set('AMOUNT', amount); } else { var taxamount = (parseFloat(TaxUnitPrice).mul(quantity)).toFixed(2); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(taxamount).div(parseFloat(taxrateb))).mul(taxrate).toFixed(2); e.record.set('TAX', tax); var amount = Add(taxamount, -tax).toFixed(2); e.record.set('AMOUNT', amount); } } this.calcDetailTotal(); } /* if (unitPrice != null) { var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var TaxUnitPrice = (parseFloat(unitPrice).mul(taxrateb)).toFixed(2); e.record.set('TAXPRICE', TaxUnitPrice); } var notaxamount = e.record.data['AMOUNT']; taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(notaxamount).mul(taxrate)).toFixed(2); e.record.set('TAX', tax); this.calcDetailTotal(); */ } else if (e.field == 'AMOUNT' || e.field == 'TAX') { this.calcDetailTotal(); } else if (e.field == 'GOODSNAME') { var selectrecords = DsStoreQueryBy(this.StoreCodeGoodInv, 'GID', e.value); if (selectrecords.getCount() > 0) { var selectdata = selectrecords.getAt(0).data; e.record.set('GOODSNAMEREF', selectdata.GOODNAME); e.record.set('GOODCODE', selectdata.GOODCODE); e.record.set('TAXRATE', selectdata.TAXRATE); e.record.set('SPEC', selectdata.SPEC); e.record.set('UNIT', selectdata.UNIT); var taxrate = e.record.data['TAXRATE']; var TaxUnitPrice = e.record.data['TAXPRICE']; var quantity = e.record.data['PKGS']; if (TaxUnitPrice != 0) { var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var unitPrice = (parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2); e.record.set('PRICE', unitPrice); if (quantity != null) { if (quantity == 1) { taxrate = parseFloat(taxrate) / 100; var tax = ((parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).mul(taxrate)).toFixed(2); e.record.set('TAX', tax); var amount = Add(TaxUnitPrice, -tax).toFixed(2); e.record.set('AMOUNT', amount); } else { var taxamount = (parseFloat(TaxUnitPrice).mul(quantity)).toFixed(2); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(taxamount).div(parseFloat(taxrateb))).mul(taxrate).toFixed(2); e.record.set('TAX', tax); var amount = Add(taxamount, -tax).toFixed(2); e.record.set('AMOUNT', amount); } } this.calcDetailTotal(); } } else { e.record.set('GOODSNAMEREF', ''); e.record.set('GOODCODE', ''); e.record.set('SPEC', ''); e.record.set('UNIT', ''); e.record.set('TAXRATE', 0); } } }, ChangeInvRate: function (InvRate) { for (var i = 0; i < this.storeDetailList.getCount(); i += 1) { var memberbody = this.storeDetailList.getAt(i); memberbody.set("TAXRATE", InvRate); var TaxUnitPrice = memberbody.data.TAXPRICE; if (TaxUnitPrice != 0) { var quantity = memberbody.data.PKGS; var taxrate = InvRate; var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var unitPrice = (parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2); memberbody.set("PRICE", unitPrice); if (quantity != null) { if (quantity == 1) { taxrate = parseFloat(taxrate) / 100; var tax = ((parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).mul(taxrate)).toFixed(2); memberbody.set("TAX", tax); var amount = Add(TaxUnitPrice, -tax).toFixed(2); memberbody.set("AMOUNT", amount); } else { var taxamount = (parseFloat(TaxUnitPrice).mul(quantity)).toFixed(2); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(taxamount).div(parseFloat(taxrateb))).mul(taxrate).toFixed(2); memberbody.set("TAX", tax); var amount = Add(taxamount, -tax).toFixed(2); memberbody.set("AMOUNT", amount); } } } memberbody.commit(); } this.calcDetailTotal(); }, calcDetailTotal: function () { var ttlamt = 0; for (var i = 0; i < this.storeDetailList.getCount(); i += 1) { var member = this.storeDetailList.getAt(i); var value = member.get('AMOUNT'); var tax = member.get('TAX'); ttlamt = ttlamt.add(parseFloat(value)); ttlamt = ttlamt.add(parseFloat(tax)); } this.setHeadFieldValue('INVAMOUNT', Ext.util.Format.number(parseFloat(ttlamt), '00.00')); var amtc = this.numtoc(parseFloat(ttlamt).toFixed(2)); var field = this.formAMT.getForm().findField('AMOUNTCAPITAL'); field.setValue(amtc); }, setHeadFieldValue: function (fieldName, value) { var field = this.formEdit.getForm().findField(fieldName); field.setValue(value); }, gridAddFeeListAfterEdit: function (editor, e, eOpts) { //需要自己实现里面的事件 if (e.value == e.originalValue) return; if (e.field == 'StlAmount') { var BalAmount = e.record.data['BalAmount']; var StlAmount = e.record.data['StlAmount']; if (BalAmount >= 0) { if (StlAmount > BalAmount) { e.record.set('StlAmount', BalAmount); Ext.Msg.show({ title: '提示', msg: '申请金额不能大于未申金额!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } } else { if (StlAmount < BalAmount) { e.record.set('StlAmount', BalAmount); Ext.Msg.show({ title: '提示', msg: '申请金额不能大于未申金额!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } } } }, onNextKeyClick: function (col) { var rows = this.gridAddFeeList.getSelectionModel().getSelection(); var row = rows[rows.length - 1]; var s = this.gridAddFeeList.getStore(); var number = s.indexOf(row) + 1; this.cellEditingFee.startEditByPosition({ row: number, column: col }); }, onUpKeyClick: function (col) { var rows = this.gridAddFeeList.getSelectionModel().getSelection(); var row = rows[rows.length - 1]; var s = this.gridAddFeeList.getStore(); var number = s.indexOf(row) - 1; if (number < 0) number = 0; this.cellEditingFee.startEditByPosition({ row: number, column: col }); }, onAddInvDetailClick: function () { var BILLNO = this.formEdit.getForm().findField('BILLNO').getValue(); var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue(); var ISNEEDPRINT = this.formEdit.getForm().findField('ISNEEDPRINT').getValue(); var ISNEEDFEE = this.formEdit.getForm().findField('ISNEEDFEE').getValue(); var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue(); var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue(); if (ISNEEDPRINT == 'true') { Ext.Msg.show({ title: '提示', msg: '已打印无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成总账凭证无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISDELETE == 'true') { Ext.Msg.show({ title: '提示', msg: '此发票已作废无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } this.formEdit.getForm().findField('GID').setDisabled(false); var GID = this.formEdit.getForm().findField('GID').getValue(); this.formEdit.getForm().findField('GID').setDisabled(true); var billtaxrate = this.formEdit.getForm().findField('EXCHANGERATE').getValue(); if (BILLNO == '*') { Ext.Msg.show({ title: '注意', msg: '请先保存业务信息再添加运输明细!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } var newSerialno = DsGetNewSerialNo(this.storeDetailList, 0); var record = Ext.create('MsChInvoiceDetail', { GID: '', PID: '*', SERIALNO: newSerialno, GOODSNAME: '', SPEC: '', UNIT: '', PKGS: 1, TAXPRICE: 0, PRICE: 0, TAXRATE: billtaxrate, AMOUNT: 0, TAX: 0, REMARK: '' }); this.storeDetailList.add(record); var n = this.storeDetailList.getCount(); this.gridDetailCellEditing.startEditByPosition({ row: n - 1, column: 1 }); }, onDelInvDetailClick: function () { var selectedRecords = this.GridDetailCheckBoxModel.selected.items; var GID = this.formEdit.getForm().findField('GID').getValue(); var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue(); var ISNEEDPRINT = this.formEdit.getForm().findField('ISNEEDPRINT').getValue(); var ISNEEDFEE = this.formEdit.getForm().findField('ISNEEDFEE').getValue(); var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue(); var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue(); if (ISNEEDPRINT == 'true') { Ext.Msg.show({ title: '提示', msg: '已打印无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成总账凭证无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISDELETE == 'true') { Ext.Msg.show({ title: '提示', msg: '此发票已作废无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定要删除选中的明细吗?', function (btn) { if (btn == 'yes') { var bodyDatas = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.GID == "" || rec.PID == "*") //如果是新增但没有保存的数据,没有必要提交到后台 { this.storeDetailList.remove(selectedRecords[i]); } else { bodyDatas.push(rec); } } var jsonBody = ConvertRecordsToJsonAll(bodyDatas); _this = this; Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/Account/Chfee_invoice/DelInvDetail', params: { bsno: GID, body: jsonBody }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { for (var i = 0; i < selectedRecords.length; i++) { this.storeDetailList.remove(selectedRecords[i]); } // this.gridList.getView().refresh(); 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); }, IsAddDetail: function () { var selectedRecords = this.gridAddFeeList.selModel.getSelection(); if (selectedRecords.length > 0) { var bodyDatas = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; bodyDatas.push(rec); } var jsonBody = ConvertRecordsToJsonAll(bodyDatas); Ext.Ajax.request({ waitMsg: '', url: '/Account/Chfee_invoiceapplication/GetIsAdd', params: { data: jsonBody }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (result.Success) { _this.addDetail(); } else { var sql = this.BillSql; this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); Ext.Msg.show({ title: '提示', msg: '已生成发票,没有需要添加的发票申请!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } } else { var sql = this.BillSql; this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); Ext.Msg.show({ title: '提示', msg: '已生成发票,没有需要添加的发票申请!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } }, scope: this }); } else { Ext.Msg.show({ title: '提示', msg: '请选择需要添加的发票申请!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } }, addDetail: function () { var basicForm = this.formEdit.getForm(); var btnEAddDetail = Ext.getCmp('btnadddetail'); btnEAddDetail.disable(); var Duino = this.formEdit.getForm().findField('BILLNO').getValue(); _this = this; if ((Duino == '*') || basicForm.isDirty()) { var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue(); var CURR = this.formEdit.getForm().findField('CURRENCY').getValue(); var INVOICENO = this.formEdit.getForm().findField('INVOICENO').getValue(); if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null) || (CURR == '') || (CURR == null)) { var selectedRecords = this.gridAddFeeList.selModel.getSelection(); if (selectedRecords.length > 0) { var rec = selectedRecords[0]; var cust = rec.data.CUSTOMERNAME; var curr = rec.data.CURRENCY; var rate = rec.data.RATE; var RECVCURR = rec.data.RECVCURR; this.formEdit.getForm().findField('RECVCURR').setValue(RECVCURR); var aINVOICECUSTNAME = rec.data.INVOICECUSTNAME; if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null)) this.formEdit.getForm().findField('CUSTOMERNAME').setValue(cust); var INVOICECUSTNAME = this.formEdit.getForm().findField('INVOICECUSTNAME'); var CUSTRATENO = this.formEdit.getForm().findField('CUSTRATENO'); var CUSTADDRTEL = this.formEdit.getForm().findField('CUSTADDRTEL'); var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK'); var CURRFIELD = this.formEdit.getForm().findField('CURRENCY'); var RECVCURR = this.formEdit.getForm().findField('RECVCURR').getValue(); var INVOICECATEGORY = this.formEdit.getForm().findField('INVOICECATEGORY'); if ((aINVOICECUSTNAME == '') || (aINVOICECUSTNAME == null)) { var recs = DsStoreQueryBy(this.storeInvCustCode, 'CustName', cust); var CURR = CURRFIELD.getValue(); if (recs.getCount() > 0) { var data = recs.getAt(0).data; INVOICECUSTNAME.setValue(data.BillRises1); CUSTRATENO.setValue(data.TaxNo); if (data.INVADDRTEL == '') CUSTADDRTEL.setValue(data.Addr + ' ' + data.Tel); else CUSTADDRTEL.setValue(data.INVADDRTEL); if (RECVCURR == 'RMB') { this.storecustbank.load({ params: { condition: " CURRENCY='RMB' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + cust + "')" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); } } }, scope: this }); } else if (RECVCURR == 'USD') { this.storecustbank.load({ params: { condition: " CURRENCY='USD' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + cust + "')" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); } } }, scope: this }); } } else { INVOICECUSTNAME.setValue(''); CUSTRATENO.setValue(''); CUSTADDRTEL.setValue(''); CUSTBANK.setValue(''); } } else { INVOICECUSTNAME.setValue(rec.data.INVOICECUSTNAME); CUSTRATENO.setValue(rec.data.CUSTRATENO); CUSTADDRTEL.setValue(rec.data.CUSTADDRTEL); CUSTBANK.setValue(rec.data.CUSTBANK); INVOICECATEGORY.setValue(rec.data.INVOICECATEGORY); } if ((CURR == '') || (CURR == null)) { this.formEdit.getForm().findField('CURRENCY').setValue(curr); } this.formEdit.getForm().findField('EXCHANGERATE').setValue(rate); } } if (this.AddMblNo == 1) { if (this.storeAddBodyList.getCount() > 0) { var rec2 = this.storeAddBodyList.getAt(0); var mblno = rec2.data.MBLNO; var REMARK = this.formEdit.getForm().findField('REMARK').getValue(); if (REMARK == '') this.formEdit.getForm().findField('REMARK').setValue(mblno); } } if (!basicForm.isValid()) { btnEAddDetail.enable(); return; } var type = 0; var PAYCOMPANYID = Ext.getCmp('PAYCOMPANYID').getValue(); if ((PAYCOMPANYID == '') || (PAYCOMPANYID == null)) { var selectedRecords = this.gridAddFeeList.selModel.getSelection(); if (selectedRecords.length > 0) { var rec = selectedRecords[0]; var PAYCOMPANYID = rec.data.PAYCOMPANYID; Ext.getCmp('PAYCOMPANYID').setValue(PAYCOMPANYID); } } this.formEdit.getForm().findField('GID').setDisabled(false); // this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false); this.formEdit.getForm().findField('COMPANYID').setDisabled(false); var data = basicForm.getValues(); var GID = this.formEdit.getForm().findField('GID').getValue(); // this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true); this.formEdit.getForm().findField('COMPANYID').setDisabled(true); this.formEdit.getForm().findField('GID').setDisabled(true); var bodydatas = []; for (var i = 0; i < this.storeDetailList.getCount(); i += 1) { var member = this.storeDetailList.getAt(i); bodydatas.push(member); } var jsonBody = ConvertRecordsToJsonAll(bodydatas); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/Account/Chfee_invoice/Save', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), body: jsonBody }, 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); this.formAMT.getForm().setValues(data); if (this.opStatus == 'add') { var arrNewRecords = this.StoreList.insert(0, returnData); this.editRecord = this.StoreList.getAt(0); } else if (this.opStatus == 'edit') { var editp = Ext.create('MsChInvoice', 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(); } this.opStatus = 'edit'; this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} }); _this.addDetailfn(); } else { btnEAddDetail.enable(); Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { btnEAddDetail.enable(); Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); } else { this.addDetailfn(); } }, //end save addDetailfn: function () { if (this.addstore) { this.storeCurrExrate.removeAll(); this.addstore = false; } var btnEAddDetail = Ext.getCmp('btnadddetail'); var Duino = this.formEdit.getForm().findField('BILLNO').getValue(); var inviceno = this.formEdit.getForm().findField('INVOICENO').getValue(); var GID = this.formEdit.getForm().findField('GID').getValue(); var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue(); var ISNEEDPRINT = this.formEdit.getForm().findField('ISNEEDPRINT').getValue(); var ISNEEDFEE = this.formEdit.getForm().findField('ISNEEDFEE').getValue(); var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue(); var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue(); if (ISNEEDPRINT == 'true') { btnEAddDetail.enable(); Ext.Msg.show({ title: '提示', msg: '已打印无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '' && VOUCHERNO != null) { btnEAddDetail.enable(); Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUNO != '' && VOUNO != null) { btnEAddDetail.enable(); Ext.Msg.show({ title: '提示', msg: '已生成总账凭证无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISDELETE == 'true') { btnEAddDetail.enable(); Ext.Msg.show({ title: '提示', msg: '此发票已作废无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var basicForm = this.formEdit.getForm(); var billcust = this.editRecord.data.CUSTOMERNAME; var billno = this.editRecord.data.BILLNO; var billcurr = this.editRecord.data.CURRENCY; var billtaxrate = this.editRecord.data.EXCHANGERATE; var selectedRecords = this.gridAddFeeList.selModel.getSelection(); var bodyAddDatas = []; _this = this; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; var cust = rec.data.CUSTOMERNAME; var curr = rec.data.CURRENCY; var acctaxrate = rec.data.RATE; if (cust == billcust) { if (billtaxrate == acctaxrate) { if (billcurr == curr) { bodyAddDatas.push(rec); } else { alert('币别与发票申请币别不一致,不能添加此费用明细!'); } } else { alert('进项税率与发票申请税率不一致,不能添加此费用明细!'); } } else { alert('费用对象与开票客户不一致,不能添加此费用明细!'); } } if (bodyAddDatas.length == 0) { btnEAddDetail.enable(); Ext.Msg.show({ title: '提示', msg: '没有要添加的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_invoice/AddAppDetail', params: { bill: billno, data: jsonbodyAddDatas, inviceno: inviceno, GID: GID }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { btnEAddDetail.enable(); Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { var sql = this.BillSql; // this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); this.storeAddFeeList.reload(); _this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" }, callback: function (r, options, success) { if (success) { if (_this.storeBodyList.getCount() > 0) { _this.comboxCurr.setReadOnly(true); _this.comboxCustCode.setReadOnly(true); } else { _this.comboxCurr.setReadOnly(false); _this.comboxCustCode.setReadOnly(false); } } }, scope: this }); this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} }); this.storeBodyAppList.load({ params: { condition: "INVBILLNO='" + billno + "'"} }); this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/GetData', params: { handle: 'edit', condition: " BILLNO='" + billno + "'", isapp: true }, 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(); this.formEdit.getForm().setValues(data); this.formAMT.getForm().setValues(data); var editp = Ext.create('MsChInvoice', data); 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(); } else { btnEAddDetail.enable(); Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } else { btnEAddDetail.enable(); Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, deleteBill: function (type) { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); var GID = this.formEdit.getForm().findField('GID').getValue(); var selectedRecords = this.gridAppList.selModel.getSelection(); if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '没有要删除的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue(); var ISNEEDPRINT = this.formEdit.getForm().findField('ISNEEDPRINT').getValue(); var ISNEEDFEE = this.formEdit.getForm().findField('ISNEEDFEE').getValue(); var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue(); var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue(); if (ISNEEDPRINT == 'true') { Ext.Msg.show({ title: '提示', msg: '已打印无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成总账凭证无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISDELETE == 'true') { Ext.Msg.show({ title: '提示', msg: '此发票已作废无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var bodyAddDatas = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; bodyAddDatas.push(rec); } var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); var sql = this.BillSql; Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/Account/Chfee_invoice/DelAppBill', params: { data: jsonbodyAddDatas, billno: billno, GID: GID }, 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; } else { var sql = this.BillSql; this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); _this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" }, callback: function (r, options, success) { if (success) { if (_this.storeBodyList.getCount() > 0) { _this.comboxCurr.setReadOnly(true); _this.comboxCustCode.setReadOnly(true); } else { _this.comboxCurr.setReadOnly(false); _this.comboxCustCode.setReadOnly(false); } } }, scope: this }); this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} }); this.storeBodyAppList.load({ params: { condition: "INVBILLNO='" + billno + "'"} }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/GetData', params: { handle: 'edit', condition: " BILLNO='" + billno + "'", isapp: true }, 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(); this.formEdit.getForm().setValues(data); this.formAMT.getForm().setValues(data); var editp = Ext.create('MsChInvoice', data); 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(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onExpRYTInvClick: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); var GID = this.formEdit.getForm().findField('GID').getValue(); var cust = this.formEdit.getForm().findField('CUSTOMERNAME').getValue(); var DZSTATUS = this.formEdit.getForm().findField('DZSTATUS').getValue(); if (DZSTATUS == '已开票') { Ext.Msg.show({ title: '提示', msg: '已开电子发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } this.formDZInvShow = Ext.widget('form', { frame: true, title: '电子开票', 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: [ { fieldLabel: '客户邮箱', //'编号', name: 'email', labelWidth: 60, enableKeyEvents: true } ] } ]//end root items }); var selectrecords = DsStoreQueryBy(_this.storeCustCodefee, 'CustName', cust); if (selectrecords.getCount() > 0) { var selectdata = selectrecords.getAt(0).data; this.formDZInvShow.getForm().findField('email').setValue(selectdata.EMAIL); } this.winDZInvShow = Ext.create('Ext.window.Window', { title: "", // closeAction: 'hide', width: 400, height: 150, layout: 'border', resizable: true, modal: true, closeAction: 'close', closable: true, items: [this.formDZInvShow], buttons: [{ text: "确定", minWidth: 70, handler: function () { // var remarkstr = formRemarkShow.getForm().findField('INVREMARK').getValue(); // var cgFILEROLE = Ext.getCmp('hjFILEROLEGet'); // var FILEROLE = cgFILEROLE.getValue(); var email = _this.formDZInvShow.getForm().findField('email').getValue(); Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_invoice/ExpRYDInv', params: { gid: GID, email: email }, 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; } else { _this.winDZInvShow.close(); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/GetData', params: { handle: 'edit', condition: " BILLNO='" + billno + "'", isapp: false }, 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(); this.formEdit.getForm().setValues(data); this.formAMT.getForm().setValues(data); var editp = Ext.create('MsChInvoice', data); 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(); this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, { text: "关闭", minWidth: 70, handler: function () { _this.winDZInvShow.close(); } }] }); _this.winDZInvShow.show(); }, onSubmitAuditClick: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); var GID = this.formEdit.getForm().findField('GID').getValue(); var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); var Duino = this.formEdit.getForm().findField('BILLNO').getValue(); if (Duino == '*') { Ext.Msg.show({ title: '提示', msg: '请先保存发票,然后才能锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; if ((billstatus != 0)) { Ext.Msg.show({ title: '提示', msg: '当前状态无法锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } _this = this; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_invoice/Lock', params: { bill: Duino }, 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; } else { var condition = " BILLNO='" + billno + "'"; this.LoadData('edit', condition); //var sql = this.BillSql; //this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); //this.storeAddBodySum.load({ params: { condition: sql} }); //_this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" }, // callback: function (r, options, success) { // if (success) { // if (_this.storeBodyList.getCount() > 0) { // _this.comboxCurr.setReadOnly(true); // _this.comboxCustCode.setReadOnly(true); // } // else { // _this.comboxCurr.setReadOnly(false); // _this.comboxCustCode.setReadOnly(false); // } // } // }, // scope: this //}); //this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} }); //this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} }); //Ext.Ajax.request({ // waitMsg: '正在查询主表数据...', // url: '/Account/Chfee_invoice/GetData', // params: { // handle: 'edit', // condition: " BILLNO='" + billno + "'", // isapp: false // }, // 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(); // this.formEdit.getForm().setValues(data); // this.formAMT.getForm().setValues(data); // var editp = Ext.create('MsChInvoice', data); // 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(); // this.GetEditStatus(); // } else { // Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); // } // }, // scope: this //}); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onSubmitAuditBackClick: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); var GID = this.formEdit.getForm().findField('GID').getValue(); var Duino = this.formEdit.getForm().findField('BILLNO').getValue(); var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue(); var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue(); if (Duino == '*') { Ext.Msg.show({ title: '提示', msg: '请先保存,然后才能撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; if (billstatus != 1) { Ext.Msg.show({ title: '提示', msg: '当前状态无法撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成总账凭证无法撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } _this = this; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_invoice/UnLock', params: { bill: Duino }, 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; } else { var condition = " BILLNO='" + billno + "'"; this.LoadData('edit', condition); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onExpInvClick: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); var GID = this.formEdit.getForm().findField('GID').getValue(); var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); var Duino = this.formEdit.getForm().findField('BILLNO').getValue(); if (Duino == '*') { Ext.Msg.show({ title: '提示', msg: '请先保存发票,然后才能锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; _this = this; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_invoice/ExpInvForm', params: { bill: Duino }, 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; } else { // var downloadfile = Ext.getCmp('downloadfile'); // var children = downloadfile.items; // if (children) { // for (var i = 0, len = children.length; i < len; i++) { // downloadfile.remove(children.items[i], true); // } // } // var downloadfiles = '' + result.Message + ''; // var htmla = Ext.widget('label', { // html: downloadfiles, // width: 120, // text: '' // }); // downloadfile.items.add(htmla); // this.winDownloadShow.show(); // return; this.LoadData('edit', "BILLNO='" + billno + "'"); var openSet = "height=300, width=600, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=" + (screen.height - 200) / 2 + ",Left=" + (screen.width - 200) / 2; var openType = "_blank"; var openUrl = "../../Reports/FileExport.aspx?filename=" + result.Data; window.open(openUrl, openType, openSet); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onExpDZInvClick: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); var GID = this.formEdit.getForm().findField('GID').getValue(); var cust = this.formEdit.getForm().findField('CUSTOMERNAME').getValue(); var DZSTATUS = this.formEdit.getForm().findField('DZSTATUS').getValue(); if (DZSTATUS == '已开票') { Ext.Msg.show({ title: '提示', msg: '已开电子发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } this.formDZInvShow = Ext.widget('form', { frame: true, title: '电子开票', 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: [ { fieldLabel: '客户邮箱', //'编号', name: 'email', labelWidth: 60, enableKeyEvents: true } ] } ]//end root items }); var selectrecords = DsStoreQueryBy(this.storeCustCodefee, 'CustName', cust); if (selectrecords.getCount() > 0) { var selectdata = selectrecords.getAt(0).data; this.formDZInvShow.getForm().findField('email').setValue(selectdata.EMAIL); } this.winDZInvShow = Ext.create('Ext.window.Window', { title: "", // closeAction: 'hide', width: 400, height: 150, layout: 'border', resizable: true, modal: true, closeAction: 'close', closable: true, items: [this.formDZInvShow], buttons: [{ text: "确定", minWidth: 70, handler: function () { // var remarkstr = formRemarkShow.getForm().findField('INVREMARK').getValue(); // var cgFILEROLE = Ext.getCmp('hjFILEROLEGet'); // var FILEROLE = cgFILEROLE.getValue(); var email = _this.formDZInvShow.getForm().findField('email').getValue(); Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_invoice/ExpDZInv', params: { gid: GID, email: email }, 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; } else { _this.winDZInvShow.close(); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/GetData', params: { handle: 'edit', condition: " BILLNO='" + billno + "'", isapp: false }, 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(); this.formEdit.getForm().setValues(data); this.formAMT.getForm().setValues(data); var editp = Ext.create('MsChInvoice', data); 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(); this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, { text: "关闭", minWidth: 70, handler: function () { _this.winDZInvShow.close(); } }] }); _this.winDZInvShow.show(); }, // ImportRemarks: function () { // var billno = this.formEdit.getForm().findField('BILLNO').getValue(); // if (billno == '*') { // Ext.Msg.show({ title: '提示', msg: '请先保存付费结算,然后才能撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); // return; // }; // Ext.Ajax.request({ // waitMsg: '正在查询主表数据...', // url: '/Account/Chfee_invoice/GetRemarksData', // params: { // billno: billno // }, // 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; // var REMARK = this.formEdit.getForm().findField('REMARK').getValue(); // this.formEdit.getForm().findField('REMARK').setValue(REMARK + ' ' + data); // } else { // Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); // } // }, // scope: this // }); // }, ImportRemarks: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); if (billno == '*') { Ext.Msg.show({ title: '提示', msg: '请先保存,然后才能撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; this.formRemarkShowGet = Ext.widget('form', { frame: true, title: '提取发票备注', region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ { xtype: 'radiogroup', fieldLabel: "模板名称", //'文件功能', name: 'TemplateName', defaults: { flex: 1 }, layout: 'hbox', items: [{ boxLabel: '模板1', //'原始', name: 'TemplateName', // id: 'TemplateName1', inputValue: '发票备注', checked: true }, { boxLabel: '模板2', //'更新', name: 'TemplateName', inputValue: '发票备注2' }, { boxLabel: '模板3', //'更新', name: 'TemplateName', inputValue: '发票备注3' }] }, { fieldLabel: '是否追加', //'是否改签', inputValue: true, xtype: 'checkboxfield', name: 'ISZHUIJIA', checked: true } ]//end root items }); this.winCustomDataShowGet = Ext.create('Ext.window.Window', { title: "", // closeAction: 'hide', width: 400, height: 150, layout: 'border', resizable: true, modal: true, closeAction: 'close', closable: true, items: [this.formRemarkShowGet], buttons: [{ text: "确定", minWidth: 70, handler: function () { // var remarkstr = formRemarkShow.getForm().findField('INVREMARK').getValue(); // var cgFILEROLE = Ext.getCmp('hjFILEROLEGet'); // var FILEROLE = cgFILEROLE.getValue(); var INVOICEMAKETIME = _this.formEdit.getForm().findField('INVOICEMAKETIME').getRawValue(); var templatename = _this.formRemarkShowGet.getForm().findField('TemplateName').getValue(); var ISZHUIJIA = _this.formRemarkShowGet.getForm().findField('ISZHUIJIA').getValue(); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/GetRemarksData', params: { billno: billno, TemplateName: templatename, invdate: INVOICEMAKETIME }, 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; var REMARK = _this.formEdit.getForm().findField('REMARK').getValue(); if (ISZHUIJIA) _this.formEdit.getForm().findField('REMARK').setValue(REMARK + ' ' + data); else _this.formEdit.getForm().findField('REMARK').setValue(data); _this.winCustomDataShowGet.close(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, { text: "关闭", minWidth: 70, handler: function () { _this.winCustomDataShowGet.close(); } }] }); _this.winCustomDataShowGet.show(); }, SetRemarksTemplate: function () { var StoreFieldName = Ext.create('Ext.data.Store', { fields: ['OPLBNAME'] }); StoreFieldName.add({ "OPLBNAME": "委托编号" }); StoreFieldName.add({ "OPLBNAME": "主提单号" }); StoreFieldName.add({ "OPLBNAME": "分提单号" }); StoreFieldName.add({ "OPLBNAME": "委托单位" }); StoreFieldName.add({ "OPLBNAME": "船名" }); StoreFieldName.add({ "OPLBNAME": "航次" }); StoreFieldName.add({ "OPLBNAME": "开船日期" }); StoreFieldName.add({ "OPLBNAME": "装货港" }); StoreFieldName.add({ "OPLBNAME": "卸货港" }); StoreFieldName.add({ "OPLBNAME": "外币金额" }); StoreFieldName.add({ "OPLBNAME": "人民币金额" }); StoreFieldName.add({ "OPLBNAME": "折算汇率" }); StoreFieldName.add({ "OPLBNAME": "目的港" }); StoreFieldName.add({ "OPLBNAME": "集装箱" }); StoreFieldName.add({ "OPLBNAME": "订舱编号" }); StoreFieldName.add({ "OPLBNAME": "外币金额(总计)" }); StoreFieldName.add({ "OPLBNAME": "人民币金额(总计)" }); StoreFieldName.add({ "OPLBNAME": "折算汇率(总计)" }); var gridField = new Ext.grid.GridPanel({ store: StoreFieldName, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: [{ sortable: true, dataIndex: 'OPLBNAME', header: '字段', width: 80 } ] }); gridField.addListener('itemdblclick', function (dataview, record, item, index, e, b) { var remarkstr = formRemarkShow.getForm().findField('INVREMARK').getValue(); remarkstr = remarkstr + '[' + record.data.OPLBNAME + ']'; formRemarkShow.getForm().findField('INVREMARK').setValue(remarkstr); }, this); var panelBs = new Ext.Panel({ title: '字段列表', layout: "border", region: 'west', width: 120, frame: true, split: true, collapsed: false, collapsible: true, trackResetOnLoad: true, items: [gridField] }); var formRemarkShow = Ext.widget('form', { frame: true, title: '模板内容', 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: 'textareafield', grow: true, height: 300, id: 'dREMARK', name: 'INVREMARK', anchor: '100%' }, { xtype: 'radiogroup', fieldLabel: "模板名称", //'文件功能', id: 'hjFILEROLE', defaults: { flex: 1 }, layout: 'hbox', items: [{ boxLabel: '模板1', //'原始', name: 'TemplateName', // id: 'TemplateName1', inputValue: '发票备注', checked: true }, { boxLabel: '模板2', //'更新', name: 'TemplateName', inputValue: '发票备注2' }, { boxLabel: '模板3', //'更新', name: 'TemplateName', inputValue: '发票备注3' }], listeners: { change: function (rd, newValue, oldValue, eOpts) { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/GetRemarksTemplate', params: { TemplateName: newValue.TemplateName.toString() }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); data = result.Data; formRemarkShow.getForm().findField('INVREMARK').setValue(data); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); winCustomDataShow = Ext.create('Ext.window.Window', { title: "", // closeAction: 'hide', width: 600, height: 500, layout: 'border', resizable: true, modal: true, closeAction: 'close', closable: true, items: [panelBs, formRemarkShow], // listeners: { // scope: this, // 'beforeshow': function (thewin, eOpts) { // var cgFILEROLE = Ext.getCmp('hjFILEROLE'); // var FILEROLE = cgFILEROLE.getValue(); // } // }, buttons: [{ text: "保存", minWidth: 70, handler: function () { var remarkstr = formRemarkShow.getForm().findField('INVREMARK').getValue(); var cgFILEROLE = Ext.getCmp('hjFILEROLE'); var FILEROLE = cgFILEROLE.getValue(); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/SaveRemarksTemplate', params: { Template: remarkstr, TemplateName: FILEROLE.TemplateName }, 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; } // winCustomDataShow.close(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, { text: "关闭", minWidth: 70, handler: function () { winCustomDataShow.close(); } }] }); winCustomDataShow.show(); if (this.firsttemplate == 1) { this.firsttemplate = 0; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/GetRemarksTemplate', params: { TemplateName: "" }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); data = result.Data; formRemarkShow.getForm().findField('INVREMARK').setValue(data); // Ext.getCmp('TemplateName1').checked = true; // formRemarkShow.getForm().findField('TemplateName').setValue('发票备注'); // var cgFILEROLE = Ext.getCmp('hjFILEROLE'); // var FILEROLE = cgFILEROLE.setValue('发票备注'); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, onRefreshClick: function (button, event) { var sql = this.getCondition(); this.sqlcontext = sql; this.storeAddFeeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} }); }, onDsQuery: function (button, event) { var sql = this.sqlcontext; this.storeAddFeeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql } }); }, onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = " BILLSTATUS=0 "; var APPLICANT = form.findField('APPLICANT').getValue(); sql = sql + getAndConSql(sql, APPLICANT, "APPLICANT='" + APPLICANT + "'"); var INVOICECATEGORY = form.findField('INVOICECATEGORY').getValue(); sql = sql + getAndConSql(sql, INVOICECATEGORY, "INVOICECATEGORY='" + INVOICECATEGORY + "'"); var custName = form.findField('CustName').getValue(); sql = sql + getAndConSql(sql, custName, "CUSTOMERNAME like '%" + custName + "%'"); var expDateBgn = form.findField('ExpDateBgn').getRawValue(); sql = sql + getAndConSql(sql, expDateBgn, "APPLYTIME >='" + expDateBgn + "'"); var expDateEnd = form.findField('ExpDateEnd').getRawValue(); sql = sql + getAndConSql(sql, expDateEnd, "APPLYTIME <='" + expDateEnd + "'"); var customNo = form.findField('BsNo').getValue(); sql = sql + getAndConSql(sql, customNo, "BILLNO like '%" + customNo + "%'"); var MblNo = form.findField('MblNo').getValue(); sql = sql + getAndConSql(sql, MblNo, " EXISTS(select 1 from ch_fee_do where BILLNO=cm.BILLNO and EXISTS(select 1 from v_op_bs where bsno=ch_fee_do.BSNO and (isnull(CUSTNO,'')+' '+isnull(MBLNO,'')+' '+isnull(HBLNO,'') like '%" + MblNo + "%') ))"); var PAYCOMPANYID = form.findField('PAYCOMPANYID').getValue(); sql = sql + getAndConSql(sql, PAYCOMPANYID, "PAYCOMPANYID = '" + PAYCOMPANYID + "'"); this.BillSql = sql; return sql; }, ExrateConversion: function (bfcurr, afcurr, fntype) { var EXRATE = 0; var achange = true; var bchange = true; formExrateConversion = 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: [{ fieldLabel: '1' + bfcurr + '=', xtype: 'numberfield', name: 'bfcurr', decimalPrecision: 6, value: 0, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 6, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, listeners: { change: function () { if (bchange) { var bfcurr = formExrateConversion.getForm().findField('bfcurr').getValue(); var field = formExrateConversion.getForm().findField('afcurr'); if (bfcurr == 0) { field.setValue(0); } else { var taxrate = (parseFloat(1).div(parseFloat(bfcurr))).toFixed(6); achange = false; field.setValue(taxrate); } } achange = true; } } }, { xtype: 'label', width: 120, text: afcurr, name: 'bfcurr2' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '1' + afcurr + '=', xtype: 'numberfield', name: 'afcurr', decimalPrecision: 6, value: 0, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 6, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, listeners: { change: function () { if (achange) { var afcurr = formExrateConversion.getForm().findField('afcurr').getValue(); var field = formExrateConversion.getForm().findField('bfcurr'); if (afcurr == 0) { field.setValue(0); } else { var taxrate = (parseFloat(1).div(parseFloat(afcurr))).toFixed(6); bchange = false; field.setValue(taxrate); } } bchange = true; } } }, { xtype: 'label', width: 120, text: bfcurr, name: 'afcurr2' } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); me = this; winExrateShow = Ext.create('Ext.window.Window', { title: "币别汇率折算", width: 450, //height : 120, //plain : true, iconCls: "addicon", resizable: false, // 是否可以拖动 // draggable:false, collapsible: true, // 允许缩放条 closeAction: 'close', closable: true, modal: 'true', buttonAlign: "center", bodyStyle: "padding:0 0 0 0", items: [formExrateConversion], buttons: [{ text: "确定", minWidth: 70, handler: function () { var form = formExrateConversion.getForm(); var UsdExrate = form.findField('bfcurr').getValue(); if (UsdExrate == '' || UsdExrate == null || UsdExrate == undefined) { Ext.Msg.show({ title: '提示', msg: '必须填折算汇率!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var recs = DsStoreQueryBy(me.storeCurrExrate, 'CURR', bfcurr); if (recs.getCount() > 0) { // var dfdata = DFrecords.getAt(0).data; // dfdata.EXRATE = UsdExrate; for (var i = 0; i < me.storeCurrExrate.getCount(); i += 1) { var member = me.storeCurrExrate.getAt(i); if (member.data.CURR == bfcurr) { // member.EXRATE = UsdExrate; member.set('EXRATE', UsdExrate); member.commit(); } } } else { me.storeCurrExrate.add({ "CURR": bfcurr, "EXRATE": UsdExrate }) } winExrateShow.close(); if (fntype == 'detail') { me.addDetail(); } if (fntype == 'bill') { me.addBill(); } return; } }, { text: "关闭", minWidth: 70, handler: function () { winExrateShow.close(); return; } }] }); if (bfcurr == 'RMB') { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', afcurr); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; var DEFRATE = dfdata.DEFRATE; } else { var DEFRATE = 0; } var field = formExrateConversion.getForm().findField('afcurr'); achange = true; field.setValue(DEFRATE); } else { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', bfcurr); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; var DEFRATE = dfdata.DEFRATE; } else { var DEFRATE = 0; } var field = formExrateConversion.getForm().findField('bfcurr'); bchange = true; field.setValue(DEFRATE); } winExrateShow.show(); // S=setInterval(function () { // if (EXRATE != 0) { // alert(EXRATE); // clearInterval(S); // } // }, 500) }, numtoc: function (numberValue) { numberValue = parseFloat(numberValue).toFixed(2); var numberValue = new String(Math.round(numberValue * 100)); // 数字金额 var chineseValue = ""; // 转换后的汉字金额 var String1 = "零壹贰叁肆伍陆柒捌玖"; // 汉字数字 var String2 = "万仟佰拾亿仟佰拾万仟佰拾元角分"; // 对应单位 var len = numberValue.length; // numberValue 的字符串长度 var Ch1; // 数字的汉语读法 var Ch2; // 数字位的汉字读法 var nZero = 0; // 用来计算连续的零值的个数 var String3; // 指定位置的数值 if (len > 15) { alert("超出计算范围"); return ""; } if (numberValue == 0) { chineseValue = "零元整"; return chineseValue; } String2 = String2.substr(String2.length - len, len); // 取出对应位数的STRING2的值 for (var i = 0; i < len; i++) { String3 = parseInt(numberValue.substr(i, 1), 10); // 取出需转换的某一位的值 if (i != (len - 3) && i != (len - 7) && i != (len - 11) && i != (len - 15)) { if (String3 == 0) { Ch1 = ""; Ch2 = ""; nZero = nZero + 1; } else if (String3 != 0 && nZero != 0) { Ch1 = "零" + String1.substr(String3, 1); Ch2 = String2.substr(i, 1); nZero = 0; } else { Ch1 = String1.substr(String3, 1); Ch2 = String2.substr(i, 1); nZero = 0; } } else { // 该位是万亿,亿,万,元位等关键位 if (String3 != 0 && nZero != 0) { Ch1 = "零" + String1.substr(String3, 1); Ch2 = String2.substr(i, 1); nZero = 0; } else if (String3 != 0 && nZero == 0) { Ch1 = String1.substr(String3, 1); Ch2 = String2.substr(i, 1); nZero = 0; } else if (String3 == 0 && nZero >= 3) { Ch1 = ""; Ch2 = ""; nZero = nZero + 1; } else { Ch1 = ""; Ch2 = String2.substr(i, 1); nZero = nZero + 1; } if (i == (len - 11) || i == (len - 3)) { // 如果该位是亿位或元位,则必须写上 Ch2 = String2.substr(i, 1); } } chineseValue = chineseValue + Ch1 + Ch2; } if (String3 == 0) { // 最后一位(分)为0时,加上“整” chineseValue = chineseValue + "整"; } return chineseValue; }, //#region 必填字段 LoadMustBe: function () { this.storeMustBe.load({ params: { condition: "BSTYPE='发票开出'" }, callback: function (r, options, success) { if (success) { if (this.storeMustBe.getCount() > 0) { for (var j = 0; j < this.storeMustBe.getCount(); j += 1) { var member = this.storeMustBe.getAt(j); var headfield = this.formEdit.getForm().findField(member.data.FIELDNAME); if (headfield != NaN && headfield != null) { if (member.data.ISMUST == "1") headfield.allowBlank = false; if (member.data.ISCOLOR == "1") headfield.setFieldStyle({ background: '#ffc' }); } }; } else { } } }, scope: this }); }, //#endregion // #region 根据权限和状态判断是否允许修改 GetIsEdit: function () { var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue(); var ISNEEDPRINT = this.formEdit.getForm().findField('ISNEEDPRINT').getValue(); var ISNEEDFEE = this.formEdit.getForm().findField('ISNEEDFEE').getValue(); var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue(); var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue(); var BILLSTATUS = this.formEdit.getForm().findField('BILLSTATUS').getValue(); if ((ISDELETE == 'true') || (ISNEEDPRINT == 'true') || (VOUCHERNO != '') || (VOUNO != '') || (BILLSTATUS != 0)) return false; else return true; }, GetEditStatus: function () { var canedit = false; var op = this.formEdit.getForm().findField('OPERATORNAME').getValue(); var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); _this = this; var isEdit = this.GetIsEdit(); if (isEdit == false) { canedit = false; this.setSaveBtnStatus(canedit); } else { this.StoreOpRange.load({ params: { optype: "modInvoiceManagement" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op); if (records.getCount() > 0) { canedit = true; } else { canedit = false; } _this.setSaveBtnStatus(canedit); } } } }); } var btnESubmitAudit = Ext.getCmp('btnSubmitAudit'); var btnESubmitAuditBack = Ext.getCmp('btnSubmitAuditBack'); var opid = this.formEdit.getForm().findField('OPERATORNAME').getValue(); var records = DsStoreQueryBy(this.StoreLockOp, 'OPID', opid); if (records.getCount() > 0) { if (billstatus == 1) { btnESubmitAudit.disable(); } else { btnESubmitAudit.enable(); } } else { btnESubmitAudit.disable(); } var records = DsStoreQueryBy(this.StoreUnLockOp, 'OPID', opid); if (records.getCount() > 0) { if (billstatus == 1) { btnESubmitAuditBack.enable(); } else { btnESubmitAuditBack.disable(); } } else { btnESubmitAuditBack.disable(); } }, setSaveBtnStatus: function (enable) { var btnESave = Ext.getCmp('btnESave'); var btnESaveAndClose = Ext.getCmp('btnESaveAndClose'); var btnESaveAndNew = Ext.getCmp('btnESaveAndNew'); var btnEAddDetail = Ext.getCmp('btnadddetail'); var btnEDeleteDetail = Ext.getCmp('btndeldetail'); var btnEAddInvDetail = Ext.getCmp('btnAddInvdetail'); var btnEDeleteInvDetail = Ext.getCmp('btndelInvdetail'); this.canedit = enable; if (enable) { btnESave.enable(); btnESaveAndClose.enable(); btnESaveAndNew.enable(); btnEAddDetail.enable(); btnEDeleteDetail.enable(); btnEAddInvDetail.enable(); btnEDeleteInvDetail.enable(); } else { btnESave.disable(); btnESaveAndClose.disable(); btnESaveAndNew.disable(); btnEAddDetail.disable(); btnEDeleteDetail.disable(); btnEAddInvDetail.disable(); btnEDeleteInvDetail.disable(); } }, // #endregion PrevRecord: function () { // var modifystr = this.getIsModify(); // if (modifystr != "") { // Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 !!!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); // return; // } var j = this.StoreList.indexOf(this.editRecord); if (j == 0) {//警告', msg: '已是最前一票' Ext.Msg.show({ title: '警告', msg: '已是最前一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } if (j == this.StoreList.count) {//警告', msg: '已是最后一票' Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } j = j - 1; this.editRecord = this.StoreList.getAt(j); if (this.opStatus == 'edit') condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'"; this.LoadData(this.opStatus, condition); }, NextRecord: function () { // var modifystr = this.getIsModify(); // if (modifystr != "") { // Ext.Msg.show({ title: Zi.LAN.Caveat, msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 !!!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); // return; // } var j = this.StoreList.indexOf(this.editRecord); if (j == (this.StoreList.data.length - 1)) {//警告', msg: '已是最后一票 Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } j = j + 1; this.editRecord = this.StoreList.getAt(j); if (this.opStatus == 'edit') condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'"; this.LoadData(this.opStatus, condition); }, Print: function () { var basicForm = this.formEdit.getForm(); var billNo = basicForm.findField('BILLNO').value; var Gid = basicForm.findField('GID').value; if (billNo == '*' || billNo == '') { Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } var printType = 'MSCHFEEINVOICE'; var sql1 = "SELECT *,(select DESCRIPTION from info_client where SHORTNAME=ch_fee_invoice.CUSTOMERNAME) CUSTFULLNAME FROM ch_fee_invoice WHERE GID='" + Gid + "'"; var sql2 = "SELECT c.GID,c.BSNO,c.FEEID,c.FEENAME,c.CURRENCY,c.AMOUNT,c.DOAMOUNT,c.ORIGCURRENCY,c.ORIGAMOUNT,c.EXCHANGERATE "; sql2 = sql2 + ",b.CUSTOMERNAME,b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD"; sql2 = sql2 + " ,b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE,b.DOC,b.SALE,b.mblno,b.CUSTNO "; sql2 = sql2 + " FROM ch_fee_do c left join v_op_bill b on (b.bsno=c.bsno)"; sql2 = sql2 + " WHERE C.BILLNO='" + billNo + "' order by c.CREATETIME,b.ETD,b.MBLNO "; var sql3 = "SELECT * FROM CH_FEE_INVOICEDETAIL WHERE PID='" + Gid + "'"; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); Ext.Ajax.request({ waitMsg: '正在查询数据...', url: '/Account/Chfee_invoice/UpdatePrint', async: false, params: { billno: billNo }, 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; } else { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice/GetData', params: { handle: 'edit', condition: " BILLNO='" + billno + "'", isapp: true }, 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(); this.formEdit.getForm().setValues(data); this.formAMT.getForm().setValues(data); var editp = Ext.create('MsChInvoice', data); 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(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } });