
<template>
	<div  style="width: 100%;">
			<a-form :model="createForm" layout="vertical"  class="resume-form">
				<a-row :gutter="20">
					<a-col span="8">
						<a-form-item label="固话" name="landline">
							<a-input v-model:value="createForm.landline" placeholder="请输入固话"   />
						</a-form-item>
					</a-col>
					<a-col span="8">
						<a-form-item required label="移动电话" name="mobile">
							<a-input v-model:value="createForm.mobile" placeholder="请输入移动电话"   />
						</a-form-item>
					</a-col>
					<a-col span="8">
						<a-form-item label="QQ" name="qq">
							<a-input v-model:value="createForm.qq" placeholder="请输入QQ"   />
						</a-form-item>
					</a-col>
					<a-col span="8">
						<a-form-item label="个人网站" name="personal_website">
							<a-input v-model:value="createForm.personal_website" placeholder="请输入个人网站"   />
						</a-form-item>
					</a-col>
					<a-col span="8">
						<a-form-item label="通信地址" name="mailing_address">
							<a-input v-model:value="createForm.mailing_address" placeholder="请输入通信地址"   />
						</a-form-item>
					</a-col>
					<a-col span="8">
						<a-form-item label="邮编" name="postal_code">
							<a-input v-model:value="createForm.postal_code" placeholder="请输入邮编" />
						</a-form-item>
					</a-col>
					<a-col span="24">
						<a-flex justify="flex-end">
							<a-space>
								<a-button @click="resetForm"   >取消</a-button>
								<a-button type="primary" @click="sumbitForm"   >保存</a-button>
							</a-space>
						</a-flex>
					</a-col>
				</a-row>
			</a-form>
		
	</div>
</template>

<script setup lang="ts">
	import { ref, onMounted, computed, defineProps, watch, defineEmits, createVNode } from 'vue';
	import { PostJobapplicantAddcontact, PostJobapplicantDelcontact, PostJobapplicantUpdatecontact, GetJobapplicantContactdetail } from '@/apis/models';
	import { intersectionAlike } from '@/utils/dataHelper';
	import { warnToast, successToast } from '@/utils/toastHelper';
	import { dataForm, otherDataForm, reset } from '@/views/jobSeeker/resume/add/contact/data.ts';
	import { useCommon } from '@/hooks/useCommon';
	let { store, dayjs, richOption, ExclamationCircleOutlined, Modal } = useCommon();
	const dayjsRef = ref(dayjs);
	let props = defineProps(['customer_record']);
	const emit = defineEmits();
	let createForm = ref<JobseekerContactType.JobseekerContactFormType>(dataForm)

	onMounted(() => {
		getBasic()
	})

	const getBasic = () => {
		GetJobapplicantContactdetail({customer_id: props.customer_record.customer_id}).then(res => {
			createForm.value = intersectionAlike(createForm.value, res.data)
			createForm.value.id = res.data.id;
			createForm.value.customer_id = res.data.customer_id;
		})
	}


	const sumbitForm = () => {
		if(createForm.value.id) {
			PostJobapplicantUpdatecontact(createForm.value).then(res => {
				successToast('保存成功');
				getBasic();
				// resetForm()
			}).catch(err => {
			})
		} else {
			PostJobapplicantAddcontact(createForm.value).then(res => {
				successToast('保存成功');
				getBasic();
				// resetForm()
			}).catch(err => {
			})
		}
	}

	const resetForm = () => {
		createForm.value = reset().dataForm as JobseekerContactType.JobseekerContactFormType;
	}

	// watch(() => [props.form_state], (newVal) => {
	// 	state.value = newVal[0];
	// 	getBasic();
	// })
</script>

<style>
</style>
