<template>
  <div class="daily">
    <h1 class="tit">山西晋能新能源日报</h1>
    <div class="daily-table">
      <el-table :data="tableData" :row-class-name="tableRowClassName">
        <el-table-column
          prop="foreignkeyname"
          align="center"
          label="风场名称"
          width="100"
        >
        </el-table-column>
        <el-table-column
          prop="speed"
          align="center"
          label="平均风速(m/s)"
          width="91"
        >
        </el-table-column>
        <el-table-column prop="rfdl" align="center" label="日发电量(万KWh)">
        </el-table-column>
        <el-table-column
          prop="yljfdl"
          align="center"
          label="月累计发电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="nljfdl"
          align="center"
          label="年累计发电量(万KWh)"
        >
        </el-table-column>
        <el-table-column prop="rswdl" align="center" label="日上网电量(万KWh)">
        </el-table-column>
        <el-table-column
          prop="yljswdl"
          align="center"
          label="月上累计网电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="nljswdl"
          align="center"
          label="年上累计网电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="zhcydl"
          align="center"
          label="综合厂用电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="yljzhcydl"
          align="center"
          label="月累计综合厂用电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="scadarfdl"
          align="center"
          label="SCADA日发电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="scadayljfdl"
          align="center"
          label="SCADA月累计发电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="scadanljfdl"
          align="center"
          label="SCADA年累计发电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="scadazhcydl"
          align="center"
          label="SCADA综合厂用电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="scadayljzhcydl"
          align="center"
          label="SCADA月累计综合厂用电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="scadazhcydl"
          align="center"
          label="SCADA综合厂用电率(%)"
        >
        </el-table-column>
        <el-table-column
          prop="rxdssdl"
          align="center"
          label="日限电损失电量(KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="yljxdssdl"
          align="center"
          label="月累计限电损失电量(万KWh)"
        >
        </el-table-column>
        <el-table-column
          prop="nljxdssdl"
          align="center"
          label="年累计限电损失电量(万KWh)"
        >
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import api from "@api/economic/index.js";
import { number } from "echarts";
export default {
  data() {
    return {
      dateArea: [
        this.fmtDate(
          new Date(
            new Date().setTime(new Date().getTime() - 60 * 60 * 24 * 1000)
          )
        ),
      ],
      tableData: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (row.isWind == 1) {
        return "warning-row";
      }
      return "";
    },
    getList: function () {
      api
        .energyDaily({
          theday: this.dateArea[0],
        })
        .then((res) => {
          let newArr = [];
          for (let key in res.data) {
            newArr.push(...res.data[key]);
          }
          for (let i = 0; i < newArr.length; i++) {
            if (newArr[i].isWind != "0") {
              newArr[i].foreignkeyname = newArr[i].foreignkeyname + "（合计）";
            }
            for (let key in newArr[i]) {
              if (typeof newArr[i][key] == "number") {
                newArr[i][key] = newArr[i][key].toFixed(2);
              }
            }
          }
          this.tableData = newArr;
        });
    },
    // 格式化日期
    fmtDate(date) {
      let curDate = date || new Date();
      let year = curDate.getFullYear();
      let mouth = curDate.getUTCMonth() + 1;
      let day = curDate.getDate();
      return (
        year +
        "-" +
        (mouth < 10 ? "0" + mouth : mouth) +
        "-" +
        (day < 10 ? "0" + day : day)
      );
    },
  },
};
</script>

<style lang="less" scoped>
.daily {
  .tit {
    text-align: center;
    color: rgb(131, 121, 121);
  }
  .daily-table {
    margin: 20px 20px 0 20px;
  }
  .active {
    background-color: beige;
  }
}
</style>