import * as echarts from "echarts";
export default {
  data() {
    return {
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        },
      list:[],
      FClist: [],
      GFlist: [
        
      ],
      loading:true,
      QBlist: [
       
      ],
      lxlist: [
        {
          name: "全部",
          id: "qb",
        },
        {
          name: "风场",
          id: "fc",
        },
        {
          name: "光伏",
          id: "gf",
        },
      ],
      tableData: [],
      beginDate: "2021-01-01",
      endDate: "2021-01-01",
      lx: "qb",
      fc: "",
      selectrowdate: {},
    };
  },
  methods: {
    check_lx() {
      this.fc = "";
      if (this.lx == "fc") {
        this.list={};
        this.list = this.FClist;
      } else if (this.lx == "gf") {
        this.list = {};
        this.list = this.GFlist;
      } else if (this.lx == "qb") {
        this.list = {};
        this.list = this.QBlist;
      }
    },
    query_fc() {
       var newData = new Date();
       this.beginDate = this.BASE.getBzDate(newData.getTime(),-1);
       this.endDate = this.BASE.getBzDate(newData.getTime(),0);
      let that = this;
      let fjj="";
      this.API.get("powercompare/windfarmAllAjax?").then((res) => {
        this.QBlist = res.data;

        for (let i = 0; i < Object.keys(this.QBlist).length; i++) {
          fjj = "";
          fjj = this.QBlist[i].id;
          if (fjj.endsWith("FDC")) {
            that.FClist.push(this.QBlist[i]);
          } else {
            that.GFlist.push(this.QBlist[i]);
          }
        }
        this.list = this.QBlist;
     });
    },
    query_table() {
      this.loading=true;
      this.tableData=[];
      this.API
        .get(
          "leaderboard/totalPowerCapacityTopList?wpIps=" +
            this.fc +
            "&pageNum=" +
            1 +
            "&pageSize=" +
            10 +
            "&orderByColumn=" +
            "" +
            "&isAsc=" +
            "asc" +
            "&beginDate=" +
            this.beginDate +
            "&endDate=" +
            this.endDate
        )
        .then((res) => {
          this.tableData = res.data;
          this.loading=false;
        });
    },
    // toExcel() {
    //   let that = this;
    //   excelHelper.exportExcel("tableData", "总发电量排行", ".xls", true);
    // },
    headStyle() {
      return "text-align:center";
    },
    changeFun(val) {
      this.selectrowdate = val;
    },
    filter_bdate(cellValue) {
      let date = new Date(cellValue.beginDate);

      return this.BASE.getBzDate(date);
    },
    filter_edate(cellValue) {
      let date = new Date(cellValue.endDate);

      return this.BASE.getBzDate(date);
    },
    filter_power(cellValue) {
      return parseFloat(cellValue.power).toFixed(2);
    },
    filter_speed(cellValue) {
      return parseFloat(cellValue.speed).toFixed(2);
    },
  },
  mounted() {
    this.query_fc();
    this.query_table();
  },
};
