<template>
  <div class="draught-fan-list">
    <div class="query mg-b-8">
      <div class="query-items">
        <div class="query-item">
          <div class="lable">场站：</div>
          <div class="search-input">
            <el-select v-model="wpId" clearable placeholder="请选择" popper-class="select">
              <el-option v-for="item in wpArray" :key="item.id" :value="item.id" :label="item.name" />
            </el-select>
          </div>
        </div>
        <div class="query-item">
          <div class="lable">日期：</div>
          <div class="search-input">
            <el-date-picker v-model="recorddate" type="date" value-format="YYYY-MM-DD" placeholder="选择日期" popper-class="date-select">
            </el-date-picker>
          </div>
        </div>
      </div>
      <div class="query-actions">
        <button class="btn green" @click="search">查询</button>
      </div>
    </div>
    <div class="mg-b-16 arrow-chart" >
      <panel :title="'场站风向24小时走向情况'"  >
        <multi-arrow-line-chart :height="'41.296vh'" :showLine="true" :list="chartData" />
      </panel>
    </div>
  </div>
</template>

<script>
import Panel from "../../components/coms/panel/panel.vue";
import multiArrowLineChart from "../../components/chart/line/multi-arrow-line-chart.vue";
import apis from "@api/wisdomOverhaul/health/index.js";
import api from "@api/wisdomOverhaul/windResources/index.js";
export default {
  setup() {},
  components: {
    Panel,
    multiArrowLineChart,
  },

  // 数据
  data () {
    return {
      wpArray: [],
      wtArray: [],
      wpId: "MHS_FDC",
      recorddate: new Date((new Date().getTime() - 3600 * 1000 * 24)).formatDate("yyyy-MM-dd"),
      chartData: [{
        title: "风速",
        value: []
      }]
    };
  },

  // 函数
  methods: {
    // 获取风场
    getWp (reGetWp) {
      apis.powercompareWindfarmAjax({}).then((res) => {
        this.wpArray = res.data;
          this.wpArray = res.data;
          this.wpId = res.data[0].id;
          this.getChartData();
      });
    },

    // 获取图表数据
    getChartData () {
      api.getWinddirection({
        wpId: this.wpId,
          recorddate: this.recorddate,
      }).then((res) => {
        const array = [];
          for (var {timestr: n, valueObjVo: {value: f,symbolRotate:r,symbolSize:s}} of res.data) {
            let obj = {'text':n , 'value': f ,'size': s,'route':r};
            // let temp = 'text: ' + n + ', value: ' + f+ ', size: ' + s+ ', route: ' + r;
            array.push(obj);
            
          }
          console.log(array);
          let chartData = [{
            title: "风速",
            value: (array || [])
          }];
          this.$nextTick(()=>{
            this.chartData = chartData;
          });
      });
    },

    search () {
      if (!this.wpId) {
        this.BASE.showMsg({
          msg: '场站为必选项'
        });
      } else {
        this.getChartData();
      }
    }
  },

  created () {
    this.getWp();
  },

  mounted () { },

  unmounted () { },
};
</script>

<style lang="less" scoped>
.draught-fan-list {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

  .btn-group-tabs {
    display: flex;
    flex-direction: row;

    .photovoltaic {
      margin-left: 1.481vh;
    }
  }

  .df-table {
    border: 0.093vh solid fade(@darkgray, 50%);
    position: relative;
    overflow: auto;
    flex-grow: 1;
    margin-top: 1.481vh;
    height: 30vh;

    &:before {
      content: '';
      width: 0.37vh;
      height: 0.37vh;
      background: @write;
      position: absolute;
      left: 0.278vh;
      top: 0.278vh;
    }

    tbody {
      height: calc(100vh - 166px);
    }
  }
}
</style>
