DealList.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.DealList', {
  3. extend : 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views : [ 'common.deallist.Viewport', 'common.datalist.GridPanel', 'common.batchDeal.Form', 'core.trigger.DbfindTrigger',
  6. 'core.form.FtField', 'core.form.ConDateField', 'core.form.YnField', 'core.form.FtDateField','common.datalist.Toolbar',
  7. 'core.form.MonthDateField','core.form.FtFindField', 'core.grid.YnColumn', 'core.grid.TfColumn',
  8. 'core.form.ConMonthDateField','core.button.Refresh' ],
  9. refs : [ {
  10. ref : 'grid',
  11. selector : '#grid'
  12. } ],
  13. init : function() {
  14. var me = this;
  15. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  16. this.control({
  17. 'erpBatchDealFormPanel button[id=query]' : {
  18. click : function(btn) {
  19. var grid = Ext.getCmp('grid');
  20. var form = btn.ownerCt.ownerCt, cond = form.getCondition(grid);
  21. grid.formCondition = cond;
  22. grid.getCount(null, null);
  23. }
  24. },
  25. 'erpBatchDealFormPanel': {
  26. alladded : function(form) {
  27. var items = form.items.items;
  28. Ext.each(items, function() {
  29. var val = getUrlParam(this.name);
  30. if(!Ext.isEmpty(val)) {
  31. this.setValue(val);
  32. if(this.xtype == 'dbfindtrigger') {
  33. this.autoDbfind('form', caller, this.name, this.name + " like '%" + val + "%'");
  34. }
  35. }
  36. });
  37. },
  38. afterrender: function(f) {
  39. f.down('button[name=query]').handler = Ext.emptyFn;
  40. f.down('button[name=export]').handler = function(btn){
  41. var grid = Ext.getCmp('grid');
  42. var condition = f.getCondition(grid);
  43. if(Ext.isEmpty(condition)) {
  44. condition = '1=1';
  45. }
  46. grid.BaseUtil.createExcel(caller, 'datalist', condition, null, null, null, grid);
  47. };
  48. }
  49. },
  50. 'erpVastDealButton': {
  51. click: function(btn) {
  52. if(caller == 'FeatureView!Query'){
  53. var ftcode = Ext.getCmp('ft_code').value;
  54. if (Ext.isEmpty(ftcode)) {
  55. showError('模版编号不能为空!');
  56. return
  57. } else {
  58. me.getGrid().setLoading(true);
  59. Ext.Ajax.request({
  60. url: basePath + 'pm/make/refreshFeatureView.action',
  61. method: 'post',
  62. params: {
  63. ftcode: ftcode
  64. },
  65. timeout: 1200000,
  66. callback: function(options, success, response) {
  67. me.getGrid().setLoading(false);
  68. var res = new Ext.decode(response.responseText);
  69. if (res.exceptionInfo != null) {
  70. showError(res.exceptionInfo);
  71. return;
  72. }
  73. Ext.Msg.alert("提示", "刷新成功!", function() {
  74. var queryBtn = Ext.getCmp('query');
  75. queryBtn.fireEvent('click', queryBtn, queryBtn);
  76. });
  77. }
  78. });
  79. }
  80. } else if(caller == 'FeatureView!Prod!Query'){
  81. var ftcode = Ext.getCmp('ft_code').value;
  82. if (Ext.isEmpty(ftcode)) {
  83. showError('模版编号不能为空!');
  84. return
  85. } else {
  86. me.getGrid().setLoading(true);
  87. Ext.Ajax.request({
  88. url: basePath + 'pm/make/refreshFeatureViewProd.action',
  89. method: 'post',
  90. params: {
  91. ftcode: ftcode
  92. },
  93. timeout: 1200000,
  94. callback: function(options, success, response) {
  95. me.getGrid().setLoading(false);
  96. var res = new Ext.decode(response.responseText);
  97. if (res.exceptionInfo != null) {
  98. showError(res.exceptionInfo);
  99. return;
  100. }
  101. Ext.Msg.alert("提示", "刷新成功!", function() {
  102. var queryBtn = Ext.getCmp('query');
  103. queryBtn.fireEvent('click', queryBtn, queryBtn);
  104. });
  105. }
  106. });
  107. }
  108. } else {
  109. var currentMonth = btn.ownerCt.ownerCt.down('monthdatefield').value;
  110. if (!currentMonth) {
  111. showError('期间不能为空!');
  112. return
  113. } else {
  114. me.getGrid().setLoading(true);
  115. Ext.Ajax.request({
  116. url: basePath + 'scm/product/RefreshProdMonthNew.action',
  117. method: 'post',
  118. params: {
  119. currentMonth: currentMonth
  120. },
  121. timeout: 1200000,
  122. callback: function(options, success, response) {
  123. me.getGrid().setLoading(false);
  124. var res = new Ext.decode(response.responseText);
  125. if (res.exceptionInfo != null) {
  126. showError(res.exceptionInfo);
  127. return;
  128. }
  129. Ext.Msg.alert("提示", "刷新成功!", function() {
  130. var queryBtn = Ext.getCmp('query');
  131. queryBtn.fireEvent('click', queryBtn, queryBtn);
  132. });
  133. }
  134. });
  135. }
  136. }
  137. }
  138. },
  139. 'monthdatefield': {
  140. afterrender: function(f) {
  141. var type = '', con = null;
  142. if(f.name == 'pwm_yearmonth' && (caller == 'Productwhmonth!subject' || caller == 'Productwhmonth!SubjectWarehouse' || caller=='Productwhmonth!warehouse')) {
  143. type = 'MONTH-P';
  144. con = Ext.getCmp('condatefield');
  145. }
  146. if(type != '') {
  147. this.getCurrentMonth(f, type, con);
  148. }
  149. }
  150. }
  151. });
  152. },
  153. getCurrentMonth: function(f, type, con) {
  154. Ext.Ajax.request({
  155. url: basePath + 'fa/getMonth.action',
  156. params: {
  157. type: type
  158. },
  159. callback: function(opt, s, r) {
  160. var rs = Ext.decode(r.responseText);
  161. if(rs.data) {
  162. f.setValue(rs.data.PD_DETNO);
  163. if(con != null) {
  164. con.setMonthValue(rs.data.PD_DETNO);
  165. }
  166. }
  167. }
  168. });
  169. }
  170. });