<template>
	<view class="sales_target">
		<view class="tab_list">
			<view class="tab_li" :class="tabIndex == item.id ? 'tab_active' : ''" v-for="(item,index) in tabList" :key="index" @click="changeTab(item.id)">
				{{item.name}}
			</view>
		</view>
		<member-target v-if="optionsTime.length && optionsDep.length && tabIndex == 1" :optionsTime="optionsTime" :optionsDep="optionsDep"></member-target>
		<department-target v-if="optionsTime.length && tabIndex == 2" :optionsTime="optionsTime"></department-target>
		<company-target v-if="optionsTime.length && tabIndex == 3" :optionsTime="optionsTime"></company-target>
	</view>
</template>

<script>
	import memberTarget from './memberTarget.vue'
	import departmentTarget from './departmentTarget.vue'
	import companyTarget from './companyTarget.vue'
	import { netGetTargetSelect } from '@/api/kehu.js'
	
	export default {
		components:{
			memberTarget,
			departmentTarget,
			companyTarget
		},
		data() {
			return {
				optionsTime:[],
				optionsDep:[],
				roleType:'',
				rules:'',
				tabIndex:1,
				tabList:[
					{id:1,name:'成员目标'},
					{id:2,name:'团队目标'},
					{id:3,name:'公司目标'}
				]
			}
		},
		onShow() {
			this.roleType = uni.getStorageSync('roleType')
			this.rules = uni.getStorageSync('rules')
			console.log(uni.getStorageSync('isSave'))
			if(uni.getStorageSync('isSave')){
				this.optionsTime = []
			}
			//获取筛选条件
			this.getSelect()
		},
		methods: {
			changeTab(id) {
				this.tabIndex = id
			},
			getSelect() {
				netGetTargetSelect().then(res=>{
					this.optionsTime = res.data.years
					this.optionsDep = res.data.department
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.tab_list{
		padding:0 30rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
		background:#fff;
		.tab_li{
			font-size:26rpx;
			color:#666;
			line-height: 80rpx;
		}
		.tab_active{
			color:#333;
			border-bottom:1rpx solid $uni-text-color;
		}
	}
	
	
	.btn_small_g {
		height: 60rpx;
		line-height: 60rpx;
		width: 150rpx;
		background-color: $uni-text-color;
		color: #fff;
		border-radius: 35rpx;
	}
</style>
