<template>
  <div class="box">
    <div class="left">
      <img src="../../assets/img/标题/回路名称.png" class="title" />
      <ul class="list">
        <li
          v-for="item in list"
          :class="res == item ? 'active' : ''"
          @click="(res = item), sendMessageToCSharp(item)"
        >
          {{ item }}
        </li>
      </ul>
      <div class="tpt">
        <div class="imgBox">
          <img src="../../assets/img/小标题栏.png" class="img" />
          <p>拓扑图</p>
        </div>
        <div id="tpt">
          <el-image
            v-for="item in arr"
            :src="item.url"
            :preview-src-list="item.srcList"
          >
          </el-image>
        </div>
      </div>
    </div>
    <img src="../../assets/pds/中间.png" v-show="falg" alt="" class="bgt" />

    <div class="boxLeft" v-if="falg">
      <div class="title">1号配电箱</div>
      <div class="container">
        <div class="head">
          <img src="../../assets/pds/组 23.png" alt="" /> <span>基本信息</span>
        </div>
        <ul class="container-box">
          <li>
            <p>设备信息</p>
            <p>xxxxxxxxxxxxxx</p>
          </li>
          <li>
            <p>设备型号</p>
            <p>xxxxxxxxxxxxxx</p>
          </li>
          <li>
            <p>生产厂家</p>
            <p>xxxxxxxxxxxxxx</p>
          </li>
          <li>
            <p>额定容量</p>
            <p>630kVA</p>
          </li>
          <li>
            <p>额定电压</p>
            <p>600V</p>
          </li>
          <li>
            <p>投运日期</p>
            <p>2001年</p>
          </li>
          <li>
            <p>投运状态</p>
            <p>运行</p>
          </li>
        </ul>
        <div class="head">
          <img src="../../assets/pds/组 23.png" alt="" /><span
            >电流/电压曲线</span
          >
        </div>
        <div class="data">
          <span :class="type == '电压' ? 'active' : ''" @click="type = '电压'"
            >电压</span
          >
          <span :class="type == '电流' ? 'active' : ''" @click="type = '电流'"
            >电流</span
          >
        </div>
        <div id="dldy"></div>
      </div>
    </div>
    <div class="boxRight" v-show="falg">
      <div class="title">1号配电箱</div>
      <div class="container">
        <div class="head">
          <img src="../../assets/pds/组 23.png" alt="" /> <span>实时数据</span>
        </div>
        <div class="iconBox">
          <div class="smallBox">
            <img src="../../assets/pds/实时功率icon.png" alt="" />
            <div class="iconRight">
              <div>245.69</div>
              <div>实时功率(kW)</div>
            </div>
          </div>
          <div class="smallBox">
            <img src="../../assets/pds/负载率icon.png" alt="" />
            <div class="iconRight">
              <div>70</div>
              <div>负载率(%)</div>
            </div>
          </div>
          <div class="smallBox">
            <img src="../../assets/pds/变损率icon.png" alt="" />
            <div class="iconRight">
              <div>6</div>
              <div>变损率(%)</div>
            </div>
          </div>
          <div class="smallBox">
            <img src="../../assets/pds/设备工况icon.png" alt="" />
            <div class="iconRight">
              <div>正常</div>
              <div>设备工况</div>
            </div>
          </div>
        </div>
        <div class="head">
          <img src="../../assets/pds/组 23.png" alt="" />
          <span>实时负荷功率</span>
        </div>
        <div id="ssfh"></div>
      </div>
    </div>
  </div>
