<template>
    <div style="padding: 0px">
      <el-col :span="24">
        <vxe-table
      :data="totalData"
      :height="vh"
      border
      stripe
      :row-config="{ isCurrent: true, isHover: true }"
      size="mini"
      ref="Steadystateschedule"
      v-loading="isLoading1"
      style="width: 100%"
      header-cell-class-name="table_header"
    >
      <vxe-table-colgroup
        align="center"
        v-for="(item, index) in tableHeaderTotal"
        :field="item.prop"
        :title="item.label"
        :min-width="item.width"
        :key="index"
        show-overflow
      >
        <!-- <template slot-scope="scope"> -->
          <!-- <span v-if="item.label == '指标趋势图'">
              <el-button type="primary" size="mini" icon="el-icon-view" @click="trendChartFn(scope.row)"
                >查看</el-button
              ></span
            > -->
          <!-- <span
            v-if="item.label == '指标趋势图'"
            type="primary"
            size="small"
            style="color: blue; text-decoration: underline; cursor: pointer"
            @click="trendChartFn(scope.row)"
            >查看</span
          >
          <span v-else>{{ scope.row[item.prop] }}</span>
        </template> -->
        <vxe-table-column
          align="center"
          v-for="(item, index) in item.children"
          :field="item.prop"
          :title="item.label"
          :min-width="item.width"
          :key="index"
        >
          <!-- <template v-for="(item, index) in item.children">
                  <vxe-table-column
                    :field="item.prop"
                    :label="item.label"
                    :key="index"
                  ></vxe-table-column>
                </template> -->
        </vxe-table-column>
      </vxe-table-colgroup>
    </vxe-table>
      </el-col>
    </div>
  </template>
  <script>
 import {
  getRMpPartHarmonicDetail,
  getPmsPowerrInfoWithInOrg,
  getRMpPartHarmonicDetailIcon,
} from "@/api/Statistical-analysis/steadyStateIndicators/steadyStateIndicators";
import { dicData } from "@/assets/commjs/dictypeData";
  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 - 50;
          this.queryData();
        } else {
          return;
        }
      },
      height(a, b) {
        if (a == 6 || a == 8 || a == 9 || a == 16) {
          setTimeout(() => {
            let str = document.getElementById("wtzbcbmxbg").style.height;
            let strsec = str.split("p");
            let height = parseInt(strsec) - 50;
            this.vh = height+10;
            this.queryData();
          }, 200);
        } else {
          return;
        }
      },
    },
    data() {
      return {
        isLoading1:false,
        disdipTable: [],
        totalData:[],
        vh: null,
        time: this.timefamt(),
        //区域超标统计
      tableHeaderTotal: [
        { prop: "orgName", label: "所属单位", width: 180 },
        { prop: "powerrName", label: "所属变电站", width: 120 },
        { prop: "monitorVoltageName", label: "监测点电压等级", width: 180 },
        { prop: "measurementPointName", label: "监测点名称", width: 120 },
        // { prop: "measurementPointId", label: "监测点编号", width: 120 },
        { prop: "measurementOverDay", label: "监测点总超标天数", width: 160 },
    //   /  { prop: "onlineMonitoring", label: "指标趋势图", width: 120 },
        { prop: "freqOverDay", label: "频率偏差", width: 120 },
        {
          label: "电压偏差",
          children: [
            {
              prop: "vdevUpOverDay",
              label: "上偏差",
              width: 80,
            },
            {
              prop: "vdevLowOverDay",
              label: "下偏差",
              width: 80,
            },
            {
              prop: "vdevOverDay",
              label: "合计",
              width: 80,
            },
          ],
        },
        { prop: "vthdOverDay", label: "电压总谐波畸变率", width: 160 },
        { prop: "voverDay", label: "谐波电压", width: 120 },
        { prop: "ioverDay", label: "谐波电流", width: 120 },
        {
          label: "谐波电压含有率",
          children: [
            {
              prop: "v2OverDay",
              label: "2次",
              width: 80,
            },
            {
              prop: "v3OverDay",
              label: "3次",
              width: 80,
            },
            {
              prop: "v4OverDay",
              label: "4次",
              width: 80,
            },
            {
              prop: "v5OverDay",
              label: "5次",
              width: 80,
            },
            {
              prop: "v6OverDay",
              label: "6次",
              width: 80,
            },
            {
              prop: "v7OverDay",
              label: "7次",
              width: 80,
            },
            {
              prop: "v8OverDay",
              label: "8次",
              width: 80,
            },
            {
              prop: "v9OverDay",
              label: "9次",
              width: 80,
            },
            {
              prop: "v10OverDay",
              label: "10次",
              width: 80,
            },
            {
              prop: "v11OverDay",
              label: "11次",
              width:80,
            },
            {
              prop: "v12OverDay",
              label: "12次",
              width: 80,
            },
            {
              prop: "v13OverDay",
              label: "13次",
              width: 80,
            },
            {
              prop: "v14OverDay",
              label: "14次",
              width: 80,
            },
            {
              prop: "v15OverDay",
              label: "15次",
              width: 80,
            },
            {
              prop: "v16OverDay",
              label: "16次",
              width: 80,
            },
            {
              prop: "v17OverDay",
              label: "17次",
              width: 80,
            },
            {
              prop: "v18OverDay",
              label: "18次",
              width: 80,
            },
            {
              prop: "v19OverDay",
              label: "19次",
              width: 80,
            },
            {
              prop: "v20OverDay",
              label: "20次",
              width: 80,
            },
            {
              prop: "v21OverDay",
              label: "21次",
              width: 80,
            },
            {
              prop: "v22OverDay",
              label: "22次",
              width: 80,
            },
            {
              prop: "v23OverDay",
              label: "23次",
              width: 80,
            },
            {
              prop: "v24OverDay",
              label: "24次",
              width: 80,
            },
            {
              prop: "v25OverDay",
              label: "25次",
              width: 80,
            },
          ],
        },
        {
          label: "谐波电流含有率",
          children: [
            {
              prop: "i2OverDay",
              label: "2次",
              width: 80,
            },
            {
              prop: "i3OverDay",
              label: "3次",
              width: 80,
            },
            {
              prop: "i4OverDay",
              label: "4次",
              width: 80,
            },
            {
              prop: "i5OverDay",
              label: "5次",
              width: 80,
            },
            {
              prop: "i6OverDay",
              label: "6次",
              width: 80,
            },
            {
              prop: "i7OverDay",
              label: "7次",
              width: 80,
            },
            {
              prop: "i8OverDay",
              label: "8次",
              width: 80,
            },
            {
              prop: "i9OverDay",
              label: "9次",
              width: 80,
            },
            {
              prop: "i10OverDay",
              label: "10次",
              width: 80,
            },
            {
              prop: "i11OverDay",
              label: "11次",
              width: 80,
            },
            {
              prop: "i12OverDay",
              label: "12次",
              width: 80,
            },
            {
              prop: "i13OverDay",
              label: "13次",
              width: 80,
            },
            {
              prop: "i14OverDay",
              label: "14次",
              width: 80,
            },
            {
              prop: "i15OverDay",
              label: "15次",
              width: 80,
            },
            {
              prop: "i16OverDay",
              label: "16次",
              width: 80,
            },
            {
              prop: "i17OverDay",
              label: "17次",
              width: 80,
            },
            {
              prop: "i18OverDay",
              label: "18次",
              width: 80,
            },
            {
              prop: "i19OverDay",
              label: "19次",
              width: 80,
            },
            {
              prop: "i20OverDay",
              label: "20次",
              width: 80,
            },
            {
              prop: "i21OverDay",
              label: "21次",
              width: 80,
            },
            {
              prop: "i22OverDay",
              label: "22次",
              width: 80,
            },
            {
              prop: "i23OverDay",
              label: "23次",
              width: 80,
            },
            {
              prop: "i24OverDay",
              label: "24次",
              width: 80,
            },
            {
              prop: "i25OverDay",
              label: "25次",
              width: 80,
            },
          ],
        },
        { prop: "inuharmOverDay", label: "间谐波电压含有率", width: 160 },
        { prop: "unbalanceOverDay", label: "三相电压不平衡度", width: 160 },
        { prop: "inegOverDay", label: "负序电流", width: 120 },
        { prop: "flickerOverDay", label: "长时闪变", width: 120 },
      ],
      form: {
        endTime: "",
        id: "",
        startTime: "",
        monitorName: "",
        voltageLevels: [],
        powerrIds: [],
        type: 0,
      },
      };
    },
    created() {
     this.getclassificationData();
     this.form.id = JSON.parse(window.sessionStorage.getItem("Info")).deptId;
      this.queryData();
    },
    mounted() {
      setTimeout(() => {
        let str = document.getElementById("wtzbcbmxbg").style.height;
        let strsec = str.split("p");
        let height = parseInt(strsec) - 50;
        this.vh = height+10;
      }, 200);
    },
    methods: {
         //获取类型
    getclassificationData() {
      //电压等级
      var code = "Dev_Voltage";
      this.voltageLevel = dicData(code, []);
      this.voltageLevel.forEach((item) => {
        this.form.voltageLevels.push(item.id);
      });
    },
      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.isLoading1 = true;
      this.form.startTime = this.time[0];
      this.form.endTime = this.time[1];
      getRMpPartHarmonicDetail(this.form).then((res) => {
        this.isLoading1 = false;
        this.totalData = res.data.splice(0,20)
      });
    },
    },
  };
  </script>
  <style>
  .xshou {
    cursor: pointer;
  }
  </style>
