<template>
  <div :style="'height:' + height">
    <iframe :src="url" style="width: 100%; height: 100%"/>
  </div>
</template>
<script>
export default {
  name: "WarmFlow",
  data() {
    return {
      height: document.documentElement.clientHeight - 94.5 + "px;",
      url: ""
    };
  },
  mounted() {
    this.url = process.env.VUE_APP_BASE_API + `/warm-flow-ui/index.html?id=${this.$route.params.id}&disabled=${this.$route.query.disabled}`;

    this.iframeLoaded();
  },
  methods: {
    iframeLoaded() {
      window.onmessage = (event) => {
        console.log(event);
        switch (event.data.method) {
          case "close":
            this.close();
            break;
        }
      }
    },
    close() {
      const obj = { path: "/flow/definition" };
      this.$tab.closeOpenPage(obj);
    }
  }
};
</script>
