<template>
	<div class="sidebar">
		<el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="collapse" background-color="#006699"
			text-color="#fff" active-text-color="#fff" unique-opened router>
			<template v-for="item in items">
				<template v-if="item.subs">
					<el-submenu :index="item.index" :key="item.index">
						<template slot="title">
							<i :class="item.icon"></i>
							<span slot="title"> {{ item.title }}</span>
						</template>
						<template v-for="subItem in item.subs">
							<el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
								<template slot="title">
									{{ subItem.title }}
									<!-- <el-badge is-dot :hidden="false">{{ subItem.title }}</el-badge> -->
								</template>
								<el-menu-item v-for="(threeItem,i) in subItem.subs" :key="i" :index="threeItem.index">
									{{ threeItem.title }}
								</el-menu-item>
							</el-submenu>
							<el-menu-item v-else :index="subItem.index" :key="subItem.index">{{ subItem.title }}
							</el-menu-item>
						</template>
					</el-submenu>
				</template>
				<template v-else>
					<el-menu-item :index="item.index" :key="item.index">
						<i :class="item.icon"></i>
						<span slot="title"> {{ item.title }}</span>
					</el-menu-item>
				</template>
			</template>
			<!-- 审稿人 -->
			<template v-if="this.user_cap.includes('reviewer')">
				<el-submenu index="8">
					<template slot="title">
						<i class="el-icon-collection"></i> {{$t('sidebar.rev_ewer')}}
					</template>
					<el-menu-item index="peerewer">
						{{$t('sidebar.rev_ewer1')}}
					</el-menu-item>
					<el-menu-item index="perhistory">
						{{$t('sidebar.rev_ewer2')}}
					</el-menu-item>
				</el-submenu>
			</template>
			<!-- 编委 -->
			<template v-if="this.user_cap.includes(',board')">
				<el-submenu index="7">
					<template slot="title">
						<i class="el-icon-notebook-1"></i> {{$t('sidebar.edit_oria')}}
					</template>
					<el-menu-item index="editorial">
						{{$t('sidebar.edit_oria1')}}
					</el-menu-item>
					<el-menu-item index="edithistory">
						{{$t('sidebar.edit_oria2')}}
					</el-menu-item>
				</el-submenu>
			</template>
			<!-- 主编 -->
			<template v-if="this.user_cap.includes('chief')">
				<el-submenu index="6">
					<template slot="title">
						<i class="el-icon-document-copy"></i> {{$t('sidebar.man_ing')}}
					</template>
					<el-menu-item index="managing">
						{{$t('sidebar.man_ing1')}}
					</el-menu-item>
					<el-menu-item index="manarticle">
						{{$t('sidebar.man_ing2')}}
					</el-menu-item>
				</el-submenu>
				<!-- <el-menu-item index="documentView">
					<i class="el-icon-document-copy"></i>
					<span slot="title"> {{$t('sidebar.document')}}</span>
				</el-menu-item> -->
				<el-submenu index="10">
					<template slot="title">
						<i class="el-icon-data-analysis"></i> {{$t('sidebar.analyp')}}
					</template>
					<el-menu-item index="citationanalysis">
						{{$t('sidebar.analysis')}}
					</el-menu-item>
				</el-submenu>
			</template>
			<!-- 青年编委 -->
			<template v-if="this.user_cap.includes('yboard')">
				<el-submenu index="9">
					<template slot="title">
						<i class="el-icon-copy-document"></i> {{$t('sidebar.you_thed')}}
					</template>
					<el-menu-item index="youthed">
						{{$t('sidebar.you_thed1')}}
					</el-menu-item>
				</el-submenu>
			</template>
			<!-- 客座编辑 -->
			<template v-if="this.user_cap.includes('special')">
				<el-submenu index="11">
					<template slot="title">
						<i class="el-icon-box"></i> {{$t('sidebar.guest')}}
					</template>
					<el-menu-item index="guestArticleL">
						{{$t('sidebar.guest1')}}
					</el-menu-item>
					<!-- <el-menu-item index="guestReviewerL">
						{{$t('sidebar.guest2')}}
					</el-menu-item> -->
				</el-submenu>
			</template>
			<!-- 超管：总经理+总监 -->
			<template v-if="this.user_cap.includes('superadmin')">				
				<el-submenu index="12">
					<template slot="title">
						<i class="el-icon-s-operation"></i> {{$t('sidebar.managingDirector')}}
					</template>
					<!-- <el-menu-item index="youthed">
						{{$t('sidebar.you_thed1')}}
					</el-menu-item> -->
				</el-submenu>
				<el-submenu index="13">
					<template slot="title">
						<i class="el-icon-s-platform"></i> {{$t('sidebar.chiefInspector')}}
					</template>
					<el-menu-item index="editorialBoard">
						{{$t('sidebar.editorialBoard1')}}
					</el-menu-item>
				</el-submenu>
			</template>
			<!-- 主编/总监统计图 -->
			<template v-if="this.userrole == 0">
				<el-submenu index="8">
					<template slot="title">
						<i class="el-icon-data-analysis"></i> {{$t('sidebar.analyp')}}
					</template>
					<el-menu-item index="citationanalysis">
						{{$t('sidebar.analysis')}}
					</el-menu-item>
				</el-submenu>
			</template>
			<!-- 分角色链接 -->
			<template v-if="this.userrole == 0">
				<el-menu-item>
					<a href="http://boss.tmrjournals.com/#/publition?Act=123" target="_blank" style="color: #bfcbd9;">
						<i class="el-icon-d-arrow-right"></i> Boss System
					</a>
				</el-menu-item>
			</template>
			<!-- 编辑 -->
			<template v-if="this.userrole == 1">
				<el-submenu index="5">
					<template slot="title">
						<i class="el-icon-paperclip"></i> {{$t('sidebar.tools')}}
					</template>
					<el-menu-item index="RejectedArticles">
						{{$t('sidebar.ReArticles')}}
					</el-menu-item>
					<!-- <el-menu-item index="1" key="1"> -->
					<a href="http://master.tmrjournals.com" target="_blank" class="linkBar">
						Management System
					</a>
					<!-- </el-menu-item> -->
					<!-- <el-menu-item index="2" key="2"> -->
					<a href="https://mail.mxhichina.com/alimail" target="_blank" class="linkBar">
						Official mailbox
					</a>
					<!-- </el-menu-item> -->
					<!-- <el-menu-item index="3" key="3"> -->
					<a href="https://www.grammarly.com" target="_blank" class="linkBar">
						www.grammarly.com
					</a>
					<!-- </el-menu-item> -->
					<!-- <el-menu-item index="4" key="4"> -->
					<a href="https://quillbot.com" target="_blank" class="linkBar">
						quillbot.com
					</a>
					<!-- </el-menu-item> -->
				</el-submenu>
			</template>
		</el-menu>
	</div>
