WriteVoucher.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.gla.WriteVoucher', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. views:[
  8. 'fa.gla.WriteVoucher', 'core.button.Accounted', 'core.grid.Panel2'
  9. ],
  10. init:function(){
  11. var me = this;
  12. this.control({
  13. 'erpGridPanel2': {
  14. afterrender: function(grid) {
  15. var f = Ext.getCmp('yearmonth');
  16. this.getCurrentMonth(grid, f);
  17. var total = Ext.getCmp('total'),
  18. enter = Ext.getCmp('enter'),
  19. commit = Ext.getCmp('commit'),
  20. audit = Ext.getCmp('audit');
  21. this.getCount(total, enter, commit, audit);
  22. }
  23. },
  24. 'erpAccountedButton': {
  25. click: function(btn) {
  26. var grid = btn.ownerCt.ownerCt.down('gridpanel');
  27. grid.setLoading(true);
  28. Ext.Ajax.request({
  29. url: basePath + 'fa/ars/accountVoucher.action',
  30. params: {
  31. month: me.currentMonth
  32. },
  33. timeout: 60000,
  34. callback: function(opt, s, r) {
  35. grid.setLoading(false);
  36. var rs = Ext.decode(r.responseText);
  37. if(rs.result) {
  38. showMessage('提示', rs.result);
  39. window.location.reload();
  40. } else if(rs.exceptionInfo) {
  41. showError(rs.exceptionInfo);
  42. } else {
  43. alert('OK!');
  44. window.location.reload();
  45. }
  46. }
  47. });
  48. }
  49. }
  50. });
  51. },
  52. getCurrentMonth: function(grid, f) {
  53. var me = this;
  54. Ext.Ajax.request({
  55. url: basePath + 'fa/getMonth.action',
  56. params: {
  57. type: 'MONTH-A'
  58. },
  59. callback: function(opt, s, r) {
  60. var rs = Ext.decode(r.responseText);
  61. if(rs.data) {
  62. me.currentMonth = rs.data.PD_DETNO;
  63. me.datestart = Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Ymd');
  64. me.dateend = Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Ymd');
  65. f.setText(rs.data.PD_DETNO + ' 从' + Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Y-m-d')
  66. + ' 到 ' + Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Y-m-d'));
  67. grid.GridUtil.loadNewStore(grid, {caller: caller, condition: 'vo_yearmonth=' +
  68. me.currentMonth + ' AND vo_statuscode=\'AUDITED\''});
  69. }
  70. }
  71. });
  72. },
  73. getCount: function(total, enter, commit, audit) {
  74. var me = this;
  75. Ext.Ajax.request({
  76. url: basePath + 'fa/ars/getVoucherCount.action',
  77. callback: function(opt, s, r) {
  78. var rs = Ext.decode(r.responseText);
  79. if(rs.data) {
  80. total.setText(String(rs.data.total));
  81. enter.setText(String(rs.data.enter));
  82. commit.setText(String(rs.data.commit));
  83. audit.setText(String(rs.data.audit));
  84. }
  85. }
  86. });
  87. }
  88. });