<template>
	<div class="box boxMinHeight">
		<el-tabs v-model="name">
			<el-tab-pane :label="item.label" :name="item.name" v-for="(item, index) in tabs" :key="index">
				<EvaluateSet v-if="item.name == 'evaluateSet'" ref="evaluateSet" :boxName="item.name"></EvaluateSet>
				<IndexSet v-if="item.name == 'indexSet'" ref="indexSet" :boxName="item.name"></IndexSet>
				<BasicsSet v-if="item.name == 'basicsSet'" ref="basicsSet" :boxName="item.name"></BasicsSet>
				<!-- <JurisdictionSet v-if="item.name=='jurisdictionSet'" ref="jurisdictionSet" :boxName="item.name"></JurisdictionSet> -->
			</el-tab-pane>
		</el-tabs>
	</div>
</template>

<script>
import BasicsSet from '@/components/set/BasicsSet';
// import JurisdictionSet from '@/components/set/JurisdictionSet';
import EvaluateSet from '@/components/set/EvaluateSet';
import IndexSet from '@/components/set/IndexSet';
export default {
	name: 'set',
	components: { BasicsSet, EvaluateSet, IndexSet },
	data() {
		return {
			name: 'evaluateSet',
			tabs: []
		};
	},
	watch: {
		name(val) {
			localStorage.removeItem('indexSet');
			if (val == 'basicsSet') {
				this.$refs.basicsSet[0].getAllSet();
			}
		}
	},
	created() {
		this.setMenu();
	},
	activated(e) {
		if (this.name == 'evaluateSet') {
			this.$refs.evaluateSet[0].getList();
		} else if (this.name == 'indexSet') {
			this.$refs.indexSet[0].getIndexList();
		}
		if (this.$getCache('setUrlName') != null) {
			this.$nextTick(() => {
				this.name = this.$getCache('setUrlName');
			});
		}
	},
	methods: {
		setMenu() {
			let tabs = [];
			if (this.$isAuthoritys([this.$13, this.$14])) {
				tabs.push({ label: '考核表设置', name: 'evaluateSet' });
			}
			if (this.$isAuthoritys(this.$12)) {
				tabs.push({ label: '指标库', name: 'indexSet' });
			}
			if (this.$isAuthoritys(this.$15)) {
				tabs.push({ label: '基础设置', name: 'basicsSet' });
			}
			this.name = tabs[0].name;
			this.tabs = tabs;
			// this.$nextTick(() => {
			// this.setName();
			// });
		},

	},
	// 离开时保存对应的展示组件
	beforeRouteLeave(to, from, next) {
		this.$setCache('setUrlName', this.name);
		next();
	}
};
</script>

<style scoped="scoped">
.box {
	padding: 20px;
	font-size: 14px;
	background-color: #fff;
}
</style>
