business.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <el-card header="业务数据">
  3. <statistic class="statistic" :cols="0">
  4. <statistic-item v-for="(item, key) in items" :key="key" :class="{active: active === key}" @click="active = key">
  5. <span>
  6. {{item.title}}
  7. <el-tooltip v-if="item.desc" :content="item.desc" :open-delay=".3" placement="top">
  8. <i style="margin-left: 5px;cursor: pointer;" class="el-icon-warning-outline"/>
  9. </el-tooltip>
  10. </span>
  11. <span>
  12. <count-to :endVal="item.percent" :decimals="2"/>%
  13. </span>
  14. </statistic-item>
  15. </statistic>
  16. <ve-histogram
  17. style="width: 100%;"
  18. height="350px"
  19. :data="chartData"
  20. :data-empty="dataEmpty"
  21. :data-zoom="dataZoom"
  22. :extend="chartExtend"
  23. ></ve-histogram>
  24. </el-card>
  25. </template>
  26. <script>
  27. import 'v-charts/lib/style.css'
  28. import 'echarts/lib/component/dataZoom'
  29. import countTo from 'vue-count-to'
  30. import veHistogram from 'v-charts/lib/histogram.common'
  31. export default {
  32. props: ['data'],
  33. components: {
  34. 've-histogram': veHistogram,
  35. 'count-to': countTo
  36. },
  37. computed: {
  38. items() {
  39. return {
  40. ACTIVATION_RATE: this.data['ACTIVATION_RATE'] || {},
  41. HOMEWORK_CREATE_RATE: this.data['HOMEWORK_CREATE_RATE'] || {},
  42. HOMEWORK_SUBMIT_RATE: this.data['HOMEWORK_SUBMIT_RATE'] || {},
  43. HOMEWORK_COMMENT_RATE: this.data['HOMEWORK_COMMENT_RATE'] || {},
  44. }
  45. },
  46. chartExtend() {
  47. return {
  48. tooltip: {
  49. axisPointer: {
  50. type: 'shadow',
  51. shadowStyle: {
  52. color: 'rgba(150,150,150,0.2)'
  53. }
  54. }
  55. }
  56. }
  57. },
  58. dataZoom() {
  59. return [
  60. {
  61. type: 'slider',
  62. start: 60,
  63. end: 100
  64. }
  65. ]
  66. },
  67. chartData() {
  68. const values = Object.values(this.items)
  69. const months = {}
  70. for (const item of values) {
  71. for (const row of (item.indexMonthData || [])) {
  72. const key = this.$helpers.dayjs(row.month).format('YYYY-MM-DD')
  73. if (!months[key]) {
  74. months[key] = {
  75. '日期': key,
  76. }
  77. }
  78. months[key][item.title] = row.percent
  79. }
  80. }
  81. return {
  82. columns: ['日期', ...values.map(item => item.title)],
  83. rows: Object.values(months)
  84. }
  85. },
  86. dataEmpty() {
  87. return !this.chartData.rows.length
  88. },
  89. },
  90. data () {
  91. return {
  92. active: 'ACTIVATION_RATE',
  93. }
  94. },
  95. }
  96. </script>
  97. <style lang="less" scoped>
  98. // .statistic{
  99. // /deep/ .statistic-content{
  100. // cursor: pointer;
  101. // &.active > span{
  102. // color: #14928a !important;
  103. // }
  104. // }
  105. // }
  106. </style>