YearCarryover.js 2.2 KB

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