<template>
  <div class="parcel-box">
    <div class="title">
      <!-- <el-select
        size="mini"
        v-model="company"
        placeholder="请选择"
        @change="getTableDate"
      >
        <el-option
          v-for="item in companyOptions"
          :key="item.id"
          :label="item.aname"
          :value="item.id"
        >
        </el-option>
      </el-select> -->
      <div class="station">
        日期
        <div class="search-input">
          <el-date-picker
            v-model="dateTime"
            size="mini"
            type="daterange"
            range-separator="-"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
            start-placeholder="开始"
            end-placeholder="结束"
            popper-class="date-select"
          >
          </el-date-picker>
        </div>
      </div>
      <!-- <div class="station">
        <span class="timeaa">时间：</span>
        <el-date-picker
          v-model="pickerTimer"
          type="daterange"
          range-separator="To"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          size="mini"
          format="YYYY/MM/DD"
          value-format="YYYY-MM-DD"
        />
      </div> -->
      <el-button round size="mini" class="searchColor" @click="getTableDate"
        >搜 索</el-button
      >
      <!-- <el-button round size="mini">导出</el-button> -->
    </div>
    <div class="data-bodys">
      <div class="line clearfix">
        <div class="leftContent left"><span>复位及时率</span></div>
      </div>
      <div class="economicTable">
        <el-table
          :data="tableData"
          style="width: 100%"
          size="mini"
          stripe
          height="100%"
        >
          <el-table-column
            align="center"
            prop="unit"
            label="风场"
            width="200"
            sortable
          ></el-table-column>
          <el-table-column
            align="center"
            header-align="center"
            prop="five"
            label="5分钟 / 复位次数(次)"
            sortable
          ></el-table-column>
          <el-table-column
            align="center"
            header-align="center"
            prop="fives"
            label="5分钟 / 复位率(%)"
            sortable
          ></el-table-column>
          <el-table-column
            align="center"
            header-align="center"
            prop="ten"
            label="10分钟 / 复位次数(次)"
            sortable
          ></el-table-column>
          <el-table-column
            align="center"
            header-align="center"
            prop="tens"
            label="10分钟 / 复位率(%)"
            sortable
          ></el-table-column>
          <el-table-column
            align="center"
            header-align="center"
            prop="fifteen"
            label="15分钟 / 复位次数(次)"
            sortable
          ></el-table-column>
          <el-table-column
            align="center"
            header-align="center"
            prop="fifteens"
            label="15分钟 / 复位率(%)"
            sortable
          ></el-table-column>
          <el-table-column
            align="center"
            header-align="center"
            prop="twenty"
            label="20分钟 / 复位次数(次)"
            sortable
          ></el-table-column>
          <el-table-column
            align="center"
            header-align="center"
            prop="twentys"
            label="20分钟 / 复位率(%)"
            sortable
          ></el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import dayjs from "dayjs";
import { companys, timelyRate } from "@/api/curveAnalyse";
import dataJson from "./dataJson.json";
export default {
  name: "restorationEfficiency",
  components: {},
  data() {
    return {
      dateTime: [],
      company: "",
      companyOptions: [],
      tableData: [],
      pickerTimer: [],
    };
  },
  watch: {},
  filters: {},
  computed: {},
  created() {
    this.dateTime = [
      dayjs().subtract(1, "week").format("YYYY-MM-DD"),
      dayjs().format("YYYY-MM-DD"),
    ];
    this.initialization();
  },
  methods: {
    initialization() {
      // this.dataChange(dataJson.data)

      companys().then(({ data: res }) => {
        this.companyOptions = res.data;
        this.company = res.data[0].id;
        this.getTableDate();
      });
    },
    getTableDate() {
      timelyRate({
        companyId: this.company,
        beginDate: this.dateTime[0],
        endDate: this.dateTime[1],
      }).then(({ data: res }) => {
        this.dataChange(res);
      });
    },
    dataChange(res) {
      if (res) {
        let data = [];
        res.data.forEach((item, index) => {
          data[index] = {
            unit: item.wpid,
            five: item.wfz,
            fives: item.wfzfwl,
            ten: item.sfz,
            tens: item.sfzfwl,
            fifteen: item.swfz,
            fifteens: item.swfzfwl,
            twenty: item.esfz,
            twentys: item.esfzfwl,
            is_light: false,
          };
        });
        this.tableData = data;
      }
    },
  },
  mounted() {},
  beforeUnmount() {},
};
</script>

<style lang="less" scoped>
.title {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-top: 10px;

  .station {
    display: flex;
    flex-direction: row;
    align-items: center;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #b3b3b3;
    margin-left: 10px;
  }
  .el-date-editor--daterange {
    background: transparent;
    border: 1px solid #2a374f;
    border-radius: 30px;
    height: 25px;
    .el-range-input {
      background: transparent;
      color: #fff;
    }
    .el-range-separator {
      width: 10%;
      color: #fff;
      position: relative;
    }
  }

  .search-input {
    margin-left: 10px;
  }

  .but {
    display: flex;
    flex-direction: row;
    align-content: center;
    margin-left: 20px;
  }

  .buttons {
    background-color: rgba(5, 187, 76, 0.2);
    border: 1px solid #3b6c53;
    color: #b3b3b3;
    font-size: 14px;

    &:hover {
      background-color: rgba(5, 187, 76, 0.5);
      color: #ffffff;
    }
  }
}

.parcel-box {
  height: 100%;
  width: 100%;
  padding: 0 10px;
  padding-bottom: 10px;
  .line {
    padding-bottom: 5px;
    .leftContent {
      width: 242px;
      height: 41px;
      line-height: 41px;
      background: url("~@/assets/imgs/title_left_bg.png") no-repeat;

      span {
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #05bb4c;
        margin-left: 25px;
      }
    }

    .rightContent {
      width: 212px;
      height: 28px;
      margin-top: 13px;
      background: url("../../../../assets/imgs/title_right_bg.png");
    }
  }
  .data-bodys {
    display: flex;
    flex-direction: column;
    background-color: rgba(0, 0, 0, 0.45);
    border-radius: 5px;
    height: calc(100% - 45px);
    padding-top: 10px;
    .economicTable {
      width: 100%;
      height: calc(100% - 40px);
    }
  }
}

.clearfix::after {
  content: "";
  clear: both;
  height: 0;
  line-height: 0;
  visibility: hidden;
  display: block;
}

.clearfix {
  zoom: 1;
}

.left {
  float: left;
}

.right {
  float: right;
}

.searchColor {
  background-color: rgba(5, 187, 76, 0.2);
  border: 1px solid #3b6c53;
  color: #b3b3b3;
  font-size: 14px;
  margin-left: 10px;
  &:hover {
    background-color: rgba(5, 187, 76, 0.5);
    color: #ffffff;
  }
}
</style>
<style lang="less" scoped>
::v-deep .el-table__body-wrapper {
  background: #142446 !important;
}
</style>
