<template>
	<van-popup
	v-model:show="showBottom"
	round
	position="bottom"
	@close="close"
	:style="{ height: '75%' }"
	>
		
		<view class="box">
			
			<view class="title">
				{{ title || '选择技师' }}
			</view>
			
			<view class="technician-list">
				<van-list
				  v-model:loading="loading"
				  :finished="finished"
				  finished-text=""
				  @load="onLoad"
				>
					<selectTechnicianCompoents :technicianList="technicianList" :select="select"/>
				</van-list>
			</view>
			
		</view>
	
	</van-popup>
</template>

<script>
	import selectTechnicianCompoents from "../selectTechnicianCompoents.vue"
	export default {
		components: {
			selectTechnicianCompoents
		},
		name:"selectTechnicianPopup",
		props : ['show', 'title'],
		data() {
			return {
				showBottom : false,
				i : 0,
				queryParams : {
					pageNo : 1,
					pageSize : 10,
					title : ''
				},
				technicianList : [],
				loading : false,
				finished : false,
			}
		},
		onShow(){
			this.getTechnicianList();
		},
		methods : {
			onLoad(){
				this.queryParams.pageSize += 10
				this.getTechnicianList()
			},
			//获取技师列表
			getTechnicianList(){
				this.$api( "getTechnicianList" , this.queryParams , res => {
					if(res.code == 200){
						this.technicianList = res.result.records
					
						if(this.queryParams.pageSize > res.result.total){
							this.finished = true
						}
					}
					this.loading = false
				})
			},
			select(e){
				this.$emit('select', e)
			},
			close(){
				this.$emit('close')
			}
		},
		watch: {
			show: {
			   handler (newValue, oldValue) {
				   this.showBottom = newValue
			   },
			   immediate: true
			}
		}
	}
</script>

<style lang="scss" scoped>
.box{
	width: 100%;
	height: 100%;
	background: #ecb978;
	box-sizing: border-box;
	padding: 40rpx;
	.title{
		font-size: 32rpx;
		text-align: center;
		color: #fff;
		margin-bottom: 40rpx;
	}
	.technician-list{
		overflow: auto;
		width: 100%;
		height: calc(100% - 45rpx);
	}
}
</style>