<template>
	<a-form  :model="createForm" :label-col="{span: 4}" labelAlign="left">
		<a-row gutter="20">
			<a-col span="8">
				<a-form-item label="意向地区">
					<a-c-cascader :dict="2009" @saveCascader="areaSave"></a-c-cascader>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="意向职位一">
					<a-c-cascader :dict="2004" @saveCascader="positionSave"></a-c-cascader>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="意向职位二">
					<a-c-cascader :dict="2004" @saveCascader="positionSave"></a-c-cascader>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="意向职位三">
					<a-c-cascader :dict="2004" @saveCascader="positionSave"></a-c-cascader>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="求职类型">
					<a-c-select :dict="2019" placeholder="请选择求职类型" @saveSelect="saveJobType"></a-c-select>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="人才类型">
					<a-c-select :dict="2020" placeholder="请选择求职类型" @saveSelect="saveTalentType"></a-c-select>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item required label="工作经验" name="work_experience">
					<a-input v-model:value="createForm.base.work_experience" placeholder="请输入工作经验" />
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item required label="其他职位" name="other_positions">
					<a-input v-model:value="createForm.base.other_positions" placeholder="请输入其他职位" />
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="月薪要求范围">
					<a-c-select :dict="2005" placeholder="请选择月薪要求范围" @saveSelect="saveSalaryRange"></a-c-select>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="可到职日期">
					<a-c-select :dict="2013" placeholder="请选择可到职日期" @saveSelect="saveAvailableDate"></a-c-select>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="职称要求">
					<a-c-select :dict="2014" placeholder="请选择职称要求" @saveSelect="saveTitleRequirement"></a-c-select>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="技能认证">
					<a-c-select :dict="2015" placeholder="请选择技能认证" @saveSelect="saveSkillCertification"></a-c-select>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="食宿要求">
					<a-c-select :dict="2016" placeholder="请选择食宿要求" @saveSelect="saveAccommodationRequirement"></a-c-select>
				</a-form-item>
			</a-col>
			<a-col span="8">
				<a-form-item label="节假日休息情况"  :label-col="{span: 6}">
					<a-c-select :dict="2017" placeholder="请选择节假日休息情况" @saveSelect="saveHolidayRest"></a-c-select>
				</a-form-item>
			</a-col>
		</a-row>
		<a-row gutter="20">
			<a-col>
				<a-button type="primary" @click="onSubmit">保存</a-button>
			</a-col>
			<a-col>
				<a-button style="margin-left: 10px">重置</a-button>
			</a-col>
		</a-row>
	</a-form>
	
</template>

<script lang="ts" setup>
	import { ref, onMounted, computed, defineProps, watch, defineEmits } from 'vue';
	import { message } from 'ant-design-vue';
	import { PostJobapplicantAdd, PostJobapplicantUpdate } from '@/apis/models';
	const emit = defineEmits();
	const onSubmit = () => {
		// PostJobapplicantAdd(createForm.value).then(res => {
		// 	message.success('基本资料保存成功')
		// 	emit('toNext', {activeKey: "2"})
		// })
		emit('toNext', { activeKey: "7" })
	}
	let createForm = ref({
		area: {
			level1: 0,
			level2: 0,
			level3: 0,
			level4: 0,
		},
		position: {
			industry: 0,
		},
		base: {
			job_type: 0,
			talent_type: 0,
			work_experience: 0,
			other_positions: '',
			salary_range: 0,
			available_date: 0,
			title_requirement: 0,
			skill_certification: 0,
			accommodation_requirement: 0,
			holiday_rest: 0,
		}
	})

	const resetForm = () => {
		createForm.value = {
			area: {
				level1: 0,
				level2: 0,
				level3: 0,
				level4: 0,
			},
			position: {
				industry: 0,
			},
			base: {
				job_type: 0,
				talent_type: 0,
				work_experience: 0,
				other_positions: '',
				salary_range: 0,
				available_date: 0,
				title_requirement: 0,
				skill_certification: 0,
				accommodation_requirement: 0,
				holiday_rest: 0,
			}
		}
	}
	// 意向地区
	const areaSave = (data) => {
		for (let i = 0; i < 4; i++) {
			createForm.value[`now_level${i + 1}`] = data.arr1[i] || 0;
		}
	}
	// 意向求职
	const positionSave = (data) => {
		for (let i = 0; i < 4; i++) {
			createForm.value[`now_level${i + 1}`] = data.arr1[i] || 0;
		}
	}
	// 求职类型
	const saveJobType = (data) => {
		createForm.value.job_type = data.val;
	}
	// 人才类型
	const saveTalentType = (data) => {
		createForm.value.base.talent_type = data.val;
	}

	// 月薪要求范围
	const saveSalaryRange = (data) => {
		createForm.value.base.salary_range = data.val;
	}
	// 可到职日期
	const saveAvailableDate = (data) => {
		createForm.value.base.available_date = data.val;
	}
	// 职称要求
	const saveTitleRequirement = (data) => {
		createForm.value.base.title_requirement = data.val;
	}

	// 技能认证
	const saveSkillCertification = (data) => {
		createForm.value.base.skill_certification = data.val;
	}

	// 食宿要求
	const saveAccommodationRequirement = (data) => {
		createForm.value.base.accommodation_requirement = data.val;
	}

	// 节假日休息情况
	const saveHolidayRest = (data) => {
		createForm.value.base.holiday_rest = data.val;
	}
</script>

<style>
</style>