<template>
	<view class="concent-footer">
		<view class="content-box">
			<view class="content-box-title"   v-for="item in datatitleList">
				<span class="title">{{item}}</span>
			</view>
		</view>
		<!-- //  一级循环 -->
		<view class="content-sam-box">
			<view class="" v-for="(pointItem,index) in dataList" :key="index">
				<view class="" style="display: flex;">
					<view class="content-box-title" @click="subordinate(index,pointItem,1,tableone)">
						<span>{{pointItem.areaCenterName || '暂无辖下组织'}}</span>
					</view>
					<view class="content-box-title" v-if="pointItem.levelName">
						<span>{{pointItem.levelName}}</span>
					</view>
					<view class="content-box-title" v-if="pointItem.count !=null">
						<span>{{pointItem.count}}</span>
					</view>
				</view>
				<!-- 				<view class="" style="display: flex;" v-if="type == '2'">
					<view class="content-box-title" v-if="pointItem.name"
						@click="subordinate(index,pointItem,1,tableone)">
						<span>{{pointItem.name}}</span>
					</view>
					<view class="content-box-title" v-if="pointItem.levelName">
						<span>{{pointItem.levelName}}</span>
					</view>
					<view class="content-box-title">
						<span>{{pointItem.count}}</span>
					</view>
				</view> -->
				<!-- 				<view class="" style="display: flex;" v-if="type == '3'">
					<view class="content-box-title" v-if="pointItem.org" @click="subordinate(index,pointItem)">
						<span>{{pointItem.org}}</span>
					</view>
					<view class="content-box-title" v-if="pointItem.levelName">
						<span>{{pointItem.levelName}}</span>
					</view>
					<view class="content-box-title" v-if="pointItem.name !=null">
						<span>{{pointItem.name}}</span>
					</view>
					<view class="content-box-title" v-if="pointItem.referrer !=null">
						<span>{{pointItem.referrer}}</span>
					</view>
				</view> -->

				<!-- 二级循环 -->
				<view class="" v-if="table_index == index && this.tableone == true && pointItem.levelCode != 'A1'">
					<view class="" v-for="(itq, index) in twoList" :key="index">
						<view style="display: flex;">
							<view class="content-box-title-a" @click="subordinate(index,itq,2,tabletwo)">
								<span style="color: #FFFFFF;font-weight: 400;">{{itq.name}}</span>
							</view>
							<view class="content-box-title">
								<!-- <span>{{itq.levelName}}</span> -->
							</view>
							<view class="content-box-title">
								<span>{{itq.name}}</span>
							</view>

						</view>
						<!-- 三级循环 -->
						<view class="" v-if="twoindex == index && this.tabletwo == true ">
							<view class="" v-for="(itm, index) in thList ">
								<view class="" style="display: flex;">
									<view class="content-box-title-two" @click="subordinate(index,itm,3,tablefour)">
										<span>{{itm.name}}</span>
									</view>
									<view class="content-box-title">
										<span>{{itm.levelName}}</span>
									</view>
									<view class="content-box-title">
										<span>{{itm.courserNum}}</span>
									</view>
								</view>
								<!-- 第四层关系-->
								<view class="" v-if="foindex == index && this.tablefour == true ">
									<view class="" v-for="(four, index) in fourList ">
										<view class="" style="display: flex;">
											<view class="content-box-title-a" style="margin-left: 30rpx;"
												@click="subordinate(index,four,4,tablefour)">
												<span>{{four.areaCenterName}}</span>
											</view>
											<view class="content-box-title">
												<!-- <span>{{four.levelName}}</span> -->
											</view>
											<view class="content-box-title">
												<span>{{four.count}}</span>
											</view>
										</view>
										
										<view class="" v-if="fiveindex == index && this.tablefive == true ">
											<view class="" v-for="(five, index) in fiveList ">
												<view class="" style="display: flex;">
													<view class="content-box-title-b"
														@click="subordinate(index,itq,2,tabletwo)">
														<span>{{five.name}}</span>
													</view>
													<view class="content-box-title">
														<span>{{five.levelName}}</span>
													</view>
													<view class="content-box-title">
														<span>{{five.courserNum}}</span>
													</view>
												</view>
								<!-- 				<view class="" v-if="foindex == index && this.tablefour == true ">
													<view class="" v-for="(four, index) in fourList ">
														<view class="" style="display: flex;">
															<view class="content-box-title"
																@click="subordinate(index,itq,2,tabletwo)">
																<span>{{four.name}}</span>
															</view>
															<view class="content-box-title">
																<span>{{four.levelName}}</span>
															</view>
															<view class="content-box-title">
																<span>{{four.courserNum}}</span>
															</view>
														</view>

													</view>
												</view> -->
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from "../../api/api";
	export default {
		props: {
			dataList: {
				type: Array,
				default: null
			},
			datatitleList: {
				type: Array,
				default: null
			},
			tabletype: {
				type: String,
				default: null
			},
			type: {
				type: String, // 这里用来去区分是哪个页面传来的值 1直属团队 2.所辖团队 3.其他团队
				default: null
			},
		},
		name: "myteam-table",
		data() {
			return {
				table_index: '', // 第二级
				tableone: false,
				twoindex: '',
				tabletwo: false, // 第三层收起
				dataFoList: [],
				twoList: [],
				thList: [],
				tablefour: false, // 第四层收起
				foindex: '',
				fourList: [],
				tablefive: false, // 第五层收起
				fiveindex: '',
				fiveList: [], 
				tablesix: false, // 第六层收起
				sixindex: '',
				sixList: [], 
			};
		},
		mounted() {

		},
		methods: {
			subordinate(index, val, type, expand) {
				if (this.tabletype == 1 || val.levelCode == 'A1') {
					uni.showToast({
						title: '暂无下级',
						duration: 1000,
						icon: 'none'
					});
					return
				} else {
					if (expand == false) {
						let CffpOrgInfoReqVO = {
							id: val.id
						}
						api.queryTeamDetail(CffpOrgInfoReqVO).then(res => {
							console.log(res, 88855)
							if (res['success']) {
								if (res.data.list.length == 0) {
									// uni.showToast({
									// 	title: '暂无数据',
									// 	duration: 1000,
									// 	icon: 'none'
									// });
									var list = [
										{
											areaCenterName:'第五级',
											levelName:'d',
											count: '25'
										}
									]
									this.ckopennextlevel(index, type, list)
								} else {
									this.ckopennextlevel(index, type, res.data.list)
								}
							}
						})
					} else {
						this.ckopennextlevel(index, type)
					}

				}
			},
			ckopennextlevel(index, val, list) {
				console.log(index, val, list, 7897)
				switch (val) {
					case 1:
						this.tableone = this.table_index == index ? !this.tableone : true
						this.table_index = index
						this.twoList = list
						break
					case 2:
						this.tabletwo = !this.tabletwo
						// this.twoindex = this.twoindex == index ? !this.tabletwo : true
						this.twoindex = index
						this.thList = list
						break
					case 3:
						this.tablefour = this.foindex == index ? !this.tablefour : true
						this.foindex = index
						this.fourList = list
						break
					case 4:
						this.tablefive = this.fiveindex == index ? !this.tablefive : true
						this.fiveindex = index
						this.fiveList = list
						break
					case 5:
						this.tableone = this.foindex == index ? !this.tablefour : true
						this.foindex = index
						this.fourList = list
						break

				}
			}
		}
	}
</script>

<style scoped>
	.content-box {
		background-color: #fff;
		display: flex;
		font-weight: 600;
		align-items: center;
		justify-content: space-between;
	}

	.content-box-title {
		padding: 5px 0;
		flex: 1;
		justify-content: space-between;
		align-items: center;
		text-align: center;
	}

	.content-box-title-two {
		padding: 5px 0;
		flex: 1;
	}

	.content-sam-box {
		/* 		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 10px 0;
		color: #333333;
		border-bottom: 1px solid #F2F2F2;; */
		font-size: 13px;
	}

	.concent-footer {
		margin: 0 5px;
	}

	.content-box-title-a {
		/* padding: 5px 0; */
		flex: 1;
		color: #FFFFFF;
		/* margin: 0 10px; */
		background: #3F52B7;
		background: url('../../static/myteam/Group1660.png');
		background-size: 100%;
		border-radius: 5px;
		border: 1px solid #fff;
	}

	/* 	.content-box-title-b{
		padding: 5px 0;
		flex: 1;
		margin: 0 10px;
		background: url('../../static/myteam/Group1662.png');
		background-size: auto 100%;
		border-radius: 5px;
		border: 1px solid #fff;
	} */
</style>
