<template>
	<a-card title="职位要求" :headStyle="{ 'background-color': '#f0f0f0' }">
		<a-form :model="createForm" layout="vertical">
			<a-row :gutter="20">
				
				<a-col span="24">
					<a-flex justify="flex-end">
						<a-space>
							<a-button type="primary" @click="sumbitForm" size="large">暂存</a-button>
						</a-space>
					</a-flex>
				</a-col>
			</a-row>
		</a-form>
	</a-card>
	
</template>

<script setup lang="ts">
	import { ref, onMounted, computed, watch, defineEmits, defineProps } from 'vue';
	import { GetDictTree, PostCompanyJobAdd, alreadyValue } from '@/apis/models';
	import { warnToast, successToast } from '@/utils/toastHelper';
	import { intersectionAlike } from '@/utils/dataHelper';
		import { dataForm, otherDataForm, reset } from '@/components/company/invite/position/demand/data.ts';
	import { useCommon } from '@/hooks/useCommon';
	let { store, dayjs, richOption, ExclamationCircleOutlined, Modal } = useCommon();
	const dayjsRef = ref(dayjs);
	const emit = defineEmits();
	const props = defineProps(['job_detail']);
	let createForm = ref<CompanyInviteDemandType.InviteDemandFormType>(dataForm)
	let addOtherForm = ref<CompanyInviteDemandType.OtherFormType>(otherDataForm)
	const job_id = ref<object>(null);
	let licenseOption = ref<Object[]>([])


	watch(() => [props.job_detail], async (newVal : string[], oldVal) => {
		
		if (newVal[0]) {
			job_id.value = newVal[0].id;
			createForm.value = intersectionAlike(createForm.value, newVal[0]);
			addOtherForm.value = {
				company_jiguan_cascader: [newVal[0].household_province, newVal[0].household_city],
				company_suozaidi_cascader: addToLocationArray(newVal[0])
			}
			sessionStorage.setItem("second", JSON.stringify(createForm.value))
			sessionStorage.setItem("secondOther", JSON.stringify(addOtherForm.value))
			
			addOtherForm.value = sessionStorage.getItem('secondOther') ? JSON.parse(sessionStorage.getItem('secondOther')) : addOtherForm.value
			createForm.value = sessionStorage.getItem('second') ? JSON.parse(sessionStorage.getItem('second')) : createForm.value
		}
	}, { immediate: true })

	

	onMounted(async () => {

	})

	

	const sumbitForm = () => {
		console.log(createForm.value)
		sessionStorage.setItem("second", JSON.stringify(createForm.value))
		sessionStorage.setItem("secondOther", JSON.stringify(addOtherForm.value))
	}

	const resetForm = () => {
		createForm.value = reset().dataForm as CompanyInviteDemandType.InviteDemandFormType;
		addOtherForm.value = reset().otherDataForm as CompanyInviteDemandType.OtherFormType;
	}
</script>

<style>
</style>