index - 副本.vue 13.8 KB
<template>
  <div class="clerk-wrapper manage-container">
    <el-header>
      <span class="asis-title">竞品详情对比分析</span>
    </el-header>
    <div class="element-main base-main">
      <el-row class="manage-content">
        <el-table :data="tableData"
            :max-height="tableHeight"
            style="width: 100%"
            header-row-class-name="manage-tab-head">
          <el-table-column align="center" :label="$t('table.order')" width="100" type="index"></el-table-column>
          <el-table-column label="对比内容" prop="content" align="center" width="180"></el-table-column>
          <el-table-column label="重庆渝北吾悦广场" prop="product1" align="center">
            <template slot-scope="scope">
              <div v-if="scope.row.type=='format'">
                <div :ref="'product1'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='businessDistrict'">
                <div :ref="'product1'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='sex'">
                <div :ref="'product1'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='age'">
                <div :ref="'product1'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='occupation'">
                <div :ref="'product1'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='education'">
                <div :ref="'product1'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='income'">
                <div :ref="'product1'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='restaurant'">
                <div :ref="'product1'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='consumptionScenario'">
                <div :ref="'product1'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else>
                {{scope.row.product1}}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="中粮重庆大悦城" prop="product2" align="center">
            <template slot-scope="scope">
              <div v-if="scope.row.type=='format'">
                <div :ref="'product2'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='businessDistrict'">
                <div :ref="'product2'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='sex'">
                <div :ref="'product2'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='age'">
                <div :ref="'product2'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='occupation'">
                <div :ref="'product2'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='education'">
                <div :ref="'product2'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='income'">
                <div :ref="'product2'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='restaurant'">
                <div :ref="'product2'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='consumptionScenario'">
                <div :ref="'product2'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else>
                {{scope.row.product2}}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="龙湖公园天街" prop="product3" align="center">
            <template slot-scope="scope">
              <div v-if="scope.row.type=='format'">
                <div :ref="'product3'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='businessDistrict'">
                <div :ref="'product3'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='sex'">
                <div :ref="'product3'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='age'">
                <div :ref="'product3'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='occupation'">
                <div :ref="'product3'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='education'">
                <div :ref="'product3'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='income'">
                <div :ref="'product3'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='restaurant'">
                <div :ref="'product3'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else-if="scope.row.type=='consumptionScenario'">
                <div :ref="'product3'+scope.row.type" style="width:100%;height:200px;margin: 0 auto;"></div>
              </div>
              <div v-else>
                {{scope.row.product3}}
              </div>
            </template>
          </el-table-column>
        </el-table>
      </el-row>

    </div>
  </div>
</template>

