/** * 预付-应付明细确认 */ Ext.define('erp.view.core.button.ConfirmYFYF',{ extend: 'Ext.Button', alias: 'widget.erpConfirmYFYFButton', //iconCls: 'x-button-icon-submit', cls: 'x-btn-gray', id:'confirmyfyf', text: $I18N.common.button.erpConfirmYFYFButton, style: { marginLeft: '10px' }, width: 140, initComponent : function(){ this.callParent(arguments); }, listeners: { click: function(m){ var grid = Ext.getCmp('batchDealGridPanel'), record = grid.getSelectionModel().getLastSelected(); if(record != null){ Ext.getCmp('confirmyfyf').turn(record); } else { showMessage('提示', '请选择需要确认的明细!'); return; } } }, turn: function(record){ var win = new Ext.window.Window({ id : 'win', height: "100%", width: "80%", maximizable : true, buttonAlign : 'center', layout : 'anchor', items: [{ xtype:'form', layout:'column', anchor : '100% 10%', frame:true, defaults:{ margin: '5 15 0 5', xtype:'textfield', columnWidth:0.5 }, items:[{ fieldLabel:'供应商号', value:record.data.vm_vendcode, readOnly: true, fieldStyle:'background:#f0f0f0;border: 0px solid #8B8970;color:blue;', id:'vecode' },{ fieldLabel:'供应商名' , value:record.data.ve_name, fieldStyle:'background:#f0f0f0;border: 0px solid #8B8970;color:blue;', readOnly: true },{ fieldLabel:'币别', value:record.data.vm_currency, fieldStyle:'background:#f0f0f0;border: 0px solid #8B8970;color:blue;', readOnly: true, id:'currency' },{ fieldLabel:'冲账金额', xtype:'separnumberfield', value:record.data.vm_prepaybalance, readOnly: false, id:'vm_prepaybalance' },{ fieldLabel:'VMID', value:record.data.vm_id, readOnly: true, id:'vm_id' }] },{ xtype : 'grid', anchor: '100% 45%', columnLines : true, id : 'grid1', plugins: [Ext.create('erp.view.core.grid.HeaderFilter', { remoteFilter: true }),Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, })], selModel: Ext.create('Ext.selection.CheckboxModel',{ checkOnly : true, ignoreRightMouseSelection : false, getEditor: function(){ return null; } }), columns : [ { text : '预付单号', cls : 'x-grid-header-1', dataIndex: 'PP_CODE', width: 100, filter: { xtype : 'textfield' } }, { text : '日期', cls : 'x-grid-header-1', dataIndex: 'PP_DATE', width: 120, filter: { xtype : 'datefield' }, renderer: function(val) {return Ext.Date.format(new Date(val), 'Y-m-d');} }, { text : '冲账币别', cls : 'x-grid-header-1', dataIndex: 'PP_CURRENCY', width: 70, filter: { xtype : 'textfield' } }, { text : '预付挂账金额', cls : 'x-grid-header-1', dataIndex: 'PP_JSAMOUNT', width: 100, filter: { xtype : 'textfield' } }, { text : '已结算金额', cls : 'x-grid-header-1', dataIndex: 'PP_HAVEBALANCE', width: 80, filter: { xtype : 'textfield' } },{ text : '类型', cls : 'x-grid-header-1', dataIndex: 'PP_TYPE', width: 120, filter: { xtype : 'textfield' } },{ text : '本次结算金额', cls : 'x-grid-header-1', dataIndex: 'PP_THISAMOUNT', width: 100, filter: { xtype : 'textfield' }, xtype:'numbercolumn', editable:true, editor:{ xtype:'numberfield', format:'0', hideTrigger: true } }, { text : '采购单号', cls : 'x-grid-header-1', dataIndex: 'PP_ORDERCODE', width: 200, filter: { xtype : 'textfield' } }], store : new Ext.data.Store({ fields : [ 'PP_CODE', 'PP_DATE', 'PP_JSAMOUNT', 'PP_HAVEBALANCE', 'PP_THISAMOUNT','PP_TYPE', 'PP_ID','PP_VENDCODE','PP_CURRENCY', 'PP_ORDERCODE' ], proxy : { type : 'ajax', url : basePath + 'fa/arp/getPrePay.action', reader : { type : 'json', root : 'data' } }, autoLoad : false }) },{ xtype : 'grid', anchor: '100% 45%', columnLines : true, id : 'grid2', plugins: [Ext.create('erp.view.core.grid.HeaderFilter', { remoteFilter: true }),Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, })], selModel: Ext.create('Ext.selection.CheckboxModel',{ checkOnly : true, ignoreRightMouseSelection : false, getEditor: function(){ return null; } }), columns : [ { text : '发票编号', cls : 'x-grid-header-1', dataIndex: 'AB_CODE', width: 100, filter: { xtype : 'textfield' } }, { text : '日期', xtype:'datecolumn', cls : 'x-grid-header-1', dataIndex: 'AB_DATE', width: 120, filter: { xtype : 'datefield' }, renderer: function(val) {return Ext.Date.format(new Date(val), 'Y-m-d');} }, { text : '发票金额', cls : 'x-grid-header-1', dataIndex: 'AB_APAMOUNT', width: 80, filter: { xtype : 'textfield' } }, { text : '已付金额', cls : 'x-grid-header-1', dataIndex: 'AB_PAYAMOUNT', width: 80, filter: { xtype : 'textfield' } }, { text : '类型', cls : 'x-grid-header-1', dataIndex: 'AB_CLASS', width: 100, filter: { xtype : 'textfield' } },{ text : '本次结算金额', cls : 'x-grid-header-1', dataIndex: 'AB_THISAMOUNT', width: 100, disable:true, filter: { xtype : 'textfield' }, xtype:'numbercolumn', editable:true, editor:{ xtype:'numberfield', format:'0', hideTrigger: true } }, { text : '采购单号', cls : 'x-grid-header-1', dataIndex: 'AB_ORDERCODE', width: 370, filter: { xtype : 'textfield' } }], store : new Ext.data.Store({ fields : [ 'AB_CODE', 'AB_DATE', 'AB_APAMOUNT', 'AB_PAYAMOUNT', 'AB_ORDERCODE','AB_CLASS', 'AB_ID','AB_VENDCODE','AB_CURRENCY', 'AB_THISAMOUNT'], proxy : { type : 'ajax', url : basePath + 'fa/arp/getAPBill.action', reader : { type : 'json', root : 'data' } }, autoLoad : false }) }], buttons : [{ name: 'confirm', text : $I18N.common.button.erpConfirmButton, iconCls: 'x-button-icon-confirm', cls: 'x-btn-gray', listeners: { buffer: 500, click: function(btn) { var grid1 = Ext.getCmp('grid1'), grid2 = Ext.getCmp('grid2'); var items1 = grid1.selModel.getSelection(), items2 = grid2.selModel.getSelection(); var data1 = Ext.Array.map(items1, function(item){ return {pp_id: item.get('PP_ID'), pp_thisamount: item.get('PP_THISAMOUNT')}; }), data2 = Ext.Array.map(items2, function(item){ return {ab_id: item.get('AB_ID'), ab_thisamount: item.get('AB_THISAMOUNT')}; }); if(data1.length > 0 || data2.length > 0) { Ext.Ajax.request({ url : basePath + 'fa/confirmPrePayAPBill.action', params: { vmid: Ext.getCmp("vm_id").value, thisamount: Ext.getCmp("vm_prepaybalance").value, data1: Ext.JSON.encode(data1).toString(), data2: Ext.JSON.encode(data2).toString() }, method : 'post', timeout: 6000000, callback : function(options,success,response){ var localJson = new Ext.decode(response.responseText); if(localJson.exceptionInfo){ var str = localJson.exceptionInfo; showError(str);return; } if(localJson.success){ if(localJson.log){ showMessage("提示", localJson.log); } Ext.getCmp('win').close(); } } }); } else { showError("请勾选需要的明细!"); } } } }, { text : $I18N.common.button.erpCloseButton, iconCls: 'x-button-icon-close', cls: 'x-btn-gray', handler : function(){ Ext.getCmp('win').close(); } }] }); win.show(); win.down('#grid1').getStore().load({ params: { vendcode: record.get('vm_vendcode'), currency: record.get('vm_currency') } }); win.down('#grid2').getStore().load({ params: { vendcode: record.get('vm_vendcode'), currency: record.get('vm_currency') } }); } });