<template>
  <div id="one">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="title"> 技术成果 </el-col>
        <el-col :span="24" class="canvas">
          <div id="oneChart" style="height: 420px"></div>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import * as echarts from 'echarts';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: statistics } = createNamespacedHelpers('statistics');
export default {
  name: 'one',
  props: {},
  components: {},
  data: function () {
    return {};
  },
  created() {},
  mounted() {
    this.init();
  },
  methods: {
    ...statistics(['query']),
    async init() {
      let res = await this.query({ type: 'product' });
      if (this.$checkRes(res)) {
        var chartDom = document.getElementById('oneChart');
        var myChart = echarts.init(chartDom);
        var option;
        option = {
          legend: {
            top: 'bottom',
          },
          toolbox: {
            show: false,
            feature: {
              mark: { show: true },
              dataView: { show: true, readOnly: false },
              restore: { show: true },
              saveAsImage: { show: true },
            },
          },
          series: [
            {
              name: '技术成果',
              type: 'pie',
              radius: '60%',
              center: ['50%', '40%'],
              roseType: 'area',
              itemStyle: {
                borderRadius: 8,
              },
              data: res.data,
            },
          ],
        };
        option && myChart.setOption(option);
      }
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    data: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .title {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    padding: 15px 0;
  }
}
</style>
