he wei
2023-07-20 5748fde24928bbda455fb3b2f764b0d18efe683c
src/views/home/home-conductor.vue
@@ -374,6 +374,15 @@
  mixins: [WSMixin],
  data() {
    return {
      // 维护 ‘其他’ 所对应的列表
      others: {
        battProd: [],
        battVol: [],
        pwrProd: [],
        // 因为投运年限有四个级别 所以要存四份
        battProdAnalysis: [[], [], [], []],
      },
      toObj: {},
      listVisible: false,
      tableData: [],
      updateFlag: false,
@@ -503,7 +512,7 @@
    },
    onWSOpen() {
      this.$nextTick(() => {
        this.SOCKET.send({});
        this.SOCKET.send("");
      });
    },
    onWSMessage(res) {
@@ -578,6 +587,7 @@
          .sort((a, b) => {
            return b.value - a.value;
          });
        this.others.pwrProd = [];
        if (arr.length <= 5) {
          res.sData = arr;
        } else {
@@ -585,6 +595,7 @@
          let value = 0;
          arr.splice(4).forEach((v) => {
            value += v.value * 1;
            this.others.pwrProd.push(v.name);
          });
          res.sData = arr;
          res.sData.push({ name, value });
@@ -611,9 +622,9 @@
      let analysis = [],
        analysis1 = [];
      let prodList = [];
      [threeYear, fiveYear, sevenYear, otherYear].forEach((item) => {
        analysis.push(this.formatTestData(item));
      // let prodList = [];
      [threeYear, fiveYear, sevenYear, otherYear].forEach((item, idx) => {
        analysis.push(this.formatTestData(item, idx));
        analysis1.push(Object.keys(item).map((v) => ({ name: v, ...item[v] })));
        // prodList.push(...Object.keys(item));
      });
@@ -622,7 +633,7 @@
      this.chartData.analysis1 = analysis1;
      // this.prodList = noRepeat(prodList);
      if (!this.battProd) {
        this.battProd = this.prodList[0] || "";
        this.battProd = this.prodList[0].name || "";
        this.updateAnalysis1();
      }
      // this.battProd = this.prodList[0] || '';
@@ -646,9 +657,10 @@
      this.$refs.battChart?.resize();
      this.$refs.analysis1?.resize();
    },
    formatTestData(data) {
    formatTestData(data, idx) {
      let sData = [[], []];
      let xLabel = [];
      let battProdAnalysis = [];
      let arr = Object.keys(data)
        .map((v) => ({ name: v, ...data[v] }))
        .sort((a, b) => {
@@ -671,6 +683,7 @@
        arr.splice(4).forEach((v) => {
          alarm += v.alarm * 1;
          change += v.change * 1;
          battProdAnalysis.push(v.name);
        });
        arr.forEach((v) => {
          sData[0].push(v.alarm);
@@ -681,11 +694,17 @@
        sData[0].push(alarm);
        sData[1].push(change);
      }
      this.others.battProdAnalysis[idx] = battProdAnalysis;
      return { xLabel, sData };
    },
    formatBattData(data, idx) {
      let res = { sData: [] };
      if (idx) {
        this.others.battVol = [];
      } else {
        this.others.battProd = [];
      }
      let arr = Object.keys(data)
        .map((v) => ({ name: idx ? v * 1 + "伏" : v, value: data[v] }))
        .sort((a, b) => {
@@ -698,6 +717,11 @@
        let value = 0;
        arr.splice(4).forEach((v) => {
          value += v.value * 1;
          if (idx) {
            this.others.battVol.push(v.name.replace('伏', '') * 1);
          } else {
            this.others.battProd.push(v.name);
          }
        });
        res.sData = arr;
        res.sData.push({ name, value });
@@ -764,6 +788,7 @@
      this.$refs.station.setData(this.chartData.station[value]);
    },
    battLevelChange(value) {
      this.$refs.battInfo.clear();
      this.$refs.battInfo.setData(this.chartData.batt[value]);
    },
    testLevelChange(value) {
@@ -849,28 +874,132 @@
      //   this.$router.push("/dataTest/movingRingSystem/" + search);
      // }
    },
    initChartEvent() {
      // 站点
      this.$refs.station.getChart().on("click", (params) => {
        // 0 : 按电压等级   1: 按类型
        let stationLevel = this.stationLevel;
        let query = [
          {
            stationType: params.name,
          },
          {
            nodeStation: params.name == "节点站" ? "1" : "0",
          },
        ][stationLevel];
        // 跳转到对应的页面
        this.$router.push({
          path: "/dataMager/totalStation",
          query,
        });
      });
      // 电池信息 饼图
      this.$refs.battInfo.getChart().on("click", (params) => {
        let battLevel = this.battLevel;
        let query = {};
        if ("其他" == params.seriesName) {
          query = [
            {
              produce: JSON.stringify(this.others.battProd),
            },
            {
              monVolType: JSON.stringify(this.others.battVol),
            },
          ][battLevel];
        } else {
          // 0: 按品牌    1:按电压
          query = [
            {
              produce: JSON.stringify([params.seriesName]),
            },
            {
              monVolType: JSON.stringify([params.seriesName.replace("伏", "")]),
            },
          ][battLevel];
        }
        // 跳转到对应的页面
        this.$router.push({
          path: "/dataMager/produceTotal",
          query,
        });
      });
      this.$refs.powerChart.getChart().on("click", (params) => {
        let producer = [];
        if ("其他" == params.seriesName) {
          producer = this.others.pwrProd;
        } else {
          producer = [params.seriesName];
        }
        // 跳转到对应的页面
        this.$router.push({
          path: "/dataMager/powerMager",
          query: {
            producer: JSON.stringify(producer),
          },
        });
      });
      this.$refs.bar3d.getChart().on("click", (params) => {
        let thistime = new Date();
        let yy = thistime.getFullYear();
        let MM = thistime.getMonth() + 1;
        let jdM = Math.floor((MM - 0.1) / 3) * 3 + 1;
        // 0: 月   1: 季度    2:年
        let startDrsj = [
          yy + "-" + MM + "-01",
          yy + "-" + jdM + "-01",
          yy + "-01-01",
        ][this.testLevel];
        let testType = params.name == "核容放电" ? "3" : "2";
        this.$router.push({
          path: "/dataTest/historyInfoMager",
          query: {
            testType,
            startDrsj,
            testStarttype: "3",
          },
        });
      });
      // 右中
      this.$refs.battChart.getChart().on("click", (params) => {
        // console.log(params.seriesName, params.name);
        // 劣化 1   损坏 0
        let quality = params.seriesName == "损坏" ? "0" : "1";
        let battProduct =
          params.name == "其他"
            ? this.others.battProdAnalysis[this.year0]
            : [params.name];
        this.$router.push({
          path: "/reportStatistics/taskplan",
          query: {
            quality,
            dateRange: this.year0,
            battProduct: JSON.stringify(battProduct),
          },
        });
      });
      // 右下
      this.$refs.analysis1.getChart().on("click", (params) => {
        // 劣化 1   损坏 0
        let quality = params.name == "损坏" ? "0" : "1";
        let battProduct = [this.battProd];
        this.$router.push({
          path: "/reportStatistics/taskplan",
          query: {
            quality,
            dateRange: this.year1,
            battProduct: JSON.stringify(battProduct),
          },
        });
      });
    },
  },
  mounted() {
    // 站点
    let stationChart = this.$refs.station.getChart();
    stationChart.on("click", (params) => {
      // 0 : 按电压等级   1: 按类型
      let stationLevel = this.stationLevel;
      let query = [
        {
          stationType: params.name,
        },
        {
          nodeStation: params.name == "节点站" ? 1 : 0,
        },
      ][stationLevel];
      // 跳转到对应的页面
      this.$router.push({
        path: "/dataMager/totalStation",
        query,
      });
    });
    this.initChartEvent();
  },
};
</script>