<template>
	<a-card title="简历搜索" :headStyle="{ 'background-color': '#f0f0f0' }">
		<a-form :model="commomParams.search" layout="vertical">
			<a-row :gutter="20">
				<a-col span="12">
					<a-form-item label="关键字" name="keyword">
						<a-input v-model:value="commomParams.search.keyword" placeholder="请输入关键字" size="large" />
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="性别" name="sex">
						<a-radio-group v-model:value="commomParams.search.gender" button-style="solid"
							style="width: 100%;" size="large">
							<a-radio-button value="男" style="width: calc(100% / 3);">男</a-radio-button>
							<a-radio-button value="女" style="width: calc(100% / 3);">女</a-radio-button>
							<a-radio-button value="不限" style="width: calc(100% / 3);">不限</a-radio-button>
						</a-radio-group>
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="职称">
						<a-xuanze :dict="2014" placeholder="请选择职称" @saveSelect="saveTitle"
							:select_content="commomParams.search.title"></a-xuanze>
					</a-form-item>
				</a-col>

				<a-col span="12">
					<a-form-item label="学历">
						<a-xuanze :dict="2006" placeholder="请选择学历" @saveSelect="saveEducation"
							:select_content="commomParams.search.education"></a-xuanze>
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="婚姻状况">
						<a-xuanze :dict="2011" placeholder="请选择婚姻状况" @saveSelect="saveMaritalStatus"
							:select_content="commomParams.search.marital_status"></a-xuanze>
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="政治面貌">
						<a-xuanze :dict="2010" placeholder="请选择政治面貌" @saveSelect="savePoliticalStatus"
							:select_content="commomParams.search.political_status"></a-xuanze>
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="可到职日期">
						<a-xuanze :dict="2013" placeholder="请选择可到职日期" @saveSelect="saveAvailableDateDesire"
							:select_content="commomParams.search.available_date_desire"></a-xuanze>
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="英语">
						<a-xuanze :dict="2008" placeholder="请选择掌握程度" @saveSelect="saveEnglish"
							:select_content="commomParams.search.english"></a-xuanze>
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="国语">
						<a-xuanze :dict="2008" placeholder="请选择掌握程度" @saveSelect="saveMandarin"
							:select_content="commomParams.search.mandarin"></a-xuanze>
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="粤语">
						<a-xuanze :dict="2008" placeholder="请选择掌握程度" @saveSelect="saveCantonese"
							:select_content="commomParams.search.cantonese"></a-xuanze>
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="第二外语">
						<a-xuanze :dict="2007" placeholder="请选择第二外语" @saveSelect="saveOtherLanguage"
							:select_content="commomParams.search.other_language"></a-xuanze>
					</a-form-item>
				</a-col>
				<a-col span="12">
					<a-form-item label="计算机能力">
						<a-input v-model:value="value" placeholder="请输入计算机能力" size="large" />
					</a-form-item>
				</a-col>
				<!-- 
				<a-col span="12">
					<a-form-item label="工作经验">
						<a-xuanze :dict="2021" placeholder="请选择工作经验" @saveSelect="saveEthnicity"
							:select_content="commomParams.search.ethnicity"></a-xuanze>
					</a-form-item>
				</a-col> -->
			<!-- 	<a-col span="6">
					<a-form-item label="最大年龄">
						<a-input-number :min="0" v-model:value="commomParams.search.keyword" placeholder="请输入最小年龄"
							size="large" style="width: 100%;"/>
					</a-form-item>
				</a-col>
				<a-col span="6">
					<a-form-item label="最大年龄">
						<a-input-number :max="99" v-model:value="commomParams.search.keyword" placeholder="请输入最大年龄"
							size="large"  style="width: 100%;"/>
					</a-form-item>
				</a-col> -->
				<a-col span="6">
					<a-form-item label="最小工作经验(年)">
						<a-input-number :min="0" v-model:value="commomParams.search.min_work_experience" placeholder="请输入最小工作经验"
							size="large"  style="width: 100%;"/>
					</a-form-item>
				</a-col>

				<a-col span="6">
					<a-form-item label="最大工作经验(年)">
						<a-input-number :max="99" v-model:value="commomParams.search.max_work_experience" placeholder="请输入最大工作经验"
							size="large"  style="width: 100%;"/>
					</a-form-item>
				</a-col>
				<a-col span="24">
					<a-flex justify="flex-end">
						<a-space>
							<a-button type="primary" @click="getData" size="large">开始搜索</a-button>
						</a-space>
					</a-flex>
				</a-col>
			</a-row>
		</a-form>
	</a-card>
