VastTurnARAPCheck.js 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * 批量对账按钮
  3. */
  4. Ext.define('erp.view.core.button.VastTurnARAPCheck', {
  5. extend: 'Ext.Button',
  6. alias: 'widget.erpVastTurnARAPCheckButton',
  7. iconCls: 'x-button-icon-save',
  8. cls: 'x-btn-gray',
  9. tooltip: '批量对账',
  10. id: 'erpVastTurnARAPCheckButton',
  11. text: $I18N.common.button.erpVastTurnARAPCheckButton,
  12. initComponent: function() {
  13. this.callParent(arguments);
  14. },
  15. width: 110,
  16. handler: function(btn) {
  17. var datef = Ext.getCmp('pi_date'),
  18. from = datef ? (datef.firstVal ? Ext.Date.toString(datef.firstVal) : null ): null,
  19. to = datef ? (datef.secondVal ? Ext.Date.toString(datef.secondVal) : null ): null;
  20. this.save(btn.ownerCt.ownerCt.dealUrl, from, to);
  21. },
  22. save: function(url, from, to) {
  23. var grid = Ext.getCmp('batchDealGridPanel');
  24. var form = Ext.getCmp('dealform');
  25. var records = grid.selModel.getSelection();
  26. if (records.length > 0) {
  27. var params = new Object();
  28. params.caller = caller;
  29. var data = new Array();
  30. var bool = false;
  31. Ext.each(records, function(record, index) {
  32. var f = form.fo_detailMainKeyField;
  33. if ((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != '' && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0) || (f && this.data[f] != null && this.data[f] != '' && this.data[f] != '0' && this.data[f] != 0)) {
  34. bool = true;
  35. var o = new Object();
  36. if (grid.keyField) {
  37. o[grid.keyField] = record.data[grid.keyField];
  38. } else {
  39. params.id[index] = record.data[form.fo_detailMainKeyField];
  40. }
  41. if (grid.toField) {
  42. Ext.each(grid.toField, function(f, index) {
  43. var v = Ext.getCmp(f).value;
  44. if (v != null && v.toString().trim() != '' && v.toString().trim() != 'null') {
  45. o[f] = v;
  46. }
  47. });
  48. }
  49. if (grid.necessaryFields) {
  50. Ext.each(grid.necessaryFields, function(f, index) {
  51. o[f] = record.data[f];
  52. });
  53. }
  54. data.push(o);
  55. }
  56. });
  57. if (bool) {
  58. params.data = Ext.encode(data);
  59. params.fromDate = from;
  60. params.toDate = to;
  61. var main = parent.Ext.getCmp("content-panel");
  62. main.getActiveTab().setLoading(true); //loading...
  63. Ext.Ajax.request({
  64. url: basePath + url,
  65. params: params,
  66. method: 'post',
  67. callback: function(options, success, response) {
  68. main.getActiveTab().setLoading(false);
  69. var localJson = new Ext.decode(response.responseText);
  70. if (localJson.exceptionInfo) {
  71. showError(localJson.exceptionInfo);
  72. return;
  73. }
  74. if (localJson.success) {
  75. if (localJson.log) {
  76. showMessage("提示", localJson.log, 15000);
  77. }
  78. Ext.Msg.alert("提示", "处理成功!", function() {
  79. Ext.getCmp('dealform').onQuery();
  80. });
  81. }
  82. }
  83. });
  84. } else {
  85. showError("没有需要处理的数据!");
  86. }
  87. } else {
  88. showError("请勾选需要的明细!");
  89. }
  90. }
  91. });