<!--
 * @Author: your name
 * @Date: 2022-04-11 15:07:47
 * @LastEditTime: 2022-04-20 11:09:34
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /gassafety-progress/gassafetyprogress-web/src/views/operationMonitor/xunjianxuncha/topChars/left.vue
-->
<template>
  <div class="charsCom all-flex-h">
    <div class="title">报警处置</div>
    <div class="two all-flex">
      <div class="left">
        <div class="first">
          <span class="text">报警情况</span>
          <span>{{hiddenBookInfo.finishNum + hiddenBookInfo.unFinishNum}}次</span>
        </div>
        <div class="second all-flex">
          <div class="left">未处理总数</div>
          <div class="right">已处理总数</div>
        </div>
        <div class="third all-flex">
          <div class="left">{{ hiddenBookInfo.unFinishNum}}</div>
          <div class="right">{{hiddenBookInfo.finishNum}}</div>
        </div>
      </div>
      <div class="right">
        <div class="first">
          <span class="text">报警处置率</span>
        </div>
        <div class="chars-box" id ="main1">
          <!--<Chars color="#604AFF" :options="option"></Chars>-->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Chars from "@/components/allCharsCom/Chars";
import { listDetectorReportData } from "@/api/detector/detectorReportData";
export default {
  components: {
    Chars,
  },
  created(){
    this.bottomOptions();
  },
  data() {
    return {

      option:{
        color:['blue','lightblue'],
        grid: {
          bottom: "7%",
          containLabel: true,
        },
        tooltip: {
          trigger: "item",
        },
        series: [
          {
            name: '访问来源',
            type: 'pie',
            radius: ['40%', '70%'],
            label: {
              show: true,
              position: 'center'
            },
            labelLine: {
              show: false
            },
            data: [
              {value: 0, name: '未处理'},
              {value: 0, name: '已处理'},
            ]
          }
        ]
      },
      hiddenBookInfo: {
        unFinishNum: 0,
        finishNum: 0
      },
      total:0
    };
  },
  methods: {
    bottomOptions() {
      listDetectorReportData({pageNum:1}).then(response => {
        this.total= response.total;
            listDetectorReportData({pageNum:1,isCancelAlarm:0}).then(res => {
              this.option.series[0].data= [
                {value: res.total, name: '未处理'},
                {value: this.total-res.total, name: '已处理'},
              ]
              this.hiddenBookInfo= {
                unFinishNum: res.total,
                  finishNum: this.total-res.total
              }
              var myChart =  this.$echarts.init(document.getElementById('main1'));
              myChart.setOption(this.option);
            });
      })

    }
  },
};
</script>

<style lang="scss" scoped>
.charsCom {
  width: 100%;
  height: 100%;
  color: #333333;
}
.title {
  text-align: center;
  font-size: 24px;
  margin-bottom: 7px;
}
.two {
  // flex: 1;
  > .left {
    margin-right: 70px;
    .first {
      margin-bottom: 6px;
    }
    .second {
      width: 200px;
      height: 30px;
      line-height: 30px;
      box-sizing: border-box;
      box-shadow: 0px 0px 3px 1px #dddddd;
      margin-bottom: 19px;
      > div {
        // flex: 1;
        text-align: center;

        &.left {
          color: #1d8cf3;
        }
        &.right {
          color: #00c3f1;
        }
      }
    }
    .third {
      text-align: center;
      width: 200px;
      margin-bottom: 24px;
    }
  }
  > .right {
    .first {
      text-align: center !important;
    }
    .chars-box {
      width: 220px;
      height: 220px;
      margin: 0 auto;
    }
  }
  > div {
    font-size: 16px;
    flex: 1;
    // display: flex;
    // flex-direction: column;
  }
  .left,
  .right {
    // display: flex;
    // flex-direction: column;
    // justify-content: space-between;
    .first {
      text-align: left;
      .text {
        display: inline-block;
        margin-right: 8px;
      }
    }
  }
}
.three {
  font-size: 16px;
  flex: 1;
  // background: red;
  .chars-box {
    flex: 1;
  }
}
</style>
