KeyData.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. Ext.define('saas.view.home.charts.KeyData', {
  2. extend: 'Ext.panel.Panel',
  3. xtype: 'key-data',
  4. id: 'key_data',
  5. cls: 'quick-graph-panel',
  6. // title: '关键数据',
  7. layout: 'fit',
  8. height: 280,
  9. padding: 0,
  10. cardTpl: [
  11. '<div class="x-container">',
  12. '<tpl for=".">',
  13. '<div class="x-box x-box-{color}">',
  14. '<div class="x-box-content">',
  15. '<div class="x-title">{label}</div>',
  16. '<div class="x-contain">',
  17. '<div class="x-icon x-icon-{icon}"></div>',
  18. '<div class="x-value">{value}元</div>',
  19. '</div>',
  20. '</div>',
  21. '</div>',
  22. '</tpl>',
  23. '</div>'
  24. ],
  25. cards: [{
  26. color: 'yellow',
  27. showIcon: true,
  28. icon: 'storageTotal',
  29. name: 'storageTotal',
  30. label: '库存总额',
  31. value: '0',
  32. viewType: 'stock-report-datalist',
  33. title: '物料库存数量金额表查询',
  34. id: 'stock-report-datalist',
  35. }, {
  36. color: 'purple',
  37. showIcon: true,
  38. icon: 'receiveTotal',
  39. name: 'receiveTotal',
  40. label: '应收总额',
  41. value: '0',
  42. viewType: 'monry-report-totalrecdetail',
  43. title: '应收总账查询',
  44. id: 'monry-report-totalrecdetail',
  45. }, {
  46. color: 'red',
  47. showIcon: true,
  48. icon: 'payTotal',
  49. name: 'payTotal',
  50. label: '应付总额',
  51. value: '0',
  52. viewType: 'monry-report-totalpaydetail',
  53. title: '应付总账查询',
  54. id: 'monry-report-totalpaydetail',
  55. }, {
  56. color: 'blue',
  57. showIcon: true,
  58. icon: 'balanceTotal',
  59. name: 'balanceTotal',
  60. label: '账户余额',
  61. value: '0',
  62. viewType: 'document-bankinformation-datalist',
  63. title: '资金账户查询',
  64. id: 'document-bankinformation-datalist',
  65. }],
  66. initComponent: function () {
  67. var me = this;
  68. var store = Ext.create('Ext.data.Store', {
  69. fields: ['color', 'showIcon', 'icon', 'label', 'value'],
  70. data: me.cards,
  71. updateValue: function(datas) {
  72. this.each(function(r, index) {
  73. var d = Ext.util.Format.number(datas[r.get('name')], '0,000.00');
  74. r.set('value', d);
  75. });
  76. },
  77. updateShowIcon: function(show) {
  78. this.each(function(r) {
  79. r.set('showIcon', show);
  80. });
  81. }
  82. });
  83. var view = Ext.create('Ext.view.View', {
  84. store: store,
  85. tpl: new Ext.XTemplate(me.cardTpl),
  86. itemSelector: 'div.x-box',
  87. listeners: {
  88. itemclick: function(th, record, item, index, e, eOpts) {
  89. saas.util.BaseUtil.openTab(record.get('viewType'), record.get('title'), record.get('id'));
  90. },
  91. }
  92. });
  93. Ext.apply(me, {
  94. items: [view]
  95. });
  96. me.view = view;
  97. me.callParent(arguments);
  98. },
  99. listeners: {
  100. afterlayout: function() {
  101. var me = this,
  102. box = me.getBox(),
  103. view = me.view,
  104. width = box.width,
  105. store = view.store;
  106. store.updateShowIcon(width >= 450);
  107. },
  108. },
  109. updateValue: function(datas) {
  110. var me = this,
  111. view = me.view,
  112. store = view.store;
  113. store.updateValue(datas);
  114. },
  115. updateShowIcon: function(showIcon) {
  116. var me = this,
  117. view = me.view,
  118. store = view.store;
  119. store.updateShowIcon(showIcon);
  120. }
  121. });