<template>
	<view class="app">
		<u-collapse :accordion='false'>
			<u-collapse-item :title="item.head" v-for="item in itemList" :key="item.id"
				:class="headitemid.find(e=>e==item.id)?'headcollapse':''" @change='tapcollapse(item.id)'>
				<view class="itemtext" v-for="uitem in item.item">
					<view class="left">
						{{uitem.body}}
					</view>
					<view class="right">
						{{uitem.text}}
					</view>
				</view>
			</u-collapse-item>
		</u-collapse>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				headitemid: [],
				itemList: [{
					head: "高血压个性服务包",
					id: 1,
					item: [{
							body: '大生化',
							text: '1/1'
						},
						{
							body: '心电图',
							text: '1/1'
						}
					]
				}, {
					head: "高血压基本公卫服务包",
					id: 2,
					item: [{
							body: '大生化',
							text: '1/1'
						},
						{
							body: '心电图',
							text: '1/1'
						}
					]
				}, {
					head: "老年人个性服务包",
					id: 3,
					item: [{
							body: '大生化',
							text: '1/1'
						},
						{
							body: '心电图',
							text: '1/1'
						}
					]
				}],
			};
		},
		methods: {
			tapcollapse(i) {
				let findindex = this.headitemid.findIndex(e => e == i)
				if (findindex != -1) {
					this.headitemid.splice(findindex, 1)
				} else {
					this.headitemid.push(i)
				}
			},
		}
	}
</script>

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

	.app {
		width: 96%;
		margin: 20rpx auto;

		::v-deep .u-collapse-title {
			font-size: 30rpx;
			font-weight: 600;
			padding-left: 10rpx;
		}

		::v-deep .u-collapse-head {
			width: 96%;
			margin: 0 auto;
		}


		::v-deep .u-arrow-down-icon {
			transform: rotate(270deg);
		}

		.itemtext {
			font-size: 28rpx;
			font-weight: 500;
			color: #868585;
			width: 94%;
			height: 100rpx;
			padding-left: 10rpx;
			line-height: 100rpx;
			border-bottom: 2rpx solid #E6E6E6;
			margin: 0 auto;
			display: flex;
		}

		.headcollapse {
			::v-deep .u-collapse-head {
				border-bottom: 2rpx solid #E6E6E6;
			}

			::v-deep .u-arrow-down-icon {
				transform: rotate(360deg) !important;
			}

			::v-deep .u-collapse-item {
				padding-bottom: 40rpx;
			}

			::v-deep .u-collapse-title {
				color: #26A888;
			}
		}

		::v-deep .u-collapse-item {
			background-color: #fff;
			margin-bottom: 20rpx;
		}
	}
</style>