CarryGl.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.gla.CarryGl', {
  3. extend: 'Ext.app.Controller',
  4. BaseUtil: Ext.create('erp.util.BaseUtil'),
  5. FormUtil: Ext.create('erp.util.FormUtil'),
  6. views: ['fa.gla.CarryGl', 'core.trigger.CateTreeDbfindTrigger', 'core.button.Close'],
  7. init: function(){
  8. this.control({
  9. 'displayfield[name=yearmonth]': {
  10. afterrender: function(f) {
  11. this.getCurrentMonth(f);
  12. }
  13. },
  14. 'cateTreeDbfindTrigger[name=ca_code]': {
  15. afterrender: function(f) {
  16. this.getDefaultCatecode(f);
  17. }
  18. },
  19. 'button[id=deal]': {
  20. click: function(btn) {
  21. var form = btn.ownerCt.ownerCt,
  22. ym = form.down('#yearmonth').value,
  23. cacode = form.down('#ca_code').value,
  24. account = form.down('#account').value;
  25. this.deal(form, ym, cacode, account);
  26. }
  27. }
  28. });
  29. },
  30. getCurrentMonth: function(f) {
  31. Ext.Ajax.request({
  32. url: basePath + 'fa/getMonth.action',
  33. params: {
  34. type: 'MONTH-A'
  35. },
  36. callback: function(opt, s, r) {
  37. var rs = Ext.decode(r.responseText);
  38. if(rs.data) {
  39. f.setValue(rs.data.PD_DETNO);
  40. }
  41. }
  42. });
  43. },
  44. getDefaultCatecode: function(f) {
  45. this.BaseUtil.getSetting('carryGl', 'broughtCatecode', function(v){
  46. if(v)
  47. f.setValue(v);
  48. });
  49. },
  50. deal: function(form, ym ,ca_code, account) {
  51. var tab = this.FormUtil.getActiveTab();
  52. tab.setLoading(true);
  53. Ext.Ajax.request({
  54. url: basePath + 'fa/gla/carrygl.action',
  55. params: {
  56. yearmonth: ym,
  57. ca_code: ca_code,
  58. account: account
  59. },
  60. timeout: 4800000,
  61. callback: function(opt, s, r) {
  62. tab.setLoading(false);
  63. var rs = Ext.decode(r.responseText);
  64. if(rs.success) {
  65. if(rs.data) {
  66. showMessage('提示', rs.data);
  67. } else {
  68. alert('结转损益成功!');
  69. }
  70. }
  71. }
  72. });
  73. }
  74. });