<!--
@ 作者: 袁纪菲
@ 时间: 2024-4-22
@ 备注: 编辑职称信息
-->
<script lang='ts' setup>
import { JobtitleCont } from '@/api/hr/people/type'
import { editJobtitleCont } from '@/api/hr/people/index'
import { jobtitlelevel } from '@/api/hr/people/datacont'
const props = defineProps({
	editisshow:{
		type:Boolean,
		default:false
	},
	keyval:{
		type:String,
		default:""
	},
	datacont:{
		type:Object,
		default(){
			return {}
		}
	}
});
const editLoading = ref(false)
const emits = defineEmits(["update:editisshow","restdata"]);
const editzcxxFormRef = ref(ElForm);
const zcxxFormData = reactive<JobtitleCont>({});
/**
 * 弹窗显示控制
 */
const editshow = computed({
	get: () => props.editisshow,
	set: (val) => {
		emits("update:editisshow", val);
	},
});
/**
 * 表单验证规则
 */
 const addzcxxRules = reactive({
	
});
/**
 * 关闭弹窗
 */
const clostEditBoxzcxx = () =>{
	emits("update:editisshow", false);
	initzcxxData()
}
/**
 * 初始化数据
 */
const initzcxxData = () =>{
	editzcxxFormRef.value.resetFields();
	editLoading.value = false;
}
 /**
 * 提交数据
 */
const submitEditzcxx = () =>{
	editzcxxFormRef.value.validate((isValid: boolean) => {
		if (isValid) {
			editJobtitleCont(zcxxFormData)
				.then(() =>{
					ElMessage.success("编辑成功");
					clostEditBoxzcxx();
					emits('restdata');
				})
				.finally(() =>{editLoading.value = false;})
		}
	});
}
/**
 * 监听数据
 */
 watch(() => props.editisshow,() => {
	if(props.editisshow){
		zcxxFormData.id= props.datacont.id.toString();
	}
	
 })
</script>
<template>
	<el-dialog v-model="editshow" width="500" title="添加职称信息" append-to-body :before-close="clostEditBoxzcxx">
		<el-form ref="editzcxxFormRef" :model="zcxxFormData" :rules="addzcxxRules" label-width="140px">
			<el-form-item label="职称级别" prop="level">
				<el-select v-model="zcxxFormData.level" placeholder="请选择职称级别">
					<el-option 
					v-for="item in jobtitlelevel" 
					:key="item.id" 
					:label="item.name"
					:value="item.id" />
				</el-select>
			</el-form-item>
			<el-form-item  label="职称系列" prop="series">
				<el-input v-model="zcxxFormData.series" placeholder="请输入职称系列" />
			</el-form-item>
			<el-form-item label="职称专业" prop="profession">
				<el-input v-model="zcxxFormData.profession" placeholder="请输入职称专业" />
			</el-form-item>
			<el-form-item label="资格证书编号" prop="serialnumber">
				<el-input v-model="zcxxFormData.serialnumber" placeholder="请输入资格证书编号" />
			</el-form-item>
            <el-form-item  label="生效时间" prop="effectivetime">
				<el-date-picker
					v-model="zcxxFormData.effectivetime"
					type="date"
					placeholder="请选择生效时间"
					format="YYYY-MM-DD"
					value-format="YYYY-MM-DD"
					style="width: 100%;"
					size="default"
				/>
			</el-form-item>
		</el-form>
		<template #footer>
			<div class="dialog-footer">
				<el-button type="primary" :loading="editLoading" @click="submitEditzcxx">确 定</el-button>
				<el-button @click="clostEditBoxzcxx">取 消</el-button>
			</div>
		</template>
	</el-dialog>
</template>
<style  lang='scss' scoped>

</style>
