<template>
	<view class="apply-list">
		<view class="apply-list-item"   v-for="(item,index) in editList" :key="index">
			<view class="apply-list-item-title">
				{{item.title}}
			</view>
			<view class="apply-info">
				<view class="apply-info-item" v-for="(item1,index1) in item.childer" :key="index1">
					<view class="apply-info-item-img">
						<image style="width: 100%;height: 100%;" :src="item1.img" mode=""></image>
						<view v-if="show" class="home-edit-item-img-icon" @click="add(item1)">
							+
						</view>
					</view>
					<view class="apply-info-item-text">
						{{item1.title}}
					</view>

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

<script>
	export default {
		name: "editContent",
		props: {
			list: {
				type: Array,
				default: () => []
			}
		},
		data() {
			return {

			};
		},
		methods: {
			add(item) {
				item.show = !item.show
				this.$emit('update:list', this.list)
			}
		},
		computed: {
			show() {
				let arr = []
				this.list.forEach(item => {
					item.childer.forEach(item1 => {
						if (item1.show) {
							arr.push(item1)
						}
					})
			
				})
				 let flag = false
				  if(arr.length >=3){
					   flag = false
				  }else {
					   flag = true
				  }
				return flag
			},
			editList() {
				let arr = []
				this.list.forEach(item => {
					let obj = {
						title: item.title,
						childer: []
					}
					item.childer.forEach(item1 => {
						if (!item1.show) {
							obj.childer.push(item1)
						}
					})
					arr.push(obj)

				})
				return arr
			}
		}
	}
</script>

<style lang="scss" scoped>
	.apply-list {
		width: 100%;

		.apply-list-item {
			padding: 32rpx 32rpx 0 32rpx;
			background-color: #fff;
			border-radius: 5.33px;
			box-shadow: 0px 0px 6.67px 0px rgba(147, 147, 147, 0.20);
			margin-bottom: 32rpx;

			.apply-list-item-title {
				font-size: 32rpx;
				margin-bottom: 32rpx;
			}
		}

		.apply-info {
			width: 100%;
			display: flex;
			flex-wrap: wrap;

			.apply-info-item {
				width: 20%;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				margin-bottom: 32rpx;

				.apply-info-item-img {
					width: 50rpx;
					height: 50rpx;
					position: relative;
				}

				.apply-info-item-text {
					font-size: 24rpx;
				}
			}
		}
	}

	.home-edit-item-img-icon {
		width: 30rpx;
		height: 32rpx;
		background-color: rgba(153, 153, 153, 1);
		font-size: 24rpx;
		color: #fff;
		text-align: center;
		line-height: 30rpx;
		border-radius: 50%;
		position: absolute;
		right: -15rpx;
		top: -15rpx;
	}
</style>