08335 / hivui-platform-template
hivui平台项目模板
Newer
Older
hivui-platform-template / project / hivuiSam / App.vue
<template>
    <analysis-sam style="height: 100%;" :conf="conf"></analysis-sam>
</template>
<script>
import { LoadUtil } from "./funclib/LoadUtil";
import { getToken } from "./utils/auth";
import { projectName, requestUrl } from "@birt/config";
import cmps from 'zhc-birt-cmps'
import AnalysisSam from './components/analysisSam/Index.vue'
export default {
  data() {
    return {
      birtModel: {},
      VUE_APP_BASE_API: requestUrl,
      pn: projectName || "birt",
      conf:{}
    };
  },
  components:{AnalysisSam},
  methods: {
    // 动态加载报表模型方法
    birtModelMethod(routePath, birtModelMethod, scope) {
      debugger
      return new Promise((resolve, reject) => {
        let me = this;
        let token = getToken();
        let vId = window.scpRequestData && window.scpRequestData.__viewItemId
        LoadUtil.loadJsBirtModel({
          loadModelUrl: this.$HI.birtModel,
          routePath: routePath,
          token: token,
          pn: this.pn,
          vId: vId,
        })
          .then((res) => {
            debugger
            try {
              let birtModel = getBirtModel(scope || me, cmps.Tool)
              resolve(birtModel);
            } catch (e) {
              console.error(e);
            }
          })
          .catch((e) => {
            reject(e);
          });
      });
    },
    // loadBirtModel(routePath) {
    //   return new Promise((resolve, reject) => {
    //     let me = this;
    //     this.birtModelMethod(routePath, this.birtModelMethod)
    //       .then((birtModel) => {
    //         debugger
    //         me.conf = birtModel;
    //         console.log("conf", me.conf);
    //         resolve();
    //       })
    //       .catch((e) => {
    //         reject(e);
    //       });
    //   });
    // },
    // 获取地址栏参数
    getQueryVariable(variable) {
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
          return pair[1];
        }
      }
      return false;
    },
  },
  created() {
    var path = window.location.pathname;
    // 编译后多e5
    if (window.HIVUI_SETTING) {
      var serverName = window.HIVUI_SETTING.serverName;
      if (serverName && path.startsWith(serverName)) {
        path = path.substring(serverName.length);
      }
    }
    let me = this;
    let token = getToken();
    let vId = window.scpRequestData && window.scpRequestData.__viewItemId
    LoadUtil.loadJsBirtModel({
      loadModelUrl: this.$HI.birtModel,
      routePath: path,
      token: token,
      pn: this.pn,
      vId: vId,
    })
      .then((res) => {
        try {
          let birtModel = getBirtModel(me, cmps.Tool)
          me.conf = birtModel;
          console.log("conf", me.conf);
        } catch (e) {
          console.error(e);
        }
      })
      .catch((e) => {
        console.error(e);
      });
    // this.loadBirtModel(path).then((res) => {
    //   console.log('res', res)
    // }).catch(e =>{
    //   console.log('error', e)
    // })
  },
};
</script>
<style>
html,body{
  height: 100%;
}
</style>