| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- Ext.define('saas.view.home.Home', {
- extend: 'Ext.container.Container',
- xtype: 'home',
- id: 'home',
- requires: [
- 'Ext.slider.Single',
- 'Ext.form.field.Display',
- 'Ext.layout.container.Border',
- 'Ext.ux.layout.ResponsiveColumn'
- ],
- controller: 'home',
- viewModel: {
- type: 'home'
- },
- cls: 'x-home-panel',
- 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: {
- marginRight: '0',
- },
- // title: '2018年11月经营分析',
- latyout: 'responsivecolumn',
- defaults: {
- margin: '0 0 0 14',
- userCls: 'big-33 small-50',
- },
- items: [{
- xtype: 'month-sale',
- }, {
- xtype: 'month-purchase',
- }, {
- xtype: 'key-data',
- }]
- }, {
- xtype: 'panel',
- // title: '2018年11月经营分析',
- latyout: 'responsivecolumn',
- style: {
- marginRight: '0',
- marginBottom: '0'
- },
- defaults: {
- margin: '0 0 0 14',
- userCls: 'big-33 small-50',
- },
- items: [{
- xtype: 'month-io',
- }, {
- xtype: 'sale-trend',
- }, {
- // xtype: 'purchase-trend'
- // }, {
- xtype: 'stock-amount'
- }]
- }],
- 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;
- }
- });
|