curriculum.vue 1.7 KB

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