MonthAccount.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.fix.MonthAccount', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views: ['fa.fix.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.getAccount(btn.ownerCt.ownerCt);
  13. }
  14. },
  15. '#info_ym': {
  16. afterrender: function(f) {
  17. this.getCurrentMonth(f);
  18. }
  19. },
  20. 'checkbox[id=chkbalance]': {
  21. change: function(f) {
  22. me.filterBalance();
  23. }
  24. }
  25. });
  26. },
  27. getAccount: function(form) {
  28. var me = this, grid = form.ownerCt.down('gridpanel');
  29. grid.setLoading(true);
  30. Ext.Ajax.request({
  31. url: basePath + 'fa/fix/monthAccount.action',
  32. params: {
  33. condition: Ext.encode({chkun: form.down('#chkun').value})
  34. },
  35. callback: function(opt, s, r) {
  36. grid.setLoading(false);
  37. var rs = Ext.decode(r.responseText);
  38. if(rs.success) {
  39. grid.store.loadData(rs.data);
  40. me.filterBalance();
  41. } else if(rs.exceptionInfo) {
  42. showError(rs.exceptionInfo);
  43. }
  44. }
  45. });
  46. },
  47. getCurrentMonth: function(f) {
  48. var me = this;
  49. Ext.Ajax.request({
  50. url: basePath + 'fa/getMonth.action',
  51. params: {
  52. type: 'MONTH-F'
  53. },
  54. callback: function(opt, s, r) {
  55. var rs = Ext.decode(r.responseText);
  56. if(rs.data) {
  57. me.currentMonth = rs.data.PD_DETNO;
  58. f.setValue(rs.data.PD_DETNO);
  59. }
  60. }
  61. });
  62. },
  63. /**
  64. * 显示客户明细;
  65. * 只显示有差额科目
  66. */
  67. filterBalance: function() {
  68. var chkbalance = Ext.getCmp('chkbalance');
  69. var grid = chkbalance.ownerCt.ownerCt.down('gridpanel');
  70. grid.store.filterBy(function(item) {
  71. return chkbalance.value ? item.get('enddiff') != 0 : true;
  72. });
  73. }
  74. });