<template>
  <div class="app-container clue-container">
    <div class="common-title">风险概览</div>
    <div class="flex-box clue-box">
      <div class="clue-echarts"><div id="echartsRisk" style="width: 100%;height:300px; margin: 0 auto;"></div></div>
      <div class="table-item">
        <el-table
          :data="viewData"
          border
          style="width: 100%"
          :default-sort = "{prop: 'date', order: 'descending'}"
        >
          <el-table-column
            prop="name"
            label="风险纬度分布"></el-table-column>
          <el-table-column
            prop="value"
            label="数量">
            <template slot-scope="scope">
              <div style="text-align: right">{{ scope.row.value }}</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="bl"
            label="占比">
            <template slot-scope="scope">
              <div style="text-align: right">{{ scope.row.bl }}</div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'Risk',
  data() {
    return {
      viewData:[
        {
          name:'开庭公告',
          value:'2',
          tz:'50.01',
          bl:'0.19%'
        },
        {
          name:'企业公告',
          value:'2',
          tz:'50.01',
          bl:'0.19%'
        },
        {
          name:'送达公告',
          value:'2',
          tz:'50.01',
          bl:'0.19%'
        },
        {
          name:'对外投资变更',
          value:'7',
          tz:'50.01',
          bl:'0.19%'
        },
        {
          name:'法院公告',
          value:'2',
          tz:'50.01',
          bl:'0.19%'
        },
        {
          name:'立案信息',
          value:'3',
          tz:'50.01',
          bl:'0.19%'
        },
        {
          name:'被执行人',
          value:'5',
          tz:'50.01',
          bl:'0.19%'
        },
        {
          name:'行政处罚',
          value:'11',
          tz:'50.01',
          bl:'0.19%'
        },
      ]
    }
  },
  created() {
  },
  mounted() {
    this.$nextTick(()=>{
      this.getDT()
    })
  },
  methods: {
    getDT(){
      let myChart = echarts.init(document.getElementById("echartsRisk"))
      let option = {
        tooltip: {
          trigger: 'item',
          borderWidth:0,
          backgroundColor:"rgba(255, 255, 255, 0.8)",
          formatter: function (params) {
            var result = ''
            result+='<h3 style="color: #232226;padding: 0 0 5px 0;margin: 0;">'+ params.data.name +'</h3>'
            result+='<p style="color: rgba(35,35,35,0.8);padding: 0;margin: 0;">'+ params.data.value +'个</p>'
            result+='<p style="color: rgba(35,35,35,0.8);padding: 0;margin: 0;">'+ params.data.tz +'亿元</p>'
            result+='<p style="color: rgba(35,35,35,0.8);padding: 0;margin: 0;">'+ params.data.bl +'%</p>'
            return result;
          },
          extraCssText:'width:150px!important;',
        },
        legend: {
          type: 'scroll',
          orient: 'horizontal',
          bottom: 20,
          data: this.viewData,
          pageButtonPosition: 'end',
        },
        color: ['#8A82F3','#5B9CF7','#43BBE0','#8ECF95','#FFDC6B', '#FE9C77', '#E8649B', '#8A82F3'],
        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)
    }
  }
}
</script>

<style lang="scss" scoped>
  .clue-container{
    margin: 0;
    padding: 24px 16px;
    background: #FFFFFF;
    .clue-box{
      width: 100%;
      justify-content: space-between;
      align-items: normal;
      margin-top: 20px;
      .clue-echarts{
        width: calc(50% - 8px);
      }
      .table-item{
        width: calc(50% - 8px);
        ::v-deep .el-table--border .el-table__cell{
          border-bottom: 0;
        }
      }
    }
  }
</style>
