MonthCarryrestore.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.fix.MonthCarryrestore', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'fa.fix.MonthCarryrestoreForm','fa.fix.MonthCarryrestore',
  8. 'core.button.ResCarryover','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. 'erpResCarryoverButton': {
  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/confirmMonthCarryrestore.action",
  38. params:{
  39. date: Ext.getCmp('date').value
  40. },
  41. method:'post',
  42. callback:function(options,success,response){
  43. me.FormUtil.setLoading(false);
  44. var localJson = new Ext.decode(response.responseText);
  45. if(localJson.success){
  46. Ext.Msg.alert("提示","操作成功!");
  47. window.location.reload();
  48. } else {
  49. if(localJson.exceptionInfo){
  50. var str = localJson.exceptionInfo;
  51. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  52. str = str.replace('AFTERSUCCESS', '');
  53. showError(str);
  54. window.location.reload();
  55. } else {
  56. showError(str);return;
  57. }
  58. }
  59. }
  60. }
  61. });
  62. },
  63. getCurrentYearmonth: function(f) {
  64. Ext.Ajax.request({
  65. url: basePath + 'fa/fix/getCurrentYearmonth.action',
  66. method: 'GET',
  67. callback: function(opt, s, r) {
  68. var rs = Ext.decode(r.responseText);
  69. if(rs.exceptionInfo) {
  70. showError(rs.exceptionInfo);
  71. } else if(rs.data) {
  72. f.setValue(rs.data);
  73. }
  74. }
  75. });
  76. }
  77. });