Ext.namespace('Shipping'); Shipping.MsChJinzhangEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsChJinzhangEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsChJinzhangEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, addstore: false, PageSize: 30, initUIComponents: function () { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.FeeSql = ''; this.BillSql = ''; this.DuiBillSql = ''; this.IsDebit = '0'; this.DRNO = getUrlParam('DRNO'); this.StoreLockOp = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' } }); this.StoreLockOp.load({ params: { optype: "modChequeLock"} }); this.StoreUnLockOp = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' } }); this.StoreUnLockOp.load({ params: { optype: "modChequeUnLock"} }); //#region 编辑form //枚举参照相关(编辑form) //表参照相关(编辑form) this.storecustbank = Ext.create('DsExt.ux.RefTableStore', { model: 'MsInfoClientBankModel', proxy: { url: '/MvcShipping/MsInfoClient/GetBankList' } }); 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, forceSelection: true, name: 'CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var INVOICECUSTNAME = this.formEdit.getForm().findField('JINZHANGCUSTNAME'); var PAYEEBANK = this.formEdit.getForm().findField('PAYEEBANK'); var PAYEEBANKACCOUNT = this.formEdit.getForm().findField('PAYEEBANKACCOUNT'); var PAYEEADR = this.formEdit.getForm().findField('PAYEEADR'); var CURR = this.formEdit.getForm().findField('CURRENCY').getValue(); INVOICECUSTNAME.setValue(records[0].data.RMBBillRises); var s = " CURRENCY='" + CURR + "' and LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + records[0].data.CustName + "')"; this.storecustbank.load({ params: { condition: s }, callback: function (r, options, success) { if (success) { if (this.storecustbank.getCount() > 0) { var member = this.storecustbank.getAt(0); PAYEEBANK.setValue(member.data.BANKNAME); PAYEEBANKACCOUNT.setValue(member.data.ACCOUNT); } else { PAYEEBANK.setValue(''); PAYEEBANKACCOUNT.setValue(''); } } }, scope: this }); } } } }); this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } }); this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' } }); this.StoreCurr.load({ params: { condition: ""} }); this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '币别', store: this.StoreCurr, forceSelection: true, allowBlank: false, name: 'CURRENCY', valueField: 'CURR', displayField: 'CURR', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var basicForm = _this.formEdit.getForm(); var newValue = basicForm.findField('AMOUNT').getValue(); var curr = records[0].data.CURR; if (curr == 'USD') basicForm.findField('AMOUNTUPPER').setValue('美元' + formatUSD(newValue)); else basicForm.findField('AMOUNTUPPER').setValue(_this.numtoc(newValue)); } } } }); this.storeInvCategory = Ext.create('DsExt.ux.RefTableStore', { model: 'DsExtEnumModel', proxy: { url: '/CommMng/PubSys/GetEnumValueList' } }); this.storeInvCategory.load({ params: { enumTypeId: 97021} }); this.comboxInvCategory = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '类型', store: this.storeInvCategory, forceSelection: true, name: 'BLTYPE', valueField: 'EnumValueName', displayField: 'EnumValueName' }); this.StoreBANK = Ext.create('DsExt.ux.RefTableStore', { model: 'JINZHANGBANK', proxy: { url: '/MvcShipping/MsBaseInfo/GetBANKList' } }); this.StoreBANK.load({ params: { condition: ""} }); this.comboxBANKID = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '银行账户', store: this.StoreBANK, forceSelection: true, // allowBlank: false, name: 'BANKID', valueField: 'GID', displayField: 'BANKNAME', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.StoreInvNo.load({ params: { condition: " b.BANKID='" + records[0].data.GID + "'"} }); var PAYBANK = this.formEdit.getForm().findField('BANK'); PAYBANK.setValue(records[0].data.BANKNAME); var PAYBANKACCOUNT = this.formEdit.getForm().findField('BANKACCOUNT'); PAYBANKACCOUNT.setValue(records[0].data.ACCOUNT); var COMPANYNAME = this.formEdit.getForm().findField('COMPANYNAME'); COMPANYNAME.setValue(records[0].data.ACCOUNTNAME); this.formEdit.getForm().findField('CURRENCY').setValue(records[0].data.CURRENCY); } } } }); //#region 编辑formHead 基本信息 this.comboxCustBank = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '出票单位银行', store: this.storecustbank, forceSelection: true, name: 'PAYEEBANK', valueField: 'BANKNAME', displayField: 'ACCOUNTNAMEREF', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var CUSTACCOUNT = this.formEdit.getForm().findField('PAYEEBANKACCOUNT'); CUSTACCOUNT.setValue(records[0].data.ACCOUNT); } } } }); _this = this; //编辑form this.formEdit = Ext.widget('form', { region: 'center', frame: true, bodyPadding: 3, trackResetOnLoad: true, // autoScroll: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'GID', name: 'GID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'BILLSTATUS', name: 'BILLSTATUS', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'CREATEUSER', name: 'CREATEUSER', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'PRINTUSER', name: 'PRINTUSER', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'COMPANYID', name: 'COMPANYID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'YEAR', name: 'YEAR', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'MONTH', name: 'MONTH', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'DAY', name: 'DAY', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'BANK', name: 'BANK', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'STLBILLNO', name: 'STLBILLNO', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '编号', readOnly: true, flex: 1, name: 'BILLNO' }, { fieldLabel: '状态', flex: 1, readOnly: true, name: 'BILLSTATUSREF' }, { fieldLabel: '是否打印', flex: 1, readOnly: true, name: 'ISPRINT' }, { fieldLabel: '是否作废', flex: 1, readOnly: true, name: 'ISDELETE' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCurr, { fieldLabel: '开票金额', 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; }, listeners: { change: function () { var basicForm = _this.formEdit.getForm(); var newValue = basicForm.findField('AMOUNT').getValue(); var curr = basicForm.findField('CURRENCY').getValue(); if (curr == 'USD') basicForm.findField('AMOUNTUPPER').setValue('美元' + formatUSD(newValue)); else basicForm.findField('AMOUNTUPPER').setValue(_this.numtoc(newValue)); }, scope: this } }, { fieldLabel: '开票日期', xtype: 'datefield', format: 'Y-m-d', name: 'JINZHANGMAKETIME', listeners: { change: function () { _this.datechange(); } } }, { fieldLabel: '开票人', readOnly: true, name: 'CREATEUSERREF' } ] } ]//end items(fieldset 1) }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', flex: 1, layout: 'anchor', defaults: { anchor: '100%' }, items: [this.comboxCustCode, { fieldLabel: '单位全称', flex: 3, name: 'JINZHANGCUSTNAME' }, this.comboxCustBank, { fieldLabel: '收款账号', name: 'PAYEEBANKACCOUNT' }, { fieldLabel: '金额大写', flex: 3, name: 'AMOUNTUPPER' }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '票结号码', name: 'BLNO' }, this.comboxInvCategory] } ] }, {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', flex: 1, layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [this.comboxBANKID] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '公司全称', name: 'COMPANYNAME' }] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '银行账号', name: 'BANKACCOUNT' }] } ] }] } ]//end root items }); //end this.formEdit //#endregion //#region 按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { id: 'btnESave', text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, '-', { text: "打印", handler: function (button, event) { this.Print(); }, scope: this }, '-', { id: 'btnESaveAndClose', text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, '-', { id: 'btnESaveAndNew', text: "保存并新建", handler: function (button, event) { this.Save('2'); this.GetEditStatus(); }, scope: this }, '-', { id: 'btnENew', text: "新建", handler: function (button, event) { this.LoadData('add', '*'); }, scope: this }, '-', { text: '锁定', tooltip: '锁定', id: 'btnSubmitAudit', handler: function (button, event) { this.onSubmitAuditClick(); }, scope: this }, '-', { text: '撤销锁定', tooltip: '撤销锁定', id: 'btnSubmitAuditBack', handler: function (button, event) { this.onSubmitAuditBackClick(); }, scope: this } ] }); //end 按钮Toolbar //#endregion //#endregion //#region 布局 //控件布局 Ext.apply(this, { items: [this.panelBtn, this.formEdit] }); //#endregion //绑定查询窗体 this.ParentWin = window.parent.opener; //初始化数据 if (this.DRNO == undefined) { this.InitData(); //绑定事件 var billno = '*'; if (this.opStatus == 'edit') { billno = this.editRecord.get('BILLNO'); }; } else { this.opStatus = 'add' this.LoadSTLData(this.opStatus,""); } }, //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') condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'"; this.LoadData(this.opStatus, condition); }, //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_jinzhang/GetData', params: { handle: opstatus, condition: condition }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } var data = result.data; // _this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false); _this.formEdit.getForm().reset(); _this.formEdit.getForm().setValues(data); // _this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true); _this.GetEditStatus(); if (opstatus == "add") _this.datechange(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, // end LoadDate LoadSTLData: function (opstatus, condition) { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.opStatus = opstatus; _this = this; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_jinzhang/GetSTLData', params: { handle: opstatus, drno: this.DRNO }, 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.formEdit.getForm().setValues(data); var basicForm = _this.formEdit.getForm(); var newValue = basicForm.findField('AMOUNT').getValue(); var curr = basicForm.findField('CURRENCY').getValue(); if (curr == 'USD') basicForm.findField('AMOUNTUPPER').setValue('美元' + formatUSD(newValue)); else basicForm.findField('AMOUNTUPPER').setValue(_this.numtoc(newValue)); // _this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true); _this.GetEditStatus(); if (opstatus == "add") _this.datechange(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } this.formEdit.getForm().findField('GID').setDisabled(false); // this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false); this.formEdit.getForm().findField('COMPANYID').setDisabled(false); var data = basicForm.getValues(); var GID = this.formEdit.getForm().findField('GID').getValue(); // this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true); this.formEdit.getForm().findField('COMPANYID').setDisabled(true); this.formEdit.getForm().findField('GID').setDisabled(true); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/Account/Chfee_jinzhang/Save', scope: this, params: { opstatus: this.opStatus, 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) { var returnData = jsonresult.Data; this.formEdit.getForm().setValues(returnData); if (this.opStatus == 'add') { var arrNewRecords = this.StoreList.add(returnData); this.editRecord = arrNewRecords[0]; } else if (this.opStatus == 'edit') { var editp = Ext.create('MsChJinzhang', returnData); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'id') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); } if (type == '0') { this.opStatus = 'edit'; } else if (type == '1') { window.close(); } else { this.LoadData('add', ''); } } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save datechange: function () { var basicForm = _this.formEdit.getForm(); var STARTDATE = basicForm.findField('JINZHANGMAKETIME').getRawValue(); var year = STARTDATE.substr(0, 4); var month = STARTDATE.substr(5, 2); var date = STARTDATE.substr(8, 2); var yearstr = _this.UppTime(year); var monthstr = _this.UppTime(month, 1); var datestr = _this.UppTime(date, 2); // basicForm.findField('YEARUPPER').setValue(yearstr); // basicForm.findField('MONTHUPPER').setValue(monthstr); // basicForm.findField('DAYUPPER').setValue(datestr); basicForm.findField('YEAR').setValue(year); basicForm.findField('MONTH').setValue(month); basicForm.findField('DAY').setValue(date); }, deleteBill: function (type) { 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 }); return; }; var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue(); var ISPRINT = this.formEdit.getForm().findField('ISPRINT').getValue(); if (ISPRINT == 'true') { 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; Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/Account/Chfee_jinzhang/DelBill', params: { billno: billno, GID: GID }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_jinzhang/GetData', params: { handle: 'edit', condition: " BILLNO='" + billno + "'" }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } var data = result.data; this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(data); var editp = Ext.create('MsChJinzhang', 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 }); }, 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 ISPRINT = this.formEdit.getForm().findField('ISPRINT').getValue(); if (ISDELETE == 'true') { Ext.Msg.show({ title: '提示', msg: '此发票已作废无法删除此支票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var sql = this.BillSql; Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/Account/Chfee_jinzhang/DeleteUp', params: { billno: billno, isprint: ISPRINT }, 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 { if (ISPRINT == "true") { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_jinzhang/GetData', params: { handle: 'edit', condition: " BILLNO='" + billno + "'" }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } var data = result.data; this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(data); var editp = Ext.create('MsChJinzhang', 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 }); }, 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_jinzhang/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 { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_jinzhang/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); var editp = Ext.create('MsChJinzhang', 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(); 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; } _this = this; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_jinzhang/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 { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_jinzhang/GetData', params: { handle: 'edit', condition: " BILLNO='" + billno + "'" }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } var data = result.data; this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(data); var editp = Ext.create('MsChJinzhang', 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 }); }, numtoc: function (numberValue, curr) { 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; }, UppTime: function (iiv_, md_) { //票据出票日期中文大写 var arr13 = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '', '拾', '佰', '仟', '万', '亿', '元', '角', '分', '整', '负'); var iNun_ = new String(iiv_).split(".")[0].split(""), iLen_ = iNun_.length, iNum_ = new Array(iLen_); if (iiv_ > 999 && iiv_ < 9999) { for (ii_ = 0; ii_ < iLen_; ii_++) { iNum_[iLen_ - 1 - ii_] = arr13[iNun_[iLen_ - 1 - ii_]] } } else if (iiv_ > 0 && iiv_ < 32) { for (ii_ = 0; ii_ < iLen_; ii_++) { iNum_[iLen_ - 1 - ii_] = (iNun_[iLen_ - 1 - ii_] == 0) ? (ii_ == 0 ? (iLen_ > 1 ? "" : arr13[0]) : (iNun_[iLen_ - ii_] == 0 ? "" : arr13[0])) : (arr13[iNun_[iLen_ - 1 - ii_]] + arr13[10 + ii_]) } } else { iNum_[0] = "" } return (((iiv_ > 0 && iiv_ < (md_ == 1 ? 3 : 10)) || iiv_ == 10 || iiv_ == 20 || iiv_ == 30) ? arr13[0] : "") + iNum_.join(""); } , // #region 根据权限和状态判断是否允许修改 GetIsEdit: function () { var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue(); var ISPRINT = this.formEdit.getForm().findField('ISPRINT').getValue(); var BILLSTATUS = this.formEdit.getForm().findField('BILLSTATUS').getValue(); if ((ISDELETE == '是') || (ISPRINT == '是') || (BILLSTATUS != 2)) return false; else return true; }, GetEditStatus: function () { var canedit = false; var op = this.formEdit.getForm().findField('CREATEUSERREF').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: "modJinzhang" }, 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('CREATEUSER').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'); if (enable) { btnESave.enable(); btnESaveAndClose.enable(); btnESaveAndNew.enable(); } else { btnESave.disable(); btnESaveAndClose.disable(); btnESaveAndNew.disable(); } }, // #endregion Print: function () { var basicForm = this.formEdit.getForm(); var billNo = basicForm.findField('BILLNO').value; var Gid = basicForm.findField('GID').value; if (billNo == '*' || billNo == '' || basicForm.isDirty()) { Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } var printType = 'MSCHFEEJINZHANG'; var sql1 = "SELECT * FROM ch_fee_jinzhang WHERE GID='" + Gid + "'"; var sql2 = ""; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); Ext.Ajax.request({ waitMsg: '正在查询数据...', url: '/Account/Chfee_jinzhang/UpdatePrint', async: false, params: { billno: billNo }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_jinzhang/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); var editp = Ext.create('MsChJinzhang', 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 }); } });