</template>

<script>
	import bus from '../common/bus';
	export default {
		data() {
			return {
				collapse: false,
				userrole: localStorage.getItem('U_status'),
				user_cap: localStorage.getItem('U_role'),
				items: [],
				// 作者
				author_items: [{
						icon: 'el-icon-lx-home',
						index: 'dashboard',
						title: this.$t('sidebar.main')
					},
					{
						icon: 'el-icon-lx-cascades',
						index: '1',
						title: this.$t('sidebar.author'),
						subs: [{
								index: 'articleList',
								title: this.$t('sidebar.author1')
							},
							{
								index: 'articleDrafts',
								title: this.$t('sidebar.author3')
							},
							{
								index: 'articleAdd',
								title: this.$t('sidebar.author2')
							},
						]
					}
					// ,{
					//     icon: 'el-icon-notebook-2',
					//     index: 'authorApplyReviewer',
					//     title: this.$t('sidebar.authorApplyReviewer')
					// }
				],
				// 编辑
				editor_items: [{
						icon: 'el-icon-lx-home',
						index: 'dashboard',
						title: this.$t('sidebar.main')
					},
					{
						icon: 'el-icon-lx-copy',
						index: 'articleListEditor',
						title: this.$t('sidebar.editor1'),
					},
					// {
					// 	icon: 'el-icon-user',
					// 	index: '3',
					// 	title: this.$t('sidebar.userTalSys'),
					// 	subs: [{
					// 		index: 'partyList',
					// 		title: this.$t('sidebar.userTalSys1')
					// 	}
					// , {
					// 	index: 'partyDelete',
					// 	title: this.$t('sidebar.userTalSys2')
					// }, {
					// 	index: 'editorBorder',
					// 	title: this.$t('sidebar.userTalSys3')
					// }, {
					// 	index: 'reviewerApplyList',
					// 	title: this.$t('sidebar.userTalSys4')
					// }, {
					// 	index: 'reviewerAuthorList',
					// 	title: this.$t('sidebar.userTalSys5')
					// }, {
					// 	index: 'reviewerList',
					// 	title: this.$t('sidebar.userTalSys6')
					// }, {
					// 	index: 'editApplyList',
					// 	title: this.$t('sidebar.userTalSys7')
					// }, {
					// 	index: 'youthApplyList',
					// 	title: this.$t('sidebar.userTalSys8')
					// },
					// ]
					// },
					{
						icon: 'el-icon-user',
						index: '4',
						title: this.$t('sidebar.userManSys'),
						subs: [{
								title: this.$t('sidebar.userManSys1'),
								index: '41',
								subs: [
									// 	{
									// 	index: 'partyListAct',
									// 	title: this.$t('sidebar.userManSys11')
									// },{
									// 	index: 'partyListIna',  
									// 	title: this.$t('sidebar.userManSys12')
									// },
									{
										index: 'partyList',
										title: this.$t('sidebar.userManSys14')
									},
									{
										index: 'partyListCorr',
										title: this.$t('sidebar.userManSys15')
									},
									{
										index: 'partyListPot',
										title: this.$t('sidebar.userManSys13')
									}
								]
							},
							// {
							// 	index: '',
							// 	title: this.$t('sidebar.userManSys2')
							// }, 
							{
								title: this.$t('sidebar.userManSys3'),
								index: '43',
								subs: [{
									index: 'reviewerList',
									title: this.$t('sidebar.userManSys31')
								}, {
									index: 'reviewerApplyList',
									title: this.$t('sidebar.userManSys32')
								}, {
									index: 'reviewerAuthorList',
									title: this.$t('sidebar.userManSys33')
								}]
							}, {
								title: this.$t('sidebar.userManSys4'),
								index: '44',
								subs: [{
									index: 'editorBorder',
									title: this.$t('sidebar.userManSys41')
								}, {
									index: 'editApplyList',
									title: this.$t('sidebar.userManSys42')
								}]
							}, {
								title: this.$t('sidebar.userManSys5'),
								index: '45',
								subs: [{
										index: 'youthList',
										title: this.$t('sidebar.userManSys51')
									},
									{
										index: 'youthApplyList',
										title: this.$t('sidebar.userManSys52')
									}
								]
							},
							{
								index: 'disseMRecord',
								title: this.$t('sidebar.userManSys6')
							},
							{
								index: 'partyDelete',
								title: this.$t('sidebar.userManSys7')
							}
						]
					},
					{
						icon: 'el-icon-data-analysis',
						index: 'citationanalysis',
						title: this.$t('sidebar.analysis'),
					},
					{
						icon: 'el-icon-chat-line-square',
						index: 'TMRGPT',
						title: 'TMRGPT',
					},
				],
				//超级管理员
				admin_items: [{
						icon: 'el-icon-lx-home',
						index: 'dashboard',
						title: this.$t('sidebar.main')
					},
					{
						icon: 'el-icon-connection',
						index: '5',
						title: this.$t('sidebar.chief'),
						subs: [{
								index: 'chiefeditor',
								title: this.$t('sidebar.chief1')
							}
							// {
							// 	index: 'chiefperiod',
							// 	title: this.$t('sidebar.chief2')
							// }
						]
					},
					{
						icon: 'el-icon-user',
						index: '2',
						title: this.$t('sidebar.editormanage'),
						subs: [{
								index: 'editorList',
								title: this.$t('sidebar.editormanage1')
							},
							{
								index: 'editorAdd',
								title: this.$t('sidebar.editormanage2')
							}
						]
					},
					{
						icon: 'el-icon-notebook-1',
						index: '3',
						title: this.$t('sidebar.journal'),
						subs: [{
								index: 'journalList',
								title: this.$t('sidebar.journal1')
							},
							{
								index: 'journalAdd',
								title: this.$t('sidebar.journal2')
							}
						]
					},
					{
						icon: 'el-icon-search',
						index: '4',
						title: this.$t('sidebar.monitor'),
						subs: [{
							index: 'monitorManuscript',
							title: this.$t('sidebar.monitor1')
						}]

					},
					{
						icon: 'el-icon-message',
						index: '9',
						title: this.$t('sidebar.email'),
						subs: [{
							index: 'mailtemplate',
							title: this.$t('sidebar.email1')
						}, ]
					},
					{
						icon: 'el-icon-discount',
						index: '6',
						title: this.$t('sidebar.suggest'),
						subs: [{
								index: 'suggestList',
								title: this.$t('sidebar.suggest1')
							},
							// {
							// 	index: 'suggestSelect',
							// 	title: this.$t('sidebar.suggest2')
							// }
						]
					},
					{
						icon: 'el-icon-coordinate',
						index: '7',
						title: this.$t('sidebar.party'),
						subs: [{
							index: 'partyEditor',
							title: this.$t('sidebar.party1')
						}, {
							index: 'partyList',
							title: this.$t('sidebar.party2')
						}, {
							index: 'partyDelete',
							title: this.$t('sidebar.party3')
						}]
					},
					{ // 总监编委系统
						icon: 'el-icon-s-opportunity',
						index: '10',
						title: this.$t('sidebar.editorialBoard'),
						subs: [{
							index: 'editorialBoard',
							title: this.$t('sidebar.editorialBoard1')
						}, 
						// {
						// 	index: 'partyList',
						// 	title: this.$t('sidebar.party2')
						// }, {
						// 	index: 'partyDelete',
						// 	title: this.$t('sidebar.party3')
						// }
					]
					},
					// ,{
					// 	icon: 'el-icon-data-analysis',
					// 	index: 'citationanalysis',
					// 	title: this.$t('sidebar.analysis')
					// },
					// {
					//     icon:'el-icon-user-solid',
					//     index:'4',
					//     title:this.$t('sidebar.reviewer'),
					//     subs:[
					//         {
					//             index:'adminImportReviewer',
					//             title:this.$t('sidebar.reviewerimport')
					//         },
					//         {
					//             index:'adminImportreviewerError',
					//             title:this.$t('sidebar.reviewerimporterror')
					//         }
					//     ]
					// }
				]
			};
		},
		computed: {
			onRoutes() {
				return this.$route.path.replace('/', '');
			}
		},
		created() {
			if (this.userrole == 2) { //其余的身份（显示作者）
				// if (this.user_cap.includes('chief')) { //主编
				// 	this.items = this.chief_items;
				// } else if (this.user_cap.includes('reviewer')) { //审稿人
				// 	this.items = this.reviewer_items;
				// } else if (this.user_cap.includes('yboard')) { //青年编委
				// 	this.items = this.yboard_items;
				// } else if (this.user_cap.includes(',board')) { //编委
				// 	this.items = this.board_items;
				// }
				this.items = this.author_items;
			} else if (this.userrole == 1) { //编辑
				this.items = this.editor_items;
				this.getDate()
			} else if (this.userrole == 0) { //超级管理员
				this.items = this.admin_items;
			}

			// 通过 Event Bus 进行组件间通信，来折叠侧边栏
			bus.$on('collapse', msg => {
				this.collapse = msg;
				bus.$emit('collapse-content', msg);
			});
		},
		methods: {
			// 获取数据
			getDate() {

			},
		},
	};
