<template>
  <div class="content white">
    <v-banner class="mb-3">
      反馈统计
      <template v-slot:actions>
        <v-btn
          text
          color="primary"
          @click="init"
        >
          <v-icon left>mdi-refresh</v-icon>
          刷新
        </v-btn>
      </template>
    </v-banner>
    <v-container v-loading="loading">
      <v-row >
        <v-col
          v-for="elevation in elevations"
          :key="elevation.value"
          cols="3"
        >
          <v-card
            class="pa-2"
            tile
            height="150"
          >
            <div class="d-flex align-center justify-center flex-column" style="height: 100%;">
              <div class="text-h3" :class="`${elevation.textColor}--text`">{{ itemData[elevation.value] }}</div>
              <div>{{ elevation.text }}</div>
            </div>
          </v-card>
        </v-col>
      </v-row>

    </v-container>
  </div>
</template>

<script>
import {
  getFeedbackStats
} from '@/api/dataChart'
export default {
  name: 'modelStatistics',
  data () {
    return {
      elevations: [
        { text: '总反馈数', value: 'total_feedback', textColor: 'primary' },
        { text: '正向反馈数', value: 'positive_feedback', textColor: 'success' },
        { text: '负向反馈数', value: 'negative_feedback', textColor: 'error' },
        { text: '已训练反馈数', value: 'trained_feedback', textColor: 'indigo' },
        { text: '未训练反馈数', value: 'untrained_feedback', textColor: 'warning' },
        { text: '正向反馈率(%)', value: 'positive_rate', textColor: 'primary' },
        { text: '训练覆盖率(%)', value: 'training_rate', textColor: 'primary' }
      ],
      itemData: {},
      loading: false
    }
  },
  created () {
    this.init()
  },
  methods: {
    async init () {
      this.loading = true
      try {
        const { data } = await getFeedbackStats()
        this.itemData = data
      } catch (error) {
        this.$snackbar.error(error)
      } finally {
        this.loading = false
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.content {
  font-size: 16px;
}
</style>
