<template>
  <div>
    <div class="query mg-b-8">
      <div class="query-items">
        <div class="query-item" v-if="option.shows == 'd'">
          <div class="lable">日期：</div>
          <div class="search-input">
            <el-date-picker
              v-model="option.date"
              type="date"
              placeholder="选择日期"
              popper-class="date-select"
              value-format="YYYY-MM-DD"
            ></el-date-picker>
          </div>
        </div>
        <div class="query-item" v-if="option.shows == 'm'">
          <div class="lable">年月：</div>
          <div class="search-input">
            <el-date-picker
              v-model="option.date"
              type="month"
              placeholder="选择年月"
              popper-class="date-select"
              value-format="YYYY-MM"
            ></el-date-picker>
          </div>
        </div>
        <div class="query-item" v-if="option.shows == 'y'">
          <div class="lable">年：</div>
          <div class="search-input">
            <el-date-picker
              v-model="option.date"
              type="year"
              placeholder="选择年"
              popper-class="date-select"
              value-format="YYYY"
            ></el-date-picker>
          </div>
        </div>
        <div class="query-actions">
          <button class="btn green" @click="getTable">查询</button>
        </div>
      </div>
    </div>
    <div class="table-box">
      <Table
        ref="curRef"
        :data="hisData"
        height="70vh"
        v-loading="tableLoading"
        element-loading-text="拼命加载中.."
        element-loading-background="rgba(0, 0, 0, 0.8)"
      ></Table>
    </div>
  </div>