</template>

<script setup lang="ts">
	import { ref, onMounted, watch, computed } from 'vue';
	import { PostJobseekerList } from '@/apis/models';
	import { useCommon } from '@/hooks/useCommon';
	let { store, commomParams, dayjs, richOption, ExclamationCircleOutlined, Modal } = useCommon();
	let props = defineProps(['search_params']);
	const emit = defineEmits();


	interface listType {
		title ?: Number,
		education ?: Number,
		marital_status ?: Number,
		ethnicity ?: Number,
		political_status ?: Number,
		available_date_desire ?: Number,
		english ?: Number,
		mandarin ?: Number,
		cantonese ?: Number,
		other_language ?: Number,
		max_work_experience ?: Number,
		min_work_experience ?: Number,
		gender ?: String,
		maxheight ?: Number,
		minheight ?: Number,
		maxweight ?: Number,
		minweight ?: Number,
	}

	commomParams.value.search = commomParams.value.search as listType;
	commomParams.value.search.title = 0;
	commomParams.value.search.education = 0;
	commomParams.value.search.marital_status = 0;
	commomParams.value.search.ethnicity = 0;
	commomParams.value.search.political_status = 0;
	commomParams.value.search.available_date_desire = 0;
	commomParams.value.search.english = 0;
	commomParams.value.search.mandarin = 0;
	commomParams.value.search.cantonese = 0;
	commomParams.value.search.other_language = 0;
	commomParams.value.search.max_work_experience = 0;
	commomParams.value.search.min_work_experience = 0;
	commomParams.value.search.gender = '';
	commomParams.value.search.maxheight = 0;
	commomParams.value.search.minheight = 0;
	commomParams.value.search.maxweight = 0;
	commomParams.value.search.minweight = 0;

	// watch(() => props.search_params, (newVal) => {
	// 	emit('searchData', commomParams.value.search)
	// }, {
	// 	immediate: true
	// })

	const getData = () => {
		emit('searchData', commomParams.value.search)
	}

	// 清空搜索
	const clearSearch = () => {
		commomParams.value.search = {
			page: 1,
			pagesize: 12,
			sort: 'id',
			sortby: 'asc',
			keyword: ''
		}

		emit('clearData', commomParams.value.search)
	}
	
	

	const saveTitle = (data) => {
		commomParams.value.search.title = data.val ? data.val : 0;
	}

	const saveEducation = (data) => {
		commomParams.value.search.education = data.val ? data.val : 0;
	}

	const saveMaritalStatus = (data) => {
		commomParams.value.search.marital_status = data.val ? data.val : 0;
	}

	const savePoliticalStatus = (data) => {
		commomParams.value.search.title = data.val ? data.val : 0;
	}

	const saveAvailableDateDesire = (data) => {
		commomParams.value.search.available_date_desire = data.val ? data.val : 0;
	}

	const saveEnglish = (data) => {
		commomParams.value.search.english = data.val ? data.val : 0;
	}

	const saveMandarin = (data) => {
		commomParams.value.search.mandarin = data.val ? data.val : 0;
	}

	const saveCantonese = (data) => {
		commomParams.value.search.cantonese = data.val ? data.val : 0;
	}

	const saveOtherLanguage = (data) => {
		commomParams.value.search.other_language = data.val ? data.val : 0;
	}
</script>

<style>
</style>

<style>
</style>