<!--
 * @Author: xiachao 958053195@qq.com
 * @Date: 2023-09-05 09:58:01
 * @LastEditors: xiachao 958053195@qq.com
 * @LastEditTime: 2024-07-12 16:05:54
 * @FilePath: \ruoyi-ui\src\layout\components\InnerLink\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div
    :style="'height:' + height"
    v-loading="loading"
    element-loading-text="正在加载页面，请稍候！"
  >
    <iframe
      :id="iframeId"
      style="width: 100%; height: 100%"
      :src="iframeSrc"
      frameborder="no"
    ></iframe>
    <div class="waterMark">
      <div class="wm-item" v-for="item in wmList" :key="item">{{ userName }}</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loading: false,
      height: document.documentElement.clientHeight - 94.5 + "px;",
      iframeSrc: "",
      iframeId: "",
      wmList: [],
      iframeList: [
        {
          url: "/wl/bm",
          name: "部门销售日报",
          id: "iframeSrc1",
          link:
            "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=d5e2f858-44a5-44d6-922e-5a930602dff4&accessToken=b7dbaa192c244f6a974d0a76d3b91f43&dd_orientation=auto",
        },
        {
          url: "/wl/qd",
          name: "渠道销售日报",
          id: "iframeSrc2",
          link:
            "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=dbd95939-46c1-45e4-bc4a-b8a194c49d2c&accessToken=d6c0aea2ff47b2e658bdf5f018143873&dd_orientation=auto",
        },
        {
          url: "/wl/xs",
          name: "湘商销售日报",
          id: "iframeSrc3",
          link:
            "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=0d924c96-24c6-4a0b-bc36-7059b4e900f4&accessToken=f16156dbe1412ebdbe4b4d0b006f6f0b&dd_orientation=auto",
        },
        {
          url: "/wl/kc",
          name: "库存日报",
          id: "iframeSrc4",
          link:
            "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=4180cd41-de52-4f2e-91b1-3e56b1c13bc0&accessTicket=d3ae2c6b-f951-4ea6-8904-31a517e693fa&dd_orientation=auto",
        },
        {
          url: "/wl/app",
          name: "移动端日报",
          id: "iframeSrc5",
          link:
            "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=b20c1307-28c7-4f28-995c-49d0f8661453&accessToken=28a393758ac504e03145e7b729b7186f&dd_orientation=auto",
        },
        {
          url: "/wl/xszb",
          name: "湘商销售周报",
          id: "iframeSrc6",
          link:
          "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=b3191c21-57fe-4f11-bfb2-6681354facd1&accessTicket=d3967b0e-4e98-48df-8257-5feeeb6564b0&dd_orientation=auto"
        },
        {
          url: "/wl/xsyb",
          name: "湘商销售月报",
          id: "iframeSrc7",
          link:
          "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=9ff6652d-1aad-441e-9a5b-982f33522fbe&accessTicket=d94a34c1-210c-4603-8a0c-089ced96dbd4&dd_orientation=auto"
        },
        {
          url: "/wl/618",
          name: "618活动报表",
          id: "iframeSrc8",
          link:
          "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=7bf02bac-1f56-4580-ad79-ad763b16dd5f&accessTicket=2dbc4df2-fc33-4d8e-8404-aa8bf7f06bee&dd_orientation=auto"
        },
        {
          url: "/wl/xsr1",
          name: "销售日报-销售一部",
          id: "iframeSrc9",
          link:
          "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=08c313fd-59fa-4ef3-b711-f3181861847d&accessTicket=a515202c-21bf-4149-a182-7810a1bd7b90&dd_orientation=auto"
        },
        {
          url: "/wl/xsr2",
          name: "销售日报-销售二部",
          id: "iframeSrc10",
          link:
          "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=1c04fa6f-ab6c-488d-8a3d-395964f59b15&accessTicket=932f83a5-a890-410e-b1ed-9147b2dbdab5&dd_orientation=auto"
        },
        {
          url: "/wl/xsr3",
          name: "销售日报-销售三部",
          id: "iframeSrc11",
          link:
          "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=7e93ccc9-269a-4e8a-9ca2-40ca9b3d213b&accessTicket=6a1bb3a7-0685-4714-8698-2ccc6b245b80&dd_orientation=auto"
        },
        {
          url: "/wl/xsr4",
          name: "销售日报-新媒体部",
          id: "iframeSrc12",
          link:
          "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=ddfb7713-aaa3-479a-832a-20f4ebebb42d&accessTicket=c898450e-5a8a-4bde-841a-595ec145ee4f&dd_orientation=auto"
        },
        {
          url: "/wl/xsr5",
          name: "销售日报-销售五部",
          id: "iframeSrc13",
          link:
          "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=012f2a54-5b69-499a-b102-6bf1c5acfa5a&accessTicket=768e50da-fcc0-4ef9-8f79-66accd18e50a&dd_orientation=auto"
        },
        {
          url: "/wl/jldf",
          name: "聚链代发日报",
          id: "iframeSrc14",
          link:
          "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=75a01918-e868-4e2d-aad5-6256b07436d8&accessTicket=60578efc-2248-45ba-a151-3a5139f70fa7&dd_orientation=auto"
        },
        {
          url: "/wl/xsjy",
          name: "湘商经营报表",
          id: "iframeSrc15",
          link:
            "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=6d71bd09-4d88-45fd-a557-ce1552c2fa85&accessTicket=d8d2141d-94e6-481b-8a54-1944fbd8c3fe&dd_orientation=auto"
        },
        {
          url: "/wl/fckcrb",
          name: "分仓库存日报",
          id: "iframeSrc16",
          link:
            "https://bi.aliyuncs.com/token3rd/dashboard/view/pc.htm?pageId=f0efafdc-12d8-440c-9666-ac88f17c5e36&accessTicket=ebf7f993-a016-42fb-acda-18553ce627c5&dd_orientation=auto"
        },

      ],
    };
  },
  watch: {
    "$route.path"(now, old) {
      this.iframeList.forEach((element) => {
        if (this.$route.path == element.url) {
          this.iframeSrc = element.link;
          this.iframeId = element.id;
        }
      });
    },
  },
  computed: {
    userName() {
      return this.$store.getters.name;
    },
  },
  created() {
    for (let i = 0; i < 30; i++) {
      this.wmList.push(i);
    }

    this.iframeList.forEach((element) => {
      if (this.$route.path == element.url) {
        this.iframeSrc = element.link;
        this.iframeId = element.id;
      }
    });
  },
  mounted() {
    var _this = this;
    const iframeId = ("#" + this.iframeId).replace(/\//g, "\\/");
    const iframe = document.querySelector(iframeId);
    // iframe页面loading控制
    if (iframe.attachEvent) {
      this.loading = true;
      iframe.attachEvent("onload", function () {
        _this.loading = false;
      });
    } else {
      this.loading = true;
      iframe.onload = function () {
        _this.loading = false;
      };
    }

    if (this.$route.fullPath == "/wl/app") {
      if (document.body.clientWidth < 760) {
        document.getElementById("top-nav").style.display = "none";
        that.height = document.documentElement.clientHeight;
      }
    }

    const that = this;
    window.onresize = function temp() {
      that.height = document.documentElement.clientHeight - 94.5 + "px;";
    };
  },
};
</script>

<style lang="scss" scope>
.waterMark {
  width: 100%;
  height: 100%;
  position: relative;
  top: -100%;
  pointer-events: none;
  overflow: hidden;
  .wm-item {
    float: left;
    color: #97a8be;
    opacity: 0.24;
    margin: 120px 180px;
    transform: rotate(-30deg);
  }
}
</style>
