MonthAccountOver.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.ars.MonthAccountOver', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'fa.ars.MonthAccountOver',
  8. 'core.button.OverAccount','core.button.Close','core.form.MonthDateField','core.button.StartAccount'
  9. ] ,
  10. init:function(){
  11. var me = this;
  12. this.control({
  13. 'erpCloseButton': {
  14. click: function(btn){
  15. me.FormUtil.onClose();
  16. }
  17. },
  18. 'erpStartAccountButton': {
  19. click: function(btn){
  20. this.startAccount();
  21. }
  22. },
  23. 'erpOverAccountButton': {
  24. click: function(btn){
  25. this.overAccount();
  26. }
  27. },
  28. 'monthdatefield': {
  29. afterrender: function(f) {
  30. me.getCurrentYearmonth(f);
  31. }
  32. }
  33. });
  34. },
  35. getForm: function(btn){
  36. return btn.ownerCt.ownerCt;
  37. },
  38. startAccount: function(){
  39. var me = this;
  40. me.FormUtil.setLoading(true);
  41. Ext.Ajax.request({
  42. url : basePath + "fa/ars/startAccount.action",
  43. params:{
  44. param:{date:Ext.getCmp('date').value}
  45. },
  46. timeout: 120000,
  47. method:'post',
  48. callback:function(options,success,response){
  49. me.FormUtil.setLoading(false);
  50. var localJson = new Ext.decode(response.responseText);
  51. if(localJson.success){
  52. Ext.Msg.alert("提示","操作成功!");
  53. window.location.reload();
  54. } else {
  55. if(localJson.exceptionInfo){
  56. var str = localJson.exceptionInfo;
  57. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  58. str = str.replace('AFTERSUCCESS', '');
  59. showMessage('提示', str);
  60. window.location.reload();
  61. } else {
  62. showError(str);return;
  63. }
  64. }
  65. }
  66. }
  67. });
  68. },
  69. overAccount: function(){
  70. var me = this;
  71. me.FormUtil.setLoading(true);
  72. Ext.Ajax.request({
  73. url : basePath + "fa/ars/overAccount.action",
  74. params:{
  75. param:{date:Ext.getCmp('date').value}
  76. },
  77. method:'post',
  78. callback:function(options,success,response){
  79. me.FormUtil.setLoading(false);
  80. var localJson = new Ext.decode(response.responseText);
  81. if(localJson.success){
  82. Ext.Msg.alert("提示","操作成功!");
  83. window.location.reload();
  84. } else {
  85. if(localJson.exceptionInfo){
  86. var str = localJson.exceptionInfo;
  87. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  88. str = str.replace('AFTERSUCCESS', '');
  89. showMessage('提示', str);
  90. window.location.reload();
  91. } else {
  92. showError(str);return;
  93. }
  94. }
  95. }
  96. }
  97. });
  98. },
  99. getCurrentYearmonth: function(f) {
  100. Ext.Ajax.request({
  101. url: basePath + 'fa/ars/getCurrentYearmonth.action',
  102. method: 'GET',
  103. callback: function(opt, s, r) {
  104. var rs = Ext.decode(r.responseText);
  105. if(rs.exceptionInfo) {
  106. showError(rs.exceptionInfo);
  107. } else if(rs.data) {
  108. f.setValue(rs.data);
  109. }
  110. }
  111. });
  112. }
  113. });