</template>
<script>
import Table from "@/components/coms/table/table-unpage.vue";
export default {
  name: "gradeHistory",
  components: { Table },
  props: {
    gridDatas: {},
    option: Object,
  },
  data() {
    return {
      res: {
        code: 200,
        data: [
          {
            id: 998841,
            windpowerstationid: "MHS_FDC",
            projectid: "MHS01_GC",
            lineid: "MHS01_XL",
            windturbineid: "MG01_01",
            recorddate: 1635696000000,
            dayfdl: 14752.0,
            monthfdl: 2.0,
            yearfdl: 53.0,
            dayllfdl: 14752.0,
            monthllfdl: 2.0,
            yearllfdl: 101.0,
            dayfs: 7.24,
            monthfs: 2.0,
            yearfs: 45.0,
            daygl: 637.84,
            monthgl: 2.0,
            yeargl: 44.0,
            daygzssdl: 0.0,
            monthgzssdl: 1.0,
            yeargzssdl: 47.0,
            dayxdssdl: 0.0,
            monthxdssdl: 4.0,
            yearxdssdl: 33.0,
            daywhssdl: 0.0,
            monthwhssdl: 1.0,
            yearwhssdl: 47.0,
            dayxnssdl: 0.0,
            monthxnssdl: 1.0,
            yearxnssdl: 20.0,
            daygzsj: 0.0,
            monthgzsj: 1.0,
            yeargzsj: 47.0,
            daywhsj: 0.0,
            monthwhsj: 2.0,
            yearwhsj: 39.0,
            dayyxsj: 23.65,
            monthyxsj: 1.0,
            yearyxsj: 47.0,
            daytjsj: 0.35,
            monthtjsj: 1.0,
            yeartjsj: 58.0,
            daylyxs: 9.83,
            monthlyxs: 2.0,
            yearlyxs: 53.0,
            daynhyd: 0.18,
            monthnhyd: 3.0,
            yearnhyd: 99.0,
            daysbklyl: 100.0,
            monthsbklyl: 2.0,
            yearsbklyl: 103.0,
            daydxkyxs: 100.0,
            monthdxkyxs: 2.0,
            yeardxkyxs: 53.0,
            dayyxfss: 23.78,
            monthyxfss: 2.0,
            yearyxfss: 47.0,
            dayxfqr: 3.0,
            monthxfqr: 4.0,
            yearxfqr: 207.0,
            dayjfpl: 0.9,
            monthjfpl: 2.0,
            yearjfpl: 52.0,
            dayglyzxxs: 31.07,
            monthglyzxxs: 4.0,
            yearglyzxxs: 112.0,
            windturbinename: null,
          },
          {
            id: 999261,
            windpowerstationid: "MHS_FDC",
            projectid: "MHS01_GC",
            lineid: "MHS01_XL",
            windturbineid: "MG01_01",
            recorddate: 1635782400000,
            dayfdl: 941.0,
            monthfdl: 4.0,
            yearfdl: 159.0,
            dayllfdl: 1240.2,
            monthllfdl: 4.0,
            yearllfdl: 287.0,
            dayfs: 3.41,
            monthfs: 4.0,
            yearfs: 165.0,
            daygl: 49.88,
            monthgl: 4.0,
            yeargl: 164.0,
            daygzssdl: 0.0,
            monthgzssdl: 2.0,
            yeargzssdl: 284.0,
            dayxdssdl: 0.0,
            monthxdssdl: 2.0,
            yearxdssdl: 244.0,
            daywhssdl: 299.2,
            monthwhssdl: 4.0,
            yearwhssdl: 304.0,
            dayxnssdl: 0.0,
            monthxnssdl: 2.0,
            yearxnssdl: 85.0,
            daygzsj: 0.0,
            monthgzsj: 2.0,
            yeargzsj: 246.0,
            daywhsj: 10.95,
            monthwhsj: 4.0,
            yearwhsj: 292.0,
            dayyxsj: 9.8,
            monthyxsj: 4.0,
            yearyxsj: 266.0,
            daytjsj: 3.25,
            monthtjsj: 4.0,
            yeartjsj: 166.0,
            daylyxs: 0.63,
            monthlyxs: 4.0,
            yearlyxs: 159.0,
            daynhyd: 0.21,
            monthnhyd: 4.0,
            yearnhyd: 114.0,
            daysbklyl: 100.0,
            monthsbklyl: 3.0,
            yearsbklyl: 92.0,
            daydxkyxs: 54.38,
            monthdxkyxs: 4.0,
            yeardxkyxs: 292.0,
            dayyxfss: 11.15,
            monthyxfss: 4.0,
            yearyxfss: 162.0,
            dayxfqr: 3.37,
            monthxfqr: 1.0,
            yearxfqr: 51.0,
            dayjfpl: 53.5,
            monthjfpl: 4.0,
            yearjfpl: 217.0,
            dayglyzxxs: 26.1,
            monthglyzxxs: 3.0,
            yearglyzxxs: 100.0,
            windturbinename: null,
          },
          {
            id: 999681,
            windpowerstationid: "MHS_FDC",
            projectid: "MHS01_GC",
            lineid: "MHS01_XL",
            windturbineid: "MG01_01",
            recorddate: 1635868800000,
            dayfdl: 5534.0,
            monthfdl: 3.0,
            yearfdl: 106.0,
            dayllfdl: 5552.43,
            monthllfdl: 3.0,
            yearllfdl: 202.0,
            dayfs: 5.2,
            monthfs: 3.0,
            yearfs: 94.0,
            daygl: 257.24,
            monthgl: 3.0,
            yeargl: 108.0,
            daygzssdl: 0.0,
            monthgzssdl: 3.0,
            yeargzssdl: 246.0,
            dayxdssdl: 0.0,
            monthxdssdl: 3.0,
            yearxdssdl: 185.0,
            daywhssdl: 18.43,
            monthwhssdl: 3.0,
            yearwhssdl: 263.0,
            dayxnssdl: 0.0,
            monthxnssdl: 3.0,
            yearxnssdl: 49.0,
            daygzsj: 0.0,
            monthgzsj: 3.0,
            yeargzsj: 117.0,
            daywhsj: 0.45,
            monthwhsj: 3.0,
            yearwhsj: 227.0,
            dayyxsj: 20.97,
            monthyxsj: 3.0,
            yearyxsj: 122.0,
            daytjsj: 2.58,
            monthtjsj: 2.0,
            yeartjsj: 147.0,
            daylyxs: 3.69,
            monthlyxs: 3.0,
            yearlyxs: 106.0,
            daynhyd: 0.17,
            monthnhyd: 2.0,
            yearnhyd: 94.0,
            daysbklyl: 100.0,
            monthsbklyl: 4.0,
            yearsbklyl: 73.0,
            daydxkyxs: 98.13,
            monthdxkyxs: 3.0,
            yeardxkyxs: 217.0,
            dayyxfss: 20.17,
            monthyxfss: 3.0,
            yearyxfss: 99.0,
            dayxfqr: 3.52,
            monthxfqr: 2.0,
            yearxfqr: 68.0,
            dayjfpl: 15.96,
            monthjfpl: 3.0,
            yearjfpl: 126.0,
            dayglyzxxs: 22.42,
            monthglyzxxs: 2.0,
            yearglyzxxs: 78.0,
            windturbinename: null,
          },
          {
            id: 1000101,
            windpowerstationid: "MHS_FDC",
            projectid: "MHS01_GC",
            lineid: "MHS01_XL",
            windturbineid: "MG01_01",
            recorddate: 1635955200000,
            dayfdl: 16556.0,
            monthfdl: 1.0,
            yearfdl: 47.0,
            dayllfdl: 16904.7,
            monthllfdl: 1.0,
            yearllfdl: 75.0,
            dayfs: 8.12,
            monthfs: 1.0,
            yearfs: 32.0,
            daygl: 708.6,
            monthgl: 1.0,
            yeargl: 35.0,
            daygzssdl: 0.0,
            monthgzssdl: 4.0,
            yeargzssdl: 109.0,
            dayxdssdl: 0.0,
            monthxdssdl: 1.0,
            yearxdssdl: 32.0,
            daywhssdl: 0.0,
            monthwhssdl: 2.0,
            yearwhssdl: 109.0,
            dayxnssdl: 348.7,
            monthxnssdl: 4.0,
            yearxnssdl: 276.0,
            daygzsj: 0.0,
            monthgzsj: 4.0,
            yeargzsj: 112.0,
            daywhsj: 0.0,
            monthwhsj: 1.0,
            yearwhsj: 35.0,
            dayyxsj: 21.35,
            monthyxsj: 2.0,
            yearyxsj: 117.0,
            daytjsj: 2.65,
            monthtjsj: 3.0,
            yeartjsj: 149.0,
            daylyxs: 11.04,
            monthlyxs: 1.0,
            yearlyxs: 47.0,
            daynhyd: 0.13,
            monthnhyd: 1.0,
            yearnhyd: 60.0,
            daysbklyl: 100.0,
            monthsbklyl: 1.0,
            yearsbklyl: 28.0,
            daydxkyxs: 100.0,
            monthdxkyxs: 1.0,
            yeardxkyxs: 47.0,
            dayyxfss: 24.0,
            monthyxfss: 1.0,
            yearyxfss: 17.0,
            dayxfqr: 3.0,
            monthxfqr: 3.0,
            yearxfqr: 203.0,
            dayjfpl: 0.0,
            monthjfpl: 1.0,
            yearjfpl: 15.0,
            dayglyzxxs: 15.32,
            monthglyzxxs: 1.0,
            yearglyzxxs: 29.0,
            windturbinename: null,
          },
        ],
      },
      tableLoading: false,
      hisData: {
        column: [
          {
            name: "风机编号",
            field: "windturbineid",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "日期",
            field: "recorddate",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
            template: function (data) {
              return new Date(data).formatDate("yyyy-MM-dd");
            },
          },
          {
            name: "发电量(kWh)",
            field: "dayfdl",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "理论发电量(kWh)",
            field: "dayllfdl",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "平均风速(m/s)",
            field: "dayfs",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "平均功率(kW)",
            field: "daygl",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "故障损失电量(kWh)",
            field: "daygzssdl",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "限电损失电量(kWh)",
            field: "dayxdssdl",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "检修损失电量(kWh)",
            field: "daywhssdl",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "性能损失电量(kWh)",
            field: "dayxnssdl",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "利用小时数(h)",
            field: "daylyxs",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "拟合优度(%)",
            field: "daynhyd",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "设备可利用率(%)",
            field: "daysbklyl",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "等效可用系数(%)",
            field: "daydxkyxs",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "有效风时数(h)",
            field: "dayyxfss",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "平均切入风速(m/s)",
            field: "dayxfqr",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "静风频率(%)",
            field: "dayjfpl",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
          {
            name: "功率一致性系数(%)",
            field: "dayglyzxxs",
            is_num: false,
            is_light: false,
            sortable: true,
            id: "id",
          },
        ],
        data: [{ a: "aaa" }],
      },
    };
  },
  created() {
    this.getTable();
  },
  beforeUpdate() {},
  methods: {
    getTable() {
      let that = this;
      let subUrl = "";
      const data = {
        wtId: this.option["windturbineid"],
      };
      if ("d" == this.option.shows) {
        subUrl = "/benchmarking/gadayhistlist";
        data["recorddate"] = this.option["date"];
      }
      if ("m" == this.option.shows) {
        subUrl = "/benchmarking/gamonthhistlist";
        const dateStr = this.option["date"].split("-");
        if (dateStr.length > 1) {
          data["year"] = dateStr[0];
          data["month"] = dateStr[1];
        }
      }
      if ("y" == this.option.shows) {
        subUrl = "/benchmarking/gayearhistlist";
        data["year"] = this.option["date"];
      }
      // that.tableLoading = true;
      // that.API.requestData({
      //   timeout: 60000,
      //   method: "POST",
      //   subUrl: subUrl,
      //   data: data,
      //   success(res) {
      //     that.tableLoading = false;
      //     if (res.code === 200) {
      //       var data = [];
      //       res.data.forEach((item, index) => {
      //         item["index"] = index;
      //         data[index] = item;
      //       });
      //       that.hisData.data = data;
      //     }
      //   },
      //   Error(res) {
      //     console.log("tag", res);
      //   }
      // });

      that.tableLoading = false;
      if (that.res.code === 200) {
        var items = [];
        that.res.data.forEach((item, index) => {
          item["index"] = index;
          items[index] = item;
        });
        that.hisData.data = items;
      }
    },
  },
};
</script>

<style lang="less"></style>
