<template>
	<view class="app">
		<view class="body">
			<view class="left">
				<u-collapse :accordion='false'>
					<u-collapse-item :title="item.year" v-for="(item, index) in itemlistleft" :key="index"
						:class="item.check?'headcollapse':''" @change='tapcollapseleft(item)'>
						<view class="itemtext" v-for="aitem in item.list" @tap="dataies(aitem)">
							<view class="left">
								{{aitem.recordDate}}
							</view>
						</view>
					</u-collapse-item>
				</u-collapse>

			</view>
			<view class="right">
				<u-collapse :item-style="itemStyle" :arrow="false" :accordion='false'>
					<u-collapse-item :title="item.tempName" v-for="(item, index) in itemList.ptList" :key="index"
						@change='tapcollapse(item)' :class="item.check?'headcollapse':''">
						<view class="itemtext">
							<view class="collapse_top" v-for="uitem in item.ptValList">
								<u-icon name="star-fill" color="#000" size="28" v-if="uitem.itemType=='1' || uitem.itemType=='2' ||uitem.itemType=='3'"></u-icon>
								<span style="margin-left: 10rpx;" v-if="uitem.itemType=='1'">健康生活方式 </span>
								<span style="margin-left: 10rpx;" v-if="uitem.itemType=='2'">治疗与康复</span>
								<span style="margin-left: 10rpx;" v-if="uitem.itemType=='3'">急症处理</span>
								<view class="itemsdata">
									<view class="itemword" v-if="uitem.val=='true'">
										<u-checkbox active-color="#26A888" v-model="checked">	{{uitem.content}}</u-checkbox>
									</view>
									<view class="itemword" v-if="uitem.val==null || uitem.val=='false'">
										<u-checkbox active-color="#26A888" v-model="checkedfalse">{{uitem.content}}</u-checkbox>
									</view>
								</view>
							</view>

						</view>
					</u-collapse-item>
				</u-collapse>
			</view>
		</view>
		<u-loading :show="show" mode="flower"  size="40"></u-loading>
	</view>
</template>

<script>
	import {dayList,detail} from "@/api/pagesB/threeHundredAndSixty/threeHundredAndSixty.js"
	export default {
		data() {
			return {
				show:true,
				checked:true,
				checkedfalse:false,
				lastrecodedata:null,
				cardNo:'',
				itemlistleft: [],
				itemList: [],
				recordCode:'',
			}
		},
		mounted() {
			this.lastrecodelist()
		},
		methods: {
			lastrecodelist() {
				if (uni.getStorageSync("userinfo").cardNo) {
					// this.cardNo=uni.getStorageSync("userinfo").cardNo
					this.cardNo = '370522196411282177'
					dayList(this.cardNo).then(res => {
						this.itemlistleft = res.data
						this.recordCode=res.data[0].list[0].recordCode
						console.log(this.recordCode)
						detail(this.recordCode).then(res => {
							this.itemList = res.data
							this.show=false
						})
					})
				}
			},
			tapcollapse(item) {
				item.check = !item.check
			},
			dataies(aitem){
				console.log(aitem,'aitem')
				this.recordCode=aitem.recordCode
				detail(this.recordCode).then(res => {
					this.itemList = res.data
				})

			},
			tapcollapseleft(item){
				console.log(item)
				item.check = !item.check

			}

		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}
	.app {
		// height: 100vh;
		padding: 32rpx 10rpx;
		text-align: center;
		font-size: 36rpx;

		.body {
			width: 100%;
			// height: 100vh;
			display: flex;
			.left {
				// height: 100vh;

				// background: aliceblue;
				::v-deep .u-collapse-title {
					font-size: 26rpx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					color: #000;
					padding-left: 10rpx;
					font-weight: 600;
				}
				::v-deep .u-collapse-head {
					width: 96%;
					margin: 0 auto;

				}

				.itemtext {
					font-size: 28rpx;
					background: #FFFFFF;
					font-weight: 500;
					color: #333333;
					height: 100rpx;
					padding-left: 10rpx;
					line-height: 100rpx;
					border-bottom: 2rpx solid #E6E6E6;
					margin: 0 auto;
					display: flex;
					justify-content: space-between;
				}

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

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


				::v-deep .u-collapse-head {
					width: 96%;
					margin: 0 auto;
					// background: #169BD5 !important;
					text-align: center;
					color: #fff;
				}

				::v-deep .u-collapse-item {
					// background-color: #4271B9;
					margin-bottom: 2rpx;
				}
			}

			.right {
				// height: 100vh;
				width: 77%;
				::v-deep .u-collapse-title {
					font-size: 30rpx;
					font-weight: 600;
					padding-left: 10rpx;
				}
				::v-deep .u-icon--right {
					color: #26A888 !important;
				}
				.headcollapse {
					::v-deep .u-collapse-head {
						border-bottom: 2rpx solid #E6E6E6;
						text-align: center !important;
					}

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

				::v-deep .u-collapse-head {
					width: 96%;
					margin: 0 auto;
					background: #26A888 !important;
					text-align: center;
					color: #fff;
				}

				// background-color: red;
				.itemtext {
					.collapse_top {
						font-size: 30rpx;
						font-weight: 500;
						color: #000;
						width: 94%;
						line-height: 40rpx;
						margin: 0 auto;
						padding: 20rpx 20rpx;

						.itemsdata {
							width: 100%;

							.itemword {
								margin: 15rpx;


							}

						}

					}
				}

			}
		}
	}
</style>
