MonthAccount.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.MonthAccount', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views: ['scm.reserve.MonthAccount'],
  6. init:function(){
  7. var me = this;
  8. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  9. this.control({
  10. 'button[id=query]': {
  11. click: function(btn) {
  12. me.getArAccount(btn.ownerCt.ownerCt);
  13. }
  14. },
  15. 'grid': {
  16. itemclick: function(selModel, record) {
  17. me.loadDetail(selModel.ownerCt.store, record);
  18. }
  19. },
  20. 'checkbox[id=chkun]': {
  21. change: function(f) {
  22. me.getArAccount(f.ownerCt);
  23. }
  24. },
  25. 'checkbox[id=chkbalance]': {
  26. change: function(f) {
  27. me.filterBalance();
  28. }
  29. },
  30. '#info_ym': {
  31. afterrender: function(f) {
  32. this.getCurrentMonth(f);
  33. }
  34. }
  35. });
  36. },
  37. loadDetail:function(store, record){
  38. var ym = record.get('cm_yearmonth'),
  39. catecode = record.get('cm_catecode');
  40. this.BaseUtil.onAdd('MADetail_' + ym + '_' + catecode, '明细',
  41. 'jsps/scm/reserve/monthAccountDetail.jsp?y=' + ym + '&c=' + catecode);
  42. },
  43. getArAccount: function(form) {
  44. var me = this;
  45. Ext.Ajax.request({
  46. url: basePath + 'scm/reserve/monthAccount.action',
  47. params: {
  48. condition: Ext.encode({chkun: form.down('#chkun').value})
  49. },
  50. callback: function(opt, s, r) {
  51. var rs = Ext.decode(r.responseText);
  52. if(rs.success) {
  53. var grid = form.ownerCt.down('gridpanel');
  54. grid.store.loadData(rs.data);
  55. me.filterBalance();
  56. } else if(rs.exceptionInfo) {
  57. showError(rs.exceptionInfo);
  58. }
  59. }
  60. });
  61. },
  62. /**
  63. * 显示客户明细;
  64. * 只显示有差额科目
  65. */
  66. filterBalance: function() {
  67. var chkbalance = Ext.getCmp('chkbalance');
  68. var grid = chkbalance.ownerCt.ownerCt.down('gridpanel');
  69. grid.store.filterBy(function(item) {
  70. var bool = true;
  71. if(bool && chkbalance.value) {
  72. bool = item.get('endbalance') != 0;
  73. }
  74. return bool;
  75. });
  76. },
  77. getCurrentMonth: function(f) {
  78. var me = this;
  79. Ext.Ajax.request({
  80. url: basePath + 'fa/getMonth.action',
  81. params: {
  82. type: 'MONTH-P'
  83. },
  84. callback: function(opt, s, r) {
  85. var rs = Ext.decode(r.responseText);
  86. if(rs.data) {
  87. me.currentMonth = rs.data.PD_DETNO;
  88. f.setValue(rs.data.PD_DETNO);
  89. }
  90. }
  91. });
  92. }
  93. });