PurchaseNotifyCancel.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**
  2. * 取消采购通知
  3. */
  4. Ext.define('erp.view.core.button.PurchaseNotifyCancel',{
  5. extend: 'Ext.Button',
  6. alias: 'widget.erpPurchaseNotifyCancelButton',
  7. iconCls: 'x-button-icon-delete',
  8. cls: 'x-btn-gray',
  9. text: '取消通知',
  10. id: 'cancelm',
  11. style: {
  12. marginLeft: '10px'
  13. },
  14. width: 120,
  15. menu: [{
  16. iconCls: 'main-msg',
  17. text: '取消通知',
  18. listeners: {
  19. click: function(m){
  20. var params=new Object();
  21. var cancel=Ext.getCmp('cancelm');
  22. params.data = unescape(Ext.JSON.encode(cancel.getRecordDatas()).replace(/\\/g,"%"));;
  23. cancel.Cancle(params,'scm/cancelPurchaseNotify.action');
  24. }
  25. }
  26. },{
  27. iconCls: 'main-msg',
  28. text: '取消当前结果通知',
  29. listeners: {
  30. click: function(m){
  31. var params=new Object();
  32. var form = Ext.getCmp('dealform');
  33. var cancel=Ext.getCmp('cancelm');
  34. params.condition = form.getCondition();
  35. cancel.Cancle(params,'scm/cancelCondPurcNotify.action');
  36. }
  37. }
  38. },{
  39. iconCls:'main-msg',
  40. text:'取消未确认通知',
  41. listeners: {
  42. click: function(m){
  43. var params=new Object();
  44. var cancel=Ext.getCmp('cancelm');
  45. params.condition="ALL";
  46. cancel.Cancle(params,'scm/cancelALLPurcNotify.action');
  47. }
  48. }
  49. }],
  50. initComponent : function(){
  51. this.callParent(arguments);
  52. },
  53. Cancle:function(param,acurl){
  54. var main = parent.Ext.getCmp("content-panel");
  55. var grid = Ext.getCmp('batchDealGridPanel');
  56. main.getActiveTab().setLoading(true);//loading...
  57. Ext.Ajax.request({
  58. url : basePath + acurl,
  59. params: param,
  60. method : 'post',
  61. timeout: 6000000,
  62. callback : function(options,success,response){
  63. main.getActiveTab().setLoading(false);
  64. var localJson = new Ext.decode(response.responseText);
  65. if(localJson.exceptionInfo){
  66. var str = localJson.exceptionInfo;
  67. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
  68. str = str.replace('AFTERSUCCESS', '');
  69. grid.multiselected = new Array();
  70. Ext.getCmp('dealform').onQuery();
  71. }
  72. showError(str);return;
  73. }
  74. if(localJson.success){
  75. if(localJson.log){
  76. showMessage("提示", localJson.log);
  77. }
  78. Ext.Msg.alert("提示", "处理成功!", function(){
  79. grid.multiselected = new Array();
  80. Ext.getCmp('dealform').onQuery();
  81. });
  82. }
  83. }
  84. });
  85. },
  86. getRecordDatas:function(){
  87. var grid = Ext.getCmp('batchDealGridPanel');
  88. var items = grid.selModel.getSelection();
  89. Ext.each(items, function(item, index){
  90. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  91. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  92. item.index = this.data[grid.keyField];
  93. grid.multiselected.push(item);
  94. }
  95. });
  96. var form = Ext.getCmp('dealform');
  97. var records = Ext.Array.unique(grid.multiselected);
  98. var data = new Array();
  99. Ext.each(records, function(record, index){
  100. var f = form.fo_detailMainKeyField;
  101. if((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  102. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)
  103. ||(f && this.data[f] != null && this.data[f] != ''
  104. && this.data[f] != '0' && this.data[f] != 0)){
  105. bool = true;
  106. var o = new Object();
  107. if(grid.keyField){
  108. o[grid.keyField] = record.data[grid.keyField];
  109. } else {
  110. params.id[index] = record.data[form.fo_detailMainKeyField];
  111. }
  112. if(grid.toField){
  113. Ext.each(grid.toField, function(f, index){
  114. var v = Ext.getCmp(f).value;
  115. if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
  116. o[f] = v;
  117. }
  118. });
  119. }
  120. if(grid.necessaryFields){
  121. Ext.each(grid.necessaryFields, function(f, index){
  122. var v = record.data[f];
  123. if(Ext.isDate(v)){
  124. v = Ext.Date.toString(v);
  125. }
  126. o[f] = v;
  127. });
  128. }
  129. data.push(o);
  130. }
  131. });
  132. return data;
  133. }
  134. });