InitStep.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.InitStep', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views: ['common.init.InitStep'],
  6. init: function(){
  7. var me = this;
  8. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  9. this.control({
  10. 'button[name=prev]': {
  11. click: function(btn){
  12. var bt = parent.Ext.ComponentQuery.query('button[step=3]')[0];
  13. bt.fireEvent('click', bt);
  14. }
  15. },
  16. 'button[name=next]': {
  17. click: function(btn){
  18. var bt = parent.Ext.ComponentQuery.query('button[step=5]')[0];
  19. bt.fireEvent('click', bt);
  20. }
  21. },
  22. 'button[name=refresh]': {
  23. click: function(btn){
  24. var grids = btn.ownerCt.ownerCt.query('grid');
  25. Ext.each(grids, function(){
  26. me.getDataCount(this.store);
  27. });
  28. }
  29. },
  30. 'grid': {
  31. afterrender: function(g) {
  32. setTimeout(function(){
  33. me.getDataCount(g.store);
  34. }, 1000);
  35. }
  36. }
  37. });
  38. },
  39. getDataCount: function(store, idx) {
  40. idx = idx || 0;
  41. var me = this, record = store.getAt(idx);
  42. if( !record ) return;
  43. if(!Ext.isEmpty(record.get('table'))) {
  44. record.set('count', 'loading');
  45. Ext.Ajax.request({
  46. url: basePath + 'ma/guide/count.action',
  47. params: {
  48. t : record.get('table'),
  49. c : record.get('cond')
  50. },
  51. callback: function(o, s, r) {
  52. me.getDataCount(store, ++idx);
  53. if( s ) {
  54. var e = r.responseText;
  55. if ( /^-?[0-9]+(.[0-9]+)?/.test(e) ) {
  56. record.set('count', e);
  57. }
  58. }
  59. }
  60. });
  61. } else {
  62. me.getDataCount(store, ++idx);
  63. }
  64. }
  65. });