<template>
  <el-container :class="'content'">
    <el-header>
      <el-button type="primary" class="add-item" @click="handleAddPoint"> 激活绘点 </el-button>
      <el-button type="primary" class="add-item" @click="handleAddLine"> 激活绘线 </el-button>
      <el-button type="primary" class="add-item" @click="handleDownload"> 下载工具包 </el-button>
    </el-header>
    <el-main>
      <iframe :src="loadSrc" frameborder="0"></iframe>
    </el-main>
  </el-container>
</template>

<script>
// 手动落图工具
export default {
  data() {
    return {
      loadSrc: "",
      src: "./static/package/collectdata/dist/index.html"
    };
  },
  mounted() {
    this.loadSrc = this.src;
  },
  methods: {
    handleAddPoint() {
      this.loadSrc = this.src + "?type=1";
    },
    handleAddLine() {
      this.loadSrc = this.src + "?type=2";
    },
    handleDownload() {
      let item = systemConfig.plugins[2];
      const elink = document.createElement("a");
      elink.href = item.src;
      elink.setAttribute("download", item.name);
      elink.style.display = "none";
      document.body.appendChild(elink);
      setTimeout(() => {
        elink.click();
        document.body.removeChild(elink);
      }, 66);
    }
  }
};
</script>

<style lang="less" scoped>
.content {
  width: calc(100% - 20px);
  margin-left: 20px;
  .el-header {
    background: #ffffff;
    margin-bottom: 20px;
    padding-top: 10px;
  }

  .el-main {
    background: #ffffff;
    overflow: hidden;
    box-sizing: border-box;

    position: relative;
    border-radius: 5px;
    padding: 0px 0px;
    iframe {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
