<template>
  <div class="border-chart-color">
    <div class="chartTitle">
      <label>{{groupName}} 客户委托量比率</label>
    </div>
    <div :style="heightObj" class="chartCont">
      <div v-if="showStatistic" style="width:90%">
        <IEcharts :option="option" :style="optionObj"></IEcharts>
      </div>
      <div v-else :style="noDataObj" class="no-statistic-bg"></div>
    </div>
    <form id="persontal-task-pie">
      <input name="groupId" type="hidden"/>
      <input name="beginDate" type="hidden"/>
      <input name="endDate" type="hidden"/>
      <input name="groupName" type="hidden"/>
      <input name="serviceType" type="hidden"/>
    </form>
  </div>
</template>

<script>
// import IEcharts from 'vue-echarts-v3/src/full'
export default {
  // components: { IEcharts },
  data() {
    return {
      // 科室名称
      groupName: '',
      showStatistic: true,
      heightObj: {
        height: '300px'
      },
      option: {
        title: {
          x: 'center',
          textStyle: {
            fontSize: 14,
            fontWeight: 'normal'
          }
        },
        tooltip: {
          trigger: 'item',
          formatter: function(a) {
            return (
              a.name +
              '</br>样品量: ' +
              a.data.value +
              '<br>占比: ' +
              a.percent +
              '%'
            )
          }
        },
        legend: {
          type: 'scroll',
          orient: 'vertical',
          right: 0,
          top: 20,
          bottom: 20,
          data: []
        },
        color: this.$echartColor,
        series: [
          {
            name: '访问来源',
            type: 'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: '30',
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: []
          }
        ]
      },
      optionObj: {
        height: ''
      },
      noDataObj: {
        marginTop: ''
      }
    }
  },
  mounted() {
    this._contHide()
  },
  methods: {
    _contHide() {
      this.optionObj.height = document.documentElement.clientHeight - 300 + 'px'
      this.heightObj.height = document.documentElement.clientHeight - 272 + 'px'
      this.noDataObj.marginTop =
        (document.documentElement.clientHeight - 450) / 2 + 'px'
      this.optionObj.width =
        (document.documentElement.clientWidth - 200) / 2.6 + 'px'
    },
    _openPie(data) {
      const testerList = []
      const seriesList = []
      let total = 0
      for (let i = 0; i < data.length; i++) {
        testerList.push(data[i].client)
        total = total + data[i].quantity
        seriesList.push({
          value: data[i].quantity,
          name: data[i].client,
          total: data[i].quantity
        })
      }
      this.option.title.text = '委托单总量(个):' + total
      this.option.legend.data = testerList
      this.option.series[0].data = seriesList
      console.log(this.option.series[0].data)
    },

    _searchParams() {
      const data = this.$serialize('persontal-task-pie')
      return this.$extend(data)
    }
  }
}
</script>
