<template>
  <div class="intelligent_drawing-container">
    <div class="apass_breadcrumb">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>在线组件工具</el-breadcrumb-item>
        <el-breadcrumb-item>智能制图</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <div class="main-container">
      <iframe ref="intelligent_drawing_iframe" width="100%" height="100%" scrolling="no" :src="znztUrl" frameborder="0"></iframe>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      url:'https://apaasgis.wodcloud.com/portal/apaasplat/viewer/mapViewer.html',
    };
  },
  computed:{
    getZnztParams() {
      return this.$store.state.znztParams;
    },
    getAppBuilderParams() {
      return this.$store.state.appBuilderParams;
    },
    znztUrl(){
      return this.url+this.urlParams
    },
    urlParams(){
      if(this.$store.state.znztParams){
        return `?webmap=${this.$store.state.znztParams.id}`;
      }else{
        return ''
      }
    },
  },
  watch: {
    getZnztParams(newVal) {
      this.urlParams = `?webmap=${newVal.id}`
      console.log('智能制图参数'+newVal)
    },
    getAppBuilderParams(newVal) {
      console.log('智能制图应用程序参数'+newVal)
    },
  },
  mounted() {
    window.addEventListener('message',event =>{
      let data = event.data;
      // 智能制图发布服务
      if (data.cmd == 'mapviewmsg'){
        console.log(data);
        this.$store.commit("setZnztParams", data.params);
        this.$router.push(`/fwzc/fwcs`);
      }
      // App Builder发布服务
      if (data.cmd == 'appbuildermsg'){
        console.log(data);
        this.$store.commit("setAppBuilderParams", data.params);
        this.$router.push(`/fwzc/fwcs`);
      }
    })
  },
  methods: {},
};
</script>

<style scoped>
.intelligent_drawing-container {
  margin: -157px 40px 20px;
}
.intelligent_drawing-container .main-container {
  height: calc(100vh - 150px - 43px);
  border-radius: 12px;
  background-color: #fff;
  padding: 0px;
}
.intelligent_drawing-container .main-container iframe {
  border-radius: 12px;
}
</style>

<style>
.intelligent_drawing-container .apass_breadcrumb {
  padding: 0 20px;
}
.intelligent_drawing-container .apass_breadcrumb > .el-breadcrumb .el-breadcrumb__inner {
  color: #626de9;
}
.intelligent_drawing-container
  .apass_breadcrumb
  > .el-breadcrumb
  .el-breadcrumb__item:last-child
  .el-breadcrumb__inner {
  color: #b4c0f5;
}
</style>
