operate.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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"/>
  13. </span>
  14. </statistic-item>
  15. </statistic>
  16. <ve-histogram style="width: 100%;" height="350px" :data="chartData"></ve-histogram>
  17. </el-card>
  18. </template>
  19. <script>
  20. import countTo from 'vue-count-to'
  21. import veHistogram from 'v-charts/lib/histogram.common'
  22. export default {
  23. props: ['data'],
  24. components: {
  25. 've-histogram': veHistogram,
  26. 'count-to': countTo
  27. },
  28. computed: {
  29. items() {
  30. return {
  31. SCHOOL: this.data['SCHOOL'] || {},
  32. MUSIC_GROUP_NUM: this.data['MUSIC_GROUP_NUM'] || {},
  33. MUSIC_GROUP_STUDENT: this.data['MUSIC_GROUP_STUDENT'] || {},
  34. OTHER_STUDENT: this.data['OTHER_STUDENT'] || {},
  35. }
  36. },
  37. chartData() {
  38. const data = this.data[this.active] || {}
  39. const values = Object.values(this.items)
  40. const months = {}
  41. for (const item of values) {
  42. for (const row of (item.indexMonthData || [])) {
  43. const key = this.$helpers.dayjs(row.month).month() + 1 + '月'
  44. if (!months[key]) {
  45. months[key] = {
  46. '月份': key,
  47. }
  48. }
  49. months[key][item.title] = row.percent
  50. }
  51. }
  52. return {
  53. columns: ['月份', ...values.map(item => item.title)],
  54. rows: Object.values(months)
  55. }
  56. }
  57. },
  58. data () {
  59. return {
  60. active: 'SCHOOL',
  61. }
  62. },
  63. }
  64. </script>
  65. <style lang="less" scoped>
  66. // .statistic{
  67. // /deep/ .statistic-content{
  68. // cursor: pointer;
  69. // &.active > span{
  70. // color: #14928a !important;
  71. // }
  72. // }
  73. // }
  74. </style>