<template>
	<div>
		<div class="head">
			<el-row>
				<el-form-item >
					<el-select filterable clearable v-model="searchInfo.checkType" placeholder="登记类型">
						<el-option  label="健康证" value="1" />
						<el-option  label="老年人" value="2" />
					</el-select>
				</el-form-item>
				<el-form-item style="margin-left: 8px;" v-if="org_list.length>0">
					<el-select filterable clearable v-model="searchInfo.sn" placeholder="请选择体检机构">
						<el-option v-for="(item, index) in org_list" :key="index" :label="item.org_name" :value="item.sn" />
					</el-select>
				</el-form-item>
				<el-form-item style="margin-left: 8px;">
					 
						<el-date-picker v-model="searchInfo.dateRange" value-format="YYYY-MM-DD" type="daterange"
							range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" />
					 
				</el-form-item>
			  
				<el-form-item> 
					<el-button type="primary" style="margin-left: 20px;" @click="GetInfo">搜索</el-button>
				</el-form-item>
		
			</el-row>
			 
		</div>
		<el-table  :data="tableData" style="width: 100%;" row-key="id" show-summary v-loading="loading">
			<el-table-column prop="org_name" label="体检机构"   />
			<el-table-column prop="org_code" label="Code" />
			<el-table-column prop="count" label="数量" />
		</el-table>
		 
	</div>
</template>

<script setup>
	import {
		ref,
		onMounted
	} from 'vue'
	import {
		ElMessage
	} from 'element-plus'
	import {
		AppointmentCount,GetHealthOrganizationEnableList
	} from '@/api/api.js'
	let loading = ref(false)
	let searchInfo = ref({
		checkType:"2",
		dateRange: [],
		sn: '',
	})
	let tableData = ref([])
	const GetInfo=()=>{
		loading.value=true
		AppointmentCount({searchInfo:searchInfo.value}).then(res => {
			loading.value=false
			if (res.status) {
				  tableData.value = res.data.list
				  searchInfo.value.dateRange=res.data.dateRange
			} else {
				ElMessage.error(res.msg)
			}
			
		})
	}
	let org_list = ref('') //机构列表
	const getHealthOrganizationEnableList = () => {
		GetHealthOrganizationEnableList().then(res => {
			if (res.status) {
				org_list.value = res.data
				if (res.data.length == 1) {
					searchInfo.value.sn = res.data[0].sn
				}
			} else {
				ElMessage.error(res.msg)
			}
	
		})
	}
	onMounted(() => {
		getHealthOrganizationEnableList()
		 GetInfo()
	})
</script>

<style>
</style>