<template>
	<header :class="'mui-bar mui-bar-nav '+headerClass" :style="headerStyle">
		<h1 class="mui-title" v-text="pageTitle"></h1>
		<a v-if="leftShow" class="mui-icon mui-icon-left-nav mui-pull-left" :routeName="routeName" @click="goBack"></a>
		<a v-if="rightLink.show" @click="doRightLink" class="fyy-bar mui-pull-right">
			<span :class="'mui-icon iconfont '+rightLink.icon" :style="rightLink.style">
				<span class="header-right-wz">
					{{rightLink.title}}<i></i>
				</span>
				<span v-if="systemMessageNum>0" class="mui-badge mui-badge-danger jp-badge" v-text="systemMessageNum"></span>
			</span>
		</a>
	</header>
</template>

<script>
	export default {
		name: 'TopHeader',
		props: {
			headerClass: {
				require: false,
				default: '',
			},
			headerStyle: {
				require: false,
				default: '',
			},
			routeName: {
				require: false,
				default: '',
			},
			pageTitle: {
				require: false,
				default: '',
			},
			leftShow: {
				require: false,
				default: true,
			},
			rightLink: {
				require: false,
				type: Object,
				default: () => ({
					show: false,
					to: '',
					icon: '',
					style: '',
					title: ''
				}),
			},
			doRightLink: {
				require: false,
				type: Function,
			},
			systemMessageNum: {
				require: false,
				default: 0
			}
		},
		methods: {
			//返回上一层
			goBack() {
				if (this.routeName) {
					this.$router.push({
						name: this.routeName
					})
				} else {
					this.$router.go(-1);
				}
			}
		},
	}
</script>

<style scoped src="$project/assets/css/xpgj.css"></style>
<style scoped>
	.jp-badge {
		font-size: 12px !important;
		margin-left: 0 !important;
		line-height: 1.4 !important;
		top: 5px !important;
		left: 50% !important;
		background-color: #F7D046 !important;
		color: #000 !important;
	}
</style>
