Ext.define('saas.view.home.HomeModel', { extend: 'Ext.app.ViewModel', alias: 'viewmodel.home', data: { month_sale_amount: '0', // 本月销售合计 month_purchase_amount: '0', // 本月采购合计 month_in: '0', // 本月收入合计 month_out: '0', // 本月支出合计 insetPadding: '12 0 0 0', // 图表insetPadding maxBarWidth: 25, // 最大柱宽 }, stores: { infoData: { model: 'saas.model.home.Info', autoLoad: true, proxy: { type: 'ajax', // url: 'http://192.168.253.58:8920/homePage/liveData', url: '/api/commons/homePage/liveData', timeout: 8000, actionMethods: { read: 'GET' }, reader: { type: 'json' }, listeners: { exception: function(proxy, response, operation, eOpts) { Ext.getCmp('infocard').setLoading(false); } } }, listeners: { beforeload: function() { Ext.getCmp('infocard').setLoading(true); }, load: function(s, d) { Ext.getCmp('infocard').setLoading(false); if(!d) return; var res = d[0].data.data || {}; Ext.getCmp('infocard').addCardItems(res); } } }, month_sale: { model: 'saas.model.chart.DataXY', autoLoad: true, proxy: { type: 'ajax', // url: 'http://192.168.253.58:8920/homePage/saleData', url: '/api/commons/homePage/saleData', timeout: 8000, actionMethods: { read: 'GET' }, reader: { type: 'json', rootProperty: 'data', }, listeners: { exception: function(proxy, response, operation, eOpts) { Ext.getCmp('month_sale').setLoading(false); } } }, listeners: { beforeload: function() { Ext.getCmp('month_sale').setLoading(true); }, load: function(s, d) { Ext.getCmp('month_sale').setLoading(false); var sum = Ext.util.Format.number(s.sum('y'), '0.00') || 0; Ext.getCmp('home').getViewModel().set('month_sale_amount', sum) } } }, month_purchase: { model: 'saas.model.chart.DataXY', autoLoad: true, proxy: { type: 'ajax', // url: 'http://192.168.253.58:8920/homePage/purchaseData?sixMonths=false', url: '/api/commons/homePage/purchaseData?sixMonths=false', timeout: 8000, actionMethods: { read: 'GET' }, reader: { type: 'json', rootProperty: 'data', }, listeners: { exception: function(proxy, response, operation, eOpts) { Ext.getCmp('month-purchase').setLoading(false); } } }, listeners: { beforeload: function() { Ext.getCmp('month-purchase').setLoading(true); }, load: function(s, d) { Ext.getCmp('month-purchase').setLoading(false); var sum = Ext.util.Format.number(s.sum('y'), '0.00') || 0; Ext.getCmp('home').getViewModel().set('month_purchase_amount', sum+'') } } }, month_io: { fields: ['x', 'main', 'other'], autoLoad: true, proxy: { type: 'ajax', // url: 'http://192.168.253.58:8920/homePage/payAndRecData', url: '/api/commons/homePage/payAndRecData', timeout: 8000, actionMethods: { read: 'GET' }, reader: { type: 'json', rootProperty: 'data', }, listeners: { exception: function(proxy, response, operation, eOpts) { Ext.getCmp('month_io').setLoading(false); } } }, listeners: { beforeload: function() { Ext.getCmp('month_io').setLoading(true); }, load: function(s, d) { Ext.getCmp('month_io').setLoading(false); s.each(function(r) { var sum = Ext.util.Format.number(r.get('main') + r.get('other'), '0.00') || 0; if(r.get('x') == '收入') { Ext.getCmp('home').getViewModel().set('month_in', sum); }else if(r.get('x') == '支出') { Ext.getCmp('home').getViewModel().set('month_out', sum); } }); } } }, sale_trend: { fields: ['x', 'sale', 'saleback'], autoLoad: true, proxy: { type: 'ajax', // url: 'http://192.168.253.58:8920/homePage/saleFutureData', url: '/api/commons/homePage/saleFutureData', timeout: 8000, actionMethods: { read: 'GET' }, reader: { type: 'json', rootProperty: 'data', }, listeners: { exception: function(proxy, response, operation, eOpts) { Ext.getCmp('sale_trend').setLoading(false); } } }, sorters: [ { property: 'x', direction: 'ASC' } ], listeners: { beforeload: function() { Ext.getCmp('sale_trend').setLoading(true); }, load: function(s, d) { Ext.getCmp('sale_trend').setLoading(false); } } }, purchase_trend: { fields: ['x', 'y'], autoLoad: true, proxy: { type: 'ajax', // url: 'http://192.168.253.58:8920/homePage/purchaseData?sixMonths=true', url: '/api/commons/homePage/purchaseData?sixMonths=true', timeout: 8000, actionMethods: { read: 'GET' }, reader: { type: 'json', rootProperty: 'data', }, listeners: { exception: function(proxy, response, operation, eOpts) { Ext.getCmp('purchase_trend').setLoading(false); } } }, sorters: [ { property: 'x', direction: 'ASC' } ], listeners: { beforeload: function() { Ext.getCmp('purchase_trend').setLoading(true); }, load: function(s, d) { Ext.getCmp('purchase_trend').setLoading(false); } } }, stock_amount: { fields: ['x', 'y'], autoLoad: true, proxy: { type: 'ajax', // url: 'http://192.168.253.58:8920/homePage/storageData', url: '/api/commons/homePage/storageData', timeout: 8000, actionMethods: { read: 'GET' }, reader: { type: 'json', rootProperty: 'data', }, listeners: { exception: function(proxy, response, operation, eOpts) { Ext.getCmp('stock_amount').setLoading(false); } } }, sorters: [ { property: 'x', direction: 'ASC' } ], listeners: { beforeload: function() { Ext.getCmp('stock_amount').setLoading(true); }, load: function(s, d) { Ext.getCmp('stock_amount').setLoading(false); } } }, }, });