/** * 委外信息修改按钮 */ Ext.define('erp.view.core.button.OSVendorUpdate',{ extend : 'Ext.Button', alias : 'widget.erpOSVendorUpdateButton', iconCls : 'x-button-icon-submit', cls : 'x-btn-gray', text : $I18N.common.button.erpOSVendorUpdateButton, style : { marginLeft : '10px' }, width : 140, initComponent : function() { this.callParent(arguments); }, listeners: { afterrender: function(btn) { var status = Ext.getCmp('ma_statuscode'),checkstatus = Ext.getCmp('ma_checkstatuscode'); if(status && (status.value == 'ENTERING' || status.value == 'FINISH')){ btn.hide(); } if(checkstatus && checkstatus.value == 'APPROVE'){ btn.hide(); } } }, handler: function() { var me = this, win = Ext.getCmp('Complaint-win'); var states = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'], data : me.getFlowStyle() }); if(!win) { var vc = Ext.getCmp('ma_vendcode'), vn = Ext.getCmp('ma_vendname'), pr = Ext.getCmp('ma_price'), cr = Ext.getCmp('ma_currency'),tr = Ext.getCmp('ma_taxrate'), pac = Ext.getCmp('ma_paymentscode'), pan = Ext.getCmp('ma_payments'),ser=Ext.getCmp('ma_servicer'), flowstyle = Ext.getCmp('ma_flowstyle').value, rate = Ext.getCmp('ma_rate').value, remark = Ext.getCmp('ma_remark').value, val1 = vc ? vc.value : '', val2 = vn ? vn.value : '', val3 = pr ? pr.value : '', val4 = cr ? cr.value : '', val5 = tr ? tr.value : '', val6 = pac ? pac.value : '', val7 = pan ? pan.value : '',val8 = ser ? ser.value : '', val9 = rate ? rate.value : '', val10 = remark ? remark.value : ''; win = Ext.create('Ext.Window', { id: 'Complaint-win', title: '更新委外单 ' + Ext.getCmp('ma_code').value + ' 的委外信息', height: 400, width: 400, items: [{ margin: '10 0 0 0', xtype: 'dbfindtrigger', fieldLabel: '委外商号', name:'ma_vendcode', value: val1, listeners:{ aftertrigger:function(t, d){ t.ownerCt.down('textfield[name=ma_vendname]').setValue(d.get('ve_name')); } } },{ margin: '3 0 0 0', xtype: 'textfield', fieldLabel: '委外商名', readOnly:true, name:'ma_vendname', value: val2 },{ margin: '3 0 0 0', xtype: 'dbfindtrigger', fieldLabel: '币别', name:'ma_currency', value: val4, listeners:{ aftertrigger:function(t, d){ t.ownerCt.down('textfield[name=ma_rate]').setValue(d.get('cr_rate')); } } },{ margin: '3 0 0 0', xtype: 'textfield', fieldLabel: '汇率', readOnly:true, name:'ma_rate', value: val9 },{ margin: '3 0 0 0', xtype: 'textfield', fieldLabel: '税率', name:'ma_taxrate', value: val5 },{ margin: '3 0 0 0', xtype: 'textfield', fieldLabel: '加工单价', name:'ma_price', value: val3, listeners:{ afterrender:function(t, d){ var res = me.getSetting('makeos.price'); if(res) { t.ownerCt.down('textfield[name=ma_price]').setReadOnly(true); } } } },{ margin: '3 0 0 0', xtype: 'erpYnField', fieldLabel: '是否免费加工', name:'ma_servicer', value: val8, hidden:!ser, },{ margin: '3 0 0 0', xtype: 'dbfindtrigger', fieldLabel: '付款方式编号', name:'ma_paymentscode', value: val6, listeners:{ aftertrigger:function(t, d){ t.ownerCt.down('textfield[name=ma_payments]').setValue(d.get('pa_name')); } } },{ margin: '3 0 0 0', xtype: 'textfield', fieldLabel: '付款方式', name:'ma_payments', readOnly:true, value: val7 },{ margin: '3 0 0 0', xtype: 'combo', name:'ma_flowstyle', fieldLabel: '委外单位', store: states, queryMode: 'local', displayField: 'name', valueField: 'abbr', value:flowstyle },{ margin: '3 0 0 0', xtype: 'textfield', name:'ma_remark', fieldLabel: '备注', value: val10 }], closeAction: 'hide', buttonAlign: 'center', layout: { type: 'vbox', align: 'center' }, buttons: [{ text: "自动获取", cls: 'x-btn-blue', handler: function(btn) { Ext.Ajax.request({ url: basePath + '/scm/purchase/getMakeVendorPrice.action', params: { id: Ext.getCmp('ma_id').value }, callback: function(opt, s, r) { var rs = Ext.decode(r.responseText); if(rs.exceptionInfo) { showError(rs.exceptionInfo); } else { Ext.Msg.alert("提示","获取成功!"); window.location.reload(); } } }); } },{ text: $I18N.common.button.erpConfirmButton, cls: 'x-btn-blue', handler: function(btn) { var form = btn.ownerCt.ownerCt, a = form.down('dbfindtrigger[name=ma_vendcode]'), b = form.down('dbfindtrigger[name=ma_currency]'), c = form.down('textfield[name=ma_taxrate]'), d = form.down('textfield[name=ma_price]'), e = form.down('textfield[name=ma_paymentscode]'), f = form.down('textfield[name=ma_payments]'); g = form.down('textfield[name=ma_servicer]'); h = form.down('textfield[name=ma_flowstyle]'); i = form.down('textfield[name=ma_remark]'); if((a.isDirty() && !Ext.isEmpty(a.value)) || (b.isDirty() && !Ext.isEmpty(b.value)) || ( c.isDirty() && !Ext.isEmpty(c.value)) ||(d.isDirty() && !Ext.isEmpty(d.value))||(g.isDirty() && !Ext.isEmpty(g.value)) ||(h.isDirty() && !Ext.isEmpty(h.value))||(i.isDirty() && !Ext.isEmpty(i.value))) { me.updateOSVendor(Ext.getCmp('ma_id').value, a.value, b.value, c.value, d.value, e.value, f.value,g.value,h.value,i.value); } } }, { text: $I18N.common.button.erpCloseButton, cls: 'x-btn-blue', handler: function(btn) { btn.ownerCt.ownerCt.hide(); } }] }); } win.show(); }, updateOSVendor: function(id, val1, val2, val3, val4, val5, val6,ser,h,i) { Ext.Ajax.request({ url: basePath + 'pm/make/updateOSVendor.action', params: { id: id, vend: val1, curr: val2, taxr: val3, price: val4, paymc: val5, paym: val6, ma_servicer: ser, maflowstyle:h, remark: i }, callback: function(opt, s, r) { var rs = Ext.decode(r.responseText); if(rs.exceptionInfo) { showError(rs.exceptionInfo); } else { Ext.Msg.alert("提示","更新成功!"); window.location.reload(); } } }); }, getFlowStyle: function() { var field = Ext.getCmp('ma_flowstyle'), datas = []; if(field && field.store) { field.store.each(function(item){ datas.push({ name: item.get('display'), abbr: item.get('value') }); }); } return datas; }, getSetting: function(type) { var result = false; Ext.Ajax.request({ url : basePath + 'common/getFieldData.action', async: false, params: { caller: 'Setting', field: 'se_value', condition: 'se_what=\'' + type + '\'' }, method : 'post', callback : function(opt, s, res){ var r = new Ext.decode(res.responseText); if(r.exceptionInfo){ showError(r.exceptionInfo);return; } else if(r.success && r.data){ result = r.data == 'true'; } } }); return result; } });