student.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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"/>{{key === 'STUDENT_CONVERSION' ? '%' : ''}}
  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. NEWLY_STUDENT_NUM: this.data['NEWLY_STUDENT_NUM'] || {},
  32. QUIT_MUSIC_GROUP_STUDENT_NUM: this.data['QUIT_MUSIC_GROUP_STUDENT_NUM'] || {},
  33. STUDENT_CONVERSION: this.data['STUDENT_CONVERSION'] || {},
  34. }
  35. },
  36. chartData() {
  37. const data = this.data[this.active] || {}
  38. const values = Object.values(this.items)
  39. const months = {}
  40. for (const item of values) {
  41. for (const row of (item.indexMonthData || [])) {
  42. const key = this.$helpers.dayjs(row.month).month() + 1 + '月'
  43. if (!months[key]) {
  44. months[key] = {
  45. '月份': key,
  46. }
  47. }
  48. months[key][item.title] = row.percent
  49. }
  50. }
  51. return {
  52. columns: ['月份', ...values.map(item => item.title)],
  53. rows: Object.values(months)
  54. }
  55. }
  56. },
  57. data () {
  58. return {
  59. active: 'NEWLY_STUDENT_NUM',
  60. }
  61. },
  62. }
  63. </script>
  64. <style lang="less" scoped>
  65. // .statistic{
  66. // /deep/ .statistic-content{
  67. // cursor: pointer;
  68. // &.active > span{
  69. // color: #14928a !important;
  70. // }
  71. // }
  72. // }
  73. </style>