HomeModel.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. s.each(function(r) {
  81. var z = r.get('z'),
  82. x = r.get('x');
  83. if(!z) {
  84. r.set('z', x.length > 3 ? (x.substr(0,3) + '...') : x);
  85. }else {
  86. r.set('z', z.length > 3 ? (z.substr(0,3) + '...') : z);
  87. }
  88. });
  89. }
  90. }
  91. },
  92. // month_purchase: {
  93. // model: 'saas.model.chart.DataXY',
  94. // autoLoad: true,
  95. // proxy: {
  96. // type: 'ajax',
  97. // // url: 'http://192.168.253.58:8920/homePage/purchaseData?sixMonths=false',
  98. // url: '/api/commons/homePage/purchaseData?sixMonths=false',
  99. // timeout: 8000,
  100. // actionMethods: {
  101. // read: 'GET'
  102. // },
  103. // reader: {
  104. // type: 'json',
  105. // rootProperty: 'data',
  106. // },
  107. // listeners: {
  108. // exception: function(proxy, response, operation, eOpts) {
  109. // var p = Ext.getCmp('month_purchase');
  110. // p && p.setLoading(false);
  111. // }
  112. // }
  113. // },
  114. // listeners: {
  115. // beforeload: function() {
  116. // var p = Ext.getCmp('month_purchase');
  117. // p && p.setLoading(true);
  118. // },
  119. // load: function(s, d) {
  120. // var p = Ext.getCmp('month_purchase');
  121. // p && p.setLoading(false);
  122. // var sum = Ext.util.Format.number(s.sum('y'), '0.00') || 0;
  123. // Ext.getCmp('home').getViewModel().set('month_purchase_amount', sum+'')
  124. // }
  125. // }
  126. // },
  127. month_io: {
  128. fields: ['x', 'main', 'other'],
  129. autoLoad: true,
  130. proxy: {
  131. type: 'ajax',
  132. // url: 'http://192.168.253.58:8920/homePage/payAndRecData',
  133. url: '/api/commons/homePage/payAndRecData',
  134. timeout: 8000,
  135. actionMethods: {
  136. read: 'GET'
  137. },
  138. reader: {
  139. type: 'json',
  140. rootProperty: 'data',
  141. },
  142. listeners: {
  143. exception: function(proxy, response, operation, eOpts) {
  144. var p = Ext.getCmp('month_io');
  145. p && p.setLoading(false);
  146. }
  147. }
  148. },
  149. listeners: {
  150. beforeload: function() {
  151. var p = Ext.getCmp('month_io');
  152. p && p.setLoading(true);
  153. },
  154. load: function(s, d) {
  155. var p = Ext.getCmp('month_io');
  156. p && p.setLoading(false);
  157. s.each(function(r) {
  158. var sum = Ext.util.Format.number(r.get('main') + r.get('other'), '0.00') || 0;
  159. if(r.get('x') == '收入') {
  160. Ext.getCmp('home').getViewModel().set('month_in', sum);
  161. }else if(r.get('x') == '支出') {
  162. Ext.getCmp('home').getViewModel().set('month_out', sum);
  163. }
  164. });
  165. }
  166. }
  167. },
  168. sale_trend: {
  169. fields: ['x', 'sale', 'saleback'],
  170. autoLoad: true,
  171. proxy: {
  172. type: 'ajax',
  173. // url: 'http://192.168.253.58:8920/homePage/saleFutureData',
  174. url: '/api/commons/homePage/saleFutureData',
  175. timeout: 8000,
  176. actionMethods: {
  177. read: 'GET'
  178. },
  179. reader: {
  180. type: 'json',
  181. rootProperty: 'data',
  182. },
  183. listeners: {
  184. exception: function(proxy, response, operation, eOpts) {
  185. var p = Ext.getCmp('sale_trend');
  186. p && p.setLoading(false);
  187. }
  188. }
  189. },
  190. sorters: [
  191. { property: 'x', direction: 'ASC' }
  192. ],
  193. listeners: {
  194. beforeload: function() {
  195. var p = Ext.getCmp('sale_trend');
  196. p && p.setLoading(true);
  197. },
  198. load: function(s, d) {
  199. var p = Ext.getCmp('sale_trend');
  200. p && p.setLoading(false);
  201. }
  202. }
  203. },
  204. // purchase_trend: {
  205. // fields: ['x', 'y'],
  206. // autoLoad: true,
  207. // proxy: {
  208. // type: 'ajax',
  209. // // url: 'http://192.168.253.58:8920/homePage/purchaseData?sixMonths=true',
  210. // url: '/api/commons/homePage/purchaseData?sixMonths=true',
  211. // timeout: 8000,
  212. // actionMethods: {
  213. // read: 'GET'
  214. // },
  215. // reader: {
  216. // type: 'json',
  217. // rootProperty: 'data',
  218. // },
  219. // listeners: {
  220. // exception: function(proxy, response, operation, eOpts) {
  221. // var p = Ext.getCmp('purchase_trend');
  222. // p && p.setLoading(false);
  223. // }
  224. // }
  225. // },
  226. // sorters: [
  227. // { property: 'x', direction: 'ASC' }
  228. // ],
  229. // listeners: {
  230. // beforeload: function() {
  231. // var p = Ext.getCmp('purchase_trend');
  232. // p && p.setLoading(true);
  233. // },
  234. // load: function(s, d) {
  235. // var p = Ext.getCmp('purchase_trend');
  236. // p && p.setLoading(false);
  237. // }
  238. // }
  239. // },
  240. stock_amount: {
  241. fields: ['x', 'y'],
  242. autoLoad: true,
  243. proxy: {
  244. type: 'ajax',
  245. // url: 'http://192.168.253.58:8920/homePage/storageData',
  246. url: '/api/commons/homePage/storageData',
  247. timeout: 8000,
  248. actionMethods: {
  249. read: 'GET'
  250. },
  251. reader: {
  252. type: 'json',
  253. rootProperty: 'data',
  254. },
  255. listeners: {
  256. exception: function(proxy, response, operation, eOpts) {
  257. var p = Ext.getCmp('stock_amount');
  258. p && p.setLoading(false);
  259. }
  260. }
  261. },
  262. sorters: [
  263. { property: 'x', direction: 'ASC' }
  264. ],
  265. listeners: {
  266. beforeload: function() {
  267. var p = Ext.getCmp('stock_amount');
  268. p && p.setLoading(true);
  269. },
  270. load: function(s, d) {
  271. var p = Ext.getCmp('stock_amount');
  272. p && p.setLoading(false);
  273. }
  274. }
  275. },
  276. key_data: {
  277. fields: ['name', 'value'],
  278. autoLoad: true,
  279. proxy: {
  280. type: 'ajax',
  281. // url: 'http://192.168.253.58:8920/homePage/keyData',
  282. url: '/api/commons/homePage/keyData',
  283. timeout: 8000,
  284. actionMethods: {
  285. read: 'GET'
  286. },
  287. reader: {
  288. type: 'json',
  289. rootProperty: 'data',
  290. },
  291. listeners: {
  292. exception: function(proxy, response, operation, eOpts) {
  293. var p = Ext.getCmp('key_data');
  294. p && p.setLoading(false);
  295. }
  296. }
  297. },
  298. listeners: {
  299. beforeload: function() {
  300. var p = Ext.getCmp('key_data');
  301. p && p.setLoading(true);
  302. },
  303. load: function(s, d) {
  304. var p = Ext.getCmp('key_data');
  305. p && p.setLoading(false),
  306. data = s.getAt(0) ? s.getAt(0).data : null;
  307. if(data) {
  308. delete data.id;
  309. p.updateValue(data);
  310. // Ext.getCmp('home').getViewModel().set('keydata', data);
  311. }
  312. }
  313. }
  314. },
  315. profit_detail: {
  316. fields: ['x', 'y', 'z'],
  317. autoLoad: true,
  318. proxy: {
  319. type: 'ajax',
  320. // url: 'http://192.168.253.58:8560/api/commons/homePage/monthProfit',
  321. url: '/api/commons/homePage/monthProfit',
  322. timeout: 8000,
  323. // header: {
  324. // Authorization: 'eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJnIiwiYXBwSWQiOiJ0cmFkZS1hcHAiLCJ1c2VySWQiOjM4LCJjb21wYW55SWQiOjIxLCJ1c2VyTmFtZSI6ImciLCJyZWFsTmFtZSI6Iue-pCIsImV4cCI6MTU0NjIyNTg5Mn0.oe6BmpVchOlL6PoR7UspHbThFEJ_HLlKTHBpV4P9wSA4YbL2Pv5sAah2U6M2q7nmu0J1DV5WwMaMClI19Us7n-8fSgNeQrl1IsVFO4sf5nSC3SrUJk0sraBq5dLAqONfAIj9qFOuyduL6tXkV2av5IfmikT1uMk8okTJKDtHj8U'
  325. // },
  326. actionMethods: {
  327. read: 'GET'
  328. },
  329. reader: {
  330. type: 'json',
  331. rootProperty: 'data',
  332. },
  333. listeners: {
  334. exception: function(proxy, response, operation, eOpts) {
  335. var p = Ext.getCmp('profit_detail');
  336. p && p.setLoading(false);
  337. }
  338. }
  339. },
  340. listeners: {
  341. beforeload: function() {
  342. var p = Ext.getCmp('profit_detail');
  343. p && p.setLoading(true);
  344. },
  345. load: function(s, d) {
  346. var p = Ext.getCmp('profit_detail');
  347. p && p.setLoading(false);
  348. s.each(function(r) {
  349. var z = r.get('z'),
  350. x = r.get('x');
  351. if(!z) {
  352. r.set('z', x.length > 3 ? (x.substr(0,3) + '...') : x);
  353. }else {
  354. r.set('z', z.length > 3 ? (z.substr(0,3) + '...') : z);
  355. }
  356. });
  357. }
  358. }
  359. },
  360. },
  361. });