<template>
	<view class="workbench-page">

		<view class="section white-wrap" v-for="item in my_tabs" :key="item.label">
         <view class="tab-title">{{item.label}}</view>
         <view class="tab-ul">
            <view class="tab-item" @click="handleGoNext(tab.url)" v-for="tab in item.child" :key="tab.label">
               <image :src="tab.img" mode="aspectFill" class="icon"/>
               <view class="label">{{tab.label}}</view>
            </view>
         </view>
		</view>

	</view>
</template>

<script>
	import {shareData} from '@/utils/config.js'
	export default{
		data() {
			return {
            my_tabs: [],
				tabs: [
					{
						label: '审批',
						child: [
							{
								label: '客户审批',
								url: '/pages-approve/custome/list',
								img: require('@/static/icon-1.png')
							},
							{
								label: '合同审批',
								url: '/pages-approve/contract/list',
								img: require('@/static/icon-2.png')
							},
							{
								label: '用印审批',
								url: '/pages-approve/seal/list',
								img: require('@/static/icon-3.png')
							},
						]
					},
					{
						label: '路演管理',
						child: [
							{
								label: '研究员日历',
								url: '/pages-roadshow/researcherCalendar/index',
								img: require('@/static/icon-5.png')
							},
							{
								label: '我的日历',
								url: '/pages-roadshow/myCalendar/index',
								img: require('@/static/icon-6.png')
							}
						]
					},
					{
						label: '问答社区',
						child: [
							{
								label: '问答管理',
								url: '/pages-question/detail/index?type=question',
								img: require('@/static/icon-question.png')
							},
							{
								label: '评论管理',
								url: '/pages-question/detail/index?type=comment',
								img: require('@/static/icon-comment.png')
							}
						]
					},
					{
						label: '出差管理',
						child: [
							{
								label: '出差日历',
								url: '/pages-businessTrip/calendar/index',
								img: require('@/static/icon-businesstrip-calendar.png')
							},
							{
								label: '出差申请',
								url: '/pages-businessTrip/apply/list',
								img: require('@/static/icon-businesstrip-apply.png')
							},
							{
								label: '出差审批',
								url: '/pages-approve/businessTrip/list',
								img: require('@/static/icon-businesstrip-approve.png')
							},
						]
					},
					{
						label: '视频',
						child: [
							{
								label: '评论管理',
								url: '/pages-video/comment/list',
								img: require('@/static/icon-comment-video.png')
							}
						]
					}
				]
			}
		},
      onLoad() {
         
        this.init()
      },
      
		onShareAppMessage() {
			return shareData
		},
		methods: {
			handleGoNext(url) {
					uni.navigateTo({
						url
					})

			},
         init() {
            const userInfo = this.$store.state.userInfo;
            this.my_tabs =  !['ficc_admin','admin'].includes(userInfo.RoleTypeCode) ? this.tabs.filter(_ => _.label !== '问答社区') : this.tabs;
			if(!userInfo.IsBusinessTrip){//删除出差审批
				this.my_tabs=this.my_tabs.map(item=>{
					item.child=item.child.filter(_=>_.label!=='出差审批')
					return item
				})
			}
			// 权益不显示出差管理模块
			if(userInfo.IsRai){
				this.my_tabs=this.my_tabs.filter(_ => _.label !== '出差管理')
			}
         }
		},
	}
</script>

<style lang="scss">
	.workbench-page{
		padding: 20rpx;
		display: flex;
		flex-wrap: wrap;
	}
	.section{
		width: 100%;
		padding: 30rpx;
		box-shadow: 0px 3px 12px rgba(175, 175, 175, 0.16);
		font-size: 12px;
		font-weight: 400;
		color: #666;
		margin-bottom: 30rpx;
		.tab-title {
			font-size: 32rpx;
			font-weight: bold;
			color: #222;
		}
		.tab-ul {
			margin-top: 40rpx;
			display: flex;
			align-items: center;
			.tab-item {
				margin-right: 60rpx;
				text-align: center;
				.icon{
					width: 78rpx;
					height: 78rpx;
					margin: 0 auto 10rpx;
				}
			}
		}
	}
</style>
