FeeAccount.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.fee.FeeAccount', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'oa.fee.FeeAccountForm','oa.fee.FeeAccount',
  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. console.log(Ext.getCmp('date').value);
  41. me.beforestartAccount(Ext.getCmp('date').value,function(data){
  42. if(data.exceptionInfo){
  43. console.log();
  44. warnMsg("当前期间还存在已提交、在录入的单据,系统统会将这部分单据的日期变更为下个月1号,确定结转么?", function(btn){
  45. if(btn == 'yes'){
  46. me.Account();
  47. }else{
  48. return;
  49. }
  50. });
  51. }else{
  52. me.Account();
  53. }
  54. });
  55. },
  56. beforestartAccount: function(f,callback) {
  57. var me = this;
  58. me.FormUtil.setLoading(true);
  59. Ext.Ajax.request({
  60. url: basePath + 'oa/fee/beforestartFeeAccount.action',
  61. method: 'post',
  62. params:{
  63. date:f
  64. },
  65. callback: function(opt, s, r) {
  66. me.FormUtil.setLoading(false);
  67. console.log(r);
  68. console.log(r.responseText);
  69. var rs = Ext.decode(r.responseText);
  70. callback.call(null,rs);
  71. }
  72. });
  73. },
  74. Account:function(){
  75. var me = this;
  76. me.FormUtil.setLoading(true);
  77. Ext.Ajax.request({
  78. url : basePath + "oa/fee/startFeeAccount.action",
  79. params:{
  80. date:Ext.getCmp('date').value
  81. },
  82. timeout: 120000,
  83. method:'post',
  84. callback:function(options,success,response){
  85. console.log(response);
  86. console.log(response.responseText);
  87. me.FormUtil.setLoading(false);
  88. var localJson = new Ext.decode(response.responseText);
  89. console.log(response);
  90. console.log(response.responseText);
  91. if(localJson.success){
  92. endArSuccess(function(){
  93. window.location.reload();
  94. });
  95. } else {
  96. if(localJson.exceptionInfo){
  97. var str = localJson.exceptionInfo;
  98. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){// 特殊情况:操作成功,但是出现警告,允许刷新页面
  99. str = str.replace('AFTERSUCCESS', '');
  100. showMessage('提示', str);
  101. window.location.reload();
  102. } else {
  103. showError(str);return;
  104. }
  105. }
  106. }
  107. }
  108. });
  109. },
  110. overAccount: function(){
  111. var me = this;
  112. me.FormUtil.setLoading(true);
  113. Ext.Ajax.request({
  114. url : basePath + "fa/ars/overAccount.action",
  115. params:{
  116. param:{date:Ext.getCmp('date').value},
  117. },
  118. method:'post',
  119. callback:function(options,success,response){
  120. me.FormUtil.setLoading(false);
  121. var localJson = new Ext.decode(response.responseText);
  122. if(localJson.success){
  123. unEndArSuccess(function(){
  124. window.location.reload();
  125. });
  126. } else {
  127. if(localJson.exceptionInfo){
  128. var str = localJson.exceptionInfo;
  129. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){// 特殊情况:操作成功,但是出现警告,允许刷新页面
  130. str = str.replace('AFTERSUCCESS', '');
  131. showMessage('提示', str);
  132. window.location.reload();
  133. } else {
  134. showError(str);return;
  135. }
  136. }
  137. }
  138. }
  139. });
  140. },
  141. getCurrentYearmonth: function(f) {
  142. Ext.Ajax.request({
  143. url: basePath + 'oa/fee/getCurrentYearmonth.action',
  144. method: 'GET',
  145. callback: function(opt, s, r) {
  146. var rs = Ext.decode(r.responseText);
  147. if(rs.exceptionInfo) {
  148. showError(rs.exceptionInfo);
  149. } else if(rs.data) {
  150. f.setValue(rs.data);
  151. }
  152. }
  153. });
  154. }
  155. });