DealList.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.defaultCondition = cond;
  22. grid.getCount(null, cond);
  23. }
  24. },
  25. 'erpBatchDealFormPanel': {
  26. afterrender: function(f) {
  27. f.down('button[name=query]').handler = Ext.emptyFn;
  28. f.down('button[name=export]').handler = function(btn){
  29. var grid = Ext.getCmp('grid');
  30. var condition = f.getCondition(grid);
  31. if(Ext.isEmpty(condition)) {
  32. condition = '1=1';
  33. }
  34. grid.BaseUtil.createExcel(caller, 'datalist', condition);
  35. };
  36. }
  37. },
  38. 'erpVastDealButton': {
  39. click: function(btn) {
  40. var currentMonth = btn.ownerCt.ownerCt.down('monthdatefield').value;
  41. if (!currentMonth) {
  42. showError('期间不能为空!');
  43. return
  44. } else {
  45. me.getGrid().setLoading(true);
  46. Ext.Ajax.request({
  47. url: basePath + 'scm/product/RefreshProdMonthNew.action',
  48. method: 'post',
  49. params: {
  50. currentMonth: currentMonth
  51. },
  52. timeout: 1200000,
  53. callback: function(options, success, response) {
  54. me.getGrid().setLoading(false);
  55. var res = new Ext.decode(response.responseText);
  56. if (res.exceptionInfo != null) {
  57. showError(res.exceptionInfo);
  58. return;
  59. }
  60. Ext.Msg.alert("提示", "刷新成功!",
  61. function() {
  62. Ext.getCmp('query').handler();
  63. });
  64. }
  65. });
  66. }
  67. }
  68. },
  69. 'monthdatefield': {
  70. afterrender: function(f) {
  71. var type = '', con = null;
  72. if(f.name == 'pwm_yearmonth' && (caller == 'Productwhmonth!subject' || caller == 'Productwhmonth!SubjectWarehouse' || caller=='Productwhmonth!warehouse')) {
  73. type = 'MONTH-P';
  74. con = Ext.getCmp('condatefield');
  75. }
  76. if(type != '') {
  77. this.getCurrentMonth(f, type, con);
  78. }
  79. }
  80. }
  81. });
  82. },
  83. getCurrentMonth: function(f, type, con) {
  84. Ext.Ajax.request({
  85. url: basePath + 'fa/getMonth.action',
  86. params: {
  87. type: type
  88. },
  89. callback: function(opt, s, r) {
  90. var rs = Ext.decode(r.responseText);
  91. if(rs.data) {
  92. f.setValue(rs.data.PD_DETNO);
  93. if(con != null) {
  94. con.setMonthValue(rs.data.PD_DETNO);
  95. }
  96. }
  97. }
  98. });
  99. },
  100. });