/** * 委外信息修改按钮 */ Ext.define('erp.view.core.button.OSInfoVendReply',{ extend : 'Ext.Button', alias : 'widget.erpOSInfoVendReplyButton', iconCls : 'x-button-icon-submit', cls : 'x-btn-gray', text : $I18N.common.button.erpOSInfoVendReplyButton, style : { marginLeft : '10px' }, width : 140, initComponent : function() { this.callParent(arguments); }, listeners: { afterrender: function(btn) { var me = this; //var res = me.getSetting('makeOSInfo.check'), status = Ext.getCmp('ma_statuscode'), checkstatus = Ext.getCmp('ma_checkstatus'); if(status && (status.value == 'ENTERING' || status.value == 'FINISH')){ btn.hide(); } /*if(res) { 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_vendorreplydate'), vn = Ext.getCmp('ma_replyqty'), pr = Ext.getCmp('ma_isok'), cr = Ext.getCmp('ma_vendorreply'), val1 = vc ? vc.value : '', val2 = vn ? vn.value : '', val3 = pr ? pr.value : '', val4 = cr ? cr.value : ''; win = Ext.create('Ext.Window', { width: 430, height: 250, closeAction: 'destroy', cls: 'custom-blue', title: '

更新供应商回信息

', layout: { type: 'vbox' }, items: [ { margin: '5 0 0 5', xtype: 'datefield', fieldLabel: '回复交期', name: 'DELIVERYREPLY', format: 'Y-m-d', value: val1, id: 'DELIVERYREPLY' }, { margin: '5 0 0 5', xtype: 'numberfield', fieldLabel: '回复数量', name: 'QTYREPLY', hideTrigger: true, value: val2, id: 'QTYREPLY' },{ margin: '5 0 0 5', xtype: 'checkbox', columnidth: 0.4, fieldLabel: '能否按时交货', name: 'isok', value:val3, id: 'isok' }, { margin: '5 0 0 5', xtype: 'textareatrigger', columnidth: 0.4, fieldLabel: '回复明细', name: 'replydetail', value:val4, id: 'replydetail' } ], buttonAlign: 'center', buttons: [{ xtype: 'button', text: '保存', width: 60, iconCls: 'x-button-icon-save', handler: function(btn) { var w = btn.up('window'); me.saveVendorInfo(w); win.close(); win.destroy(); } }, { xtype: 'button', columnWidth: 0.1, text: '关闭', width: 60, iconCls: 'x-button-icon-close', margin: '0 0 0 10', handler: function(btn) { var win = btn.up('window'); win.close(); win.destroy(); } }] }); } win.show(); }, saveVendorInfo: function(w) { var deliveryreply = w.down('field[name=DELIVERYREPLY]').getValue(); var qty = w.down('field[name=QTYREPLY]').getValue(); if (!deliveryreply && !qty && !Ext.getCmp('replydetail').value) { showError('请先设置回复信息'); return; } else { var isok = w.down('field[name=isok]').getValue(); var dd = { ma_id:Ext.getCmp('ma_id').getValue() , ma_replyqty: qty ? qty: 0, ma_vendorreplydate: deliveryreply ? Ext.Date.format(deliveryreply, 'Y-m-d') : null, ma_isok: isok ? '是': '否', ma_vendorreply:Ext.getCmp('replydetail').value }; Ext.Ajax.request({ url: basePath + 'pm/make/updateVendorInfo.action', params: { data: unescape(Ext.JSON.encode(dd)), caller: caller }, method: 'post', callback: function(opt, s, res) { var r = new Ext.decode(res.responseText); if (r.success) { showMessage('提示', '更新成功!', 1000); window.location.reload(); } else if (r.exceptionInfo) { showError(r.exceptionInfo); } else { saveFailure(); } } }); } }, 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 + '\'' }, 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; } });