MakeFeeClose.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. materialsCatecode = form.down('#materialsCatecode').value,
  22. account = form.down('#account').value,
  23. account2 = form.down('#account2').value;
  24. if (!Ext.isEmpty(makeCatecode) && !Ext.isEmpty(makeToCatecode)) {
  25. this.deal(makeCatecode, makeToCatecode, materialsCatecode, account, account2);
  26. } else {
  27. alert('请先选择制造成本科目.');
  28. }
  29. }
  30. },
  31. 'displayfield[name=yearmonth]' : {
  32. afterrender: function(f) {
  33. this.getMonth(f);
  34. }
  35. },
  36. '#makeCatecode' : {
  37. afterrender: function(f) {
  38. this.BaseUtil.getSetting('MakeFeeClose', 'makeCatecode', function(d){
  39. f.setValue(d);
  40. d && (typeof f.autoDbfind === 'function') && f.autoDbfind('form', null, 'ca_code', 'ca_code=\'' + d + '\'');
  41. });
  42. }
  43. },
  44. '#makeToCatecode' : {
  45. afterrender: function(f) {
  46. this.BaseUtil.getSetting('MakeFeeClose', 'makeToCatecode', function(d){
  47. f.setValue(d);
  48. d && (typeof f.autoDbfind === 'function') && f.autoDbfind('form', null, 'ca_code', 'ca_code=\'' + d + '\'');
  49. });
  50. }
  51. },
  52. '#materialsCatecode' : {
  53. afterrender: function(f) {
  54. this.BaseUtil.getSetting('MakeFeeClose', 'materialsCatecode', function(d){
  55. f.setValue(d);
  56. d && (typeof f.autoDbfind === 'function') && f.autoDbfind('form', null, 'ca_code', 'ca_code=\'' + d + '\'');
  57. });
  58. }
  59. }
  60. });
  61. },
  62. getForm : function(btn) {
  63. return btn.ownerCt.ownerCt;
  64. },
  65. deal : function(makeCatecode, makeToCatecode, materialsCatecode, account, account2) {
  66. if(account2 && Ext.isEmpty(materialsCatecode)){
  67. showError("请先选择材料成本差异科目.");
  68. return;
  69. }
  70. var tab = this.BaseUtil.getActiveTab();
  71. tab.setLoading(true);
  72. Ext.Ajax.request({
  73. url : basePath + 'co/cost/makeCreate.action',
  74. params : {
  75. makeCatecode : makeCatecode,
  76. makeToCatecode : makeToCatecode,
  77. materialsCatecode : materialsCatecode,
  78. account : account,
  79. account2 : account2
  80. },
  81. timeout: 120000,
  82. callback : function(opt, s, r) {
  83. tab.setLoading(false);
  84. var rs = Ext.decode(r.responseText);
  85. if(rs.data) {
  86. showMessage('提示', rs.data);
  87. } else if(rs.exceptionInfo) {
  88. showMessage('错误', rs.exceptionInfo);
  89. }
  90. }
  91. });
  92. },
  93. getMonth: function(f) {
  94. Ext.Ajax.request({
  95. url: basePath + 'fa/getMonth.action',
  96. params: {
  97. type: 'MONTH-A'
  98. },
  99. callback: function(opt, s, r) {
  100. var rs = Ext.decode(r.responseText);
  101. if(rs.data) {
  102. f.setValue(rs.data.PD_DETNO);
  103. }
  104. }
  105. });
  106. }
  107. });