MakeFeeClose.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.co.cost.MakeFeeClose', {
  3. extend : 'Ext.app.Controller',
  4. FormUtil : Ext.create('erp.util.FormUtil'),
  5. BaseUtil : Ext.create('erp.util.BaseUtil'),
  6. views : [ 'co.cost.MakeFeeClose', 'core.trigger.DbfindTrigger',
  7. 'core.button.MakeFeeClose', 'core.button.Close' ],
  8. init : function() {
  9. var me = this;
  10. this.control({
  11. 'erpCloseButton' : {
  12. click : function(btn) {
  13. me.FormUtil.onClose();
  14. }
  15. },
  16. 'erpMakeFeeCloseButton' : {
  17. click : function(btn) {
  18. var form = btn.ownerCt.ownerCt,
  19. makeCatecode = form.down('#makeCatecode').value,
  20. makeToCatecode = form.down('#makeToCatecode').value,
  21. account = form.down('#account').value;
  22. if (!Ext.isEmpty(makeCatecode) && !Ext.isEmpty(makeToCatecode)) {
  23. this.deal(makeCatecode, makeToCatecode, account);
  24. } else {
  25. alert('请先选择制造成本科目.');
  26. }
  27. }
  28. },
  29. 'displayfield[name=yearmonth]' : {
  30. afterrender: function(f) {
  31. this.getMonth(f);
  32. }
  33. },
  34. '#makeCatecode' : {
  35. afterrender: function(f) {
  36. this.getSetting('MakeCatecode', function(d){
  37. f.setValue(d);
  38. (typeof f.autoDbfind === 'function') && f.autoDbfind('form', null, 'ca_code', 'ca_code=\'' + d + '\'');
  39. });
  40. }
  41. },
  42. '#makeToCatecode' : {
  43. afterrender: function(f) {
  44. this.getSetting('MakeToCatecode', function(d){
  45. f.setValue(d);
  46. (typeof f.autoDbfind === 'function') && f.autoDbfind('form', null, 'ca_code', 'ca_code=\'' + d + '\'');
  47. });
  48. }
  49. }
  50. });
  51. },
  52. getForm : function(btn) {
  53. return btn.ownerCt.ownerCt;
  54. },
  55. deal : function(makeCatecode, makeToCatecode, account) {
  56. var tab = this.BaseUtil.getActiveTab();
  57. tab.setLoading(true);
  58. Ext.Ajax.request({
  59. url : basePath + 'co/cost/makeCreate.action',
  60. params : {
  61. makeCatecode : makeCatecode,
  62. makeToCatecode : makeToCatecode,
  63. account : account
  64. },
  65. timeout: 120000,
  66. callback : function(opt, s, r) {
  67. tab.setLoading(false);
  68. var rs = Ext.decode(r.responseText);
  69. if(rs.data) {
  70. showMessage('提示', rs.data);
  71. } else if(rs.exceptionInfo) {
  72. showMessage('错误', rs.exceptionInfo);
  73. }
  74. }
  75. });
  76. },
  77. getMonth: function(f) {
  78. Ext.Ajax.request({
  79. url: basePath + 'fa/getMonth.action',
  80. params: {
  81. type: 'MONTH-A'
  82. },
  83. callback: function(opt, s, r) {
  84. var rs = Ext.decode(r.responseText);
  85. if(rs.data) {
  86. f.setValue(rs.data.PD_DETNO);
  87. }
  88. }
  89. });
  90. },
  91. getSetting: function(code, fn) {
  92. Ext.Ajax.request({
  93. url : basePath + 'common/getFieldData.action',
  94. params: {
  95. caller: 'Setting',
  96. field: 'se_value',
  97. condition: 'se_what=\'' + code + '\''
  98. },
  99. method : 'post',
  100. callback : function(opt, s, res){
  101. var r = new Ext.decode(res.responseText);
  102. if(r.exceptionInfo){
  103. showError(r.exceptionInfo);return;
  104. } else if(r.success && r.data){
  105. fn.call(null, r.data);
  106. }
  107. }
  108. });
  109. }
  110. });