<template>
  <div style="padding: 0px">
    <el-col :span="24">
      <el-table
        stripe
        :data="list"
        :height="vh"
        border
        class="mt10"
        style="width: 100%; height: 100%"
        v-loading="isLoading"
        header-cell-class-name="table_header"
      >
        <el-table-column
          show-overflow-tooltip
          label="供电公司"
          prop="gdName"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="变电站"
          show-overflow-tooltip
          prop="subName"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="监测点"
          show-overflow-tooltip
          prop="lineName"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="暂降次数"
          show-overflow-tooltip
          prop="tail"
          align="center"
        >
        </el-table-column>
      </el-table>
    </el-col>
  </div>
</template>
<script>
import { dicData } from "@/assets/commjs/dictypeData";
import { getEventHeatMap } from "@/api/sagSeverity.js";
export default {
  props: {
    item: {
      type: Object,
      default: null,
    },
    item2: {
      type: Object,
      default: null,
    },
    height: {
      type: Number,
      default: null,
    },
    height2: {
      type: Number,
      default: null,
    },
  },
  watch: {
    height2(a, b) {
      if (a == 24) {
        this.vh = document.getElementById("conmentId").offsetHeight;
        this.queryData();
      } else {
        return;
      }
    },
    height(a, b) {
      if (a == 6 || a == 8 || a == 9 || a == 16) {
        setTimeout(() => {
          let str = document.getElementById("areahotable").style.height;
          let strsec = str.split("p");
          let height = parseInt(strsec) - 50;
          this.vh = height;
          this.queryData();
        }, 200);
      } else {
        return;
      }
    },
    deep: true,
  },
  data() {
    return {
      isLoading: false,
      vh: null,
      h: 0,
      classificationData: [],
      list: [],
      time: this.timefamt(),
      formData: {
        deptIndex: JSON.parse(window.sessionStorage.getItem("Info")).deptId,
        lineGrade: null,
        loadType: null,
        manufacturer: null,
        monitorFlag: 2,
        powerFlag: 1,
        reportFlag: 3,
        scale: null,
        searchBeginTime: "",
        searchEndTime: "",
        serverName: "",
        statFlag: true,
        statisticalType: "",
        timeFlag: 0,
      },
      //   classificationData: [],
    };
  },
  created() {
    this.getclassificationData();
    this.queryData();
  },
  mounted() {
    setTimeout(() => {
      let str = document.getElementById("areahotable").style.height;
      let strsec = str.split("p");
      let height = parseInt(strsec) - 50;
      this.vh = height;
    }, 200);
  },
  methods: {
    //获取统计类型
    getclassificationData() {
      var code = "Statistical_Type";
      this.classificationData = dicData(code, ["Report_Type"]);

      this.formData.statisticalType = this.classificationData[0];
    },
    timefamt() {
      var date = new Date();
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var day = date.getDate();
      month = month > 9 ? month : "0" + month;
      day = day < 10 ? "0" + day : day;
      var arr = [];
      var time1 = year + "-" + month + "-01";
      arr.push(time1);
      var time2 = year + "-" + month + "-" + day;
      arr.push(time2);
      return arr;
    },
    queryData() {
      this.isLoading = true;
      this.formData.searchBeginTime = this.time[0];
      this.formData.searchEndTime = this.time[1];
      getEventHeatMap(this.formData).then((res) => {
        if (res.data.eventHeatMapValue != []) {
          res.data.eventHeatMapValue.forEach((val) => {
            val.forEach((item) => {
              this.list.push(item);
            });
          });
        }
        this.isLoading = false;
      });
    },
  },
};
</script>
