Ext.namespace('DsTruck'); DsTruck.FinanceBankStlEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.FinanceBankStlEdit.superclass.constructor.call(this); }; Ext.extend(DsTruck.FinanceBankStlEdit, 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'; //#region 编辑form //枚举参照相关(编辑form) //表参照相关(编辑form) this.formname = "formFinanceBankStlEdit"; //页面名称 this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } }); this.storeBuyer_F = Ext.create('DsExt.ux.RefTableStore', { model: 'Tradermb', proxy: { url: '/CommMng/BasicDataRef/GetTrader' } }); this.storeBuyer_F.load({ params: { condition: " 1=1 "} }); this.comboxBuyer_F = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '融资银行', forceSelection: true, store: this.storeBuyer_F, name: 'CUSTOMER', valueField: 'name', displayField: 'codename' }); Ext.define('MsFeeCurr', { extend: 'Ext.data.Model', idProperty: 'CURR', fields: [ { name: 'CURR', type: 'string' }, { name: 'DEFRATE', type: 'number' } ] }); 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: 'F_CURRENCY', valueField: 'CURR', displayField: 'CURR' }); //编辑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: '融资业务编号', name: 'F_NO', readOnly: true, hidden: false }, { fieldLabel: 'GID', name: 'GID', readOnly: true, hidden: true }, { fieldLabel: 'F_TYPE', name: 'F_TYPE', readOnly: true, hidden: true }, { fieldLabel: 'ISFEE', name: 'ISFEE', readOnly: true, hidden: true }, { fieldLabel: '操作', name: 'OP', readOnly: true, hidden: true }, this.comboxBuyer_F, { fieldLabel: '还款日期', id: 'ENDDATE', format: 'Y-m-d', xtype: 'datefield', renderer: Ext.util.Format.dateRenderer('Y-m-d'), name: 'ENDDATE' }, { fieldLabel: '操作时间', format: 'Y-m-d H:i:s', xtype: 'datefield', renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'), name: 'ENTERDATE' }, { fieldLabel: '操作人', readOnly: true, flex: 1, name: 'OPREF' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCurr,{ fieldLabel: '融资本金', name: 'F_AMOUNT', value: 0 }, { fieldLabel: '本金利息', name: 'INTERESTUSD', value: 0 }, { name: 'EXCHANGERATE', fieldLabel: '汇率', value: 0, listeners: { blur: function (field, eOpts) { var basicForm = this.formEdit.getForm(); var F_AMOUNT = basicForm.findField('F_AMOUNT').getRawValue(); var INTERESTUSD = basicForm.findField('INTERESTUSD').getRawValue(); var newValue = field.value; var rmbvalue = Mul(Add(F_AMOUNT,INTERESTUSD), newValue) basicForm.findField('RMBVALUE').setValue(rmbvalue); }, scope: this } }, { fieldLabel: '折合RMB', name: 'RMBVALUE', value: 0 }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '锁定状态', name: 'ISFEEREF', readOnly: true, hidden: false }, { fieldLabel: '备注', flex: 4, name: 'REMARK' }] } ]//end items(fieldset 1) }//end fieldset 1 ]//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 } , '-', { id: 'btnSubmitAudit', text: '提交锁定', tooltip: '提交锁定', handler: function (button, event) { this.onSubmitAuditClick(); }, scope: this },'-', { id: 'btnSubmitAuditBack', text: '撤销锁定', tooltip: '撤销锁定', handler: function (button, event) { this.onSubmitAuditBackClick(); }, scope: this } ] }); //end 按钮Toolbar //#endregion //#region 明细表 //明细表表格相关 this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); //明细表-数据集 this.storeBodyList = Ext.create('Ext.data.Store', { model: 'Financemb', remoteSort: true, proxy: { type: 'ajax', url: '/Import/Finance/GetBankStlDetailList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.gridList = new Ext.grid.GridPanel({ store: this.storeBodyList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selModel: this.GridCheckBoxModel, tbar: [{ text: '删除申请明细', tooltip: '删除申请明细', id: 'btndeldetail', iconCls: "btndeletedetail", handler: function (button, event) { this.onDeleteClick(button, event, 1); }, scope: this }], columns: [{ sortable: true, dataIndex: 'F_NO', header: '融资业务号', width: 110 }, { sortable: true, dataIndex: 'BANK_INTEREST_RATE', header: '融资金额', width: 80 }, { sortable: true, dataIndex: 'CUST_INTEREST_RATE', header: '核销金额', width: 80 }, { sortable: true, dataIndex: 'BANK_INTEREST', header: '美元利息', width: 80 }, { sortable: true, dataIndex: 'CUSTOMER', header: '融资客户', width: 100 }, { sortable: true, dataIndex: 'STARTDATE', header: '融资开始时间', width: 100 }, { sortable: true, dataIndex: 'OPREF', header: '申请人', width: 80 }, { sortable: true, dataIndex: 'ENTERDATE', header: '申请时间', width: 80 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 80 } ] }); //#region 添加业务列表 this.storeBodyAddList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'Financemb', remoteSort: true, proxy: { type: 'ajax', url: '/Import/Finance/GetAddBankFinalList', reader: { id: 'BSNO', root: 'data', totalProperty: 'totalCount' } } }); 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, selModel: this.AddGridCheckBoxModel, tbar: [{ text: '添加融资申请', tooltip: '添加融资申请', id: 'btnadddetail', iconCls: "btnadddetail", handler: function (button, event) { this.onAddClick(button, event); }, scope: this }], columns: [{ sortable: true, dataIndex: 'F_NO', header: '融资业务号', width: 110 }, { sortable: true, dataIndex: 'BANK_INTEREST_RATE', header: '融资金额', width: 80 }, { sortable: true, dataIndex: 'CUST_INTEREST', header: '未还金额', width: 80 }, { sortable: true, dataIndex: 'BANK_INTEREST', header: '美元利息', width: 80 }, { sortable: true, dataIndex: 'FINANCE_BANK', header: '融资银行', width: 100 }, { sortable: true, dataIndex: 'CUSTOMER', header: '客户名称', width: 100 }, { sortable: true, dataIndex: 'STARTDATE', header: '融资开始时间', width: 100 }, { sortable: true, dataIndex: 'OPREF', header: '申请人', width: 80 }, { sortable: true, dataIndex: 'ENTERDATE', header: '申请时间', width: 80 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 80 } ], // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeBodyAddList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.gridAddList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { // DsOpenEditWin("/TruckMng/MsWlPc/Edit"); }, this); _this = this; //#endregion _this = this; this.storeBuyer = Ext.create('DsExt.ux.RefTableStore', { model: 'Tradermb', proxy: { url: '/CommMng/BasicDataRef/GetTrader' } }); this.storeBuyer.load({ params: { condition: " 1=1 "} }); this.comboxBuyer = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '融资银行', store: this.storeBuyer, name: 'BANK', valueField: 'name', displayField: 'codename' }); this.formSearch = Ext.widget('form', { frame: true, region: 'north', 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: [this.comboxBuyer, { fieldLabel: '融资业务号', name: 'BillNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '从..融资日期', format: 'Y-m-d', xtype: 'datefield', name: 'STARTDATE_Min' }, { fieldLabel: '到..融资日期', format: 'Y-m-d', xtype: 'datefield', name: 'STARTDATE_Max' }, { xtype: 'button', width: 90, text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { xtype: 'button', width: 30, // text: "重置条件", iconCls: "btnreset", handler: function (button, event) { this.onClearSql(button, event); }, scope: this }, { xtype: 'button', width: 30, // text: "高级查询", iconCls: "btnmore", handler: function (button, event) { var sql = this.getCondition(); var winAccess = new Shipping.DsQuery({ }); winAccess.StoreList = this.storeBodyAddList; winAccess.formname = this.formname; winAccess.condition = sql; winAccess.show(); return; }, scope: this } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); this.paneldetail = new Ext.Panel({ title: '申请明细', layout: "border", height: 240, region: "north", split: true, items: [ this.gridList ] }); this.paneladddetail = new Ext.Panel({ layout: "border", region: 'center', height: 300, items: [this.gridAddList ] }); this.paneladd = new Ext.Panel({ title: '添加申请融资明细', layout: "border", // region: 'south', region: "center", // height: 420, items: [ this.formSearch, this.paneladddetail ] }); //#endregion 明细表 //#region 布局 //控件布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 160, items: [this.panelBtn, this.formEdit] }); Ext.apply(this, { items: [this.panelTop, this.paneldetail, this.paneladd] }); //#endregion //绑定查询窗体 this.ParentWin = window.parent.opener.panelIndex; //初始化数据 this.InitData(); //绑定事件 var billno = '*'; if (this.opStatus == 'edit') { billno = this.editRecord.get('F_NO'); }; this.storeBodyList.on('beforeload', function (store) { var sql = " F_NO='" + 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); }, //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 = " F_NO='" + this.editRecord.get('F_NO') + "'"; 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: '/Import/Finance/GetBankStlData', params: { handle: opstatus, condition: condition }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } var data = result.data; _this.formEdit.getForm().reset(); _this.formEdit.getForm().setValues(data); _this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); var billno = '*'; if (this.opStatus == 'edit') { billno = this.editRecord.get('F_NO'); }; this.storeBodyList.load({ params: { condition: " d.F_NO='" + billno + "'" }, callback: function (r, options, success) { if (success) { if (this.storeBodyList.getCount() > 0) { // this.comboxCurr.setReadOnly(true); this.comboxBuyer_F.setReadOnly(true); } else { // this.comboxCurr.setReadOnly(false); this.comboxBuyer_F.setReadOnly(false); } } }, scope: this }); }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var data = basicForm.getValues(); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/Import/Finance/SaveBankStl', 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.insert(0, returnData); this.editRecord = this.StoreList.getAt(0); } else if (this.opStatus == 'edit') { var editp = Ext.create('Financemb', 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 onAddBillClick: function (button, event) { this.addBill(); }, //end onAddDetailClick onDelDetailClick: function (button, event, type) { this.deleteDetail(); }, //onDelDetailClick onAddClick: function (button, event) { this.addBill(); }, //end onAddDetailClick onDeleteClick: function (button, event) { this.deleteBill(); }, //end onAddDetailClick 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 }); }, addBill: function () { var basicForm = this.formEdit.getForm(); var Duino = this.formEdit.getForm().findField('F_NO').getValue(); _this = this; if ((Duino == '*') || (Duino == '') || basicForm.isDirty()) { var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMER').getValue(); if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null)) { var selectedRecords = this.gridAddList.selModel.getSelection(); if (selectedRecords.length > 0) { var rec = selectedRecords[0]; var cust = rec.data.FINANCE_BANK; if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null)) this.formEdit.getForm().findField('CUSTOMER').setValue(cust); // if ((CURR == '') || (CURR == null)) // this.formEdit.getForm().findField('CURR').setValue(curr); } } if (!basicForm.isValid()) { return; } var type = 0; var data = basicForm.getValues(); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/Import/Finance/SaveBankStl', 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.insert(0, returnData); this.editRecord = this.StoreList.getAt(0); } else if (this.opStatus == 'edit') { var editp = Ext.create('Financemb', 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.addBillfn(); } 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 }); } } }); } else { this.addBillfn(); } }, //end save addBillfn: function () { var billno = this.editRecord.get('F_NO'); var billcust = this.editRecord.get('CUSTOMER'); var feeBSNOSql = ''; var sql = ''; var selectedRecords = this.gridAddList.selModel.getSelection(); if (selectedRecords.length == 0) { 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 cust = rec.data.FINANCE_BANK; if (cust == billcust) { bodyAddDatas.push(rec); } else { // Ext.Msg.show({ title: '提示', msg: '费用对象与收费申请客户不一致,不能添加此申请!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); alert('费用对象与申请客户不一致,不能添加此费用明细!'); } } _this = this; var AddBody = ConvertRecordsToJsonAll(bodyAddDatas); Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Import/Finance/AddBankStlBill', params: { billno: billno, addbody: AddBody }, 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 { dataList = result.Data; if (dataList == null) { var sql = this.sqlcontext; this.storeBodyAddList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); _this.storeBodyList.load({ params: { condition: " d.F_NO='" + billno + "'" }, callback: function (r, options, success) { if (success) { if (_this.storeBodyList.getCount() > 0) { // _this.comboxCurr.setReadOnly(true); _this.comboxBuyer_F.setReadOnly(true); } else { // _this.comboxCurr.setReadOnly(false); _this.comboxBuyer_F.setReadOnly(false); } } }, scope: this }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Import/Finance/GetBankStlData', params: { handle: 'edit', condition: " F_NO='" + 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('Financemb', 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 { return; } } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, deleteBill: function (type) { var billno = this.formEdit.getForm().findField('F_NO').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 bodyAddDatas = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; bodyAddDatas.push(rec); } var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); var sql = this.sqlcontext; _this = this; Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/Import/Finance/DelBankStlBill', params: { data: jsonbodyAddDatas, 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 { var sql = this.sqlcontext; this.storeBodyAddList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); _this.storeBodyList.load({ params: { condition: " d.F_NO='" + billno + "'" }, callback: function (r, options, success) { if (success) { if (_this.storeBodyList.getCount() > 0) { // _this.comboxCurr.setReadOnly(true); _this.comboxBuyer_F.setReadOnly(true); } else { // _this.comboxCurr.setReadOnly(false); _this.comboxBuyer_F.setReadOnly(false); } } }, scope: this }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Import/Finance/GetBankStlData', params: { handle: 'edit', condition: " F_NO='" + 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('Financemb', 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 Duino = this.formEdit.getForm().findField('F_NO').getValue(); var billstatus = this.formEdit.getForm().findField('ISFEE').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; } if (this.storeBodyList.getCount() == 0) { Ext.Msg.show({ title: '提示', msg: '没有融资明细,无法提交锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var data = basicForm.getValues(); var FinanceBank = []; for (i = 0; i < this.storeBodyList.getCount(); i += 1) { var memberyf = this.storeBodyList.getAt(i); FinanceBank.push(memberyf); }; var jsonFinanceBank = ConvertRecordsToJsonAll(FinanceBank); _this = this; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Import/Finance/SubmitBankStl', params: { bill: Ext.JSON.encode(data), body: jsonFinanceBank }, 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: '/Import/Finance/GetBankStlData', params: { handle: 'edit', condition: " F_NO='" + 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; } var data = result.data; _this.formEdit.getForm().reset(); _this.formEdit.getForm().setValues(data); var editp = Ext.create('Financemb', 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 Duino = this.formEdit.getForm().findField('F_NO').getValue(); var billstatus = this.formEdit.getForm().findField('ISFEE').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; var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var data = basicForm.getValues(); Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Import/Finance/SubmitBackBankStl', params: { bill: Ext.JSON.encode(data), }, 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: '/Import/Finance/GetBankStlData', params: { handle: 'edit', condition: " F_NO='" + 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; } var data = result.data; _this.formEdit.getForm().reset(); _this.formEdit.getForm().setValues(data); var editp = Ext.create('Financemb', 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 }); }, onRefreshClick: function (button, event) { var sql = this.getCondition(); this.sqlcontext = sql; this.storeBodyAddList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} }); }, onDsQuery: function () { //var girdcolums = this.gridList.getColumnMode(); var sql = this.sqlcontext; 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 buyer = form.findField('BANK').getValue(); sql = sql + getAndConSql(sql, buyer, "b.BANK= '" + buyer + "'"); var BillNo = form.findField('BillNo').getRawValue(); sql = sql + getAndConSql(sql, BillNo, "b.F_NO like '%" + BillNo + "%'"); var STARTDATE_Min = form.findField('STARTDATE_Min').getRawValue(); sql = sql + getAndConSql(sql, STARTDATE_Min, "f.STARTDATE >= '" + STARTDATE_Min + "'"); var STARTDATE_Max = form.findField('STARTDATE_Max').getRawValue(); sql = sql + getAndConSql(sql, STARTDATE_Max, "f.STARTDATE <= '" + STARTDATE_Max + " 23:59:59'"); return sql; }, // #region 根据权限和状态判断是否允许修改 GetEditStatus: function () { var canedit = false; // var btnESubmitAudit = Ext.getCmp('btnSubmitAudit'); // var btnESubmitAuditBack = Ext.getCmp('btnSubmitAuditBack'); }, 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'); if (enable) { btnESave.enable(); btnESaveAndClose.enable(); btnESaveAndNew.enable(); btnEAddDetail.enable(); btnEDeleteDetail.enable(); } else { btnESave.disable(); btnESaveAndClose.disable(); btnESaveAndNew.disable(); btnEAddDetail.disable(); btnEDeleteDetail.disable(); } }, // #endregion Print: function () { var basicForm = this.formEdit.getForm(); var billNo = basicForm.findField('F_NO').value; if (billNo == '*' || billNo == '') { Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } var printType = 'MSFINANCEAPP'; var sql1 = "SELECT * FROM IMPORT_FINANCE WHERE F_NO='" + billNo + "'"; var sql2 = "SELECT c.GID,c.F_NO,c.ContractNo,c.AMOUNT "; sql2 = sql2 + ",b.HTH,b.billno,b.BUYER,b.seller, C.NAME COMPANYNAME"; sql2 = sql2 + ",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=10 and EnumValueID=b.port) as portRef" sql2 = sql2 + ",(select NAME from [COMPANY] where GID=b.COMPANY) as COMPANYNAME" sql2 = sql2 + " FROM Import_Finance_do c left join Import_main b on (b.ContractNo=c.ContractNo)"; sql2 = sql2 + " WHERE C.F_NO='" + billNo + "' ORDER BY b.ContractNo,b.HTH"; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } ,onSelectFee: function (button, event) { //Ext.getCmp("zongshu").setText("1234"); var selectedRecords = this.gridAddFeeList.selModel.getSelection(); var sum = 0; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; sum = sum + rec.get("Amount"); } sum = sum.toFixed(2); Ext.getCmp("zongshu").setText(" 选中金额:" + sum); } });