<template>
  <div class="tongji">
    <dv-border-box-8>
      <div class="center-cmp">
        <div class="cc-header">
          <dv-decoration-1 style="width:200px;height:50px;" />
          <div style="text-align: center; padding-top: 10px;">
            企业端数据统计汇总
            <br />
            <small>统计时间：{{tjNumberObj.statisticsTime}}</small>
          </div>
          <dv-decoration-1 style="width:200px;height:50px;" />
        </div>

        <div class="cc-details">
          <div class="deItem ce">
            <div>危险源总数</div>
            <div class="card" v-for="(i, index) in jktotalArr" :key="index">{{i}}</div>
          </div>
        </div>

        <div class="cc-main-container">
          <div class="ccmc-left">
            <div class="station-info">
              预警处理中数量
              <span>{{tjNumberObj.alarmingNum}}</span>
            </div>
            <div class="station-info">
              预警已处理数量
              <span>{{tjNumberObj.handleAlarmNum}}</span>
            </div>
          </div>

          <dv-active-ring-chart class="ccmc-middle" :config="config" v-if="config.data.length > 0"/>

          <div class="ccmc-right">
            <div class="station-info">
              <span>{{tjNumberObj.alarmTotal}}</span>预警总数
            </div>
            <div class="station-info">
              <span>{{tjNumberObj.cameraNum}}</span>视频监控数量
            </div>
          </div>
          <div class="label-tag" v-if="config.data.length > 0">
            <div class="label-item" v-for="(item, inde) in config.data" :key="inde">
              {{ item.name }}
              <div :style="`background-color: ${config.color[inde]};`"></div>
            </div>
          </div>
        </div>
      </div>
    </dv-border-box-8>
  </div>
</template>
<script lang="ts">
import { Component, Vue, Provide } from "vue-property-decorator";
import METHOD from "@/utils/methods";
@Component({
  components: {},
})
export default class statistics extends Vue {
  @Provide() config: any = {
    data: [
    ],
    color: ["#469f4b", "#ffc530"], //"#fff", "#ffc530", "#469f4b"
    lineWidth: 30,
    radius: "55%",
    activeRadius: "60%",
  };

  @Provide() labelConfig: any = {
    data: ["企业预警处理中数量", "企业预警已处理数量"],
  };

  @Provide() tjNumberObj: any = {};
  @Provide() jktotalArr: any = [];
  getStatiData() {
    let that = this;
    METHOD.axiosGet(
      that,
      `/dataStatistics/enterpriseDataStatistics/${METHOD.enterpriseId}`,
      function (res: any) {
        if (res.code == 0) {
          that.tjNumberObj = res.data;
          let obj = res.data,
            arr: any = [];
          arr.push({
            name: "预警处理中",
            value: obj.alarmingNum,
          });
          arr.push({
            name: "预警已处理",
            value: obj.handleAlarmNum,
          });
          let ar = obj.dangerNum.toString().split("");
          that.jktotalArr = [...ar];
          that.$nextTick(() => {
            that.$set(that.config, "data", arr);
          });
        }
      }
    );
  }
  created() {
    this.getStatiData();
  }
}
</script>
<style lang="scss">
.tongji {
  background: #011250;
  color: #ffffff;
}
.center-cmp {
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
  display: flex;
  flex-direction: column;
  .cc-header {
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 30px;
    .dv-decoration-1 svg{
      left: auto;
      right: auto;
    }
    small {
      font-size: 14px;
    }
  }
  .cc-details {
    height: 120px;
    display: flex;
    justify-content: space-around;
    font-size: 32px;
    align-items: center;
    .deItem{
      &.lr{
        font-size: 20px;
        text-align: center;
        b{
          color:#ffff00;
        }
      }
      &.ce{
        > div{
          display: inline-block;
          line-height: 70px;
        }
      }
    }
    .card {
      background-color: rgba(4, 49, 128, 0.6);
      color: #08e5ff;
      height: 70px;
      width: 70px;
      font-size: 45px;
      font-weight: bold;
      line-height: 70px;
      text-align: center;
      margin: 10px;
    }
  }
  .cc-main-container {
    position: relative;
    flex: 1;
    display: flex;
    .ccmc-middle {
      width: 50%;
      height: 90%;
      .active-ring-name {
        font-size: 20px !important;
      }
    }
    .ccmc-left,
    .ccmc-right {
      width: 25%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      font-size: 24px;
      span {
        font-size: 40px;
        font-weight: bold;
      }
      .station-info {
        height: 80px;
        display: flex;
        align-items: center;
      }
    }
    .ccmc-left {
      align-items: flex-end;
      span {
        margin-left: 20px;
      }
    }
    .ccmc-right {
      align-items: flex-start;
      span {
        margin-right: 20px;
      }
    }
  }
  .label-tag {
    position: absolute;
    width: 500px;
    height: 30px;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
  }
}
.label-tag {
  display: flex;
  justify-content: center;
  align-items: center;
  .label-item {
    margin: 5px;
    font-size: 15px;
    display: flex;
    align-items: center;
    > div {
      width: 12px;
      height: 12px;
      margin-left: 5px;
    }
  }
}
</style>