<template>
  <div class="app-container clue-container">
    <div class="common-title">商机线索</div>
    <el-tabs v-model="activeName" @tab-click="handleClick" class="tabpane selfTab">
      <el-tab-pane label="按金额" name="first"></el-tab-pane>
      <el-tab-pane label="按项目" name="second"></el-tab-pane>
    </el-tabs>
    <div class="flex-box clue-box">
      <div class="clue-echarts"><div id="echartsClue" style="width: 100%;height:300px; margin: 0 auto;"></div></div>
      <div class="table-item">
        <el-table
          :data="tableData"
          border
          style="width: 100%"
          :default-sort = "{prop: 'date', order: 'descending'}"
        >
          <el-table-column
            prop="name"
            label="名称"></el-table-column>
          <el-table-column
            prop="number"
            label="数量">
            <template slot-scope="scope">
              <div style="text-align: right">{{ scope.row.number }}</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="amount"
            label="占比">
            <template slot-scope="scope">
              <div style="text-align: right">{{ scope.row.amount }}</div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="flex-box clue-type">
      <div class="flex-box clue-type-item" :class="{'on':typeName==index}" v-for="(item, index) in typeList" :key="index" @click="handleType(index)"><img :src="item.ico">{{item.name}}</div>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'Busclue',
  data() {
    return {
      viewData:[
        {
          name:'7亿~12亿',
          value:'12'
        },
        {
          name:'4亿~6亿',
          value:'2'
        },
        {
          name:'1亿~3亿',
          value:'42'
        },
        {
          name:'5000万~1亿',
          value:'2'
        },
        {
          name:'5000万以下',
          value:'2'
        },
      ],
      activeName:'first',
      typeName: 0,
      //表格数据
      tableData:[
        {name: '7亿～10亿', number: '2', amount: '0.19%'},
        {name: '4亿~6亿', number: '2', amount: '0.19%'},
        {name: '1亿~3亿', number: '2', amount: '0.19%'},
        {name: '5000万~1亿', number: '2', amount: '0.19%'},
        {name: '5000万以下', number: '2', amount: '0.19%'}
      ],
      typeList:[
        {name: '土地交易', ico: require("@/assets/images/detail/overview/clue_ico1.png")},
        {name: '拟建项目', ico: require("@/assets/images/detail/overview/clue_ico2.png")},
        {name: '专项债项目', ico: require("@//assets/images/detail/overview/clue_ico3.png")},
        {name: '招标计划', ico: require("@/assets/images/detail/overview/clue_ico4.png")},
        {name: '招标公告', ico: require("@/assets/images/detail/overview/clue_ico5.png")},
        {name: '标讯Pro', ico: require("@/assets/images/detail/overview/clue_ico6.png")},
        {name: '行政许可', ico: require("@/assets/images/detail/overview/clue_ico7.png")},
      ]
    }
  },
  created() {
  },
  mounted() {
    this.$nextTick(()=>{
      this.getDT()
    })
  },
  methods: {
    getDT(){
      let myChart = echarts.init(document.getElementById("echartsClue"))
      let option = {
        tooltip: {
          trigger: 'item',
          borderWidth:0,
          backgroundColor:"rgba(255, 255, 255, 0.8)",
          formatter: '{b}<br/>{d}%',
        },
        legend: {
          type: 'scroll',
          orient: 'horizontal',
          bottom: 20,
          data: this.viewData,
          pageButtonPosition: 'end',
        },
        color: ['#8A82F3','#5B9CF7','#43BBE0','#8ECF95','#FFDC6B'],
        series: [
          {
            type: 'pie',
            radius: '55%',
            center: ['50%', '40%'],
            data: this.viewData,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      myChart.setOption(option)
    },
    handleClick(){

    },
    handleType(idx){
      this.typeName = idx
    }
  }
}
</script>

<style lang="scss" scoped>
  .clue-container{
    margin: 0;
    padding: 24px 16px;
    background: #FFFFFF;
    .selfTab{
      margin: 30px 0 0 -12px;
      ::v-deep .el-tabs__nav-wrap::after{
        display: none;
      }
      ::v-deep .el-tabs__item{
        height: 30px;
        line-height: 30px;
        padding: 0 12px;
      }
    }
    .clue-box{
      width: 100%;
      justify-content: space-between;
      align-items: normal;
      margin-top: 4px;
      .clue-echarts{
        width: calc(50% - 8px);
      }
      .table-item{
        width: calc(50% - 8px);
        margin-top:15px;
      }
    }
    .clue-type{
      width: 100%;
      justify-content: space-between;
      border-top: 1px solid #EEEEEE;
      padding-top: 22px;
      margin-right: -16px;
      margin-left: -16px;
      padding-left: 16px;
      padding-right: 16px;
      .clue-type-item{
        color: #232323;
        cursor: pointer;
        &.on{
          color: #0081FF;
        }
        img{
          width: 40px;
          height: 40px;
          margin-right: 8px;
        }
      }
    }
  }
</style>