</template>
<script>
import Viewer from "viewerjs";
import { pdsJs } from "../../utils/pds";
import * as echarts from "echarts";
export default {
  data() {
    return {
      arr: [],
      list: [],
      res: "",
      falg: true,
      type: "电流",
      option: {
        tooltip: {
          trigger: "axis",
        },
        legend: {
          data: ["A相", "B相", "C相"],
          left: "right",
          textStyle: {
            color: "#fff",
            fontSize: 20,
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },

        xAxis: {
          type: "category",
          boundaryGap: false,
          data: ["14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00"],
          axisLabel: {
            show: true,
            textStyle: {
              color: "#fff",
              fontSize: 20,
            },
          },
          axisLine: {
            lineStyle: {
              color: "#fff", // 将红色作为X轴线条的颜色
            },
          },
        },
        yAxis: {
          type: "value",
          name: "单位:A",
          nameTextStyle: {
            color: "#fff",
            fontSize: 20,
            padding: 10,
          },
          axisLabel: {
            show: true,
            textStyle: {
              color: "#fff",
              fontSize: 20,
            },
          },
        },
        series: [
          {
            name: "A相",
            type: "line",
            showSymbol: false, // 设置为 false 隐藏数据点
            data: [120, 132, 101, 134, 90, 230, 210],
            itemStyle: {
              normal: {
                color: "#00DE8D", // 设置线条颜色为红色
              },
            },
          },
          {
            name: "B相",
            type: "line",
            showSymbol: false, // 设置为 false 隐藏数据点
            data: [220, 182, 191, 234, 290, 330, 310],
            itemStyle: {
              normal: {
                color: "#00FBFE", // 设置线条颜色为红色
              },
            },
          },
          {
            name: "C相",
            type: "line",
            showSymbol: false, // 设置为 false 隐藏数据点
            data: [150, 232, 201, 154, 190, 330, 410],
            itemStyle: {
              normal: {
                color: "#8E7CFF", // 设置线条颜色为红色
              },
            },
          },
        ],
      },
      option1: {
        tooltip: {
          trigger: "axis",
        },
        legend: {
          data: ["昨日", "今日"],
          left: "right",
          textStyle: {
            color: "#fff",
            fontSize: 20,
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },

        xAxis: {
          type: "category",
          boundaryGap: false,
          data: ["14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00"],
          axisLabel: {
            show: true,
            textStyle: {
              color: "#fff",
              fontSize: 20,
            },
          },
          axisLine: {
            lineStyle: {
              color: "#fff", // 将红色作为X轴线条的颜色
            },
          },
        },
        yAxis: {
          type: "value",
          name: "单位:kW",
          nameTextStyle: {
            color: "#fff",
            fontSize: 20,
            padding: 10,
          },
          axisLabel: {
            show: true,
            textStyle: {
              color: "#fff",
              fontSize: 20,
            },
          },
        },
        series: [
          {
            name: "昨日",
            type: "line",
            smooth: true,
            showSymbol: false, // 设置为 false 隐藏数据点
            data: [220, 182, 191, 234, 290, 330, 310],
            itemStyle: {
              normal: {
                color: "#1181C3", // 设置线条颜色为红色
                width: 2,
              },
            },
            areaStyle: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "rgba(7, 140, 217, 0.9)", // 渐变色的起始颜色
                },
                {
                  offset: 0.5,
                  color: "rgba(7, 140, 217, 0.6)", // 渐变色的起始颜色
                },
                {
                  offset: 0.8,
                  color: "rgba(7, 140, 217, 0.3)", // 渐变色的起始颜色
                },
                {
                  offset: 1,
                  color: "rgba(7, 140, 217, 0.1)", // 渐变色的结束颜色
                },
              ]),
            },
          },
          {
            name: "今日",
            type: "line",
            smooth: true,
            showSymbol: false, // 设置为 false 隐藏数据点
            data: [120, 132, 101, 134, 90, 230, 210],
            itemStyle: {
              normal: {
                color: "#86B763", // 设置线条颜色为红色
                width: 2,
              },
            },
            areaStyle: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "rgba(188, 244, 93, 0.9)", // 渐变色的起始颜色
                },
                {
                  offset: 0.5,
                  color: "rgba(188, 244, 93, 0.9)", // 渐变色的起始颜色
                },
                {
                  offset: 0.8,
                  color: "rgba(188, 244, 93, 0.9)", // 渐变色的起始颜色
                },
                {
                  offset: 1,
                  color: "rgba(188, 244, 93, 0.9)", // 渐变色的起始颜色
                },
              ]),
            },
          },
        ],
      },
    };
  },
  created() {
    this.getList(this.$route.query.type);
    this.changeArr(this.$route.query.type);
  },
  watch: {
    //长时间不操作返回首页
    "$store.state.NoOperation": {
      handler(newValue, oldValue) {
        if (newValue == "无操作标识") {
          this.$router.push("/");
        }
      },
    },
  },
  methods: {
    initViewer() {
      this.viewer = new Viewer(this.$el, {
        inline: false,
        button: true,
        navbar: true,
        title: false,
        toolbar: true,
        tooltip: true,
        movable: false,
        zoomable: true,
        rotatable: false,
        scalable: true,
        transition: true,
        fullscreen: true,
        keyboard: true,
        url(image) {
          console.log(image.src);
          return image.src;
        },
        ready() {
          console.log("Viewer is ready");
        },
      });
    },
    //根据三维传参拿到回路名称列表
    getList(name) {
      var list = [];
      pdsJs.forEach((item) => {
        if (item.name == name) {
          list = item.list;
        }
      });
      this.list = list;
    },
    sendMessageToCSharp(name) {
      this.falg = true;
      let that = this;
      window.vuplex.postMessage({
        type: that.$route.query.type,
        message: name,
      });
    },
    changeArr(name) {
      // var url = require("../../assets/tpt/" + name + ".png");
      // this.arr[0] = {
      //   url: url,
      //   srcList: [url],
      // };
      if (name == "总降电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/总降电力室.png"),
          srcList: [require("../../assets/tpt/总降电力室.png")],
        };
      } else if (name == "矿山电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/矿山电力室.png"),
          srcList: [require("../../assets/tpt/矿山电力室.png")],
        };
      } else if (name == "原材料电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/原材料电力室.png"),
          srcList: [require("../../assets/tpt/原材料电力室.png")],
        };
      } else if (name == "一线生料磨电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/一线生料电力室.png"),
          srcList: [require("../../assets/tpt/一线生料电力室.png")],
        };
      } else if (name == "二线生料磨电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/二线生料电力室.png"),
          srcList: [require("../../assets/tpt/二线生料电力室.png")],
        };
      } else if (name == "窑尾电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/窑尾电力室.png"),
          srcList: [require("../../assets/tpt/窑尾电力室.png")],
        };
      } else if (name == "一线窑头电力室1") {
        this.arr[0] = {
          url: require("../../assets/tpt/一线窑头电力室1.png"),
          srcList: [require("../../assets/tpt/一线窑头电力室1.png")],
        };
      } else if (name == "一线窑头电力室2") {
        this.arr[0] = {
          url: require("../../assets/tpt/一线窑头电力室2.png"),
          srcList: [require("../../assets/tpt/一线窑头电力室2.png")],
        };
      } else if (name == "二线窑头电力室1") {
        this.arr[0] = {
          url: require("../../assets/tpt/二线窑头电力室1.png"),
          srcList: [require("../../assets/tpt/二线窑头电力室1.png")],
        };
      } else if (name == "二线窑头电力室2") {
        this.arr[0] = {
          url: require("../../assets/tpt/二线窑头电力室2.png"),
          srcList: [require("../../assets/tpt/二线窑头电力室2.png")],
        };
      } else if (name == "一线原煤电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/一线原煤电力室.png"),
          srcList: [require("../../assets/tpt/一线原煤电力室.png")],
        };
      } else if (name == "水泥磨电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/水泥磨电力室.png"),
          srcList: [require("../../assets/tpt/水泥磨电力室.png")],
        };
      } else if (name == "万吨仓电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/万吨仓电力室.png"),
          srcList: [require("../../assets/tpt/万吨仓电力室.png")],
        };
      } else if (name == "余热发电电力室") {
        this.arr[0] = {
          url: require("../../assets/tpt/余热发电电力室.png"),
          srcList: [require("../../assets/tpt/余热发电电力室.png")],
        };
      }
      //以下暂无拓扑图
      // else if (name == "三号线熟料配电室") {
      //   this.arr[0] = {
      //     url: require("../../assets/tpt/三号线熟料配电室.png"),
      //     srcList: [require("../../assets/tpt/三号线熟料配电室.png")],
      //   };
      // } else if (name == "三号线窑头配电室") {
      //   this.arr[0] = {
      //     url: require("../../assets/tpt/三号线窑头配电室.png"),
      //     srcList: [require("../../assets/tpt/三号线窑头配电室.png")],
      //   };
      // } else if (name == "三号线窑尾配电室") {
      //   this.arr[0] = {
      //     url: require("../../assets/tpt/三号线窑尾配电室.png"),
      //     srcList: [require("../../assets/tpt/三号线窑尾配电室.png")],
      //   };
      // } else if (name == "三号线生料配电室") {
      //   this.arr[0] = {
      //     url: require("../../assets/tpt/三号线生料配电室.png"),
      //     srcList: [require("../../assets/tpt/三号线生料配电室.png")],
      //   };
      // } else if (name == "辅料处理配电室") {
      //   this.arr[0] = {
      //     url: require("../../assets/tpt/辅料处理配电室.png"),
      //     srcList: [require("../../assets/tpt/辅料处理配电室.png")],
      //   };
      // } else if (name == "原料配料配电室") {
      //   this.arr[0] = {
      //     url: require("../../assets/tpt/原料配料配电室.png"),
      //     srcList: [require("../../assets/tpt/原料配料配电室.png")],
      //   };
      // } else if (name == "石灰石破碎配电室") {
      //   this.arr[0] = {
      //     url: require("../../assets/tpt/石灰石破碎配电室.png"),
      //     srcList: [require("../../assets/tpt/石灰石破碎配电室.png")],
      //   };
      // } else if (name == "石灰石输送控制室1、2") {
      //   this.arr[0] = {
      //     url: require("../../assets/tpt/石灰石输送控制室1、2.png"),
      //     srcList: [require("../../assets/tpt/石灰石输送控制室1、2.png")],
      //   };
      // }
    },
    dldy() {
      var chartDom = document.getElementById("dldy");
      var myChart = echarts.init(chartDom);
      myChart.setOption(this.option);
    },
    ssfh() {
      var chartDom = document.getElementById("ssfh");
      var myChart = echarts.init(chartDom);
      myChart.setOption(this.option1);
    },
  },
  mounted() {
    this.initViewer();
    this.dldy();
    this.ssfh();
  },
  beforeDestroy() {
    this.falg = false;
    if (this.viewer) {
      this.viewer.destroy();
    }
  },
};
</script>
<style scoped lang="less">
.box {
  width: 100%;
  height: 100%;
  padding-top: 400px;
  box-sizing: border-box;
  display: flex;
  background-color: transparent;
  background-image: url(../../assets/pds/遮罩.png);
  background-position: left;
  justify-content: space-between;
  background-repeat: no-repeat;
  position: relative;

  .left {
    width: 1237px;
    height: 2500px;
    margin-left: 61px;
    background-image: url("../../assets/img/侧边.png");
    padding-left: 59px;
    padding-right: 45px;
    box-sizing: border-box;

    .title {
      margin-top: 15px;
      margin-left: 60px;
    }

    .list {
      margin-top: 50px;
      list-style-type: none;
      color: #fff;
      font-size: 30px;
      max-height: 1300px;
      min-height: 600px;
      overflow-y: auto;
      overflow-x: hidden;
      li {
        width: 1128px;
        height: 103px;
        background-color: #123c63;
        text-align: left;
        line-height: 103px;
        text-indent: 50px;
        margin: 20px;
        cursor: pointer;
      }

      .active {
        color: #00fcff;
      }
    }

    .tpt {
      position: relative;
      margin-top: 56px;
      .data {
        position: absolute;
        font-size: 20px;
        font-family: "DOUYU";
        color: #ffffff;
        line-height: 18px;
        display: flex;
        right: 0;
        top: 120px;
        z-index: 1;
        cursor: pointer;
        span {
          width: 122px;
          height: 38px;
          margin: 10px;
          display: block;
          line-height: 38px;
          text-align: center;
        }
        .active {
          background: linear-gradient(
            to right,
            rgba(33, 76, 124, 0.3) 20%,
            rgba(152, 207, 230, 0.3) 100%,
            rgba(33, 76, 124, 0.3) 20%
          );
        }
      }
      .imgBox {
        height: 93px;
        width: 1156px;
        p {
          position: absolute;
          color: #fff;
          top: 20px;
          left: 50px;
          font-size: 30px;
          font-family: "MicrosoftYaHei";
        }
      }
      #tpt {
        width: 1155px;
        height: 500px;
        margin-top: 50px;
        /deep/ .el-image {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
.bgt {
  // width: 1113px;
  // height: 2055px;
  width: 1525px;
  height: 480px;
  position: absolute;
  left: 45%;
  top: 60%;
  // border: 2px solid #20d6fe;
}
.head {
  position: relative;
  img {
    position: absolute;
  }
  span {
    margin-left: 70px;
  }
}
.boxLeft {
  width: 1089px;
  height: 1468px;
  position: absolute;
  left: 2370px;
  top: 1200px;
  color: #ffffff;
  background: url(../../assets/pds/左.png);
  background-size: cover;
  .data {
    position: absolute;
    font-size: 20px;
    font-family: "DOUYU";
    color: #ffffff;
    line-height: 18px;
    display: flex;
    right: 0;
    top: 650px;
    z-index: 1;
    cursor: pointer;
    right: 60px;

    span {
      width: 122px;
      height: 38px;
      margin: 10px;
      display: block;
      line-height: 38px;
      text-align: center;
    }

    .active {
      background: linear-gradient(
        to right,
        rgba(33, 76, 124, 0.3) 20%,
        rgba(152, 207, 230, 0.3) 100%,
        rgba(33, 76, 124, 0.3) 20%
      );
    }
  }
  .title {
    background-size: cover;
    height: 49px;
    font-size: 30px;
    font-weight: bold;
    height: 104px;
    line-height: 104px;
    text-indent: 92px;
  }
  .container {
    height: calc(100% - 104px);
    width: 100%;
    padding: 0 60px 0 60px;
    box-sizing: border-box;
    .head {
      font-size: 24px;
      font-weight: bold;
      line-height: 104px;
      height: 104px;
    }
    .container-box {
      list-style: none;
      li {
        height: 52px;
        font-size: 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        p:nth-of-type(1) {
          margin-left: 100px;
        }
        p:nth-of-type(2) {
          width: 550px;
          text-align: center;
          color: #bdf55d;
        }
      }
      li:nth-of-type(2n-1) {
        background-image: url(../../assets/pds/列表.png);
        background-size: cover;
      }
    }
    #dldy {
      width: 100%;
      height: 600px;
      margin-top: 40px;
    }
  }
}
.boxRight {
  width: 1089px;
  height: 1317px;
  background: url(../../assets/pds/右.png);
  background-size: cover;
  position: absolute;
  left: 4970px;
  top: 1200px;
  .title {
    background-size: cover;
    height: 49px;
    font-size: 30px;
    font-family: "MicrosoftYaHei";
    font-weight: bold;
    height: 104px;
    color: #ffffff;
    line-height: 104px;
    text-indent: 92px;
  }
  .container {
    height: calc(100% - 104px);
    width: 100%;
    padding: 0 60px 0 60px;
    box-sizing: border-box;
    color: #fff;
    .head {
      font-size: 24px;
      font-weight: bold;
      line-height: 104px;
      height: 104px;
    }
    .iconBox {
      display: flex;
      align-items: center;
      justify-content: space-around;
      flex-wrap: wrap;
      .smallBox {
        width: 40%;
        display: flex;
        align-items: center;
        img {
          width: 137px;
          height: 137px;
        }
        .iconRight {
          height: 130px;
          margin-left: 30px;
          display: flex;
          flex-direction: column;
          justify-content: space-around;
          div:nth-of-type(1) {
            font-size: 37px;
            color: #bdf55d;
          }
          div:nth-of-type(2) {
            font-size: 20px;
            font-weight: bold;
          }
        }
      }
    }
    #ssfh {
      width: 100%;
      height: 600px;
      margin-top: 20px;
    }
  }
}
</style>
