<template>
  <div class="intelligent_appbuilder-container">
    <div class="apass_breadcrumb">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>在线组件工具</el-breadcrumb-item>
        <el-breadcrumb-item>智能制图</el-breadcrumb-item>
        <!-- <el-breadcrumb-item>资源详情</el-breadcrumb-item> -->
      </el-breadcrumb>
    </div>

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

<script>
const gisServiceUrl = window.serviceConfig.gisServiceRoot;
export default {
  data() {
    return {
      originUrl: gisServiceUrl + '/portal/apps/webappbuilder/index.html'
    };
  },
  computed:{
    appbuilderUrl(){
      let _self = this;
      if(_self.$route.name == 'intelligent_appbuilder'){
        return `${_self.originUrl}?title=${_self.$route.query.title}&tags=${_self.$route.query.tags}&summary=${_self.$route.query.summary}&sharewithwebmap=${_self.$route.query.sharewithwebmap}&webmap=${_self.$route.query.webmap}`
      }
    },
    getAppBuilderParams() {
      return this.$store.state.appBuilderParams;
    },
  },
  watch: {
    getAppBuilderParams(newVal) {
      console.log('智能制图应用程序参数'+newVal)
    },
  },
  mounted() {
    window.addEventListener('message',event =>{
      let data = event.data;
      // App Builder发布服务
      if (data.cmd == 'appbuildermsg'){
        console.log(data);
        this.$store.commit("setAppBuilderParams", data.params);
        this.$router.push(`/fwzc/fwcs?map=4`);
      }
    })
  },
  methods: {},
};

</script>

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

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