<template>
	<view style="padding-bottom: 20rpx;">
		<view class="listbox-item" v-for="(item, key, index) in abnormalList" :key="index">
			<picker mode="date" fields="month" :value="key" style="display:inline-block;" @change="bindMonthChange">
				<view class="listbox-item-datepicker">
					<text>{{key}}</text>
					<image src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png"></image>
				</view>
			</picker>
			<view class="listbox-item-card" v-for="(dayinfo,time,idx) in item" :key="idx">
				<view class="listbox-item-time">{{time}}</view>
				<view class="listbox-item-carditem border-line" v-for="(it,i) in dayinfo" :key="i" @tap="handleDetail(it)">
					<view class="listbox-item-carditem-left">
						<slot :data="it"></slot>
						<text>{{it.num}} {{unit}}</text>
					</view>
					<text class="listbox-item-carditem-minute">{{$timeFormat(it.createTime, "hh:MM")}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"abnormalList",
		props: {
			abnormalList: {
				type: Object,
				default: {}
			},
			unit: {
				type: String,
				default: ""
			},
			// 数据类型， bs血糖
			type: {
				type: String,
				default: "bs"
			}
		},
		data() {
			return {
				month: ""
			}
		},
		methods: {
			bindMonthChange(e) {
				this.$emit("monthChange",e.detail.value)
			},
			handleDetail(item) {
				let param = {}
				if(this.type == 'bs') {
					param = {
						createTime: item.createTime,
						num: item.num
					}
					uni.navigateTo({
						url: "/pages_watch/healthMonitoring/bloodSugarDetail?param="+ JSON.stringify(param),
					})
				} else if(this.type == 'bp') {
					param = {
						createTime: item.createTime,
						sbp: item.num.split('/')[0],
						dbp: item.num.split('/')[1]
					}
					uni.navigateTo({
						url: "/pages_watch/healthMonitoring/bloodPressureDetail?param="+ JSON.stringify(param),
					})
				} 
			}
		}
	}
</script>

<style lang="scss" scoped>
	@mixin u-flex($flexD, $alignI, $justifyC) {
		display: flex;
		flex-direction: $flexD;
		align-items: $alignI;
		justify-content: $justifyC;
	}

	.listbox-item {
		padding: 0 24rpx;

		&-datepicker {
			height: 96rpx;
			line-height: 96rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 30rpx;
			color: #333333;
			@include u-flex(row, center, flex-start);
			image {
				width: 48rpx;
				height: 48rpx;
			}
		}

		&-card {
			padding: 16rpx 24rpx 24rpx 24rpx;
			margin-bottom: 20rpx;
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #757575;

			&:last-of-type {
				margin-bottom: 0;
			}
		}

		&-time {
			height: 72rpx;
			line-height: 72rpx;
			margin-bottom: 10rpx;
		}

		&-carditem {
			height: 144rpx;
			@include u-flex(row, center, space-between);

			&:last-of-type::after {
				border: none !important;
			}

			&-left {
				font-size: 30rpx;
				color: #222222;
				@include u-flex(row, center, flex-start);
			}

			&-minute {
				flex-shrink: 0;
				font-weight: 400;
				font-size: 24rpx;
				color: #999999;
			}
		}
	}
</style>