HomeModel.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. var p = Ext.getCmp('infocard');
  30. p && p.setLoading(false);
  31. }
  32. }
  33. },
  34. listeners: {
  35. beforeload: function() {
  36. var p = Ext.getCmp('infocard');
  37. p && p.setLoading(true);
  38. },
  39. load: function(s, d) {
  40. var p = Ext.getCmp('infocard');
  41. p && p.setLoading(false);
  42. if(!d) return;
  43. var res = d[0].data.data || {};
  44. Ext.getCmp('infocard').addCardItems(res);
  45. }
  46. }
  47. },
  48. month_sale: {
  49. model: 'saas.model.chart.DataXY',
  50. autoLoad: true,
  51. proxy: {
  52. type: 'ajax',
  53. // url: 'http://192.168.253.58:8920/homePage/saleData',
  54. url: '/api/commons/homePage/saleData',
  55. timeout: 8000,
  56. actionMethods: {
  57. read: 'GET'
  58. },
  59. reader: {
  60. type: 'json',
  61. rootProperty: 'data',
  62. },
  63. listeners: {
  64. exception: function(proxy, response, operation, eOpts) {
  65. var p = Ext.getCmp('infocard');
  66. p && p.setLoading(false);
  67. }
  68. }
  69. },
  70. listeners: {
  71. beforeload: function() {
  72. var p = Ext.getCmp('infocard');
  73. p && p.setLoading(true);
  74. },
  75. load: function(s, d) {
  76. var p = Ext.getCmp('infocard');
  77. p && p.setLoading(false);
  78. var sum = Ext.util.Format.number(s.sum('y'), '0.00') || 0;
  79. Ext.getCmp('home').getViewModel().set('month_sale_amount', sum)
  80. }
  81. }
  82. },
  83. month_purchase: {
  84. model: 'saas.model.chart.DataXY',
  85. autoLoad: true,
  86. proxy: {
  87. type: 'ajax',
  88. // url: 'http://192.168.253.58:8920/homePage/purchaseData?sixMonths=false',
  89. url: '/api/commons/homePage/purchaseData?sixMonths=false',
  90. timeout: 8000,
  91. actionMethods: {
  92. read: 'GET'
  93. },
  94. reader: {
  95. type: 'json',
  96. rootProperty: 'data',
  97. },
  98. listeners: {
  99. exception: function(proxy, response, operation, eOpts) {
  100. var p = Ext.getCmp('month_purchase');
  101. p && p.setLoading(false);
  102. }
  103. }
  104. },
  105. listeners: {
  106. beforeload: function() {
  107. var p = Ext.getCmp('month_purchase');
  108. p && p.setLoading(true);
  109. },
  110. load: function(s, d) {
  111. var p = Ext.getCmp('month_purchase');
  112. p && p.setLoading(false);
  113. var sum = Ext.util.Format.number(s.sum('y'), '0.00') || 0;
  114. Ext.getCmp('home').getViewModel().set('month_purchase_amount', sum+'')
  115. }
  116. }
  117. },
  118. month_io: {
  119. fields: ['x', 'main', 'other'],
  120. autoLoad: true,
  121. proxy: {
  122. type: 'ajax',
  123. // url: 'http://192.168.253.58:8920/homePage/payAndRecData',
  124. url: '/api/commons/homePage/payAndRecData',
  125. timeout: 8000,
  126. actionMethods: {
  127. read: 'GET'
  128. },
  129. reader: {
  130. type: 'json',
  131. rootProperty: 'data',
  132. },
  133. listeners: {
  134. exception: function(proxy, response, operation, eOpts) {
  135. var p = Ext.getCmp('month_io');
  136. p && p.setLoading(false);
  137. }
  138. }
  139. },
  140. listeners: {
  141. beforeload: function() {
  142. var p = Ext.getCmp('month_io');
  143. p && p.setLoading(true);
  144. },
  145. load: function(s, d) {
  146. var p = Ext.getCmp('month_io');
  147. p && p.setLoading(false);
  148. s.each(function(r) {
  149. var sum = Ext.util.Format.number(r.get('main') + r.get('other'), '0.00') || 0;
  150. if(r.get('x') == '收入') {
  151. Ext.getCmp('home').getViewModel().set('month_in', sum);
  152. }else if(r.get('x') == '支出') {
  153. Ext.getCmp('home').getViewModel().set('month_out', sum);
  154. }
  155. });
  156. }
  157. }
  158. },
  159. sale_trend: {
  160. fields: ['x', 'sale', 'saleback'],
  161. autoLoad: true,
  162. proxy: {
  163. type: 'ajax',
  164. // url: 'http://192.168.253.58:8920/homePage/saleFutureData',
  165. url: '/api/commons/homePage/saleFutureData',
  166. timeout: 8000,
  167. actionMethods: {
  168. read: 'GET'
  169. },
  170. reader: {
  171. type: 'json',
  172. rootProperty: 'data',
  173. },
  174. listeners: {
  175. exception: function(proxy, response, operation, eOpts) {
  176. var p = Ext.getCmp('sale_trend');
  177. p && p.setLoading(false);
  178. }
  179. }
  180. },
  181. sorters: [
  182. { property: 'x', direction: 'ASC' }
  183. ],
  184. listeners: {
  185. beforeload: function() {
  186. var p = Ext.getCmp('sale_trend');
  187. p && p.setLoading(true);
  188. },
  189. load: function(s, d) {
  190. var p = Ext.getCmp('sale_trend');
  191. p && p.setLoading(false);
  192. }
  193. }
  194. },
  195. purchase_trend: {
  196. fields: ['x', 'y'],
  197. autoLoad: true,
  198. proxy: {
  199. type: 'ajax',
  200. // url: 'http://192.168.253.58:8920/homePage/purchaseData?sixMonths=true',
  201. url: '/api/commons/homePage/purchaseData?sixMonths=true',
  202. timeout: 8000,
  203. actionMethods: {
  204. read: 'GET'
  205. },
  206. reader: {
  207. type: 'json',
  208. rootProperty: 'data',
  209. },
  210. listeners: {
  211. exception: function(proxy, response, operation, eOpts) {
  212. var p = Ext.getCmp('purchase_trend');
  213. p && p.setLoading(false);
  214. }
  215. }
  216. },
  217. sorters: [
  218. { property: 'x', direction: 'ASC' }
  219. ],
  220. listeners: {
  221. beforeload: function() {
  222. var p = Ext.getCmp('purchase_trend');
  223. p && p.setLoading(true);
  224. },
  225. load: function(s, d) {
  226. var p = Ext.getCmp('purchase_trend');
  227. p && p.setLoading(false);
  228. }
  229. }
  230. },
  231. stock_amount: {
  232. fields: ['x', 'y'],
  233. autoLoad: true,
  234. proxy: {
  235. type: 'ajax',
  236. // url: 'http://192.168.253.58:8920/homePage/storageData',
  237. url: '/api/commons/homePage/storageData',
  238. timeout: 8000,
  239. actionMethods: {
  240. read: 'GET'
  241. },
  242. reader: {
  243. type: 'json',
  244. rootProperty: 'data',
  245. },
  246. listeners: {
  247. exception: function(proxy, response, operation, eOpts) {
  248. var p = Ext.getCmp('stock_amount');
  249. p && p.setLoading(false);
  250. }
  251. }
  252. },
  253. sorters: [
  254. { property: 'x', direction: 'ASC' }
  255. ],
  256. listeners: {
  257. beforeload: function() {
  258. var p = Ext.getCmp('stock_amount');
  259. p && p.setLoading(true);
  260. },
  261. load: function(s, d) {
  262. var p = Ext.getCmp('stock_amount');
  263. p && p.setLoading(false);
  264. }
  265. }
  266. },
  267. key_data: {
  268. fields: ['name', 'value'],
  269. autoLoad: true,
  270. proxy: {
  271. type: 'ajax',
  272. // url: 'http://192.168.253.58:8920/homePage/keyData',
  273. url: '/api/commons/homePage/keyData',
  274. timeout: 8000,
  275. actionMethods: {
  276. read: 'GET'
  277. },
  278. reader: {
  279. type: 'json',
  280. rootProperty: 'data',
  281. },
  282. listeners: {
  283. exception: function(proxy, response, operation, eOpts) {
  284. var p = Ext.getCmp('key_data');
  285. p && p.setLoading(false);
  286. }
  287. }
  288. },
  289. listeners: {
  290. beforeload: function() {
  291. var p = Ext.getCmp('key_data');
  292. p && p.setLoading(true);
  293. },
  294. load: function(s, d) {
  295. var p = Ext.getCmp('key_data');
  296. p && p.setLoading(false),
  297. data = s.getAt(0) ? s.getAt(0).data : null;
  298. if(data) {
  299. delete data.id;
  300. p.updateValue(data);
  301. // Ext.getCmp('home').getViewModel().set('keydata', data);
  302. }
  303. }
  304. }
  305. },
  306. },
  307. });