/** * 修改仓库按钮 */ Ext.define('erp.view.core.button.UpdateWHCode',{ extend: 'Ext.Button', alias: 'widget.erpUpdateWHCodeButton', iconCls: 'x-button-icon-submit', cls: 'x-btn-gray', text: '更新仓库', style: { marginLeft: '10px' }, width: 80, initComponent : function(){ this.callParent(arguments); }, listeners: { afterrender: function(btn) { var form = btn.ownerCt.ownerCt; if(form && form.readOnly) { btn.hide(); } }, click:function(){ var whcode=Ext.getCmp('pi_whcode'); var inwhcode=Ext.getCmp('pi_purpose'); if(whcode && whcode.value){ var codevalue=whcode.value; var value=Ext.getCmp('pi_whname').getValue(); var inwhname=Ext.getCmp('pi_purposename'); if(caller=='ProdInOut!AppropriationOut' && (!inwhcode || !inwhcode.value)){ Ext.Msg.alert('提示','请选择对应拨出拨入仓库!'); } Ext.MessageBox.show({ title:'确认修改?', msg: '将统一更新明细仓库?', buttons: Ext.Msg.YESNO, icon: Ext.Msg.WARNING, fn: function(btn){ if(btn == 'yes'){ //保存 var grid=Ext.getCmp('grid'); var store=grid.getStore(); Ext.Array.each(store.data.items,function(item){ if(item.data.pd_prodcode){ item.set('pd_whcode',codevalue); item.set('pd_whname',value); if(caller=='ProdInOut!AppropriationOut' && inwhcode && inwhname){ item.set('pd_inwhcode',inwhcode.value); item.set('pd_inwhname',inwhname.value); } } }); } else if(btn == 'no'){ //不保存 return; } else { return; } } }); }else { Ext.Msg.alert('提示','请选择仓库!'); } }} });