<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<title>主页 - 贸理通综合贸易管理平台</title>
		<script>
			document.getElementsByTagName('html')[0].style.fontSize = (100*window.innerWidth/1440)+'px';
		</script>
		<!--/*  头部静态资源 */-->
		<div th:substituteby="common/resourceMainHeader :: resourceMainHeader"></div>
	</head>
	<body>
		<!--[if lt IE 8]>
		    <div class="alert alert-danger">您正在使用 <strong>过时的</strong> 浏览器. 是时候 <a href="http://browsehappy.com/">更换一个更好的浏览器</a> 来提升用户体验了.</div>
		<![endif]-->
			<div class="yk_head">
				<ul>
<!--					<li style="padding-top:0.22rem;">-->
<!--						<div class="head_circleBox yk_headStaticsBtn">-->
<!--							<i class="icon icon-bar-chart"></i>-->
<!--							<div id="statisticsManage" style="display:none;" tag:hasPermission="statisticsManage">统计模块</div>-->
<!--						</div>-->
<!--						-->
<!--					</li>-->
					<li style="padding:0;padding-top:0.22rem;" th:include="common/message :: message"></li>
					<li style="padding:0;padding-top:0.22rem;" class="headTagLi" th:include="common/userInfo :: userInfo"></li>
				</ul>
			</div>
			<div class="yk_content scrollbar">
				<div class="yk_menubox" th:include="common/sidebar :: sidebar"></div>
				<div class="yk_rightcontent"></div>
				<div id="vueApp">
					<keep-alive :include="keepAliveInclude">
						<router-view :key="key"></router-view>
					</keep-alive>
				</div>
			</div>
			<!-- <li class="light-blue dropdown-modal" th:include="common/userInfo :: userInfo"></li> -->
			<!-- <div class="tableToolTip"></div> -->
			<div class="yk_adjustMask"></div>
			<ul style="display:none;">
				<li th:each="msgType,msgTypes:${msgTypeList}" th:value="${msgType?.id}" class="getmessageType"><a style="padding-left:8px;" href="###" th:text="${msgType?.name}"></a></li>
			</ul>
			<div class="yinkeSignInOvertimeGoLogin" style="width:0;height:0;overflow:hidden;display:none;"></div>
		<!--/*  js资源 */-->
		<div th:substituteby="common/resourceMainFooter :: resourceMainFooter"></div>
	</body>
</html>
<script type="module">
	import { router, routes } from '/frontEnd/router/index.js'
	import * as utils  from '/frontEnd/utils/index.js'
	import api from '/frontEnd/api/index.js'
	import store from '/frontEnd/store/index.js'
	import { getJurisdictionBtnCode } from '/frontEnd/api/dictionary.js'
	let routerStatus = false
	router.beforeEach(async(to, from, next) => {
		if(to.path === from.path) {
			routerStatus = false
			next()
		}else {
			if(to.meta.cache && from.meta.cache ) {
				routerStatus = true
			}else if(!Object.keys(from.meta).length && to.meta.cache) {
				routerStatus = true
			}else {
				routerStatus = false
			}
			next()
		}
	})
	new Vue({
		router,
		store,
		el: '#vueApp',
		data() {
			return {
				includeData: []
			}
		},
		computed: {
			key() {
				return this.$route.path
			},
			keepAliveInclude() {
				this.includeData = []
				if(this.$route.path !== '/home' && !routerStatus) {
						if(Object.keys(this.$route.meta).length) {
							this.handleKeepAliveData(routes)
							return this.includeData
						}else {
							return []
						}
				}else {
					if(routerStatus) {
						if(Object.keys(this.$route.meta).length) {
							return [this.$route.name]
						}else {
							return []
						}
					}else {
						return []
					}

				}
			}
		},
		created() {
			getJurisdictionBtnCode().then(({data}) => {
				utils.setSessionStorage('button', JSON.stringify(data) )
			})
		},
		methods: {
			handleKeepAliveData(list) {
				list.forEach(item => {
					if (item.meta.cache) {
						this.includeData.push(item.name)
					}
					if (item.children && item.children.length) {
						this.handleKeepAliveData(item.children)
					}
				})
			}
		}
	})
	Vue.prototype.$ELEMENT = { size: 'small' };
	Vue.prototype.$utils = utils;
	Vue.prototype.$api = api;
	Vue.component('cy-dialog', httpVueLoader('/frontEnd/components/Dialog/index.vue'))
	Vue.component('cy-amount-input', httpVueLoader('/frontEnd/components/AmountInput/index.vue'))
	Vue.component('time-axis', httpVueLoader('/frontEnd/components/TimeAxis/index.vue'))
	Vue.component('up-down-drag', httpVueLoader('/frontEnd/components/UpDownDrag/index.vue'))
	Vue.component('cy-steps', httpVueLoader('/frontEnd/components/Steps/index.vue'))
	Vue.component('cy-upload', httpVueLoader('/frontEnd/components/Upload/index.vue'))
	Vue.component('cy-view-bar', httpVueLoader('/frontEnd/components/ViewBar/index.vue'))
	Vue.component('cy-unified-editor', httpVueLoader('/frontEnd/components/UnifiedEditor/index.vue'))
	Vue.component('cy-org-list', httpVueLoader('/frontEnd/components/OrgList/index.vue'))
	Vue.directive('power', {
		inserted(el, type) {
			const powerList = JSON.parse(JSON.stringify(utils.getSessionStorage('button')))
			const [one, two] = type.value.split(":")
			if (one && !powerList.includes(one)) {
				if(two === 'tab') {
					const idAttr = el.getAttribute("aria-labelledby")
					setTimeout(() => {
						document.getElementById(idAttr).style.display = 'none'
					}, 100);
				}else {
					el.remove()
					// el.style.display = 'none'
				}
			}
		}
	})
</script>
