SelectThrowNotify.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. Ext.define('erp.view.core.button.SelectThrowNotify',{
  2. extend: 'Ext.Button',
  3. alias: 'widget.erpSelectThrowNotifyButton',
  4. iconCls: 'x-button-icon-save',
  5. cls: 'x-btn-gray-1',
  6. text: $I18N.common.button.erpSelectThrowButton,
  7. style: {
  8. marginLeft: '10px'
  9. },
  10. width:90,
  11. initComponent : function(){
  12. this.callParent(arguments);
  13. },
  14. handler:function(btn){
  15. var grid = Ext.getCmp('batchDealGridPanel');
  16. var items = grid.selModel.getSelection();
  17. Ext.each(items, function(item, index){
  18. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  19. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  20. item.index = this.data[grid.keyField];
  21. grid.multiselected.push(item);
  22. }
  23. });
  24. var form = Ext.getCmp('dealform');
  25. var records = Ext.Array.unique(grid.multiselected);
  26. if(records.length > 0){
  27. var params = new Object();
  28. params.id=new Array();
  29. params.caller = caller;
  30. var data = new Array();
  31. var bool = false;
  32. Ext.each(records, function(record, index){
  33. var f = form.fo_detailMainKeyField;
  34. if((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  35. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)
  36. ||(f && this.data[f] != null && this.data[f] != ''
  37. && this.data[f] != '0' && this.data[f] != 0)){
  38. bool = true;
  39. var o = new Object();
  40. if(grid.keyField){
  41. o[grid.keyField] = record.data[grid.keyField];
  42. } else {
  43. params.id[index] = record.data[form.fo_detailMainKeyField];
  44. }
  45. if(grid.toField){
  46. Ext.each(grid.toField, function(f, index){
  47. var v = Ext.getCmp(f).value;
  48. if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
  49. o[f] = v;
  50. }
  51. });
  52. }
  53. if(grid.necessaryFields){
  54. Ext.each(grid.necessaryFields, function(f, index){
  55. var v = record.data[f];
  56. if(Ext.isDate(v)){
  57. v = Ext.Date.toString(v);
  58. }
  59. o[f] = v;
  60. });
  61. }
  62. data.push(o);
  63. }
  64. });
  65. if(bool){
  66. params.data = unescape(Ext.JSON.encode(data).replace(/\\/g,"%"));;
  67. var main = parent.Ext.getCmp("content-panel");
  68. main.getActiveTab().setLoading(true);//loading...
  69. Ext.Ajax.request({
  70. url : basePath + 'pm/wcplan/throwpurchasenotify.action',
  71. params: params,
  72. method : 'post',
  73. timeout: 6000000,
  74. callback : function(options,success,response){
  75. main.getActiveTab().setLoading(false);
  76. var localJson = new Ext.decode(response.responseText);
  77. if(localJson.exceptionInfo){
  78. var str = localJson.exceptionInfo;
  79. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
  80. str = str.replace('AFTERSUCCESS', '');
  81. grid.multiselected = new Array();
  82. Ext.getCmp('dealform').onQuery();
  83. }
  84. showError(str);return;
  85. }
  86. if(localJson.success){
  87. if(localJson.log){
  88. showMessage("提示", localJson.log);
  89. }
  90. Ext.Msg.alert("提示", "处理成功!", function(){
  91. grid.multiselected = new Array();
  92. Ext.getCmp('dealform').onQuery();
  93. });
  94. }
  95. }
  96. });
  97. } else {
  98. showError("没有需要处理的数据!");
  99. }
  100. }
  101. }
  102. });