<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="))
    let userLoginName = sessionStorage.getItem("userLoginName");
    let userPassword = sessionStorage.getItem("userPassword");
    // let deptId = sessionStorage.getItem("deptId");
    let deptId =
      sessionStorage.getItem("deptId") == "DP001003"
        ? "DP00100301"
        : sessionStorage.getItem("deptId");
    this.hrefs =
      "http://10.223.3.39:9090/irpt/esmain/login.do?id=" +
      userLoginName +
      "&pw={" +
      userPassword +
      "}&url=..%2Fei%2Fclient%2Fadddata.do%3Fuserid%3D" +
      deptId +
      "%26curbbhid%3D" +
      deptId +
      window.location.href.split("url=")[1];
    // this.hrefs = 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");
      this.hrefs =
        "http://10.223.3.39:9090/irpt/esmain/login.do?id=" +
        userLoginName +
        "&pw={" +
        userPassword +
        "}&url=..%2Fei%2Fclient%2Fadddata.do%3Fuserid%3D" +
        deptId +
        "%26curbbhid%3D" +
        deptId +
        window.location.href.split("url=")[1];

      // this.hrefs = 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>
