| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- 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: 'month-sale',
- padding: '0 0 0 14',
- }, {
- xtype: 'profit-detail',
- padding: '0 0 0 14',
- }, {
- xtype: 'key-data',
- margin: 0
- }]
- }, {
- xtype: 'panel',
- latyout: 'responsivecolumn',
- style: {
- background: '#f4f4f4',
- },
- defaults: {
- margin: '0 16 0 0',
- userCls: 'x-home-chart big-33 small-50',
- },
- items: [{
- xtype: 'sale-trend',
- padding: '0 0 0 14',
- }, {
- xtype: 'month-io',
- padding: '0 0 0 14',
- }, {
- xtype: 'stock-amount',
- margin: 0,
- padding: '0 0 0 14',
- }]
- }],
- initComponent: function() {
- var me = this;
- this.lastTime = Ext.Date.now();
- //判断当前是否未完成新手导航
- saas.util.BaseUtil.request({
- url: '/api/commons/init/check'
- }).then(function(res) {
- if(!res.data.begin){
- saas.util.BaseUtil.openTab('sys-guide-formpanel', '新手导航', 'sys-guide-formpanel')
- }
- if(!res.data.currency){
- me.getController().setDefaultCurrency();
- }
- }).catch(function(e) {
- saas.util.BaseUtil.showErrorToast(e.message);
- })
- 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;
- }
- });
|