<template>
  <div>
    <!-- 汇总 -->
    <!-- iframe 嵌入  -->
    <iframe
      id="iReport"
      :src="hrefs"
      name="myFrameName"
      scrolling="no"
      frameborder="0"
      style="width: 100%"
    ></iframe>
  </div>
</template>

<script>
export default {
  name: "iReport",
  data() {
    return {
      hrefs: "",
      fullHeight: document.documentElement.clientHeight,
    };
  },
  // 初始化拿到src
  created() {
    // if(this.$route.query.breadCrumbs) {
    //   //面包屑导航传参
    //   sessionStorage.setItem('menuArr',this.$route.query.breadCrumbs)
    // }
    // let token = localStorage.getItem('token');
    // let url = localStorage.getItem('href');
    //   console.log(window.location.href.split("url="))
    // console.log(
    //   "6",
    //   decodeURI(
    //     "http://10.223.3.39:9090/irpt/esmain/login.do?id=传入用户&pw=传入密码&url=..%2Fei%2Fclient%2Fadddata.do%3Fcmd%3Dshow%26taskid%3D%7B041451C0-8F71-4EB5-A570-95BA67CB7ABD%7D.ab13e3548eb644b4f98d336b5ab660f4%26userid%3D部门编码%26btype%3D0%26dataset%3Dmain%26curbbhid%3D部门编码%26curbbhtype%3D0%26isjchpage%3Dtrue%26bbq%3D2023----%26menuvisible%3Dtrue%26webtaskreadonly%3Dfalse"
    //   )
    // );
    let userLoginName = sessionStorage.getItem("userLoginName");
    let userPassword = sessionStorage.getItem("userPassword");
    let deptId = sessionStorage.getItem("deptId");
    this.hrefs =
      // decodeURIComponent(
      "http://10.223.3.39:9090/irpt/esmain/login.do?id=" +
      userLoginName +
      "&pw={" +
      userPassword +
      "}&url=..%2Fei%2Fportal%2Flistbbq.do%3Fuserid%3DDP001002%26curbbhid%3D" +
      deptId +
      window.location.href.split("url=")[1];
    // );

    // decodeURI(
    //   "http://10.223.3.39:9090/irpt/esmain/login.do?id=传入用户&pw=传入密码&url=..%2Fei%2Fclient%2Fadddata.do%3Fcmd%3Dshow%26taskid%3D%7B041451C0-8F71-4EB5-A570-95BA67CB7ABD%7D.ab13e3548eb644b4f98d336b5ab660f4%26userid%3D部门编码%26btype%3D0%26dataset%3Dmain%26curbbhid%3D部门编码%26curbbhtype%3D0%26isjchpage%3Dtrue%26bbq%3D2023----%26menuvisible%3Dtrue%26webtaskreadonly%3Dfalse"
    // );
    //  decodeURI(
    //   "http://" +
    //     window.location.host +
    //     "/" +
    //     window.location.href.split("url=")[1]
    // );
    // console.log('iiiiiiiiiiii',url,this.hrefs)
  },
  mounted() {
    // document.getElementById('iReport').style.height = this.fullHeight + 'px'
    document.getElementById("iReport").style.height = this.fullHeight + "px";
    const that = this;
    window.onresize = () => {
      return (() => {
        window.fullHeight = document.documentElement.clientHeight;
        that.fullHeight = window.fullHeight;
      })();
    };
  },
  methods: {},
  watch: {
    fullHeight(val) {
      if (!this.timer) {
        console.log(val);
        this.fullHeight = val;
        document.getElementById("iReport").style.height = val + "px";
        this.timer = true;
        const that = this;
        setTimeout(function () {
          that.timer = false;
        }, 400);
      }
    },
    $route: function (newVal, oldVal) {
      let userLoginName = sessionStorage.getItem("userLoginName");
      let userPassword = sessionStorage.getItem("userPassword");
      let deptId =
        sessionStorage.getItem("deptId") == "DP001003"
          ? "DP00100301"
          : sessionStorage.getItem("deptId");
      this.hrefs =
        // decodeURIComponent(
        "http://10.223.3.39:9090/irpt/esmain/login.do?id=" +
        userLoginName +
        "&pw={" +
        userPassword +
        "}&url=..%2Fei%2Fportal%2Flistbbq.do%3Fuserid%3DDP001002%26curbbhid%3D" +
        deptId +
        window.location.href.split("url=")[1];
      // );
      // decodeURI(
      //   "http://" +
      //     window.location.host +
      //     "/" +
      //     window.location.href.split("url=")[1]
      // );
    },
  },
};
</script>
<style scoped>
.contentBox {
  margin-top: 20px;
  padding: 0px 20px;
}

.el-select {
  display: inline-block;
  position: relative;
}
</style>