</script>

<style scoped>
	.sidebar {
		display: block;
		position: absolute;
		left: 0;
		top: 70px;
		bottom: 0;
		overflow-y: scroll;
		/* -webkit-box-shadow: 0px 0px 25px 0px rgb(45 69 95 / 10%); */
		-moz-box-shadow: 0px 0px 25px 0px rgba(45, 69, 95, 0.1);
		box-shadow: 0px 0px 25px 0px rgb(45 69 95 / 10%);
		z-index: 100;
	}

	.sidebar::-webkit-scrollbar {
		width: 0;
	}

	.sidebar-el-menu:not(.el-menu--collapse) {
		width: 260px;
	}

	.sidebar>ul {
		height: 100%;
	}

	/* 	.sidebar ul li.el-menu-item.is-active::before {
		background: #fff;
		content: "";
		height: 100%;
		left: 0;
		position: absolute;
		top: 0;
		width: 3px;
	} */

	.sidebar ul li.el-menu-item.is-active {
		background-color: rgba(0, 0, 0, .3) !important;
	}

	.el-menu {
		border-right: 0;
	}

	.el-menu-item:hover {
		/* 	color: #006699 !important;
		background-color: #e3e9ef !important; */
	}

	.el-submenu__title i {
		color: #fff !important;
		top: 55% !important;
	}

	.el-menu-item i {
		color: #fff;
	}

	.linkBar {
		color: #fff;
		display: block;
		line-height: 50px;
		padding: 0 0 0 40px;
		font-size: 14px;
	}

	.linkBar:hover {
		background: #00527a;
	}
</style>
