<template>
  <div>
    <el-form :inline="true" :model="form" class="demo-form-inline">
      <el-form-item label="监测点:">
        <el-input
          v-model.trim="form.valuePoint"
          placeholder="请输入"
          clearable
        ></el-input>
      </el-form-item>

      <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="
          managementData.slice(
            (currentPage - 1) * pageSize,
            currentPage * pageSize
          )
        "
        :height="vh"
        border
        v-loading="isLoading2"
        style="width: 100%"
        header-cell-class-name="table_header"
        :cell-style="cellstyle"
      >
        <template v-for="(item, index) in tableHeaderAlarm">
          <el-table-column
            :prop="item.prop"
            :label="item.label"
            :key="index"
            :width="item.width"
          >
          </el-table-column>
        </template>
      </el-table>
      <el-pagination
        background
        align="right"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[20, 30, 40, 50, 100]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="managementData.length"
        class="mt10"
      >
      </el-pagination>
    </el-form>
  </div>
</template>

<script>
import { getMonitoringpointAlarmData } from "@/api/Distributionnetwork-analysis/IndicatorAlarmStatistics/IndicatorAlarmStatistics";
// 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: {},
      isLoading2: false,
      device: "",
      currentPage: 1, // 当前页码
      total: 20, // 总条数
      pageSize: 20, // 每页的数据条数
      //监测点告警管理
      tableHeaderAlarm: [
        { prop: "company", label: "单位", width: 150 },
        { prop: "substation", label: "所属变电站", width: 150 },
        { prop: "stationArea", label: "所属台区", width: 150 },
        { prop: "userName", label: "用户名称", width: 150 },
        { prop: "monitoringPoint", label: "监测点类别", width: 150 },
        { prop: "voltageLevel", label: "监测点电压等级(kV)", width: 150 },
        { prop: "monitoringName", label: "监测点名称", width: 150 },
        { prop: "deviation", label: "电压偏差告警", width: 150 },
        { prop: "frequency", label: "频率偏差告警", width: 150 },
        { prop: "unbalance", label: "三相电压不平衡告警", width: 160 },
        { prop: "harmonic", label: "谐波电压告警", width: 150 },
        { prop: "flicker", label: "闪变告警" },
        { prop: "sagVoltage", label: "电压暂降告警", width: 150 },
        { prop: "interruption", label: "电压中断告警", width: 150 },
        { prop: "rating", label: "告警评级" },
      ],
      managementData: [],
    };
  },
  created() {
    this.onSubmit();
  },
  mounted() {
    this.device = window.devicePixelRatio;
    this.vh = document.getElementById("app-main-in").offsetHeight - 165;
  },
  methods: {
    //每页条数改变时触发 选择一页显示多少行
    handleSizeChange(val) {
      this.currentPage = 1;
      this.pageSize = val;
    },
    //当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      this.currentPage = val;
    },
    onSubmit() {
      this.isLoading2 = true;
      this.managementData = [];
      ///方法调用监测点告警管理
      getMonitoringpointAlarmData().then((res) => {
        this.isLoading2 = false;
        this.managementData = res.data;
      });
    },
    // 切换选项
    handleNodeClick(data) {
      // console.log(data);
    },
    cellstyle(row) {
      // console.log(row);
      if (
        row.row.monitoringPoint == "Ⅱ类监测点" ||
        row.row.monitoringPoint == "Ⅲ类监测点"
      ) {
        row.row.substation = "/";
      }
      if (
        row.row.monitoringPoint == "Ⅰ类监测点" ||
        row.row.monitoringPoint == "Ⅲ类监测点"
      ) {
        row.row.stationArea = "/";
      }
      if (
        row.row.monitoringPoint == "Ⅰ类监测点" ||
        row.row.monitoringPoint == "Ⅱ类监测点"
      ) {
        row.row.userName = "/";
      }
    },
  },
};
</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>