AccountProject.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.plm.cost.AccountProject', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'plm.cost.AccountProject',
  8. 'core.button.Close','core.form.MonthDateField','core.button.BOMCost'
  9. ] ,
  10. init:function(){
  11. var me = this;
  12. this.control({
  13. 'erpCloseButton': {
  14. click: function(btn){
  15. me.FormUtil.onClose();
  16. }
  17. },
  18. 'erpBOMCostButton': {
  19. click: function(btn){
  20. this.startAccount();
  21. }
  22. },
  23. 'monthdatefield': {
  24. afterrender: function(f) {
  25. this.getCurrentMonth(f, "MONTH-O");
  26. }
  27. }
  28. });
  29. },
  30. getForm: function(btn){
  31. return btn.ownerCt.ownerCt;
  32. },
  33. startAccount: function(){
  34. var me = this;
  35. me.FormUtil.setLoading(true);
  36. Ext.Ajax.request({
  37. url : basePath + "plm/project/startAccount.action",
  38. params:{
  39. param:{date:Ext.getCmp('date').value}
  40. },
  41. timeout: 120000,
  42. method:'post',
  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. getCurrentMonth: function(f, type) {
  65. Ext.Ajax.request({
  66. url: basePath + 'fa/getMonth.action',
  67. params: {
  68. type: type
  69. },
  70. callback: function(opt, s, r) {
  71. var rs = Ext.decode(r.responseText);
  72. if(rs.data) {
  73. f.setValue(rs.data.PD_DETNO);
  74. }
  75. }
  76. });
  77. }
  78. });