<template>
  <div>
    <el-form :inline="true" :model="form" class="demo-form-inline">
      <el-form-item>
        <Area @click="handleNodeClick"></Area>
      </el-form-item>

      <el-form-item>
        <Timeinterval :interval="1" ref="interval"></Timeinterval>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          @click="onSubmit"
          class="ml10"
          icon="el-icon-search"
          >查询</el-button
        >
        <el-button type="primary" icon="el-icon-download">导出</el-button>
      </el-form-item>
      <el-table
        stripe
        :data="alarmData"
        :height="vh"
        border
        v-loading="isLoading3"
        style="width: 100%"
        header-cell-class-name="table_header"
      >
        <template v-for="(item, index) in tableHeaderCensus">
          <el-table-column
            :prop="item.prop"
            :label="item.label"
            :key="index"
            :width="item.width"
          >
          </el-table-column>
        </template>
      </el-table>
    </el-form>
  </div>
</template>

<script>
import { getCensusData } from "@/api/areaalarm";
// import { dictypeData } from "@/api/user";
import Area from "@/views/components/Area/Area.vue";
import Timeinterval from "../../../components/Timeinterval.vue";
export default {
  components: { Area, Timeinterval },
  data() {
    return {
      vh: null,
      date: "",
      input: "",
      form: {},
      CompanyList: [], //所属单位数据
      isLoading3: false,
      device: "",
      //告警统计
      tableHeaderCensus: [
        { prop: "company", label: "单位", width: 180 },
        { prop: "monitoring", label: "在线监测点数" },
        { prop: "alarmMonitoring", label: "告警监测点数" },
        { prop: "proportion", label: "告警监测点占比(%)" },
        { prop: "alarmProportion", label: "告警监测点占比同比(%)" },
      ],
      alarmData: [],
    };
  },
  created() {
    this.onSubmit();
  },
  mounted() {
    this.device = window.devicePixelRatio;
    this.vh = document.getElementById("app-main-in").offsetHeight - 123;
  },
  methods: {
    onSubmit() {
      this.isLoading3 = true;
      //方法调用告警统计
      getCensusData().then((res) => {
        this.isLoading3 = false;
        this.alarmData = res.data;
      });
    },
    // 切换选项
    handleNodeClick(data) {
      // console.log(data);
    },
  },
};
</script>

<style lang="less" scoped>
@import url("../../../../styles/comStyle.less");
/deep/.el-table .cell {
  text-align: center;
}
/deep/.el-tabs--border-card > .el-tabs__content {
  padding: 10px;
}
/deep/.el-form-item {
  margin-bottom: 0;
}
</style>