<template>
  <div style="height: 100%; padding: 10px 20px">
    <div class="query mg-b-8">
      <div class="query-items">
        <div class="query-item">
          <div class="lable">场站：</div>
          <div class="search-input">
            <el-select
              size="mini"
              v-model="value1"
              clearable
              placeholder="请选择"
              popper-class="select"
            >
              <el-option
                v-for="item in ChangZhan"
                :key="item.id"
                :value="item.id"
                :label="item.name"
              >
              </el-option>
            </el-select>
          </div>
        </div>
        <div class="query-item">
          <div class="lable">日期：</div>
          <div class="search-input">
            <el-date-picker
              size="mini"
              v-model="date"
              type="date"
              placeholder="选择日期"
              popper-class="date-select"
              value-format="YYYY-MM-DD"
            >
            </el-date-picker>
          </div>
        </div>
        <div class="query-actions">
          <el-button size="mini" round class="searchColor" @click="getTable"
            >查 询</el-button
          >
        </div>
      </div>
    </div>
    <div class="table-box">
      <div class="leftContent">
        <span>{{ showTitle }}</span>
      </div>
      <el-table
        :data="tableData.data"
        stripe
        height="calc(100% - 40px)"
        size="mini"
      >
        <el-table-column
          :sortable="item.field != 'nemCode' && item.field != 'recordDate'"
          align="center"
          v-for="(item, index) in tableData.column"
          :key="index"
          :prop="item.field"
          :label="item.name"
        >
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import api1 from "@api/economic/index.js";
import { getCurveIntervalfittingmainList } from "@api/wisdomOverhaul/energy/index.js";
export default {
  name: "Qxqjpcl",

  data() {
    return {
   
      ChangZhan: [],
      value1: "",
      date: "",
      showTitle: "曲线区间偏差率",
      tableLoading: true,
      tableData: {
        column: [
          {
            name: "风机",
            field: "nemCode",
          },
          {
            name: "日期",
            field: "recordDate",
          },

          {
            name: "3-5米",
            field: "y35mqxpcl",
          },
          {
            name: "5-11米",
            field: "y511mqxpcl",
          },
          {
            name: "11米以上",
            field: "y11mycqxpcl",
          },
        ],
        data: [],
      },
    };
  },
  created() {
    this.ChangZhanVal();
    this.date = new Date().formatDate("yyyy-MM-dd");
  },
  methods: {
    // 获取表格数据
    getTable() {
      this.tableLoading = true;

      const param = {
        wpId: this.value1,
        recorddate: this.date,
      };

      getCurveIntervalfittingmainList(param).then(({ data: res }) => {
        this.tableLoading = false;
        console.log(res.code);
        if (res.code === 200) {
          res.data.forEach((ele) => {
            ele.recordDate = this.date;
          });
          this.tableData.data = res.data || [];
        }
      });
    },
    // tab
    handleOpen(vl, index) {
      this.cur = index;
      this.showTitle = vl;
      this.date = new Date().formatDate(`yyyy-MM${index ? "-dd" : ""}`);
      this.getTable();
    },
    // 场站
    ChangZhanVal() {
      api1
        .getWpList({
          type: "-1",
        })
        .then((res) => {
          if (res.data.code === 200) {
            this.ChangZhan = res.data.data;
            this.value1 = res.data.data[0].id;
            this.getTable();
          }
        });
    },
  },
};
</script>
<style scoped lang="less">
.table-box {
  height: calc(100% - 80px);
  .leftContent {
    width: 242px;
    height: 45px;
    line-height: 45px;
    background: url("~@/assets/imgs/title_left_bg1.png") no-repeat;

    span {
      font-size: 16px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #05bb4c;
      margin-left: 25px;
    }
  }
}
.query-actions {
  margin-left: 0 !important;
}
button {
  margin-left: 10px;
  background: rgba(67, 81, 107, 0.3);
  border: 1px solid #274934;
  color: #b3b3b3;
}

.searchColor {
  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;
  }
}

.newspan {
  line-height: 30px;
  cursor: pointer;
  padding: 0 1vw;
  margin: 0 2px;
  color: #9ca5a8;
  transition: color 0.2s ease-in-out;
  position: relative;
}
.newspan:hover {
  background: linear-gradient(
    to top,
    rgba(5, 187, 76, 0.5),
    rgba(5, 187, 76, 0)
  );
  color: white;
  position: relative;
}
.newspan:hover::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 0.463vh;
  border: 0.093vh solid #05bb4c;
  border-top: 0;
  left: 0;
  bottom: 0;
  box-sizing: border-box;
}
.active {
  background: linear-gradient(
    to top,
    rgba(5, 187, 76, 0.5),
    rgba(5, 187, 76, 0)
  );
  color: white;
  position: relative;
}
.active::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 4px;
  border: 1px solid #05bb4c;
  border-top: 0;
  left: 0;
  bottom: 0;
  box-sizing: border-box;
}
.title {
  background: rgba(255, 255, 255, 0.1);
  margin-bottom: 8px;
  padding: 8px;
}
</style>
