<template>
  <div class="safe">
    <div class="label">安检</div>
    <!--<div class="d1">-->
    <div class="f2">
      <div id="safe"></div>
      <div id="safeerror"></div>
    </div>
    <div class="f1">
      <table>
        <tr>
          <td class="td1"><img src="../../../../static/ManageHomePic/图层11.png"></td>
          <td>安检总数<br/>&nbsp;<span class="s1">22万</span></td>
        </tr>
        <tr>
          <td class="td1"><img src="../../../../static/ManageHomePic/椭圆8拷贝6.png"></td>
          <td>隐患总数<br/>&nbsp;<span class="s2">23万</span></td>
        </tr>
      </table>
    </div>

    <!--</div>-->
  </div>
</template>

<script>
  export default {
    name: "safe-check",
    props:{
      listenheight:String,
    },
    data() {
      return {
        xc: '',
        safedata: [{value: 6000, name: '已完成'}, {value: 1000, name: '未完成'}],
        safeerrordata: [{value: 6000, name: '已完成'}, {value: 1000, name: '未完成'}],
      }
    },
    methods: {
      setBar(id, iddata) {
        this.xc = this.$echarts.init(document.getElementById(id))
        var scale = 0.8
        var color = ["#e7c83c", "#2f3f2b"]
        var center = [66, 82]
        if (id == 'safeerror') {
          color = ["#69d8d2", "#013e48"]
          center = [66, 82]
        }
        this.xc.setOption({
          color: color,
          series: [
            {
              name: 'demo',
              type: 'pie',
              center: ['52%', '55%'],
              radius: ['30%', '50%'],
              minAngle: 15,//最小角度
              startAngle: 90, //起始角度
              avoidLabelOverlap: false,
              hoverAnimation: false,
              label: {
                normal: {
                  formatter: function (params, ticket, callback) {
                    if (id == 'safe') {
                      return '{a|' + params.name + '}{a|' + params.value + '}\n';
                    }
                    return '{b|' + params.name + '}{b|' + params.value + '}\n';
                  },
                  borderWidth: 20 * scale,
                  borderRadius: 4 * scale,
                  padding: [0, -80 * scale],
                  rich: {
                    a: {
                      color: '#f3c832',
                      fontSize: 12 * scale,
                    },
                    b: {
                      fontSize: 12 * scale,
                      color: '#6fd9d0'
                    }
                  }
                }
              },
              labelLine: {
                normal: {
                  length: 10 * scale,
                  length2: 80 * scale,
                  lineStyle: {
                    color: color[0]
                  }
                }
              },
              data: iddata
            }
          ]
        })
      },
    },
    watch:{
      'listenheight':{
        deep:true,
        handler(val) {
          if(this.listenheight!==''){
            var self= this.$echarts.init(document.getElementById('safe'))
            this.$parent.$parent.changeresize(self)
            var self1= this.$echarts.init(document.getElementById('safeerror'))
            this.$parent.$parent.changeresize(self1)
          }
        },
      }
    },
    ready() {
      this.setBar('safe', this.safedata)
      this.setBar('safeerror', this.safeerrordata)
    }
  }
</script>

<style scoped>
  .label {
    margin-left: 6%;
    font-size: 0.85em;
    float: left;
    color: #fff;
    height: 8%;
  }

  .safe {

  }

  table {
    width: 100%;
    height: 100%;
  }

  td {
    /*width: 94px;*/
    /*height: 120px;*/
    font-size: 0.75em;
    width: 50%;
    height: 50%;
    color: #ffffff;
  }

  .td1 {
    width: 30%;
  }

  .f1 {
    /*height: 314px;*/
    /*width: 180px;*/
    padding: 0% 0% 0% 5%;
    height: 90%;
    width: 40%;
    float: left;
  }

  .f2 {
    height: 100%;
    width: 60%;
    float: right;
  }

  span {
    font-size: 1.5em;
  }

  #safe {
    width: 100%;
    height: 50%;
  }

  #safeerror {
    width: 100%;
    height: 50%;
  }

  .s1 {
    color: #f3c832;
  }

  .s2 {
    color: #05c3c7;
  }

  img {
    width: 78%;
    /*height: 34%;*/
  }
</style>
