MonthCarryover.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.fix.MonthCarryover', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'fa.fix.MonthCarryoverForm','fa.fix.MonthCarryover',
  8. 'core.button.Carryover','core.button.Close','core.form.MonthDateField'
  9. ] ,
  10. init:function(){
  11. var me = this;
  12. this.control({
  13. 'erpCloseButton': {
  14. click: function(btn){
  15. me.FormUtil.onClose();
  16. }
  17. },
  18. 'erpCarryoverButton': {
  19. click: function(btn){
  20. this.confirm();
  21. }
  22. },
  23. 'monthdatefield': {
  24. afterrender: function(f) {
  25. me.getCurrentYearmonth(f);
  26. }
  27. }
  28. });
  29. },
  30. getForm: function(btn){
  31. return btn.ownerCt.ownerCt;
  32. },
  33. confirm: function(){
  34. var me = this;
  35. me.FormUtil.setLoading(true);
  36. Ext.Ajax.request({
  37. url : basePath + "fa/fix/confirmMonthCarryover.action",
  38. params:{
  39. date: Ext.getCmp('date').value
  40. },
  41. method:'post',
  42. timeout: 60000,
  43. callback:function(options,success,response){
  44. me.FormUtil.setLoading(false);
  45. var localJson = new Ext.decode(response.responseText);
  46. if(localJson.success){
  47. Ext.Msg.alert("提示","操作成功!");
  48. window.location.reload();
  49. } else {
  50. if(localJson.exceptionInfo){
  51. var str = localJson.exceptionInfo;
  52. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  53. str = str.replace('AFTERSUCCESS', '');
  54. showMessage('提示', str);
  55. window.location.reload();
  56. } else {
  57. showError(str);return;
  58. }
  59. }
  60. }
  61. }
  62. });
  63. },
  64. getCurrentYearmonth: function(f) {
  65. Ext.Ajax.request({
  66. url: basePath + 'fa/fix/getCurrentYearmonth.action',
  67. method: 'GET',
  68. callback: function(opt, s, r) {
  69. var rs = Ext.decode(r.responseText);
  70. if(rs.exceptionInfo) {
  71. showError(rs.exceptionInfo);
  72. } else if(rs.data) {
  73. f.setValue(rs.data);
  74. }
  75. }
  76. });
  77. }
  78. });