Ext.define('make.view.osmake.osMake.ModifyVendInfoWin', { extend: 'Ext.window.Window', xtype: 'osmake-osmake-modifyvendinfowin', cls: 'x-window-dbfind', modal: true, width: 1000, minHeight: 300, scrollable: true, bodyPadding: 10, constrain: true, closable: true, layout: 'fit', title: '外协信息更新', viewModel: { data: { form : { id:null, ma_vendid:null, ma_vendcode:null, ma_vendname:null, ma_contact:null, ma_shipaddresscode:null, ma_tel:null, ma_paymentscode:null, ma_paymentsid:null, ma_payments:null, ma_currency:null, ma_taxrate:null, ma_taxprice:null, ma_ipdid:null } }, }, items: [{ xtype: 'form', layout: 'column', autoScroll: true, buttonAlign : 'center', defaults:{ columnWidth:0.3 , margin: '0 0 10 0', labelAlign: 'right', labelWidth: 90 }, bodyPadding: '8 12 8 12', _saveUrl: '/api/make/make/modifyVendInfo', _getVendPrice:'/api/make/make/getVendPrice', items:[{ xtype: 'hidden', name: 'id', fieldLabel: 'id', allowBlank: true, columnWidth: 0, bind:'{form.id}', },{ xtype: "vendorDbfindTrigger", name: "ma_vendname", fieldLabel: "外协厂商", allowBlank: false, bind:'{form.ma_vendname}', }, { xtype: "hidden", name: "ma_vendid", fieldLabel: "外协厂商ID", bind:'{form.ma_vendid}', }, { xtype: "hidden", name: "ma_vendcode", fieldLabel: "外协厂商编号", bind:'{form.ma_vendcode}', },{ xtype: "textfield", name: "ma_contact", fieldLabel: "联系人", bind:'{form.ma_contact}', }, { xtype: "textfield", name: "ma_shipaddresscode", fieldLabel: "交货地址", bind:'{form.ma_shipaddresscode}', },{ xtype: "textfield", name: "ma_tel", fieldLabel: "联系电话", bind:'{form.ma_tel}', }, { xtype: 'hidden', name: 'ma_paymentscode', fieldLabel: '付款方式编号', bind:'{form.ma_paymentscode}', }, { xtype: 'hidden', fieldLabel: '付款方式编号', name: "ma_paymentsid", bind:'{form.ma_paymentsid}', },{ xtype: "remotecombo", name: "ma_payments", fieldLabel: "付款方式", storeUrl:'/api/document/paymentspay/list/enable', valueField:'pa_name', displayField: 'pa_name', allowBlank: false, bind:'{form.ma_payments}', addHandler: function (b) { var document = Ext.create('saas.view.document.paymentspay.DataList', {}); var form = this.ownerCmp.ownerCt; this.dialog = form.getController().getView().add({ xtype: 'document-paymentspay-window', bind: { title: '新增付款方式' }, dataKind: 'paymentspay', belong: document.etc['paymentspay'], _parent: form, _combo: this.ownerCmp, record: null, session: true }); this.dialog.show(); }, editHandler:function(btn,type){ saas.util.BaseUtil.openTab('document-paymentspay-datalist', '付款方式设置','maintab--document-paymentspay-datalist'); var combo = btn.ownerCt.up('remotecombo'); if(combo){ combo.collapse(); } } }, { xtype: 'hidden', name:'ma_tasktype', fieldLabel: '单据类型', allowBlank: false, defaultValue:'OS', bind:'{form.ma_tasktype}', },{ xtype: 'currencyCombo', name:'ma_currency', fieldLabel: '币种', allowBlank: false, rateField:'ma_rate', bind:'{form.ma_currency}', },{ xtype: 'hidden', fieldLabel: '汇率', name:'ma_rate', allowBlank: false, bind:'{form.ma_rate}', },{ xtype: 'numberfield', fieldLabel: '税率', name:'ma_taxrate', allowBlank: true, bind:'{form.ma_taxrate}', },{ xtype: 'numberfield', fieldLabel: '含税单价', name:'ma_taxprice', fixDecimal:false, decimalPrecision:8, bind:'{form.ma_taxprice}', thousandSeparator: ',', renderer: function (v){ if(!v){ v=0; } return '

'+saas.util.BaseUtil.numberFormat(v, 8, true)+'' } },{ xtype: 'numberfield', fieldLabel: '明细id', name:'ma_ipdid', hidden:true, bind:'{form.ma_ipdid}' },{ xtype: 'numberfield', fieldLabel: 'qty', name:'ma_qty', hidden:true, bind:'{form.ma_qty}' },{ xtype: 'textfield', fieldLabel: 'ma_prodcode', name:'ma_prodcode', hidden:true, bind:'{form.ma_prodcode}' }], buttons: [{ text:'保存', disabled: true, formBind: true, handler:function(){ this.up('window').onSave(); } }, { text:'按供应商取价', disabled: true, formBind: true, bind: { disabled: '{form.ma_vendcode}' }, handler:function(){ this.up('window').getVendPrice(window); } },{ text: '关闭', handler:function(){ this.up('window').onClose(); } }] }], initComponent: function () { var me = this; me.callParent(); }, /** * 保存 */ onSave: function(){ var me = this, form = me.down('form'), vm = me.getViewModel(); params = Ext.clone(vm.get('form')); form.setLoading(true); saas.util.BaseUtil.request({ url: form._saveUrl, params: JSON.stringify(params), method: 'POST', }) .then(function(localJson) { form.setLoading(false); if(localJson.success){ //刷新查询页面 saas.util.FormUtil.loadData(me._parent); saas.util.BaseUtil.showSuccessToast('保存成功'); me.onClose(); } }) .catch(function(e) { form.setLoading(false); saas.util.BaseUtil.showErrorToast('保存失败: ' + e.message); }); }, getVendPrice:function(win){ var me = this, form = me.down('form'), vm = me.getViewModel(), formparams = Ext.clone(vm.get('form')); if(!formparams.ma_vendcode){ saas.util.BaseUtil.showErrorToast('请先选择供应商.'); return false; } if(!formparams.ma_currency){ saas.util.BaseUtil.showErrorToast('请先选择币别.'); return false; } if(!formparams.ma_prodcode){ saas.util.BaseUtil.showErrorToast('请先选择产品.'); return false; } var params = { vendId:formparams.ma_vendid, currency:formparams.ma_currency, prodCode:formparams.ma_prodcode, qty:formparams.ma_qty }; form.setLoading(true); saas.util.BaseUtil.request({ url: form._getVendPrice, params: JSON.stringify(params), method: 'POST', }) .then(function(localJson) { form.setLoading(false); if(localJson.success){ //刷新查询页面 if(localJson.data){ if(localJson.data.ipdId){ form.down('[name=ma_taxprice]').setValue(localJson.data.price); form.down('[name=ma_ipdid]').setValue(localJson.data.ipdId); saas.util.BaseUtil.showSuccessToast('取价成功'); }else{ form.down('[name=ma_ipdid]').setValue(-1); saas.util.BaseUtil.showSuccessToast('取价失败 无产品价格信息。'); } } } }) .catch(function(e) { form.setLoading(false); saas.util.BaseUtil.showErrorToast('保取价失败: ' + e.message); }); }, onClose:function(){ this.close(); } })