Ext.namespace('Shipping'); Shipping.MsChInvoiceBLEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsChInvoiceBLEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, addstore: false, PageSize: 30, sqlcontext: '', initUIComponents: function () { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.FeeSql = ''; this.BillSql = ''; this.DuiBillSql = ''; this.IsDebit = '0'; this.canedit = false; this.selectfeesql = ''; this.firsttemplate = 1; this.formname = "MsChInvoiceBLEdit_HangXin"; //页面名称 var baseflex = 1; var labelwidth_sale = 70; var labelwidth_top1 = 65; //#region store this.StoreLockOp = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' } }); this.StoreLockOp.load({ params: { optype: "modInvLock" } }); this.StoreUnLockOp = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' } }); 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' } } }); Ext.define('DsShipping.ux.MsClientGroup', { extend: 'Ext.data.Model', fields: [{ name: 'SHORTNAME', type: 'string' }, { name: 'PCORPNAME', type: 'string' }, { name: 'CODENAME', type: 'string' }] }); this.StoreClientGroup = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.MsClientGroup', proxy: { url: '/MvcShipping/MsInfoClient/GetClientGroupList' } }); this.StoreClientGroup.load({ params: { condition: "PCORPNAME<>'' " } }); 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.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', matchFieldWidth: false, listeners: { beforequery: function (e) { return FilterCombox(e); //在beforequery使用此方法 }, scope: this } }); this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefListRm' } }); this.storeOpCode.load(); this.storeOpCode2 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefListRm' } }); this.storeOpCode3 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefListRm' } }); this.storeOpCode.on('load', function (store, records) { if (store.getCount() > 0) { this.storeOpCode2.add(records); this.storeOpCode3.add(records); } }, this); this.comboxOPERATOR = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '开票人', //'客服', matchFieldWidth: false, store: this.storeOpCode, forceSelection: true, //queryMode: 'remote', flex: 0.5, labelWidth: labelwidth_top1, minChars: 0, //queryParam: 'CODENAME', name: 'OPERATOR', valueField: 'GID', displayField: 'UserName', enableKeyEvents: true }); this.comboxPAYEE = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '收款人', //'客服', matchFieldWidth: false, store: this.storeOpCode3, //forceSelection: true, //queryMode: 'remote', flex: 0.5, labelWidth: labelwidth_top1, minChars: 0, //queryParam: 'CODENAME', name: 'PAYEE', valueField: 'UserName', displayField: 'UserName', enableKeyEvents: true }); this.comboxCHECKER = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '复核人', //'客服', matchFieldWidth: false, store: this.storeOpCode2, //forceSelection: true, //queryMode: 'remote', flex: 0.5, labelWidth: labelwidth_top1, minChars: 0, //queryParam: 'CODENAME', name: 'CHECKER', valueField: 'UserName', displayField: 'UserName', enableKeyEvents: true }); //#endregion //#region 编辑form //#region 枚举参照相关 (编辑form) this.comboxPTORRED = getEnumcombox({ LABEL: '开票类型', NAME: 'PTORRED', FLEX: baseflex * 0.5, enumTypeId: 80001, ALLOWBLANK: false, readOnly: true }); this.comboxPUSHMODE = getEnumcombox({ LABEL: '开票通知推送', NAME: 'PUSHMODE', FLEX: 1, enumTypeId: 80002 }); this.comboxINVOICELINE = getEnumcombox({ LABEL: '发票种类', NAME: 'INVOICELINE', FLEX: 0.65, enumTypeId: 80003, listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { _this.setInvTile(records[0].data.EnumValueName); } } } }); this.storeInfoClientMailTel = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.InfoClientContactModel', proxy: { url: '/CommMng/BasicDataRef/GetInfoClientMailTel' } }); this.comboxInfoClientMailTel = Ext.create('DsExt.ux.RefTableCombox', { labelWidth: 55, fieldLabel: '推送邮箱', flex: 1.4, store: this.storeInfoClientMailTel, forceSelection: false, name: 'PUSHEMAIL', valueField: 'EMAIL', displayField: 'NAMEANDEMAIL', listeners: { focus: function (field, newValue, oldValue) { //在focus时 如果记录数为1 则载入 var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue(); _this = this; var currmail = this.formEdit.getForm().findField('PUSHEMAIL').getValue(); if (!isNullorEmpty(CUSTOMERNAME)) this.storeInfoClientMailTel.load({ params: { CUSTOMERNAME: CUSTOMERNAME } , callback: function (r, options, success) { if (!isNullorEmpty(currmail)) { Data_pushmail = { EMAIL: currmail, NAMEANDEMAIL: currmail }; _this.storeInfoClientMailTel.add(Data_pushmail); _this.formEdit.getForm().findField('PUSHEMAIL').setValue(currmail); } }, scope: this }); }, scope: this } }); this.comboxINVOICELINE.labelWidth = labelwidth_top1; //#endregion //#region 表参照相关(编辑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.load({ params: { condition: "" } }); this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '系统客户', store: this.storeCustCode, //allowBlank: false, flex: 1.5, labelWidth: labelwidth_sale, forceSelection: true, name: 'CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName', //matchFieldWidth: false, listeners: { scope: this, 'beforequery': function (e) { return FilterCombox(e); //在beforequery使用此方法 }, '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 CUSTADDR = this.formEdit.getForm().findField('CUSTADDR'); var CUSTTEL = this.formEdit.getForm().findField('CUSTTEL'); 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); CUSTADDRTEL.setValue(data.INVADDRTEL); CUSTTEL.setValue(getEndTel(data.INVADDRTEL)); CUSTADDR.setValue(data.INVADDRTEL.replace( getEndTel(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(''); CUSTADDR.setValue(''); CUSTTEL.setValue(''); } var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME'); 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: '代开客户', labelWidth: labelwidth_sale, flex: 1.5, store: this.storeInvCustCode, forceSelection: true, name: 'ACTUALCUSTOMERNAME', matchFieldWidth: false, valueField: 'CustName', displayField: 'CodeAndName', listeners: { scope: this, 'beforequery': function (e) { return FilterCombox(e); //在beforequery使用此方法 }, '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 CUSTADDR = this.formEdit.getForm().findField('CUSTADDR'); var CUSTTEL = this.formEdit.getForm().findField('CUSTTEL'); 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); CUSTADDRTEL.setValue(data.INVADDRTEL); CUSTTEL.setValue(getEndTel(data.INVADDRTEL)); CUSTADDR.setValue(data.INVADDRTEL.replace(getEndTel(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(''); CUSTADDR.setValue(''); CUSTTEL.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.StoreDateCurr = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeNowInvCurrList' } }); this.StoreDateCurr.load({ params: { condition: "" } }); //20191024 改为币别固定为RMB //this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', { // fieldLabel: '币别', // store: this.StoreCurr, // forceSelection: true, // allowBlank: false, // labelWidth: 60, // name: 'CURRENCY', // valueField: 'CURR', // displayField: 'CURR' //}); 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, flex: 1, 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'); this.setBank(CURR) 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.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: '发票类型', labelWidth: labelwidth_sale, flex: 1, store: this.storeInvCategory, forceSelection: true, name: 'INVOICECATEGORY', valueField: 'EnumValueId', displayField: 'EnumValueName' }); this.StoreInvNo = Ext.create('DsExt.ux.RefTableStore', { model: 'MsChInvoiceNo', proxy: { url: '/Account/Chfee_invoice_HangXin/GetInvoiceNo' } }); ///航信接口不能指定发票号 //this.comboxInvNo = Ext.create('DsExt.ux.RefTableCombox', { // store: this.StoreInvNo, // fieldLabel: '发票号', // flex: 1.5, // 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: '收款单位', //'委托分公司', tooltip: '注意,销售方信息将使用这里选择的分公司信息', store: this.storeSaleCompany, forceSelection: true, name: 'SALECORPID', labelWidth: labelwidth_sale, flex: 1, id: 'PAYCOMPANYID', valueField: 'GID', displayField: 'NAME', listeners: { scope: this, 'beforequery': function (e) { return FilterCombox(e); //在beforequery使用此方法 }, 'select': function (combo, records, eOpts) { if (records.length > 0) { var companyid = records[0].data.GID; this.StoreBANK.load({ params: { condition: " LINKID='" + companyid + "'" } }); } } } }); 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: labelwidth_sale, // forceSelection: true, name: 'ACCOUNT', valueField: 'BANKACCOUNT', displayField: 'BANKACCOUNT' }); //#endregion //编辑form this.formEdit = Ext.widget('form', { region: 'center', frame: true, bodyPadding: 3, trackResetOnLoad: true, // autoScroll: true, fieldDefaults: { margins: '4 0 0 0', labelAlign: 'right', flex: 1, labelWidth: 77, msgTarget: 'qtip' }, items: [{ //fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [ { //第一大格第一行 xtype: 'container', layout: 'hbox', defaultType: 'textfield', margins: '4 0 0 4', 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: 'INVITERFACE', name: 'INVITERFACE', 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: 'OPERATORNAME', name: 'OPERATORNAME', 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: 'COMPANYID', name: 'COMPANYID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'INVOICETYPE', value: '1', name: 'INVOICETYPE', flex: 0, hidden: true, margins: '0' }, //{ // fieldLabel: 'REMARK', // name: 'REMARK', // flex: 0, // hidden: true, // margins: '0' //}, { fieldLabel: '编号', readOnly: true, hidden: true, flex: 1, name: 'BILLNO' }, { fieldLabel: '发票类别', readOnly: true, flex: 0.5, name: 'INVOICETYPEREF' }, { fieldLabel: '开票日期', labelWidth: labelwidth_top1, tooltip: '记录“开出发票”的时间', flex: 0.5, format: 'Y-m-d', xtype: 'datefield', name: 'INVOICEMAKETIME' }, this.comboxOPERATOR, this.comboxPAYEE, this.comboxCHECKER, { fieldLabel: '是否锁定', labelWidth: labelwidth_top1, flex: 0.5, readOnly: true, name: 'BILLSTATUSREF' }, { fieldLabel: '是否打印', labelWidth: labelwidth_top1, flex: 0.5, readOnly: true, name: 'ISNEEDPRINT' }, { fieldLabel: '是否结算', labelWidth: labelwidth_top1, flex: 0.5, readOnly: true, name: 'ISNEEDFEE' }, { fieldLabel: '是否作废', labelWidth: labelwidth_top1, flex: 0.5, readOnly: true, name: 'ISDELETE' }, { fieldLabel: '被冲红', labelWidth: labelwidth_top1, flex: 0.5, readOnly: true, name: 'SETRED' }, { xtype: 'hiddenfield', flex: 0 }] }, { //第一大格第二行 xtype: 'container', layout: 'hbox', defaultType: 'textfield', margins: '4 0 0 4', items: [this.comboxPTORRED, this.comboxINVOICELINE, { fieldLabel: 'EINVOICESTATE', hidden: true, flex: 1, name: 'EINVOICESTATE' }, { fieldLabel: '发票号', readOnly: true, labelWidth: labelwidth_top1, flex: 0.85, name: 'INVOICENO', listeners: { // 鼠标移动到文本框显示悬浮框 render: function (p) { p.getEl().on('mouseover', function (p1) { updateTip(p, '目前纸票和电票的票号都不可以指定\r\n\n纸票需要开出后自动生成发票号,\n然后根据这个发票号放置相应票号的空白发票进行打印'); }); } } }, { fieldLabel: '发票代码', labelWidth: labelwidth_top1, readOnly: true, flex: 1, name: 'INVOICECODE' }, { fieldLabel: '发票流水号', labelWidth: labelwidth_top1, readOnly: true, flex: 1, name: 'INVOICESERIALNUM' }, { fieldLabel: '开票状态', labelWidth: labelwidth_top1, flex: 1, readOnly: true, name: 'EINVOICESTATEREF' }, { fieldLabel: '发票详情页', hidden: true, flex: 1, readOnly: true, name: 'INVOICEINFOURL' }, { fieldLabel: '发票PDF地址', hidden: true, flex: 1, readOnly: true, name: 'INVOICEPDFURL' } //, //{ // xtype:'hiddenfield',flex:0.01 //} ] } ] //end items(fieldset 1) }, //end fieldset 1 { xtype: 'container', //fieldset外侧带框线 defaultType: 'textfield', layout: 'hbox', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'anchor', flex: 2.5, defaultType: 'textfield', margins: '2 0 0 4', items: [{ xtype: 'container', layout: 'hbox', margins: '0 0 0 0', defaultType: 'textfield', items: [{ xtype: 'label', flex: 0.5, text: '', },{ xtype: 'label', id: 'INVTITLE', flex:1, text: '增值税普通发票', style: { width: '95%', align: 'center', marginBottom: '10px', color: '#9c5223', fontSize: '30px' } }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '发票抬头', name: 'INVOICECUSTNAME' },{ fieldLabel: '纳税人识别号', name: 'CUSTRATENO' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '地址、电话', hidden: true, name: 'CUSTADDRTEL' }, { fieldLabel: '电话', flex: 0.8, name: 'CUSTTEL' }, { fieldLabel: '地址', flex: 1.2, labelWidth: 30, name: 'CUSTADDR' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCustBank] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxPUSHMODE, { labelWidth: 60, fieldLabel: '*推送手机', flex: 1.1, name: 'PUSHMOBILE' }, //{ // labelWidth: 55, // fieldLabel: '推送邮箱', // flex: 1.4, // name: 'PUSHEMAIL' // } this.comboxInfoClientMailTel ] }] }, { xtype: 'fieldset', defaultType: 'textfield', flex: 5, layout: 'anchor', margins: '4 0 0 4', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [ //this.comboxCurr,//币别固定为rmb { fieldLabel: '币别', labelWidth: 60, name: 'CURRENCY', hidden: true }, this.comboxInvCategory, this.comboxCurr2, { fieldLabel: '实际金额', labelWidth: labelwidth_sale, flex: 1, name: 'AMOUNT', 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; } }, { fieldLabel: '开票金额', labelWidth: labelwidth_sale, flex: 1, name: 'INVAMOUNT', 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; } }, { fieldLabel: '开票税率', labelWidth: labelwidth_sale, flex: 1, name: 'EXCHANGERATE', listeners: { scope: this, blur: function (field, The, eOpts) { _this.ChangeInvRate(field.value); } } }, { fieldLabel: '外币金额', labelWidth: labelwidth_sale, flex: 1, name: 'OTCURRAMOUNT', 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; } } ] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [ this.comboxSaleCompany //所属分部 , this.comboxBANK //银行账户 , this.comboxCustCode , this.comboxInvCustCode ] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [ { xtype: 'textareafield', grow: true, labelWidth: labelwidth_sale, name: 'REMARK', height: 61, fieldLabel: '备注', anchor: '100%' } , { xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', region: 'east', width: 160, defaults: { anchor: '100%' }, items: [ //this.comboxBANK //, { xtype: 'container', layout: 'hbox', //flex: 1, defaultType: 'textfield', items: [{ xtype: 'button', text: "提取备注", handler: function (button, event) { this.ImportRemarks(); }, scope: this }] }, { xtype: 'container', layout: 'hbox', //flex: 1, defaultType: 'textfield', items: [{ xtype: 'button', text: "模板设置", handler: function (button, event) { this.SetRemarksTemplate(); }, scope: this }] }] }, ////// { fieldLabel: '船名航次', hidden: true, labelWidth: 60, flex: 1, name: 'VESSELVOYAGE' }, { fieldLabel: '提单号', hidden: true, labelWidth: 60, name: 'MBLNO', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'render': function (_field, eOpts) { //自定义函数,定义双击事件 var _this = this; _field.getEl().on('dblclick', function (e, t, eOpts) { var mblno = _this.formEdit.getForm().findField('MBLNO').getValue(); _this.formSearch.getForm().findField('CustomNo').setValue(mblno); _this.onRefreshClick(); }); } } }, { fieldLabel: '委托编号', hidden: true, labelWidth: 60, name: 'BSNO', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'render': function (_field, eOpts) { //自定义函数,定义双击事件 var _this = this; _field.getEl().on('dblclick', function (e, t, eOpts) { var mblno = _this.formEdit.getForm().findField('BSNO').getValue(); _this.formSearch.getForm().findField('CustomNo').setValue(mblno); _this.onRefreshClick(); }); } } }, { fieldLabel: '起运港', hidden: true, labelWidth: 60, name: 'POL' } ] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '卸货港', hidden: true, labelWidth: 60, name: 'POD' }, { fieldLabel: 'ETD', hidden: true, labelWidth: 60, name: 'ETD' } ] } ] }] //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: "打印", hidden: true, 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 }, { id: 'btnECopyNew', text: "复制新建", handler: function (button, event) { 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('INVOICECODE'); field.setValue(''); field = basicForm.findField('EINVOICESTATE'); 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('INVOICESERIALNUM'); field.setValue(""); //正票 field = basicForm.findField('PTORRED'); field.setValue("1"); //被冲红设置为false field = basicForm.findField('SETRED'); field.setValue("False"); //清空流水号 field = basicForm.findField('INVOICEINFOURL'); field.setValue(""); //清空流水号 field = basicForm.findField('INVOICEPDFURL'); field.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(); this.GetEditStatus(); }, 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: '开票', id:"btn_KP", tooltip: '通过诺诺(瑞宏)开放平台开出发票', handler: function (button, event) { this.onNNMakeInvClick(); }, scope: this }, { text: '邮件转发', id: "btn_Invinfo", iconCls: 'btn-mail', tooltip: '打开诺诺(瑞宏)平台中的发票详细信息并保存,小窗下方"获取发票"内有邮件转发pdf的选项;已有流水号但开票状态不是开出成功或开出失败的发票,可以通过这个按钮获取发票详细信息。', handler: function (button, event) { this.onNNReadInvClick(); }, scope: this }, { text: '查看发票', id: "btn_Pdf", tooltip: '打开诺诺(瑞宏)开放平台中的发票PDF文件并保存发票详细信息;已有流水号但开票状态不是开出成功或开出失败的发票,可以通过这个按钮获取发票详细信息。', handler: function (button, event) { this.onNNReadInvPDFClick(); }, scope: this }, '-', { text: '作废', id: "btn_Void", tooltip: '实际操作成功后才修改发票状态。注意:电票不可作废,纸票月内作废,月外冲红', handler: function (button, event) { this.onNNVoidInvClick(); }, scope: this }, '-', { text: '冲红', id: "btn_Setred", hidden: true, tooltip: '注意,未冲红、未作废的发票才能进行此操作', handler: function (button, event) { this.onNNSetRedClick(); }, scope: this }] }); //end 按钮Toolbar //#endregion //#region 发票明细 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_HangXin/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', //width: 820, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, // 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: 'GOODSNAME', // header: '货物或应税劳务名称', // editor: { // xtype: 'textfield', // allowBlank: false, // selectOnFocus: true // }, // summaryType: 'count', // width: 120 // } , { sortable: false, dataIndex: 'SPEC', header: '规格型号', editor: { xtype: 'textfield', allowBlank: false, selectOnFocus: true }, width: 120 }, { 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: 60 }, { 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; }, 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: 60 }, { 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 }, { sortable: false, dataIndex: 'ISUSEPREF', header: '是否享受优惠政策', width: 100, renderer: function (value, p, record) { if (value == '1') return '是'; return '否'; } }, { sortable: false, dataIndex: 'DEFREMARK', header: '增值税特殊管理', width: 100 }, { sortable: false, dataIndex: 'ZTAXTYPE', header: '零税率标识', width: 80, renderer: function (value, p, record) { if (value == '') return '非零税率'; else if (value == '0') return '出口退税'; else if (value == '1') return '免征'; else if (value == '2') return '不征收'; else if (value == '3') return '普通零税率'; } } ] }); 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: 38, 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, flex: 3, name: 'AMOUNTCAPITAL' }, { fieldLabel: '被冲红发票号码', readOnly: true, flex: 1, name: 'REDNUM' }, { fieldLabel: '被冲红发票代码', readOnly: true, flex: 1, name: 'REDCODE' }] //end items(fieldset 1) } //end fieldset 1 ] //end root items }] }); //end this.formEdit //#region 明细表 //明细表表格相关 this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); //明细表-数据集 this.storeBodyList = Ext.create('Ext.data.Store', { model: 'Chfee_do_detail', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoice_HangXin/GetBillList', reader: { id: 'BSNO,FEEDOID', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.initgirdcolums = [{ 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: '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: 'INPUTMODE', header: '录入方式', width: 60 }, { sortable: true, dataIndex: 'DESTINATIOIN', header: '目的港', width: 120 }]; this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.initgirdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 _this = this; this.gridList = new Ext.grid.GridPanel({ store: this.storeBodyList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, viewConfig: { enableTextSelection: true }, selModel: this.GridCheckBoxModel, tbar: [{ text: '删除明细', tooltip: '删除明细', id: 'btndeldetail', iconCls: "btndeletedetail", handler: function (button, event) { this.onDeleteClick(button, event, 1); }, scope: this }, '-', { text: "保存列表样式", id: "btntest", menu: [{ text: "保存", handler: function (button, event) { _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.girdcolums, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.initgirdcolums, 1, true); } }], scope: this }], columns: this.girdcolums }); 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); // DsOpenEditWin("/TruckMng/MsWlPc/Edit"); }, this); this.storeBodySum = Ext.create('Ext.data.Store', { model: 'Chfee_do_sum', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoice_HangXin/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.storeBodyAddList = Ext.create('Ext.data.Store', { model: 'MsAddBillCustFee', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoice_HangXin/GetBillDataList', reader: { id: 'BSNO', root: 'data', totalProperty: 'totalCount' } } }); this.Pagenum = Ext.create('Ext.form.field.Number', { name: 'bottles', fieldLabel: '每页记录数', labelAlign: 'right', value: this.PageSize, maxValue: 100000, width: 180, minValue: 0, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.initaddgirdcolums = [{ sortable: true, dataIndex: 'BSNO', header: 'BSNO', hidden: true, width: 100 }, { sortable: true, dataIndex: 'CUSTNO', header: '委托编号', width: 108 }, { sortable: true, dataIndex: 'MBLNO', header: '主提单号', width: 108 }, { sortable: true, dataIndex: 'FEEOBJNAME', header: '结费单位', width: 90 }, { sortable: true, dataIndex: 'RMBDrBalAmount', header: 'RMB未开', 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: 'USDDrBalAmount', header: 'USD未开', width: 70, 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: 'OTDrBalAmount', 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: 'OPLBNAME', header: '业务类别', width: 80 }, { 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: 'SALE', header: '揽货人', width: 80 }, { sortable: true, dataIndex: 'ACCDATE', header: '会计期间', width: 80 }, { sortable: true, dataIndex: 'OP', header: '操作', width: 80 }, { sortable: true, dataIndex: 'INPUTBY', header: '录入人', width: 80 }, { sortable: true, dataIndex: 'PORTLOAD', header: '起运港', width: 120 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '目的港', width: 120 }, { sortable: true, dataIndex: 'VESSEL', header: '船名', width: 150 }, { sortable: true, dataIndex: 'VOYNO', header: '航次', width: 60 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 80 }]; this.addgirdcolums = DsTruck.GetGridPanel(USERID, this.formname + 'add', this.initaddgirdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.AddGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridAddList = new Ext.grid.GridPanel({ store: this.storeBodyAddList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, viewConfig: { enableTextSelection: true }, selModel: this.AddGridCheckBoxModel, tbar: [{ text: '添加发票明细', tooltip: '添加发票明细', id: 'btnaddbill', iconCls: "btnadddetail", handler: function (button, event) { this.onAddClick(button, event); }, scope: this }, '-', { text: "保存列表样式", id: "btntest", menu: [{ text: "保存", handler: function (button, event) { _this.addgirdcolums = DsTruck.SaveGridPanel(USERID, _this.formname + 'add', _this.gridAddList.columns, _this.addgirdcolums, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.addgirdcolums = DsTruck.SaveGridPanel(USERID, _this.formname + 'add', _this.gridAddList.columns, _this.initaddgirdcolums, 1, true); } }], scope: this }], columns: this.addgirdcolums, bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeBodyAddList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }), this.Pagenum] }); this.gridAddList.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); // DsOpenEditWin("/TruckMng/MsWlPc/Edit"); }, this); //#endregion _this = this; this.FeeGroup = new Ext.form.RadioGroup({ id: 'FeeGroup', xtype: 'radiogroup', fieldLabel: '发票明细', labelWidth: 90, columns: 2, items: [{ boxLabel: '费用合计', name: 'Curr', inputValue: 'false', checked: true }, { boxLabel: '费用列表', name: 'Curr', inputValue: 'true' }] }); //#region 添加费用列表 this.storeAddFeeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'Chfee_add_detail', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoice_HangXin/GetFeeDetailList', reader: { id: 'BSNO', root: 'data', totalProperty: 'totalCount' } } }); this.initgirdfeecolums = [{ sortable: true, dataIndex: 'CH_ID', header: 'CH_ID', hidden: true, width: 100 }, { sortable: true, dataIndex: 'BSNO', header: 'BSNO', hidden: true, width: 100 }, { sortable: true, dataIndex: 'CustomerName', header: '客户名称', width: 90 }, { sortable: true, dataIndex: 'FeeType_Ref', header: '收付', width: 40 }, { sortable: true, dataIndex: 'FeeName', header: '费用名称', width: 90 }, { sortable: true, dataIndex: 'Amount', header: '金额', width: 70, 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: 'Currency', header: '币别', width: 40 }, { sortable: true, dataIndex: 'BalAmount', header: '未开票金额', width: 70, 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: 'StlAmount', header: '本次开票金额', editor: { xtype: 'numberfield', keyNavEnabled: false, allowDecimals: true, decimalPrecision: 2, selectOnFocus: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(9) } else if (e.getKey() == 38) { _this.onUpKeyClick(9) } } } }, 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: 70 }, { sortable: true, dataIndex: 'ExChangerate', header: '原始汇率', width: 60 }, { sortable: true, dataIndex: 'INPUTMODE', header: '录入方式', width: 60 }, { sortable: true, dataIndex: 'Remark', header: '备注', width: 60 }]; this.girdfeecolums = this.initgirdfeecolums; this.AddFeeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.cellEditingFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, listeners: { 'edit': function (editor, e) { } } }); this.gridAddFeeList = new Ext.grid.GridPanel({ store: this.storeAddFeeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingFee], viewConfig: { enableTextSelection: true, autoFill: true }, selModel: this.AddFeeGridCheckBoxModel, tbar: [{ text: '添加发票费用明细', tooltip: '添加发票费用明细', iconCls: "btnadddetail", id: "btnadddetail", handler: function (button, event) { this.onAddDetailClick(button, event); }, scope: this }, '-', { text: "保存列表样式", id: "btntestfee", menu: [{ text: "保存", handler: function (button, event) { _this.girdfeecolums = DsTruck.SaveGridPanel(USERID, _this.formname + 'feeadd', _this.gridAddFeeList.columns, _this.girdfeecolums, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.girdfeecolums = DsTruck.SaveGridPanel(USERID, _this.formname + 'feeadd', _this.gridAddFeeList.columns, _this.initgirdfeecolums, 1, true); } }], scope: this }], columns: this.girdfeecolums, // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeAddFeeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.girdfeecolums = DsTruck.GetGridPanel(USERID, this.formname + 'feeadd', this.girdfeecolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.gridAddFeeList.reconfigure(this.storeAddFeeList, this.girdfeecolums); this.gridAddFeeList.on('edit', function (editor, e, eOpts) { this.gridAddFeeListAfterEdit(editor, e, eOpts); }, this); this.storeSelectSum = Ext.create('Ext.data.Store', { model: 'Chfee_do_selectsum' }); this.gridSelectSum = new Ext.grid.GridPanel({ store: this.storeSelectSum, enableHdMenu: false, // anchor: '100% 50%', region: 'south', height: 80, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, tbar: [{ xtype: 'label', width: 220, id: 'SelectGrid', height: 22, text: '所选费用合计' }], columns: [{ sortable: true, dataIndex: 'RMBDRAMOUNT', header: 'RMB未开', width: 80 }, { sortable: true, dataIndex: 'USDDRAMOUNT', header: 'USD未开', width: 80 }, { sortable: true, dataIndex: 'OTDRAMOUNT', header: '其他未开', width: 80 }] }); //#endregion _this = this; this.storeCustCodefee = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRmAll' } }); this.storeCustCodefee.load({ params: { condition: "" } }); this.comboxAddCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '费用对象', store: this.storeCustCodefee, forceSelection: true, name: 'CUSTNAME', valueField: 'CustName', displayField: 'CodeAndName', queryMode: 'remote', minChars: 1, queryParam: 'CODENAME', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.StoreOpLb = Ext.create('Ext.data.Store', { fields: ['OPLBNAME'] }); this.StoreOpLb.add({ "OPLBNAME": "海运出口" }); this.StoreOpLb.add({ "OPLBNAME": "海运进口" }); this.StoreOpLb.add({ "OPLBNAME": "报关业务" }); this.StoreOpLb.add({ "OPLBNAME": "进口贸易" }); this.StoreOpLb.add({ "OPLBNAME": "大宗散货" }); this.StoreOpLb.add({ "OPLBNAME": "综合业务" }); this.StoreOpLb.add({ "OPLBNAME": "陆运派车单" }); this.comboxOpLb = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '业务类别', store: this.StoreOpLb, valueField: 'OPLBNAME', displayField: 'OPLBNAME', forceSelection: true, name: 'OPLBNAME', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeAddDCType = Ext.create('Ext.data.Store', { fields: ['DC', 'NAME'] }); this.storeAddDCType.add({ "DC": "", "NAME": "全部" }); this.storeAddDCType.add({ "DC": "1", "NAME": "应收" }); this.storeAddDCType.add({ "DC": "2", "NAME": "应付" }); this.comboxaddDCType = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '收/付', store: this.storeAddDCType, valueField: 'DC', displayField: 'NAME', // readOnly: true, forceSelection: true, name: 'DC', //flex: 0.5, value: '1', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.comboxCurr2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '币别', store: this.StoreCurr, forceSelection: true, name: 'Currency', valueField: 'CURR', //flex: 0.5, displayField: 'CURR', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.FeeTypeRefModel', proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' } }); this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '费用名称', store: this.storeFeeNameRef, forceSelection: true, name: 'FeeName', valueField: 'Name', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeFeeNameRef.load({ params: { condition: "" } }); this.storeCurrExrate = Ext.create('Ext.data.Store', { fields: ['CURR', 'EXRATE', 'DFEXRATE'] }); this.storeFSTATUS = Ext.create('Ext.data.Store', { fields: ['FSTATUS', 'NAME'] }); this.storeFSTATUS.add({ "FSTATUS": "0", "NAME": "全部" }); this.storeFSTATUS.add({ "FSTATUS": "9", "NAME": "未结金额" }); this.storeFSTATUS.add({ "FSTATUS": "8", "NAME": "结算完毕" }); this.comboxFSTATUS = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '费用范围', store: this.storeFSTATUS, valueField: 'FSTATUS', displayField: 'NAME', forceSelection: true, name: 'FSTATUS', value: '', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.formSearch = Ext.widget('form', { frame: true, region: 'north', bodyPadding: 5, title: '添加发票明细', collapsible: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 60, msgTarget: 'qtip' }, items: [{ //fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxAddCustCode, this.comboxOpLb, { fieldLabel: '编号检索', name: 'CustomNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '业务日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateBgn', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '业务日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateEnd', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxFSTATUS, { xtype: 'button', width: 45, text: "", iconCls: "btnreset", handler: function (button, event) { this.onClearSql(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 }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxaddDCType, this.comboxCurr2, { fieldLabel: '对账编号', name: 'DuiNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxFeeNameRef, { fieldLabel: '会计期间', xtype: 'monthfield', name: 'ACCDATEFR', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '会计期间', xtype: 'monthfield', name: 'ACCDATETO', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { xtype: 'button', width: 90, text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }] }] //end items(fieldset 1) } //end fieldset 1 ] //end root items }); //#region 发票备注 //#endregion this.panelInvDetail = new Ext.Panel({ layout: "border", //layout: "anchor", // height: 220, region: "center", margin: '2 2', items: [this.gridDetailList, this.formAMT]//this.formRemark, }); 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.panelAddService = new Ext.Panel({ layout: "border", region: 'center', margin: '2 2', items: [this.gridAddList] }); this.panelAddfee = new Ext.Panel({ layout: "border", region: 'east', width: 550, split: true, margin: '2 2', items: [this.gridAddFeeList, this.gridSelectSum] }); this.paneladddetail = new Ext.Panel({ layout: "border", region: 'center', items: [this.panelAddService, this.panelAddfee] }); this.paneladd = new Ext.Panel({ //title: '添加发票明细', layout: "border", // region: 'south', //collapsible: true, region: "center", items: [this.formSearch, this.paneladddetail] }); //#endregion 明细表 //#region 布局 //控件布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 285, 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.panelInvDetail] }); this.tabpanel = new Ext.TabPanel({ activeTab: 0, autoWidth: true, border: false, frame: false, height: 220, 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) { billno = this.editRecord.get('BILLNO'); 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.storeBodySum.on('beforeload', function (store) { billno = this.editRecord.get('BILLNO'); var sql = " BILLNO='" + billno + "'"; Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.storeBodyAddList.on('beforeload', function (store) { // var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: this.sqlcontext }); }, this); this.storeAddFeeList.on('beforeload', function (store) { var sql = ''; if (this.selectfeesql == '') sql = '1=2 '; else sql = this.selectfeesql; Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.storeBodyAddList.on('load', function (store, records) { if (store.getCount() > 0) { this.gridAddList.getSelectionModel().select(0); var btnEAddbill = Ext.getCmp('btnaddbill'); if (this.canedit) btnEAddbill.enable(); } else { this.storeAddFeeList.removeAll(); } }, this); this.storeAddFeeList.on('load', function (store, records) { if (store.getCount() > 0) { var btnEAddDetail = Ext.getCmp('btnadddetail'); if (this.canedit) btnEAddDetail.enable(); } else { } }, this); var isloadfee = true; this.gridAddList.getSelectionModel().on('select', function (model, record, index) { if (!isloadfee) return; var bsno = record.data.BSNO; var feeobjname = record.data.FEEOBJNAME; var sql = ""; sql = " BSNO='" + bsno + "' AND CUSTOMERNAME='" + feeobjname + "'"; sql = sql + getAndConSql(sql, this.FeeSqlStr, this.FeeSqlStr); this.selectfeesql = sql; isloadfee = false; this.storeAddFeeList.load({ params: { condition: sql }, callback: function (r, options, success) { if (success) { isloadfee = true; } } }); }, this); _this = this; this.gridAddList.on({ selectionchange: function (sm, selections) { var SelectGridtext = Ext.getCmp('SelectGrid'); _this.storeSelectSum.removeAll(); SelectGridtext.setText('所选费用合计'); if (selections.length == 0) { return; } _this.storeSelectSum.add({ "RMBDRAMOUNT": 0, "RMBCRAMOUNT": 0, "USDDRAMOUNT": 0, "USDCRAMOUNT": 0, "OTDRAMOUNT": 0, "OTCRAMOUNT": 0 }); var R = selections.length; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; var memberyf = _this.storeSelectSum.getAt(0); var amount = memberyf.data.RMBDRAMOUNT; var cramount = memberyf.data.RMBCRAMOUNT; amount = (parseFloat(amount).add(parseFloat(rec.data.RMBDrBalAmount))).toFixed(2); cramount = (parseFloat(cramount).add(parseFloat(rec.data.RMBCrBalAmount))).toFixed(2); var usdamount = memberyf.data.USDDRAMOUNT; var usdcramount = memberyf.data.USDCRAMOUNT; usdamount = (parseFloat(usdamount).add(parseFloat(rec.data.USDDrBalAmount))).toFixed(2); usdcramount = (parseFloat(usdcramount).add(parseFloat(rec.data.USDCrBalAmount))).toFixed(2); var otamount = memberyf.data.OTDRAMOUNT; var otcramount = memberyf.data.OTCRAMOUNT; otamount = (parseFloat(otamount).add(parseFloat(rec.data.OTDrBalAmount))).toFixed(2); otcramount = (parseFloat(otcramount).add(parseFloat(rec.data.OTCrBalAmount))).toFixed(2); memberyf.set("RMBDRAMOUNT", amount); memberyf.set("RMBCRAMOUNT", cramount); memberyf.set("USDDRAMOUNT", usdamount); memberyf.set("USDCRAMOUNT", usdcramount); memberyf.set("OTDRAMOUNT", otamount); memberyf.set("OTCRAMOUNT", otcramount); memberyf.commit(); } SelectGridtext.setText('所选费用合计(选中' + R + '票业务)'); } }); //#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 this.storeModuleEnable = Ext.create('Ext.data.Store', { model: 'DsShipping.ux.ModuleModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsBaseInfo/GetUserModuleEnableList', reader: { id: 'id', root: 'data', totalProperty: 'totalCount' } } }); this.storeModuleEnable.load({ params: { condition: "sys_module.[NAME]='modInvoiceSetRed'" }, callback: function (r, options, success) { if (success) { if (this.storeModuleEnable.getCount() > 0) { for (var j = 0; j < this.storeModuleEnable.getCount(); j += 1) { var member = this.storeModuleEnable.getAt(j); var btnEdit = Ext.getCmp('btn_Setred'); btnEdit.setVisible(true); }; } 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') + "'"; 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_HangXin/GetData', params: { handle: opstatus, condition: condition, 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().findField('BILLSTATUS').setDisabled(false); _this.formEdit.getForm().reset(); _this.formAMT.getForm().reset(); //_this.formRemark.getForm().reset(); _this.formEdit.getForm().setValues(data); _this.formAMT.getForm().setValues(data); _this.setInvTile(data.INVOICELINE); //_this.formRemark.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')); //} } } } } }); var companyid = data.SALECORPID; this.StoreBANK.load({ params: { condition: " LINKID='" + companyid + "'" } , callback: function (r, options, success) { if (this.opStatus == 'add') _this.setBank('RMB'); } }); // _this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true); Data_pushmail = { EMAIL: data.PUSHEMAIL, NAMEANDEMAIL: data.PUSHEMAIL }; this.storeInfoClientMailTel.removeAll(); this.storeInfoClientMailTel.add(Data_pushmail); 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 + "'" } }); }, // end LoadDate //#region 复制新建 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('INVOICESERIALNUM'); field.setValue(""); //正票 field = basicForm.findField('PTORRED'); field.setValue("1"); //被冲红设置为false field = basicForm.findField('SETRED'); field.setValue("False"); //清空流水号 field = basicForm.findField('INVOICEINFOURL'); field.setValue(""); //清空流水号 field = basicForm.findField('INVOICEPDFURL'); field.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(); }, //#endregion 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 remarks = this.formRemark.getForm().findField('REMARK').getValue(); //this.formEdit.getForm().findField('REMARK').setValue(remarks); 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); data.REDCODE = this.formAMT.getForm().findField('REDCODE').getValue(); data.REDNUM = this.formAMT.getForm().findField('REDNUM').getValue(); 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_HangXin/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) { _this.dealReturnData(jsonresult.Data); if (type == '0') { this.opStatus = 'edit'; this.storeDetailList.load({ params: { condition: " PID='" + GID + "'" } }); } else if (type == '1') { window.close(); } else if (type == '2') { this.LoadData('add', ''); } else if (type == "MakeInv") { this.DoMakeNNInv(); } } 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 dealReturnData: function (returnData) { //var returnData = jsonresult.Data; this.formEdit.getForm().setValues(returnData); this.formAMT.getForm().setValues(returnData); 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(); } GID = this.editRecord.get('GID'); this.GetEditStatus(); }, onAddDetailClick: function (button, event) { this.addstore = true; this.addDetail(); }, //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 onDelInvClick: function (button, event) { this.DeleteInv(); }, gridListDetailAfterEdit: function (editor, e, eOpts) { if (e.value == e.originalValue) return; if (e.field == 'PKGS' || e.field == 'PRICE') { var unitPrice = e.record.data['PRICE']; var quantity = e.record.data['PKGS']; var taxrate = e.record.data['TAXRATE']; if (taxrate != null) { var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var TaxUnitPrice = (unitPrice.mul(taxrateb)).toFixed(2); e.record.set('TAXPRICE', TaxUnitPrice); } var amount = (unitPrice.mul(quantity)).toFixed(2); e.record.set('AMOUNT', amount); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(amount).mul(taxrate)).toFixed(2); e.record.set('TAX', tax); 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) { var amount = (parseFloat(unitPrice).mul(quantity)).toFixed(2); e.record.set('AMOUNT', amount); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(amount).mul(taxrate)).toFixed(2); e.record.set('TAX', tax); } 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 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) { var amount = (parseFloat(unitPrice).mul(quantity)).toFixed(2); e.record.set('AMOUNT', amount); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(amount).mul(taxrate)).toFixed(2); e.record.set('TAX', tax); } 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 unitPrice = e.record.data['PRICE']; var quantity = e.record.data['PKGS']; var TaxUnitPrice = e.record.data['TAXPRICE']; if (TaxUnitPrice != 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) { var amount = (parseFloat(unitPrice).mul(quantity)).toFixed(2); e.record.set('AMOUNT', amount); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(amount).mul(taxrate)).toFixed(2); e.record.set('TAX', tax); } 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) { var amount = (parseFloat(unitPrice).mul(quantity)).toFixed(2); memberbody.set("AMOUNT", amount); taxrate = parseFloat(taxrate) / 100; var tax = (parseFloat(amount).mul(taxrate)).toFixed(2); memberbody.set("TAX", tax); } } 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(); 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 BILLNO = this.formEdit.getForm().findField('BILLNO').getValue(); if (selectedRecords.length == 0) { 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_HangXin/DelInvDetail', params: { billno: BILLNO, body: jsonBody, GID: GID }, 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); }, addDetail: function () { var btnEAddDetail = Ext.getCmp('btnadddetail'); btnEAddDetail.disable(); var basicForm = this.formEdit.getForm(); 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(); 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; if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null)) { this.formEdit.getForm().findField('CUSTOMERNAME').setValue(cust); var recs = DsStoreQueryBy(this.storeInvCustCode, 'CustName', cust); var INVOICECUSTNAME = this.formEdit.getForm().findField('INVOICECUSTNAME'); var CUSTRATENO = this.formEdit.getForm().findField('CUSTRATENO'); var CUSTADDRTEL = this.formEdit.getForm().findField('CUSTADDRTEL'); var CUSTADDR = this.formEdit.getForm().findField('CUSTADDR'); var CUSTTEL = this.formEdit.getForm().findField('CUSTTEL'); var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK'); var CURRFIELD = this.formEdit.getForm().findField('CURRENCY'); this.formEdit.getForm().findField('RECVCURR').setValue(curr); var RECVCURR = curr; this.setBank(RECVCURR) var CURR = CURRFIELD.getValue(); if (recs.getCount() > 0) { var data = recs.getAt(0).data; INVOICECUSTNAME.setValue(data.BillRises1); CUSTRATENO.setValue(data.TaxNo); CUSTADDRTEL.setValue(data.INVADDRTEL); CUSTTEL.setValue(getEndTel(data.INVADDRTEL)); CUSTADDR.setValue(data.INVADDRTEL.replace(getEndTel(data.INVADDRTEL), "")); if (RECVCURR == 'RMB') CUSTBANK.setValue(data.RMBBank); if (RECVCURR == 'USD') CUSTBANK.setValue(data.USDBank); // if (CURR == '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 (CURR == '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(''); CUSTADDR.setValue(''); CUSTTEL.setValue(''); } } if ((CURR == '') || (CURR == null)) { btnEAddDetail.enable(); Ext.Msg.show({ title: '提示', msg: '币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } } } if (!basicForm.isValid()) { return; } var type = 0; var PAYCOMPANYID = Ext.getCmp('PAYCOMPANYID').getValue(); if ((PAYCOMPANYID == '') || (PAYCOMPANYID == null)) { var selectedRecords = this.gridAddList.selModel.getSelection(); if (selectedRecords.length > 0) { var rec = selectedRecords[0]; var PAYCOMPANYID = rec.data.SALECORPID; Ext.getCmp('PAYCOMPANYID').setValue(PAYCOMPANYID); } } this.addBsMbl(); this.formEdit.getForm().findField('GID').setDisabled(false); // this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false); this.formEdit.getForm().findField('COMPANYID').setDisabled(false); //var remarks = this.formRemark.getForm().findField('REMARK').getValue(); //this.formEdit.getForm().findField('REMARK').setValue(remarks); 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); data.REDCODE = this.formAMT.getForm().findField('REDCODE').getValue(); data.REDNUM = this.formAMT.getForm().findField('REDNUM').getValue(); 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_HangXin/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 () { var btnEAddDetail = Ext.getCmp('btnadddetail'); if (this.addstore) { this.storeCurrExrate.removeAll(); this.addstore = false; } var Duino = this.formEdit.getForm().findField('BILLNO').getValue(); var GID = this.formEdit.getForm().findField('GID').getValue(); var jobValue = this.FeeGroup.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(); var EINVOICESTATEREF = this.formEdit.getForm().findField('EINVOICESTATEREF').getValue(); if (EINVOICESTATEREF != '未开票' && EINVOICESTATEREF != '' && EINVOICESTATEREF != null) { btnEAddDetail.enable(); Ext.Msg.show({ title: '提示', msg: '当前开票状态不能修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } 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 invoiceno = this.editRecord.data.INVOICENO; var selectedRecords = this.gridAddFeeList.selModel.getSelection(); var billgroupcorp = this.GetGroupCorp(billcust); var bodyAddDatas = []; _this = this; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; var cust = rec.data.CustomerName; var custgroupcorp = this.GetGroupCorp(cust); var bsno = rec.data.BSNO; var curr = rec.data.Currency; var acctaxrate = rec.data.AccTaxRate; var ExChangerate = rec.data.ExChangerate; if (cust == billcust || cust == billgroupcorp || (custgroupcorp == billgroupcorp && custgroupcorp != '')) { if (billtaxrate == acctaxrate) { if (billcurr == curr) { rec.data.DoAmount = rec.data.StlAmount; } else { var recs = DsStoreQueryBy(_this.storeCurrExrate, 'CURR', curr); if (recs.getCount() > 0) { var data = recs.getAt(0).data; var EXRATE = data.EXRATE; rec.data.ExChangerate = EXRATE; rec.data.DoAmount = parseFloat(rec.data.StlAmount).mul(parseFloat(EXRATE)); } else { _this.ExrateConversion(curr, billcurr, 'detail', ExChangerate); return; } } bodyAddDatas.push(rec); } else { // Ext.Msg.show({ title: '提示', msg: '费用进项税率与发票申请税率不一致,不能添加此费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); alert('费用进项税率与发票申请税率不一致,不能添加此费用明细!'); } } else { alert('费用对象与开票客户不一致,不能添加此费用明细!'); // Ext.Msg.show({ title: '提示', msg: '费用对象与开票客户不一致,不能添加此费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } } 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_HangXin/AddDetail', params: { bill: billno, data: jsonbodyAddDatas, curr: billcurr, islist: jobValue, GID: GID, invoiceno: invoiceno }, 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 { this.storeAddFeeList.reload(); var sql = this.BillSql; if (!isNullorEmpty(sql)) this.storeBodyAddList.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.storeDetailList.load({ params: { condition: " PID='" + GID + "'" } }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice_HangXin/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(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } else { btnEAddDetail.enable(); Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, addBill: function () { var btnEAddbill = Ext.getCmp('btnaddbill'); btnEAddbill.disable(); var basicForm = this.formEdit.getForm(); 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(); if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null) || (CURR == '') || (CURR == null)) { if (this.storeAddFeeList.getCount() > 0) { var rec = this.storeAddFeeList.getAt(0); var cust = rec.data.CustomerName; var curr = rec.data.Currency; if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null)) { this.formEdit.getForm().findField('CUSTOMERNAME').setValue(cust); var recs = DsStoreQueryBy(this.storeInvCustCode, 'CustName', cust); var INVOICECUSTNAME = this.formEdit.getForm().findField('INVOICECUSTNAME'); var CUSTRATENO = this.formEdit.getForm().findField('CUSTRATENO'); var CUSTADDRTEL = this.formEdit.getForm().findField('CUSTADDRTEL'); var CUSTTEL = this.formEdit.getForm().findField('CUSTTEL'); var CUSTADDR = this.formEdit.getForm().findField('CUSTADDR'); var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK'); var CURRFIELD = this.formEdit.getForm().findField('CURRENCY'); this.formEdit.getForm().findField('RECVCURR').setValue(curr); var RECVCURR = curr; this.setBank(RECVCURR) var CURR = CURRFIELD.getValue(); if (recs.getCount() > 0) { var data = recs.getAt(0).data; INVOICECUSTNAME.setValue(data.BillRises1); CUSTRATENO.setValue(data.TaxNo); CUSTADDRTEL.setValue(data.INVADDRTEL); CUSTTEL.setValue(getEndTel(data.INVADDRTEL)); CUSTADDR.setValue(data.INVADDRTEL.replace(getEndTel(data.INVADDRTEL), "")); // CUSTADDRTEL.setValue(data.Addr + ' ' + data.Tel); if (RECVCURR == 'RMB') CUSTBANK.setValue(data.RMBBank); if (RECVCURR == 'USD') CUSTBANK.setValue(data.USDBank); // if (CURR == '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 (CURR == '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(''); CUSTADDR.setValue(''); CUSTTEL.setValue(''); } } if ((CURR == '') || (CURR == null)) this.formEdit.getForm().findField('CURRENCY').setValue(curr); } else { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: '结算客户和币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } } if (!basicForm.isValid()) { btnEAddbill.enable(); return; } var type = 0; this.addBsMbl(); var PAYCOMPANYID = Ext.getCmp('PAYCOMPANYID').getValue(); if ((PAYCOMPANYID == '') || (PAYCOMPANYID == null)) { var selectedRecords = this.gridAddList.selModel.getSelection(); if (selectedRecords.length > 0) { var rec = selectedRecords[0]; var PAYCOMPANYID = rec.data.SALECORPID; Ext.getCmp('PAYCOMPANYID').setValue(PAYCOMPANYID); } } this.formEdit.getForm().findField('GID').setDisabled(false); this.formEdit.getForm().findField('COMPANYID').setDisabled(false); //var remarks = this.formRemark.getForm().findField('REMARK').getValue(); //this.formEdit.getForm().findField('REMARK').setValue(remarks); var data = basicForm.getValues(); var GID = this.formEdit.getForm().findField('GID').getValue(); this.formEdit.getForm().findField('COMPANYID').setDisabled(true); this.formEdit.getForm().findField('GID').setDisabled(true); data.REDCODE = this.formAMT.getForm().findField('REDCODE').getValue(); data.REDNUM = this.formAMT.getForm().findField('REDNUM').getValue(); 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_HangXin/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.addBillfn(); } else { btnEAddbill.enable(); Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { btnEAddbill.enable(); Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); } else { this.addBillfn(); } }, //end save addBillfn: function () { var btnEAddbill = Ext.getCmp('btnaddbill'); 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') { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: '已打印无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '' && VOUCHERNO != null) { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUNO != '' && VOUNO != null) { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: '已生成总账凭证无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISDELETE == 'true') { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: '此发票已作废无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (this.addstore) { this.storeCurrExrate.removeAll(); this.addstore = false; } var billcust = this.editRecord.data.CUSTOMERNAME; var billno = this.editRecord.data.BILLNO; var billcurr = this.editRecord.data.CURRENCY; var billgroupcorp = this.GetGroupCorp(billcust); var GID = this.formEdit.getForm().findField('GID').getValue(); var jobValue = this.FeeGroup.getValue(); var feeBSNOSql = ''; var sql = ''; var selectedRecords = this.gridAddList.selModel.getSelection(); if (selectedRecords.length == 0) { btnEAddbill.enable(); 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]; var custgroupcorp = this.GetGroupCorp(rec.data.FEEOBJNAME); if (rec.data.FEEOBJNAME == billcust || rec.data.FEEOBJNAME == billgroupcorp || (custgroupcorp == billgroupcorp && custgroupcorp != '')) { var feeBSNO = " (BSNO='" + rec.data.BSNO + "' AND CUSTOMERNAME='" + rec.data.FEEOBJNAME + "') "; if (feeBSNOSql == '') { feeBSNOSql = feeBSNO; } else { feeBSNOSql = feeBSNOSql + " OR " + feeBSNO; } } else { alert('费用对象与开票客户不一致,不能添加此费用明细!'); } } if (feeBSNOSql == '') { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: '没有要添加的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); sql = " "; return; } else { sql = " (" + feeBSNOSql + ")"; sql = sql + getAndConSql(sql, this.FeeSqlStr, this.FeeSqlStr); } _this = this; var bodydatas = []; for (var i = 0; i < this.storeCurrExrate.getCount(); i += 1) { var member = this.storeCurrExrate.getAt(i); if (member.data.EXRATE == 0) { _this.ExrateConversion(member.CURR, billcurr, 'bill', 0); return; } bodydatas.push(member); } var currBody = ConvertRecordsToJsonAll(bodydatas); var data = this.formEdit.getForm().getValues(); Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_invoice_HangXin/AddBill', params: { bill: Ext.JSON.encode(data), feesql: sql, storeCurrExrate: currBody, islist: jobValue, GID: GID, custgroup: true }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { dataList = result.Data; if (dataList == null) { this.storeBodyAddList.reload(); var sql = this.BillSql; //if (!isNullorEmpty(sql)) //this.storeBodyAddList.load({ // params: { // start: 0, // limit: _this.PageSize, // sort: '', // condition: sql // } //}); // this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql, billtype: 2} }); 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_HangXin/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(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } else { if (dataList.lenght != 0) { for (var i = 0; i < dataList.length; i++) { var record = dataList[i]; _this.storeCurrExrate.add(record); } _this.ExrateConversion(record.CURR, billcurr, 'bill', 0); return; } } } } else { btnEAddbill.enable(); Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, deleteBill: function (type) { var btnEDeleteDetail = Ext.getCmp('btndeldetail'); btnEDeleteDetail.disable(); var billno = this.formEdit.getForm().findField('BILLNO').getValue(); var GID = this.formEdit.getForm().findField('GID').getValue(); var selectedRecords = this.gridList.selModel.getSelection(); if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '没有要删除的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); btnEDeleteDetail.enable(); 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 }); btnEDeleteDetail.enable(); return; } if (VOUCHERNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); btnEDeleteDetail.enable(); return; } if (VOUNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成总账凭证无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); btnEDeleteDetail.enable(); return; } if (ISDELETE == 'true') { Ext.Msg.show({ title: '提示', msg: '此发票已作废无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); btnEDeleteDetail.enable(); 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; _this = this; Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/Account/Chfee_invoice_HangXin/DelBill', 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 }); btnEDeleteDetail.enable(); return; } else { var sql = this.BillSql; if (!isNullorEmpty(sql)) this.storeBodyAddList.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 + "'" } }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice_HangXin/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 }); btnEDeleteDetail.enable(); 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(); btnEDeleteDetail.enable(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); btnEDeleteDetail.enable(); } }, scope: this }); } } else { btnEDeleteDetail.enable(); Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, DeleteInv: function (type) { var billno = this.formEdit.getForm().findField('BILLNO').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('VOUCHERNO').getValue(); 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 sql = this.BillSql; _this = this; Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/Account/Chfee_invoice_HangXin/DeleteInv', params: { billno: billno, isprint: ISNEEDPRINT }, 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; if (!isNullorEmpty(sql)) this.storeBodyAddList.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 + "'" } }); if (ISNEEDPRINT == "true") { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice_HangXin/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(); } 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_HangXin/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_HangXin/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_HangXin/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 sql = this.BillSql; if (!isNullorEmpty(sql)) this.storeBodyAddList.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.storeDetailList.load({ params: { condition: " PID='" + GID + "'" } }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice_HangXin/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_HangXin/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 sql = this.BillSql; if (!isNullorEmpty(sql)) { this.storeBodyAddList.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.storeDetailList.load({ params: { condition: " PID='" + GID + "'" } }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_invoice_HangXin/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 }); }, 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_HangXin/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 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_HangXin/ExpDZInvForm', 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 }); }, getformvalue: function (fieldname) { return this.formEdit.getForm().findField(fieldname).getValue(); }, fieldisnull: function (fieldname) { if (isNullorEmpty(this.getformvalue(fieldname))) return true; else return false; }, onNNMakeInvClick: function () { var AMOUNT = this.formEdit.getForm().findField('AMOUNT').getValue(); var INVAMOUNT = this.formEdit.getForm().findField('INVAMOUNT').getValue(); if (INVAMOUNT != AMOUNT) { Ext.MessageBox.confirm('提示', '开票金额和实际金额不一致,确定要开票吗?', function (btn) { if (btn != 'yes') { return; } }, this); } var btn_KP = Ext.getCmp("btn_KP"); btn_KP.disable(); _this = this; setTimeout(function () { _this.setInvoiceButtonStatus() }, 5000); this.Save("MakeInv"); //_this.setInvoiceButtonStatus() }, DoMakeNNInv: 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; }; var EINVOICESTATEREF = this.formEdit.getForm().findField('EINVOICESTATEREF').getValue(); if (EINVOICESTATEREF == '开票中') { Ext.Msg.show({ title: '提示', msg: '已经在开票中,不允许重复开票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } errormsg = this.checkPost(); if (isNullorEmpty(errormsg)) { this.doPostInv(); } else Ext.MessageBox.confirm('提示', errormsg + ' 确定要进行开票吗?', function (btn) { if (btn == 'yes') { this.doPostInv(); } }); }, checkPost: function () { errormsg = ""; if (this.fieldisnull('INVOICECUSTNAME')) errormsg = errormsg + "未选择购方信息;"; if (this.fieldisnull('CUSTRATENO')) errormsg = errormsg + "未填写购方税号;"; if (this.fieldisnull('CUSTTEL')) errormsg = errormsg + "未填写购方电话;"; if (this.fieldisnull('CUSTADDR')) errormsg = errormsg + "未填写购方地址;"; if (this.fieldisnull('CUSTBANK')) errormsg = errormsg + "未填写购方银行账号;"; if (this.fieldisnull('ACCOUNT')) errormsg = errormsg + "未选择销方银行和账户;"; if (this.fieldisnull('PAYEE')) errormsg = errormsg + "未选择收款人;"; if (this.fieldisnull('CHECKER')) errormsg = errormsg + "未选择复核人;"; return errormsg; }, doPostInv: function () { _this = this; var billno = this.formEdit.getForm().findField('BILLNO').getValue(); Ext.Ajax.request({ waitMsg: '正在提交开票信息...', url: '/Account/Chfee_invoice_HangXin/NNMakeInv', params: { bill: billno, redirecturl: GetHangXinRedirectUrl() }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { this.ShowTokenPage(result); } else { var pageurl = result.Data.INVOICEINFOURL; _this.dealReturnData(result.Data); //开票成功 直接显示返回的发票详情页地址 if (isNullorEmpty(pageurl)) { if (!isNullorEmpty(result.Message)) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } else if (!isNullorEmpty(result.Data.INVOICESERIALNUM)) { Ext.Msg.show({ title: '提示', msg: "开票信息发送成功,请稍后点击【查看发票】或【邮件转发】。", icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } else { alert("未知错误"); } var condition = " BILLNO='" + _this.editRecord.get('BILLNO') + "'"; _this.LoadData('edit', condition); } else { var url = result.Data.INVOICEINFOURL.replace("http://", "").replace("https://", "").replace("https//", ""); DsOpenEditWin_FullUrl(url, "发票信息", 600, 800, 300, 300); } } } else { //如果返回错误的内容是无法获取token 那就需要打开诺诺平台的税号/密码窗口 //使用返回值内的url直接打开 Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onNNReadInvClick: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); if (billno == '*' || billno == '') { Ext.Msg.show({ title: '提示', msg: '请先保存发票,然后才能进行其他操作!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; _this = this; Ext.Ajax.request({ waitMsg: '正在读取开票信息...', url: '/Account/Chfee_invoice_HangXin/NNReadInv', params: { BILLNO: billno, redirecturl: GetHangXinRedirectUrl() }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { this.ShowTokenPage(result); } else { _this.dealReturnData(result.Data); var pageurl = result.Data.INVOICEINFOURL; if (isNullorEmpty(pageurl)) pageurl = result.Data.INVOICEPDFURL; if (isNullorEmpty(pageurl)) { if (!isNullorEmpty(result.Message)) { if (result.Message.indexOf("保存成功") >= 0) { } else { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } } else if (!isNullorEmpty(result.Data.INVOICESERIALNUM)) { Ext.Msg.show({ title: '提示', msg: "开票信息发送成功,但还未正确开出,请检查诺诺客户端的运行情况,或稍后再次执行'查看发票'。", icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } else { alert("未知错误"); } } else { var url = result.Data.INVOICEINFOURL.replace("http://", "").replace("https://", "").replace("https//", ""); DsOpenEditWin_FullUrl(url, "发票信息", 600, 800, 300, 300); } } } else { //如果返回错误的内容是无法获取token 那就需要打开诺诺平台的税号/密码窗口 //使用返回值内的url直接打开 Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onNNVoidInvClick: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); if (billno == '*' || billno == '') { Ext.Msg.show({ title: '提示', msg: '请先保存发票,然后才能进行其他操作!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; _this = this; Ext.Ajax.request({ waitMsg: '正在发送开票信息...', url: '/Account/Chfee_invoice_HangXin/NNVoidInv', params: { BILLNO: billno, redirecturl: GetHangXinRedirectUrl() }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { this.ShowTokenPage(result); } else { _this.dealReturnData(result.Data); var pageurl = result.Data.INVOICEINFOURL; if (isNullorEmpty(pageurl)) pageurl = result.Data.INVOICEPDFURL; if (isNullorEmpty(pageurl)) { if (!isNullorEmpty(result.Message)) { if (result.Message.indexOf("保存成功") >= 0) { } else { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } } else if (!isNullorEmpty(result.Data.INVOICESERIALNUM)) { Ext.Msg.show({ title: '提示', msg: "发票作废信息发送成功,但还未完成处理,请检查诺诺客户端的运行情况,或稍后再次执行'查看发票'。", icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } else { alert("未知错误"); } } else { DsOpenEditWin_FullUrl(result.Data.INVOICEPDFURL.replace("http://", "").replace("https://", "").replace("https//", ""), "发票信息", 600, 800, 300, 300); } } } else { //如果返回错误的内容是无法获取token 那就需要打开诺诺平台的税号/密码窗口 //使用返回值内的url直接打开 Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onNNSetRedClick: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); if (billno == '*' || billno == '') { Ext.Msg.show({ title: '提示', msg: '请先保存发票,然后才能进行其他操作!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; _this = this; Ext.Ajax.request({ waitMsg: '正在发送开票信息...', url: '/Account/Chfee_invoice_HangXin/NNSetRed', params: { bill: billno, redirecturl: GetHangXinRedirectUrl() }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { this.ShowTokenPage(result); } else { _this.dealReturnData(result.Data); var pageurl = result.Data.INVOICEINFOURL; if (isNullorEmpty(pageurl)) pageurl = result.Data.INVOICEPDFURL; if (isNullorEmpty(pageurl)) { if (!isNullorEmpty(result.Message)) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } else if (!isNullorEmpty(result.Data.INVOICESERIALNUM)) { Ext.Msg.show({ title: '提示', msg: "开票信息发送成功,但还未正确开出,请检查诺诺客户端的运行情况,或稍后再次执行'查看发票'。", icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } else { alert("未知错误"); } } else { var url = result.Data.INVOICEINFOURL.replace("http://", "").replace("https://", "").replace("https//", ""); DsOpenEditWin_FullUrl(url, "发票信息", 600, 800, 300, 300); } } } else { //如果返回错误的内容是无法获取token 那就需要打开诺诺平台的税号/密码窗口 //使用返回值内的url直接打开 Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, ShowTokenPage: function (result) { if (result.Message == "需要认证诺诺用户名和密码") { DsOpenEditWin_NoUrl(result.Data, "平台开票信息认证", 600, 400, 300, 300); } else Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); }, onNNReadInvPDFClick: function (result) { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); if (billno == '*' || billno == '') { Ext.Msg.show({ title: '提示', msg: '请先保存发票,然后才能进行其他操作!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; _this = this; Ext.Ajax.request({ waitMsg: '正在读取开票信息...', url: '/Account/Chfee_invoice_HangXin/NNReadInv', params: { BILLNO: billno, redirecturl: GetHangXinRedirectUrl() }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { this.ShowTokenPage(result); } else { _this.dealReturnData(result.Data); var pageurl = result.Data.INVOICEPDFURL; if (isNullorEmpty(pageurl)) { if (!isNullorEmpty(result.Message)) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } else if (!isNullorEmpty(result.Data.INVOICESERIALNUM)) { Ext.Msg.show({ title: '提示', msg: "开票信息发送成功,但还未正确开出,请检查诺诺客户端的运行情况,或稍后再次执行'查看发票'。", icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); } else { alert("未知错误"); } } else { DsOpenEditWin_FullUrl(pageurl.replace("http://", "").replace("https://", "").replace("https//", ""), "发票信息", 600, 800, 300, 300); } } } else { //如果返回错误的内容是无法获取token 那就需要打开诺诺平台的税号/密码窗口 //使用返回值内的url直接打开 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 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 }, 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": "折算汇率(总计)" }); 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_HangXin/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_HangXin/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_HangXin/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 }); } }, setInvTile: function (invline) { var INVTITLE = Ext.getCmp('INVTITLE'); if (invline.indexOf('专用') != -1){ INVTITLE.setText('增值税专用发票', false); } else if (invline.indexOf('电') != -1){ INVTITLE.setText('增值税电子普通发票', false); } else { INVTITLE.setText('增值税普通发票', false); } }, addBsMbl: function () { var selectedRecords = this.gridAddList.selModel.getSelection(); if (selectedRecords.length == 0) { return; }; var rec = selectedRecords[0]; this.formEdit.getForm().findField('MBLNO').setValue(rec.data.MBLNO); this.formEdit.getForm().findField('VESSELVOYAGE').setValue(rec.data.VESSEL + '/' + rec.data.VOYNO); var ETD = rec.data.ETD; var mydatestr = ""; if (ETD != '') { mydatestr = Ext.util.Format.date(ETD, 'Y-m-d'); } this.formEdit.getForm().findField('ETD').setValue(mydatestr); this.formEdit.getForm().findField('POL').setValue(rec.data.PORTLOAD); this.formEdit.getForm().findField('POD').setValue(rec.data.PORTDISCHARGE); this.formEdit.getForm().findField('BSNO').setValue(rec.data.CUSTNO); //var remark = this.formRemark.getForm().findField('REMARK').getValue(); var remark = this.formEdit.getForm().findField('REMARK').getValue(); if (remark == '') this.formEdit.getForm().findField('REMARK').setValue(rec.data.MBLNO); }, setCustBank(CUSTNAME, CURR) { var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK'); if (CURR == 'RMB') { this.storecustbank.load({ params: { condition: " CURRENCY='RMB' AND LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + 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='" + CUSTNAME + "')" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { CUSTBANK.setValue(this.storecustbank.data.items[0].data.BANKNAME_ACCOUNT); } } }, scope: this }); } }, setBank(CURR) { var BANK = this.formEdit.getForm().findField('ACCOUNT'); var recs = DsStoreQueryBy2(this.StoreBANK, 'CURRENCY', CURR, 'ISDEF','True'); if (recs.getCount() > 0) { var data = recs.getAt(0).data; BANK.setValue(data.BANKACCOUNT); } else { var recs = DsStoreQueryBy(this.StoreBANK, 'CURRENCY', CURR); if (recs.getCount() > 0) { var data = recs.getAt(0).data; BANK.setValue(data.BANKACCOUNT); } } }, onRefreshClick: function (button, event) { var sql = this.getCondition(); this.sqlcontext = sql; this.PageSize = this.Pagenum.getValue(); this.storeBodyAddList.pageSize = this.PageSize; this.storeBodyAddList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql } }); }, onDsQuery: function (button, event) { var sql = this.sqlcontext; this.PageSize = this.Pagenum.getValue(); this.storeBodyAddList.pageSize = this.PageSize; this.storeBodyAddList.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 = ''; var customNo = form.findField('CustomNo').getValue(); sql = sql + getAndConSql(sql, customNo, " (isnull(b.CUSTNO,'')+' '+isnull(b.MBLNO,'')+' '+isnull(b.HBLNO,'')+' '+isnull(b.CUSTOMNO,'')+' '+isnull(b.ORDERNO,'') like '%" + customNo + "%')"); var OPLBNAME = form.findField('OPLBNAME').getValue(); sql = sql + getAndConSql(sql, OPLBNAME, "b.OPLBNAME='" + OPLBNAME + "'"); var expDateBgn = form.findField('ExpDateBgn').getRawValue(); sql = sql + getAndConSql(sql, expDateBgn, "b.ETD >='" + expDateBgn + "'"); var expDateEnd = form.findField('ExpDateEnd').getRawValue(); sql = sql + getAndConSql(sql, expDateEnd, "b.ETD <='" + expDateEnd + "'"); var ACCDATE = form.findField('ACCDATEFR').getRawValue(); sql = sql + getAndConSql(sql, ACCDATE, "b.ACCDATE>='" + ACCDATE + "'"); var ACCDATETO = form.findField('ACCDATETO').getRawValue(); sql = sql + getAndConSql(sql, ACCDATETO, "b.ACCDATE<='" + ACCDATETO + "'"); this.FeeSqlStr = this.getFeeCondition(); sql = sql + getAndConSql(sql, this.FeeSqlStr, this.FeeSqlStr); // sql = sql + getAndConSql(sql, feesql, feesql); this.BillSql = sql; return sql; }, getFeeCondition: function () { var form = this.formSearch.getForm(); var feesql = ' (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) '; var CUSTNAME = form.findField('CUSTNAME').getValue(); feesql = feesql + getAndConSql(feesql, CUSTNAME, "f.CUSTOMERNAME='" + CUSTNAME + "'"); var DC = form.findField('DC').getValue(); feesql = feesql + getAndConSql(feesql, DC, "f.FEETYPE=" + DC); var Currency = form.findField('Currency').getValue(); feesql = feesql + getAndConSql(feesql, Currency, "f.Currency='" + Currency + "'"); var FeeName = form.findField('FeeName').getValue(); feesql = feesql + getAndConSql(feesql, FeeName, "f.FeeName='" + FeeName + "'"); var FSTATUS = form.findField('FSTATUS').getValue(); if (FSTATUS == 8) { feesql = feesql + getAndConSql(feesql, FSTATUS, " (F.FEESTATUS=9 or F.FEESTATUS=8) "); } else if (FSTATUS == 9) { feesql = feesql + getAndConSql(feesql, FSTATUS, " (F.SETTLEMENT<>F.AMOUNT) "); } var DuiNo = form.findField('DuiNo').getValue(); //feesql = feesql + getAndConSql(feesql, DuiNo, " f.GID IN (SELECT GID FROM V_DUI_FEE WHERE DUINO='" + DuiNo + "')"); //展濠模糊查询 feesql = feesql + getAndConSql(feesql, DuiNo, " f.GID IN (SELECT GID FROM V_DUI_FEE WHERE DUINO like '%" + DuiNo + "%')"); return feesql; }, ExrateConversion: function (bfcurr, afcurr, fntype, dfexrate) { 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, iconCls: "addicon", resizable: 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) { for (var i = 0; i < me.storeCurrExrate.getCount(); i += 1) { var member = me.storeCurrExrate.getAt(i); if (member.data.CURR == bfcurr) { 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(); me.GetEditStatus(); return; } }] }); if (bfcurr == 'RMB') { var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', afcurr); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; var DEFRATE = ffdata.DEFRATE; } else { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', afcurr); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; var DEFRATE = dfdata.DEFRATE; } else { var DEFRATE = 1; } } var field = formExrateConversion.getForm().findField('afcurr'); achange = true; field.setValue(DEFRATE); } else if (afcurr == 'RMB') { var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', bfcurr); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; var DEFRATE = ffdata.DEFRATE; } else { var recs = DsStoreQueryBy(me.storeCurrExrate, 'CURR', bfcurr); if (recs.getCount() > 0) { var dfdata = recs.getAt(0).data; var DEFRATE = dfdata.DFEXRATE; } else var DEFRATE = dfexrate; } var field = formExrateConversion.getForm().findField('bfcurr'); achange = true; field.setValue(DEFRATE); } else { var field = formExrateConversion.getForm().findField('bfcurr'); var recs = DsStoreQueryBy(me.storeCurrExrate, 'CURR', bfcurr); if (recs.getCount() > 0) { var dfdata = recs.getAt(0).data; var DEFRATE = dfdata.DFEXRATE; } else var DEFRATE = dfexrate; bchange = true; field.setValue(DEFRATE); } winExrateShow.show(); }, 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; }, GetGroupCorp: function (custname) { _this = this; var records = DsStoreQueryBy(_this.StoreClientGroup, 'SHORTNAME', custname); if (records.getCount() > 0) { return records.getAt(0).data.PCORPNAME; } else { return ''; } }, SaveInvHead: function () { var CUSTNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue(); var INVOICECUSTNAME = this.formEdit.getForm().findField('INVOICECUSTNAME').getValue(); var CUSTRATENO = this.formEdit.getForm().findField('CUSTRATENO').getValue(); var CUSTADDRTEL = this.formEdit.getForm().findField('CUSTADDRTEL').getValue(); Ext.MessageBox.confirm('提示', '确实要更新客户资料里的开票信息吗?', function (btn) { if (btn == 'yes') { var basicForm = this.formEdit.getForm(); var data = basicForm.getValues(); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/Account/Chfee_invoice_HangXin/UpdateCustInvHead', scope: this, params: { data: Ext.JSON.encode(data) }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { Ext.Msg.show({ title: '提示', msg: '更新完成!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } 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 }); } } }); } }); }, //#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 opid = this.formEdit.getForm().findField('OPERATOR').getValue(); var btnESubmitAudit = Ext.getCmp('btnSubmitAudit'); var btnESubmitAuditBack = Ext.getCmp('btnSubmitAuditBack'); 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'); var btnEAddbill = Ext.getCmp('btnaddbill'); this.canedit = enable; var btn_KP = Ext.getCmp("btn_KP"); var btn_Void = Ext.getCmp("btn_Void"); var btn_Setred = Ext.getCmp("btn_Setred"); this.canedit = enable; this.setInvoiceButtonStatus(); if (enable) { btnESave.enable(); btnESaveAndClose.enable(); btnESaveAndNew.enable(); btnEAddbill.enable(); btnEAddDetail.enable(); btnEDeleteDetail.enable(); btnEAddInvDetail.enable(); btnEDeleteInvDetail.enable(); } else { btnESave.disable(); btnESaveAndClose.disable(); btnESaveAndNew.disable(); btnEAddDetail.disable(); btnEDeleteDetail.disable(); btnEAddbill.disable(); btnEAddInvDetail.disable(); btnEDeleteInvDetail.disable(); btn_KP.disable(); //btn_Void.disable(); //btn_Setred.disable(); } }, setInvoiceButtonStatus: function (enable) { var INVOICESERIALNUM = this.formEdit.getForm().findField('INVOICESERIALNUM').getValue(); var INVOICENO = this.formEdit.getForm().findField('INVOICENO').getValue(); var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();//1已锁定 0未锁定 var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue();//true false var SETRED = this.formEdit.getForm().findField('SETRED').getValue();//true false var PTORRED = this.formEdit.getForm().findField('PTORRED').getValue();//true false var btn_KP = Ext.getCmp("btn_KP"); var btn_Invinfo = Ext.getCmp("btn_Invinfo"); var btn_Pdf = Ext.getCmp("btn_Pdf"); var btn_Void = Ext.getCmp("btn_Void"); var btn_Setred = Ext.getCmp("btn_Setred"); ///1.如果流水号没有 同时未锁定 而且没有作废 才能点开票 if (isNullorEmpty(INVOICESERIALNUM) && billstatus == 0 && ISDELETE != "True") { btn_KP.enable(); } else { btn_KP.disable(); } ///2.如果流水号没有 不能点读取 if (isNullorEmpty(INVOICESERIALNUM)) { btn_Invinfo.disable(); btn_Pdf.disable(); } else { btn_Invinfo.enable(); btn_Pdf.enable(); } ///3.如果同时有了发票号和发票流水号 才能点冲红和作废 if (!isNullorEmpty(INVOICENO) && !isNullorEmpty(INVOICESERIALNUM)) { //如果已经作废 则作废不可点 if (ISDELETE == "True" || SETRED == "True") { btn_Void.disable(); } else { btn_Void.enable(); } //如果已经被作废 或者是红票 或者已经被冲红 则冲红不可点 if (ISDELETE == "True" || PTORRED == "2" || SETRED == "True") { btn_Setred.disable(); } else { btn_Setred.enable(); } } else { btn_Void.disable(); btn_Setred.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); } });