<template>
	<view class="doctor">
		<view class="doctor_title">{{ isDoctor ? '筛选已绑定志愿者' : '筛选所属医生' }}</view>
		<view class="doctor_list">
			<view class="doctor_list_item" v-for="(item,index) in selectPersonList" :key="item[isDoctor ? 'volunteerUserId' : 'doctorUserId']"
				@click="onSelect(item)">
				<image mode="heightFix" v-if="item.url" :src="item.url"></image>
				<view class="doctor_list_item_avatar" v-else>
					{{item[isDoctor ? 'volunteerUserName' : 'doctorUserName'].substring(0,1)}}</view>
				<view class="doctor_list_item_name">{{item[isDoctor ? 'volunteerUserName' : 'doctorUserName']}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			person: {
				type: Array,
				default: []
			},
			isDoctor: {
				type: Boolean,
				default: true
			}
		},
		name: "addCase",
		data() {
			return {
				selectPersonList: [], // 人员列表
			}
		},
		methods: {
			// 选择的志愿者、医生
			onSelect(item) {
				this.$emit('selectPerson', item)
			}
		},
		watch: {
			person: {
				handler(newVal, oldVal) {
					this.selectPersonList = this.person
				},
				immediate: true,
				deep: true,
			},
		},
	}
</script>

<style lang="scss" scoped>
	.doctor {
		padding: 108rpx 32rpx 0;
		height: 300px;
		overflow: hidden;

		&_title {
			color: #86909C;
			font-size: 26rpx;
			font-weight: 400;
			line-height: 44rpx;
			/* 157.143% */
		}

		&_list {
			height: calc(100% - 44rpx);
			overflow: auto;
			width: 100%;

			&_item {
				cursor: pointer;
				margin: 16rpx 0;
				display: flex;
				align-items: center;
				width: 100%;

				uni-image {
					width: 64rpx;
					height: 64rpx;
					border-radius: 50%;
					overflow: hidden;
				}

				&_avatar {
					width: 64rpx;
					height: 64rpx;
					line-height: 64rpx;
					border-radius: 50%;
					overflow: hidden;
					background-color: #c9cdd4;
					color: #fff;

					text-align: center;
					font-size: 28rpx;
					font-weight: 700;
				}

				&_name {
					color: #000;
					font-size: 28rpx;
					font-weight: 400;
					line-height: 28rpx;
					/* 100% */
					margin-left: 16rpx;
				}
			}
		}
	}
</style>