WriteVoucher.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. }
  18. },
  19. 'erpAccountedButton': {
  20. click: function(btn) {
  21. var grid = btn.ownerCt.ownerCt.down('gridpanel');
  22. grid.setLoading(true);
  23. Ext.Ajax.request({
  24. url: basePath + 'fa/ars/accountVoucher.action',
  25. params: {
  26. month: me.currentMonth
  27. },
  28. callback: function(opt, s, r) {
  29. grid.setLoading(false);
  30. var rs = Ext.decode(r.responseText);
  31. if(rs.result) {
  32. showMessage('提示', rs.result);
  33. window.location.reload();
  34. } else if(rs.exceptionInfo) {
  35. showError(rs.exceptionInfo);
  36. } else {
  37. alert('OK!');
  38. window.location.reload();
  39. }
  40. }
  41. });
  42. }
  43. }
  44. });
  45. },
  46. getCurrentMonth: function(grid, f) {
  47. var me = this;
  48. Ext.Ajax.request({
  49. url: basePath + 'fa/getMonth.action',
  50. params: {
  51. type: 'MONTH-A'
  52. },
  53. callback: function(opt, s, r) {
  54. var rs = Ext.decode(r.responseText);
  55. if(rs.data) {
  56. me.currentMonth = rs.data.PD_DETNO;
  57. me.datestart = Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Ymd');
  58. me.dateend = Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Ymd');
  59. f.setText(rs.data.PD_DETNO + ' 从' + Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Y-m-d')
  60. + ' 到 ' + Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Y-m-d'));
  61. grid.GridUtil.loadNewStore(grid, {caller: caller, condition: 'vo_yearmonth=' +
  62. me.currentMonth + ' AND vo_statuscode=\'AUDITED\''});
  63. }
  64. }
  65. });
  66. }
  67. });