AutoDepreciation.js 2.2 KB

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