<template>
<analysis-sam ref="sam" style="height: 100%;" :conf="conf"></analysis-sam>
</template>
<script>
import { LoadUtil } from "./funclib/LoadUtil";
import { getToken } from "./utils/auth";
import { projectName, requestUrl } from "@sam/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) {
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);
});
});
},
// 获取地址栏参数
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;
if(me.conf.analyseFields && me.conf.analyseFields.length){
let havingForm = {}
me.conf.analyseFields.forEach(item => {
havingForm[item.prop] = {
value: undefined,
value2: undefined,
label: item.label,
sign: 'inRange'
}
});
me.conf.havingForm = JSON.parse(JSON.stringify(havingForm))
this.$refs['sam'].havingForm = havingForm
this.$refs['sam'].pageSizes = me.conf.pageSizes || [10,20,50,100]
this.$refs['sam'].pageSize = me.conf.pageSize || 100
}
} catch (e) {
console.error(e);
}
})
.catch((e) => {
console.error(e);
});
},
};
</script>
<style>
html,body{
height: 100%;
}
</style>