<template>
	<view>
		<view class="content">
			<view class="section" v-for="(item,index) in list" :key="index">
				<view class="box">
					<view class="item">
						<view class="left">
							<view class="icon" v-if="active == index" @click.stop="change_active(index,item.id)">
								<image src="./icon/close.png" mode=""></image>
							</view>
							<view class="icon" v-if="active != index" @click.stop="change_active(index,item.id)">
								<image src="./icon/open.png" mode=""></image>
							</view>
							<view class="text">{{item.title}}</view>
						</view>
					</view>
					<view class="list" v-if="active == index">
						<view class="item" v-for="(item_2,index_2) in list_2" :key="index_2"
							@click="go_detail_apply(item_2.title,item_2.id)">
							<view class="left">
								<view class="text">{{item_2.title}}</view>
							</view>
							<view class="right">
								<uni-icons type="compose"></uni-icons>
							</view>
						</view>
					</view>
				</view>
			</view>

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

<script>
	export default {
		data() {
			return {
				list: [],
				// 当前展开
				active: 99999999,
				
				// 可申请列表
				list_2:[]

			};
		},
		onLoad() {
			this.get_list()
		},
		methods: {
			get_list() {
				this.$api.worksheet_classify_list({
					
				}).then((res)=>{
					console.log(res.data.data)
					
					this.list = res.data.data
				})
			},
			change_active(index, id) {
				this.list_2 = []
				if (this.active == index) {
					this.active = 99999999
				} else {
					this.active = index
					
					uni.showLoading({
						mask:true
					})
					this.$api.worksheet_design_list({
						id:id
					}).then((res)=>{
						uni.hideLoading()
						console.log(res.data.data)
						
						this.list_2 = res.data.data
					})
				}
				
			},
			
			go_detail_apply(title,id) {
				uni.navigateTo({
					url: "./apply/apply?title=" + title + "&id=" + id
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F3F8F7;
	}

	.search {
		margin-bottom: 20rpx;
		background-color: #FFFFFF;
		box-sizing: border-box;
		padding: 25rpx 30rpx;

		.box {
			height: 80rpx;
			background-color: #F4F4F4;
			border-radius: 50rpx;

			display: flex;
			align-items: center;

			box-sizing: border-box;
			padding: 0 25rpx;

			.icon {
				margin-right: 10rpx;
			}

			.text {
				font-size: 30rpx;
				color: #BBBBBB;
			}
		}
	}

	.content {
		background-color: #FFFFFF;

		.title {
			height: 110rpx;
			display: flex;
			align-items: center;

			box-sizing: border-box;
			padding: 0 25rpx;
			border-bottom: 1rpx solid #F3F8F7;

			.tab {
				width: 350rpx;
				line-height: 110rpx;
				position: relative;

				.text {
					text-align: center;
				}

				.line {
					position: absolute;
					left: 50%;
					bottom: 0;

					transform: translateX(-40rpx);

					width: 80rpx;
					height: 4rpx;
					background-color: #00A0E8;
				}

				.active {
					color: #00A0E8;
					font-weight: 700;
				}
			}
		}

		.section {
			box-sizing: border-box;
			padding: 0 20rpx;

			.box {

				.item {
					height: 110rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;

					margin-left: 20rpx;
					border-bottom: 1rpx solid #F3F8F7;

					.left {
						display: flex;
						align-items: center;

						.icon {
							line-height: 110rpx;
							width: 90rpx;
							text-align: center;

							image {
								width: 24rpx;
								height: 24rpx;
							}
						}

						.text {
							font-size: 32rpx;
						}
					}

				}

				.list {
					.item {
						height: 110rpx;

						display: flex;
						justify-content: space-between;
						align-items: center;

						margin-left: 80rpx;
						border-bottom: 1rpx solid #F3F8F7;

						.left {
							width: 450rpx;
							.text {
								margin-left: 18rpx;
								font-size: 30rpx;

							}
						}

						.right {
							line-height: 110rpx;
							width: 90rpx;
							text-align: center;
						}

					}
				}

			}

		}

	}
</style>
