KeyData.js 4.3 KB

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