analyze.vue 3.45 KB
<!--
 * @Description: 售后客户价值分析
 * @Author: huyue
 * @Date: 2022-06-23 15:05:21
 * @LastEditors: huyue
 * @LastEditTime: 2022-06-28 11:40:13
-->
<template>
  <div>
    <div class="title">售后客户价值分析</div>
    <div class="analyze-content" :style="{ height: height - 4.9 + 'vh' }">
      <div class="content-left bg">
        <div id="analyzeBar" style="height: 100%"></div>
      </div>
      <div class="contetn-right bg">
        <pie-chart :id="chart.id" :list="analyzeData" :height="height - 4.9 + 'vh'" :radius="chart.radius" @pieAction="pieAction"></pie-chart>
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import datas from '../../utils/data'
export default {
  name: 'Analyze',
  props: ['height'],
  data() {
    return {
      barChart: '',
      chart: {
        id: 'analyzePie',
        radius:['60%', '78%']
      },
      analyzeData:[],
      option: {},
      barData: []
    }
  },
  mounted() {
    this.getChart()
  },
  methods: {
    getChart() {
      var chartDom = document.getElementById('analyzeBar')
      var myChart = echarts.init(chartDom)
      var option
      option = {
        grid: {
          left: '3%',
          right: '4%',
          top: '2%',
          bottom: '2%',
          containLabel: true
        },
        yAxis: {
          type: 'category',
          data: this.yData,
          splitLine: {
            show: false
          },
          axisTick: {
            show: false
          },
          axisLine: {
            show: false
          }
        },
        xAxis: {
          type: 'value',
          splitLine: {
            show: false
          },
          axisLabel: {
            show: false
          }
        },
        series: [
          {
            data: [120, 200, 150, 80, 70, 110, 130, 300],
            type: 'bar',
            barWidth: 12,
            itemStyle: {
              normal: {
                label: {
                  show: true,
                  position: 'center',
                  textStyle: {
                    fontSize: '12',
                    color: '#fff',
                    height: '12',
                    padding: [1, 0, 0, 0]
                  }
                },
                color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [
                  {
                    offset: 0,
                    color: '#F79902'
                  },
                  {
                    offset: 1,
                    color: '#EB6001'
                  }
                ])
              }
            }
          }
        ]
      }
      this.barChart.setOption(this.option)
    },
    getValueType() {
      const params = {
        req: {
          corporateGroupName: '集团1',
          queryItem: 'valueanalyse',
          queryTime: '2022-06-23',
          queryType: 0
        }
      }
      this.api.afterSales.aftersaleother(params).then(res => {
        console.log(res)
        const reqData = JSON.parse(res.data.dataList[0].distribution)
        console.log(reqData)
        this.barData = []
        for (let i in reqData) {
          this.barData.push(reqData[i])
        }
        console.log(this.barData)

        this.getChart()
      })
    },
    pieAction(data){

    }
  }
}
</script>

<style lang="scss" scoped>
.analyze-content {
  display: flex;
  padding: 0 8px 1.8vh;
  .bg {
    background-color: #262525;
  }
  .content-left {
    flex: 1;
  }
  .contetn-right {
    width: 43%;
    margin-left: 8px;
  }
}
</style>