| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- 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);
- }
- }
- },
- },
- });
|