<script>
  import echarts from 'echarts'
  export default {
    data() {
      return {
        optionPie: {
          tooltip: {
            trigger: 'item',
            formatter: '{b} : {d}%'
          },
          color:["#3BB8FF", "#FFC62E", "#FF9631", "#4396ec", "#f39c38",
                "#4054af", "#d83965", "#e35241", "#6041b0", "#4fb9d1",
                "#3f9488", "#97c05c", "#154bee"],
          series: [
            {
              type: 'pie',
              radius: '50%',
              data: []
            }
          ]
        },
        optionBar:{
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            }
          },
          grid: {
              left: '4%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },
          color:["#3BB8FF", "#FFC62E", "#FF9631", "#4396ec"],
          xAxis: {
            type: 'category',
            data: ['中央公园','空港新城','悦来','翠云']
          },
          yAxis: {
            type: 'value'
          },
          series: [
            {
              name: '居住人口',
              data: [],
              type: 'bar',
              stack:'1',
               barWidth: '30',
            },
            {
              name: '办公人口',
              data: [],
              type: 'bar',
              stack:'1',
              barWidth: '30',
            }
          ]
        },
        formatDistribution:['零售','餐饮','儿童亲子','文体娱乐','生活服务','其他类型'],//业态分布
        businessDistrict:['中央公园','空港新城','悦来','翠云'],//商区区位
        sexArr:['男','女'],//性别
        ageArr:['18岁以下','19-24','25-34','35-44','45-54','55岁以上'],//年龄
        occupationArr:['制造','教育','零售','建筑','水电煤气等','其他'],//职业
        educationArr:['专科','本科及以上','高中及以下'],//学历
        incomeArr:['3000以下','3000-5000','5000-8000','8000-15000','15000-20000','20000-30000','30000-50000','50000以上'],//收入
        restaurantArr:['50以下','50-100','100-300','300以上'],//餐饮
        consumptionScenarioArr:['餐饮行业到访','购物到访','医疗健康到访','教育培训到访','休闲娱乐到访','其他到访'],//消费场景
        tableData: [],
        formatData:[[8,40,2,6,6,0],[69,42,4,12,6,4],[11,34,2,6,5,3]],
        businessDistrictData:[[[44500,20600,20400,3],[20400,8600,16600,16]],[[43100,25400,4800,100],[19500,27700,2400,16]],[[44600,23200,13400,63],[20300,18300,6100,42]]],
        sexData:[[48.9,51.1],[48.9,51.1],[49.0,51.0]],
        ageData:[[14.8,14.2,19.8,18.4,13.3,18.5],[14.7,14,20.2,19.3,13.4,18.3],[14.8,14.2,20,19.3,13.3,18.4]],
        occupationData:[[17.2,14.7,11.6,11.4,8.6,36.5],[17.0,14.9,11.3,11.4,8.7,36.7],[16.9,14.7,11.6,11.4,8.6,36.8]],
        educationData:[[20.7,12.2,67.1],[21,12.5,66.5],[20.8,12.4,66.8]],
        incomeData:[[6.1,40,43.4,8.5,1.5,0.3,0.2,0],[6.1,40,43.3,8.6,1.5,0.3,0.2,0],[6.1,40,43.3,8.6,1.5,0.3,0.2,0]],
        restaurantData:[[18.4,78.3,3.0,0.3],[16.5,79.2,3.9,0.4],[16.5,79.2,3.9,0.4]],
        consumptionScenarioData:[[22.1,19.4,3.4,3.3,3.3,48.5],[21.2,18.8,3.1,3.5,3.5,50.1],[21.9,18.8,3.3,3.4,3.3,49.3]],
      }
    },
    computed: {
      tableHeight() {
        const windowInnerHeight = window.innerHeight;
        return (
          windowInnerHeight -
          (windowInnerHeight <= 720
            ? windowInnerHeight * 0.26
            : windowInnerHeight * 0.24)
        );
      }
    },
    mounted() {
      this.init()
    },
    methods: {
      init(){
        this.tableData = [
          {
          content: '面积',
          product1: '12.4万㎡',
          product2: '18万㎡',
          product3: '14万㎡',
          }, {
          content: '业态分布',
          type:'format',
          product1: [8,40,2,6,6,0],
          product2: [69,42,4,12,6,4],
          product3: [11,34,2,6,5,3],
          }, {
          content: '辐射片区',
          type:'businessDistrict',
          product1: '',
          product2: '',
          product3: '',
          },{
          content: '性别',
          type:'sex',
          product1: '',
          product2: '',
          product3: '',
          },{
          content: '年龄',
          type:'age',
          product1: '',
          product2: '',
          product3: '',
          },{
          content: '职业分布',
          type:'occupation',
          product1: '',
          product2: '',
          product3: '',
          },{
          content: '学历分布',
          type:'education',
          product1: '',
          product2: '',
          product3: '',
          },{
          content: '收入分布',
          type:'income',
          product1: '',
          product2: '',
          product3: '',
          },{
          content: '餐饮人均消费',
          type:'restaurant',
          product1: '',
          product2: '',
          product3: '',
          },{
          content: '消费场景偏好',
          type:'consumptionScenario',
          product1: '',
          product2: '',
          product3: '',
          },
        ]
        // 业态
        this.getCharts('format',this.formatData,this.formatDistribution)
        // 商品区位
        this.getBarCharts('businessDistrict')
        // 性别
        this.getCharts('sex',this.sexData,this.sexArr)
        // 年龄
        this.getCharts('age',this.ageData,this.ageArr)
        // 职业
        this.getCharts('occupation',this.occupationData,this.occupationArr)
        // 学历
        this.getCharts('education',this.educationData,this.educationArr)
        // 收入
        this.getCharts('income',this.incomeData,this.incomeArr)
        // 餐饮人均消费
        this.getCharts('restaurant',this.restaurantData,this.restaurantArr)
        // 消费场景偏好
        this.getCharts('consumptionScenario',this.consumptionScenarioData,this.consumptionScenarioArr)

      },
      getBarCharts(type){
        setTimeout(()=>{
          for (var i = 0; i < 3; i++) {
            let num = i+1
            let myChart = echarts.init(this.$refs['product'+num +type ]);
            this.optionBar.series[0].data=this.businessDistrictData[i][0]
            this.optionBar.series[1].data=this.businessDistrictData[i][1]
            myChart.setOption(this.optionBar)
          }
        },1000)
      },
      /**
       * type 类型
        chartData 数据
        nameArr:名称
       */
      getCharts(type,chartData,nameArr){
        setTimeout(()=>{
          for (var i = 0; i < 3; i++) {
            let num = i+1
            let myChart = echarts.init(this.$refs['product'+num +type ]);
            this.optionPie.series[0].data=this.objectFun(chartData[i],nameArr)
            myChart.setOption(this.optionPie)
          }
        },1000)
      },
      objectFun(arr1,arr2){
        let newArr = []
        arr1.forEach((item,index)=>{
          newArr.push({
            value:item,
            name:arr2[index]
          })
        })
        return newArr
      }
    },
  }
</script>

<style scoped lang="less">
  .element-main{
    padding: 12px 18px;
    margin-top: 60px !important;
  }
  .manage-container{
    height: calc(100% - 60px) !important;
  }
  .manage-content{
    /deep/.manage-tab-head th {
      padding-top: 13px;
      padding-bottom: 11px;
    }
  }
</style>