ResSubmitNoStandard.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. Ext.define('erp.view.core.button.ResSubmitNoStandard',{
  2. extend: 'Ext.Button',
  3. alias: 'widget.erpResSubmitNoStandardButton',
  4. iconCls: 'x-button-icon-submit',
  5. cls: 'x-btn-gray',
  6. text: '反提交(转非标准)',
  7. style: {
  8. marginLeft: '10px'
  9. },
  10. width:120,
  11. initComponent : function(){
  12. this.callParent(arguments);
  13. },
  14. hidden:true,
  15. listeners:{
  16. 'afterrender':function(btn){
  17. var standard=Ext.getCmp('pr_standardized');
  18. var statuscode =Ext.getCmp('pr_standardstatus');
  19. if(statuscode && statuscode.value=='COMMITED'){
  20. btn.show();
  21. if(standard && standard.value!=-1){
  22. btn.setText('反提交(入标准库)');
  23. }else btn.setText('反提交(出标准库)');
  24. }
  25. }
  26. },
  27. handler:function(){
  28. var form = Ext.getCmp('form');
  29. var id=Ext.getCmp(form.keyField).value;
  30. form.FormUtil.setLoading(true);
  31. Ext.Ajax.request({
  32. url : basePath +'scm/product/resSubmitNoStandard.action',
  33. params : {
  34. id:id
  35. },
  36. method : 'post',
  37. callback : function(options,success,response){
  38. form.FormUtil.setLoading(false);
  39. var localJson = new Ext.decode(response.responseText);
  40. if(localJson.success){
  41. showMessage('提示', '反提交成功!', 1000);
  42. window.location.reload();
  43. } else if(localJson.exceptionInfo){
  44. var str = localJson.exceptionInfo;
  45. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  46. str = str.replace('AFTERSUCCESS', '');
  47. showMessage('提示', '反提交成功!', 1000);
  48. showError(str);
  49. } else {
  50. showError(str);
  51. return;
  52. }
  53. } else{
  54. showMessage('提示', '反提交失败', 1000);
  55. }
  56. }
  57. });
  58. }
  59. });