HomeModel.js 8.7 KB

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