import * as echarts from "echarts";
export default {
  data() {
    return {
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        },
      wpIdslist: {
        name: "",
        id: "",
      },
      pjIdslist: {
        name: "麻黄山一期工程",
        id: "MHS01_GC",
      },
      xlIdslist: {
        name: "麻黄山一号集电线路",
        id: "MHS01_XL",
      },
      fc: "MHS_FDC",
      pj: "麻黄山一期工程",
      xl: "麻黄山一号集电线路",
      year: "2021",
      month: "01",
      activeName: "no_1",
      loading: true,
      loading2: true,
      loading3: true,
      xllist: [],
      scatter_1: [],
      scatter_2: [],
      scatter_3: [],
    };
  },
  created() { },
  methods: {
    /**
     * 查询风场
     */
    query_wpid() {
      let that = this;
      let newData = new Date();
      this.year = newData.getFullYear() + '';
      let month = newData.getMonth() +'';
      if(this.month==0){that.month=12;that.year=that.year-1};
      if (month < 10) { that.month = '0' + month };
      this.API.get("powercompare/windfarmAjax?").then((res) => {
        this.wpIdslist = res.data;
        this.query_xml();
        this.query_xl();
      });
      this.query_xl();
    },
    /**
     * 当前卡片判断
     */
    handleClick() {
      if (this.activeName == "no_1") {
        this.query_scatter_1();
      } else if (this.activeName == "no_2") {
        this.query_scatter_2();
      } else if (this.activeName == "no_3") {
        this.query_scatter_3();
      }
    },
    /**
     * 查线路
     */
    query_xl() {
      this.xl = "";
      Object.assign(this.$data.xlIdslist, this.$options.data().xlIdslist);
      this.API
        .get("powercompare/lineWpIdAjax?wpId=" + this.fc)
        .then((res) => {
          this.xlIdslist = res.data;
        });
    },
    /**
     * 查数据
     */
    query_scatter_1() {
      let that = this;
      Object.assign(this.$data.scatter_1, this.$options.data().scatter_1);
      var digital = new URLSearchParams();
      digital.append("wpId", this.fc);
      digital.append("lnId", "");
      digital.append("pjId", "");
      digital.append("year", this.year);
      digital.append("month", this.month);
      this.API.postL("/scatter/scatterAjax", digital).then((res) => {
        this.scatter_1 = res.data.data;
        this.loading1 = false;
        this.ECZM.sdt("scatter_diagram_1",this.scatter_1);

      });
    },
    query_scatter_2() {
      let that = this;
      Object.assign(this.$data.scatter_2, this.$options.data().scatter_2);
      var digital = new URLSearchParams();
      digital.append("wpId", this.fc);
      digital.append("lnId", "");
      digital.append("pjId", this.pj);
      digital.append("year", this.year);
      digital.append("month", this.month);
      this.API.postL("/scatter/scatterAjax", digital).then((res) => {
        this.scatter_2 = res.data.data;
        this.loading2 = false;
        this.ECZM.sdt("scatter_diagram_2",this.scatter_2);

      });
    },
    query_scatter_3() {
      Object.assign(this.$data.scatter_3, this.$options.data().scatter_3);
      var digital = new URLSearchParams();
      digital.append("wpId", this.fc);
      digital.append("lnId", this.xl);
      digital.append("pjId", "");
      digital.append("year", this.year);
      digital.append("month", this.month);
      this.API.postL("/scatter/scatterAjax", digital).then((res) => {
        this.scatter_3 = res.data.data;
        this.loading3 = false;
        this.ECZM.sdt("scatter_diagram_3",this.scatter_3);
      });
    },
    /**
     * 查项目
     */
    query_xml() {
      let that = this;
      Object.assign(this.$data.xllist, this.$options.data().xllist);
      Object.assign(this.$data.pjIdslist, this.$options.data().pjIdslist);
      this.pj = "";
      this.xl = "";
      this.xllist = [];
      this.API
        .get("powercompare/projectAjax?wpIds=" + this.fc)
        .then((res) => {
          this.pjIdslist = res.data;
          for (let i = 0; i < Object.keys(this.pjIdslist).length; i++) {
            that.xllist.push(that.pjIdslist[i].id);
          }
        });
    },
    /**
     * 过滤
     */
    filter() {
      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]);
        }
      }
    },
  },
  mounted() {
    this.query_wpid();
    this.query_scatter_1();
  },
};
