<!doctype html>
<html>
	<head>
		<meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
		<title>报表容器</title>
		
		<script type="text/javascript">
			var vue_ = null;
			var pageVue = null;
			function loadJsCss(callback) {
				var jscss_urls = [];
				window.top.initJsCss(document, jscss_urls, callback);
			};
			
			function initVue() {
				vue_ = new FormVue({
					el: "#vbody",
					data: {
						title: "报表容器",
						iframe_url: "",
						reporttypeurl: "",
						reporturl: "",
						
						popupParames: {},
					},
					created() {
						// var url = window.top.tab.selected.option.url;
						// this.reporturl = url.split('?')[1];
						
						var url = window.location.href;
						var url_list = url.split('?');
						this.reporttypeurl = url_list[1];
						this.reporturl = url_list[2];
						// var urlParam = getGetParamsByUrl(url);
						
					},
					
					mounted() {
						var me = this;
						// 以服务的方式调用的 Loading 需要异步关闭
						this.$nextTick(() => { 
							hideLoading();
							me.getReportToken();
						});
					},
					
					methods:{
						getReportToken() {
							var me = this;
							
							var param_ = "";
							if (window.top.vue.userinfo.currentactor.actor_type == "Customer") { // 经销商
								param_ = "&actor=" + window.top.vue.userinfo.currentactor.actor_type + "&accountId=" + window.top.vue.userinfo.currentactor.target_id
							}
							else if (window.top.vue.userinfo.currentactor.actor_type == "Sales") { // 销售
								param_ = "&actor=" + window.top.vue.userinfo.currentactor.actor_type + "&positionID=" + window.top.vue.userinfo.currentactor.target_id + "&level=" + window.top.vue.userinfo.position_level_field
							}
							else if (window.top.vue.userinfo.currentactor.actor_type == "Business" || window.top.vue.userinfo.currentactor.actor_type == "Org") { // 商务、运营
								param_ = "&actor=" + window.top.vue.userinfo.currentactor.actor_type //+ "&positionID=" + window.top.vue.userinfo.currentactor.target_id
							}
							else if (window.top.vue.userinfo.currentactor.actor_type == "Admin") { // Admin
								param_ = "&actor=" + window.top.vue.userinfo.currentactor.actor_type
							}
							if (param_) {
								this.reporturl += param_
							}
							else {
								this.$message({
									message: '该角色没有报表页面权限',
									type: 'warning'
								});
								return;
							}
							
							var param = {
								type: "get",
							}
							Server.call("rootreport/login/cross/domain?fine_username="+window.top.config.report_user.name+"&fine_password="+window.top.config.report_user.password+"&validity=-2", param, function(result) {
								console.log(result);
								// 以服务的方式调用的 Loading 需要异步关闭
								me.$nextTick(() => { 
									hideLoading();
								});
								me.iframe_url = window.top.config.url_root + "rootreport/"+me.reporttypeurl+"?" + me.reporturl;
								// me.iframe_url = window.top.config.url_report + "/view/form?" + me.reporturl;
							});
						}
					}
				});
			};
			
			loadJsCss(function () {
				initVue();
			});
		</script>
		
		<style>
			/*  在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
			[v-cloak] {
				display: none !important;
			}
		</style>
	</head>
	
	<body style="position: absolute; top: 0; bottom: 0; left: 0; right: 0;">
		<div v-cloak id="vbody">
			<div id="page_root">
				<div style="position: absolute; top: 0px; bottom: 5px; left: 0; right: 0;">
					<iframe :src="iframe_url" style="width: 100%; height: 100%;" frameborder="0"></iframe>
				</div>
			</div>
			
			<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 50vh;">
				<div class="spinner">
				  <div class="cube1"></div>
				  <div class="cube2"></div>
				</div>
			</div>
		</div>	
		
	</body>
</html>