operate.vue 1.8 KB

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