operate.vue 2.1 KB

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