HomeModel.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. Ext.define('saas.view.home.HomeModel', {
  2. extend: 'Ext.app.ViewModel',
  3. alias: 'viewmodel.home',
  4. data: {
  5. month_sale_amount: '0', // 本月销售合计
  6. month_purchase_amount: '0', // 本月采购合计
  7. month_in: '0', // 本月收入合计
  8. month_out: '0', // 本月支出合计
  9. insetPadding: '12 0 0 0', // 图表insetPadding
  10. maxBarWidth: 25, // 最大柱宽
  11. },
  12. stores: {
  13. infoData: {
  14. model: 'saas.model.home.Info',
  15. autoLoad: true,
  16. proxy: {
  17. type: 'ajax',
  18. // url: 'http://192.168.253.58:8920/homePage/liveData',
  19. url: '/api/commons/homePage/liveData',
  20. timeout: 8000,
  21. actionMethods: {
  22. read: 'GET'
  23. },
  24. reader: {
  25. type: 'json'
  26. },
  27. listeners: {
  28. exception: function(proxy, response, operation, eOpts) {
  29. Ext.getCmp('infocard').setLoading(false);
  30. }
  31. }
  32. },
  33. listeners: {
  34. beforeload: function() {
  35. Ext.getCmp('infocard').setLoading(true);
  36. },
  37. load: function(s, d) {
  38. Ext.getCmp('infocard').setLoading(false);
  39. if(!d) return;
  40. var res = d[0].data.data || {};
  41. Ext.getCmp('infocard').addCardItems(res);
  42. }
  43. }
  44. },
  45. month_sale: {
  46. model: 'saas.model.chart.DataXY',
  47. autoLoad: true,
  48. proxy: {
  49. type: 'ajax',
  50. // url: 'http://192.168.253.58:8920/homePage/saleData',
  51. url: '/api/commons/homePage/saleData',
  52. timeout: 8000,
  53. actionMethods: {
  54. read: 'GET'
  55. },
  56. reader: {
  57. type: 'json',
  58. rootProperty: 'data',
  59. },
  60. listeners: {
  61. exception: function(proxy, response, operation, eOpts) {
  62. Ext.getCmp('month_sale').setLoading(false);
  63. }
  64. }
  65. },
  66. listeners: {
  67. beforeload: function() {
  68. Ext.getCmp('month_sale').setLoading(true);
  69. },
  70. load: function(s, d) {
  71. Ext.getCmp('month_sale').setLoading(false);
  72. var sum = Ext.util.Format.number(s.sum('y'), '0.00') || 0;
  73. Ext.getCmp('home').getViewModel().set('month_sale_amount', sum)
  74. }
  75. }
  76. },
  77. month_purchase: {
  78. model: 'saas.model.chart.DataXY',
  79. autoLoad: true,
  80. proxy: {
  81. type: 'ajax',
  82. // url: 'http://192.168.253.58:8920/homePage/purchaseData?sixMonths=false',
  83. url: '/api/commons/homePage/purchaseData?sixMonths=false',
  84. timeout: 8000,
  85. actionMethods: {
  86. read: 'GET'
  87. },
  88. reader: {
  89. type: 'json',
  90. rootProperty: 'data',
  91. },
  92. listeners: {
  93. exception: function(proxy, response, operation, eOpts) {
  94. Ext.getCmp('month-purchase').setLoading(false);
  95. }
  96. }
  97. },
  98. listeners: {
  99. beforeload: function() {
  100. Ext.getCmp('month-purchase').setLoading(true);
  101. },
  102. load: function(s, d) {
  103. Ext.getCmp('month-purchase').setLoading(false);
  104. var sum = Ext.util.Format.number(s.sum('y'), '0.00') || 0;
  105. Ext.getCmp('home').getViewModel().set('month_purchase_amount', sum+'')
  106. }
  107. }
  108. },
  109. month_io: {
  110. fields: ['x', 'main', 'other'],
  111. autoLoad: true,
  112. proxy: {
  113. type: 'ajax',
  114. // url: 'http://192.168.253.58:8920/homePage/payAndRecData',
  115. url: '/api/commons/homePage/payAndRecData',
  116. timeout: 8000,
  117. actionMethods: {
  118. read: 'GET'
  119. },
  120. reader: {
  121. type: 'json',
  122. rootProperty: 'data',
  123. },
  124. listeners: {
  125. exception: function(proxy, response, operation, eOpts) {
  126. Ext.getCmp('month_io').setLoading(false);
  127. }
  128. }
  129. },
  130. listeners: {
  131. beforeload: function() {
  132. Ext.getCmp('month_io').setLoading(true);
  133. },
  134. load: function(s, d) {
  135. Ext.getCmp('month_io').setLoading(false);
  136. s.each(function(r) {
  137. var sum = Ext.util.Format.number(r.get('main') + r.get('other'), '0.00') || 0;
  138. if(r.get('x') == '收入') {
  139. Ext.getCmp('home').getViewModel().set('month_in', sum);
  140. }else if(r.get('x') == '支出') {
  141. Ext.getCmp('home').getViewModel().set('month_out', sum);
  142. }
  143. });
  144. }
  145. }
  146. },
  147. sale_trend: {
  148. fields: ['x', 'sale', 'saleback'],
  149. autoLoad: true,
  150. proxy: {
  151. type: 'ajax',
  152. // url: 'http://192.168.253.58:8920/homePage/saleFutureData',
  153. url: '/api/commons/homePage/saleFutureData',
  154. timeout: 8000,
  155. actionMethods: {
  156. read: 'GET'
  157. },
  158. reader: {
  159. type: 'json',
  160. rootProperty: 'data',
  161. },
  162. listeners: {
  163. exception: function(proxy, response, operation, eOpts) {
  164. Ext.getCmp('sale_trend').setLoading(false);
  165. }
  166. }
  167. },
  168. sorters: [
  169. { property: 'x', direction: 'ASC' }
  170. ],
  171. listeners: {
  172. beforeload: function() {
  173. Ext.getCmp('sale_trend').setLoading(true);
  174. },
  175. load: function(s, d) {
  176. Ext.getCmp('sale_trend').setLoading(false);
  177. }
  178. }
  179. },
  180. purchase_trend: {
  181. fields: ['x', 'y'],
  182. autoLoad: true,
  183. proxy: {
  184. type: 'ajax',
  185. // url: 'http://192.168.253.58:8920/homePage/purchaseData?sixMonths=true',
  186. url: '/api/commons/homePage/purchaseData?sixMonths=true',
  187. timeout: 8000,
  188. actionMethods: {
  189. read: 'GET'
  190. },
  191. reader: {
  192. type: 'json',
  193. rootProperty: 'data',
  194. },
  195. listeners: {
  196. exception: function(proxy, response, operation, eOpts) {
  197. Ext.getCmp('purchase_trend').setLoading(false);
  198. }
  199. }
  200. },
  201. sorters: [
  202. { property: 'x', direction: 'ASC' }
  203. ],
  204. listeners: {
  205. beforeload: function() {
  206. Ext.getCmp('purchase_trend').setLoading(true);
  207. },
  208. load: function(s, d) {
  209. Ext.getCmp('purchase_trend').setLoading(false);
  210. }
  211. }
  212. },
  213. stock_amount: {
  214. fields: ['x', 'y'],
  215. autoLoad: true,
  216. proxy: {
  217. type: 'ajax',
  218. // url: 'http://192.168.253.58:8920/homePage/storageData',
  219. url: '/api/commons/homePage/storageData',
  220. timeout: 8000,
  221. actionMethods: {
  222. read: 'GET'
  223. },
  224. reader: {
  225. type: 'json',
  226. rootProperty: 'data',
  227. },
  228. listeners: {
  229. exception: function(proxy, response, operation, eOpts) {
  230. Ext.getCmp('stock_amount').setLoading(false);
  231. }
  232. }
  233. },
  234. sorters: [
  235. { property: 'x', direction: 'ASC' }
  236. ],
  237. listeners: {
  238. beforeload: function() {
  239. Ext.getCmp('stock_amount').setLoading(true);
  240. },
  241. load: function(s, d) {
  242. Ext.getCmp('stock_amount').setLoading(false);
  243. }
  244. }
  245. },
  246. },
  247. });