123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- Ext.define('saas.view.home.Home', {
- extend: 'Ext.container.Container',
- xtype: 'home',
- id: 'home',
- requires: [
- 'Ext.layout.container.Border',
- 'Ext.ux.layout.ResponsiveColumn'
- ],
- controller: 'home',
- viewModel: {
- type: 'home'
- },
- cls: 'x-home-panel',
- padding: '0 16 0 0',
- layout: 'responsivecolumn',
- scrollable: true,
- REFRESH_INTERVALS: 5 * 60 * 1000, // 刷新间隔
- defaults: {
- shadow: true,
- cls: 'x-home-box',
- userCls: 'big-100 small-100',
- },
- items: [{
- style: {
- marginRight: '0',
- },
- xtype: 'infocard'
- }, {
- xtype: 'panel',
- style: {
- background: '#f4f4f4',
- },
- latyout: 'responsivecolumn',
- defaults: {
- margin: '0 16 0 0',
- userCls: 'x-home-chart big-33 small-50',
- },
- items: []
- }, {
- xtype: 'panel',
- latyout: 'responsivecolumn',
- style: {
- background: '#f4f4f4',
- },
- defaults: {
- margin: '0 16 0 0',
- userCls: 'x-home-chart big-33 small-50',
- },
- items: []
- }],
- initComponent: function() {
- this.lastTime = Ext.Date.now();
- this.callParent(arguments);
- },
- listeners: {
- onTabActivate: function(p) {
- p.refreshId = window.setInterval((p.refreshStores.bind(p)()).bind(p), p.REFRESH_INTERVALS);
- },
- onTabDeactivate: function(p) {
- p.lastTime = 0;
- window.clearInterval(p.refreshId);
- }
- },
- refreshStores: function() {
- var me = this,
- lastTime = me.lastTime || 0,
- now = Ext.Date.now(),
- viewModel = me.getViewModel(),
- stores = viewModel.storeInfo;
- if(now - lastTime > me.REFRESH_INTERVALS) {
- for(var key in stores) {
- var store = stores[key];
- store.load();
- }
- me.lastTime = Ext.Date.now();
- }
- return me.refreshStores;
- }
- });
|