<template>
	<view class='waiting-method-page'>
		<visitor-list @clickEvent="getVisitorListData" @dataEvent="setVisitorListData" ref="visitors" :add="true"></visitor-list>

		<uni-card v-if="(visitor_id==0 || (visitor_id!=0 && visitor_id==item.id)) && pageShow" v-for="(item,key) in visitor_list" :title="item.name" :extra="'身份证：'+item.idcard_txt"  :class="((visitor_list && item.h_list && item.h_list.length>0)?'':'empty')" margin="0 0 0rpx 0" shadow="none" :border="false" padding="24rpx">
			<view class="visitor-account">
				<VisitorAccount @closeEvent="closeCollapse" @getinfo="get_visitor_info" :isOpen="isOpen" :title="item2.hospital+' '+item2.depart" v-for="(item2,key2) in item.h_list" :visitorInfo="visitorInfo" v-if="visitor_list && item.h_list && item.h_list.length>0" :depart_id="item2.depart_id" :visitor_id="item.id" :thumb="cssUrl+'hicon.svg'" :errmsg="(!item2.weeks ? (item2.days?(item2.days+'天未看病，请及时复诊'):'') : (' '+(item2.weeks<=10?item2.weeks:('超过10')))+'周未看病，请及时复诊')"/>
			</view>
		</uni-card>
		<view class="bt btPadding"></view>

	</view>
</template>

<script>
	import visitorList from '@/components/visitorList.vue'
	import visitorAccount from '@/components/visitorAccount.vue'

	export default {
		data() {
			return {
				cssUrl:this.cssUrl,
				depart_id:0,
				visitor_list:false,
				visitor_id:0,
				pageShow:false,
				visitorInfo:{},
				isOpen:false
			}
		},
		components:{
			visitorList,
			visitorAccount
		},
		onShow() {
			this.pageInit()
		},
		methods: {
			closeCollapse() {
				this.isOpen = false
			},
			pageInit() {
				this.$refs.visitors.getVisitors()
			},
			setVisitorListData(e) {
				this.visitor_list = e
				this.pageShow = true
			},
			getVisitorListData(visitor_id){
				this.visitor_id = visitor_id
			},
			get_visitor_info(param) {
				this.visitorInfo = false

				var obj = new Object()
				obj.depart_id = param.depart_id
				obj.visitor_id = param.visitor_id

				this.$http.req('api/user/get_visitor_info', obj, 'POST').then(data=>{
					if(data == 1) return
					this.visitorInfo = data
					this.isOpen = true
					// if((this.visitorInfo.single_items && this.visitorInfo.single_items.length > 0) || (this.visitorInfo.treatment_package && Object.keys(this.visitorInfo.treatment_package).length > 0)) {
					// 	this.$emit('hasrecord', 1)
					// }else{
					// 	this.$emit('hasrecord', 0)
					// }

				});
		}
	}
}
</script>

<style lang="scss" scoped>
.waiting-method-page{
	overflow: hidden;
	.visitor-account{
		margin-top: 28rpx;
	}

	::v-deep {
		.uni-card{
			border-radius: 0;
			padding: 34rpx 42rpx !important;
			margin-bottom: 20rpx !important;
			.uni-collapse-item__title-arrow{
				margin-right: 0;
			}
			.uni-collapse-item{
				background: #F9FAFB;
			}

			&.empty{
				.uni-card__content{
					display: none;
				}
			}
			.uni-collapse-item__title-wrap{
				width: calc(100% - 40rpx);
			}
			.uni-card__content{
				padding: 0 !important;
				background: white;
			}
			.uni-collapse-item__title{
				background: #F9FAFB;
				&.uni-collapse-item-border{
					border: none;
				}
			}
			.uni-collapse-item__title-img{
				width: 32rpx;
				height: 32rpx;
				margin-right: 12rpx;
			}
			.uni-collapse-item__title-box{
				padding: 0;
				background: #F9FAFB;
				height: 39rpx;
				line-height: 39rpx;
				color: #333333;
				font-size: 28rpx;
				letter-spacing: 2rpx;
				font-weight: 600;
			}
			@supports (-webkit-touch-callout: none) {
				.uni-collapse-item__title-box{
					font-weight: 500;
				}
			}
			.uni-card__header{
				border: none;
				padding: 0;
				.uni-card__header-extra .uni-card__header-extra-text{
					font-size: 24rpx;
					font-weight: normal;
					line-height: normal;
					letter-spacing: 0.14rpx;
					color: #949699;
				}

				.uni-card__header-content .uni-card__header-content-title{
					font-weight: 600;
					line-height: 42rpx;
					font-size: 32rpx;
					color: #333333;
					&:before{
						content: '';
						display: inline-block;
						width: 8rpx;
						height: 34rpx;
						z-index: 0;
						border-radius: 10rpx;
						background: #58CA7F;
						position: relative;
						top: 5rpx;
						margin-right: 12rpx;
					}
				}
			}
		}
	}
	.h-name{
		padding: 36rpx 24rpx;
		box-sizing: border-box;
		width: 100%;
		height: 116rpx;
		margin-bottom: 20rpx;
		background: white;
		display: flex;
		align-items: center;
		font-size: 32rpx;
		color: #000000;
	}
	.title-wrap{
		width: 100%;
		height: 100rpx;
	}
	.submit{
		position: fixed;
		width: 100%;
		top: 82.41%;
		.submitbtn{
			width: 666rpx;
			margin: 0 auto;
		}
		.tip{
			text-align: center;
			font-size: 28rpx;
			color: #B3B4BC;
			margin-top: 33rpx;
		}
	}
}
</style>
