123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <template>
- <el-card header="运营数据">
- <statistic class="statistic" :cols="0">
- <statistic-item v-for="(item, key) in items" :key="key" :class="{active: active === key}" @click="active = key">
- <span>{{item.title}}</span>
- <span>
- <count-to :endVal="item.percent"/>
- </span>
- </statistic-item>
- </statistic>
- <ve-histogram :data="chartData"></ve-histogram>
- </el-card>
- </template>
- <script>
- import countTo from 'vue-count-to'
- import veHistogram from 'v-charts/lib/histogram.common'
- export default {
- props: ['data'],
- components: {
- 've-histogram': veHistogram,
- 'count-to': countTo
- },
- computed: {
- items() {
- return {
- SCHOOL: this.data['SCHOOL'] || {},
- MUSIC_GROUP_NUM: this.data['MUSIC_GROUP_NUM'] || {},
- MUSIC_GROUP_STUDENT: this.data['MUSIC_GROUP_STUDENT'] || {},
- OTHER_STUDENT: this.data['OTHER_STUDENT'] || {},
- }
- },
- chartData() {
- const data = this.data[this.active] || {}
- const values = Object.values(this.items)
- const months = {}
- for (const item of values) {
- for (const row of (item.indexMonthData || [])) {
- const key = this.$helpers.dayjs(row.month).month() + 1 + '月'
- if (!months[key]) {
- months[key] = {
- '月份': key,
- }
- }
- months[key][item.title] = row.percent
- }
- }
- return {
- columns: ['月份', ...values.map(item => item.title)],
- rows: Object.values(months)
- }
- }
- },
- data () {
- return {
- active: 'SCHOOL',
- }
- },
- }
- </script>
- <style lang="less" scoped>
- .statistic{
- /deep/ .statistic-content{
- cursor: pointer;
- &.active > span{
- color: #14928a !important;
- }
- }
- }
- </style>
|