<!--
@ 作者: 袁纪菲
@ 时间: 2024-4-22
@ 备注: 用工关系
-->
<script lang="ts" setup>
import { yonggongguanxi } from "@/api/hr/people/type";
import {
	getEmploymentrelationsCont,
	editEmploymentrelationsContState,
} from "@/api/hr/people/index";

/**
 * 引入页面
 */
import EditEmploymentrelations from "@/views/hr/archives/basicinformation/employmentrelationsedit.vue";
import AddEmploymentrelations from "@/views/hr/archives/basicinformation/employmentrelationsadd.vue";

const props = defineProps({
	tabsid: {
		type: String,
		default: "1",
	},
	usercont: {
		type: Object,
		default() {
			return {};
		},
	},
});
const addyggxBoxPage = ref(false); 
const edityggxBoxPage = ref(false); 
const tableLoading = ref(false);
const yggxList = ref([]);
const yggxInfo = ref<yonggongguanxi>();
const getyggxList = () => {
	tableLoading.value = true;
	getEmploymentrelationsCont({ id: props.usercont.keystr })
		.then((data) => {
			yggxList.value = data.data;
		})
		.finally(() => {
			tableLoading.value = false;
		});
}
/**
 * 监听数据
 */
watch(
	() => props.tabsid,
	() => {
		if (props.tabsid == "13") {
			getyggxList();
		}
	}
);
/**
@ 作者: 秦东
@ 时间: 2024-08-31 16:14:47
@ 功能: 首页页面渲染加载
*/
onMounted(()=>{
	getyggxList();
})
/**
 * 添加数据
 */
const addyggxBox = (key: string) => {
	addyggxBoxPage.value = true;
}
/**
 * 编辑用工关系
 */
const edityggxBox = (cont: yonggongguanxi) => {
	yggxInfo.value = cont;
	edityggxBoxPage.value = true;
}
/**
 * 删除用工关系
 */
const delyggxBox = (cont: yonggongguanxi) => {
	ElMessageBox.confirm("确认删除<" + cont.id + ">此数据项?", "警告", {
		confirmButtonText: "确定",
		cancelButtonText: "取消",
		type: "warning",
	}).then(() => {
		editEmploymentrelationsContState({ id: toString(), state: 3, isdel: 1 }).then(
      () => {
        ElMessage.success("删除成功");
		getyggxList();
		});
	});
}
</script>
<template>
    <AddEmploymentrelations 
	v-model:addisshow="addyggxBoxPage" 
	:keyval="props.usercont.keystr"
	@restdata="getyggxList" />
	<EditEmploymentrelations
	v-model:editisshow="edityggxBoxPage" 
	:keyval="props.usercont.keystr"
	:datacont="yggxInfo" 
	@restdata="getyggxList" 
    />
	<el-descriptions
		class="margin-top"
		:column="3"
		:size="size"
		border
	>
		<template #extra>
			<el-button type="primary">编辑</el-button>
		</template>
		<el-descriptions-item>
			<template #label>
				<div class="cell-item">入职渠道</div>
			</template>
			{{yggxList.channel}}
		</el-descriptions-item>
		<el-descriptions-item>
			<template #label>
				<div class="cell-item">参加工作日期</div>
			</template>
			{{yggxList.jobstartdate}}
		</el-descriptions-item>
		<el-descriptions-item>
			<template #label>
				<div class="cell-item">社会工龄（年）</div>
			</template>
			{{yggxList.shehuiGongli}}
		</el-descriptions-item>
		<el-descriptions-item>
			<template #label>
				<div class="cell-item">加入集团日期</div>
			</template>
			{{yggxList.entrydate}}
		</el-descriptions-item>
		<el-descriptions-item>
			<template #label>
				<div class="cell-item">集团工龄（年）</div>
			</template>
			{{yggxList.jiTuanGongli}}
		</el-descriptions-item>
	</el-descriptions>
	
	
</template>
<style  scoped>
.el-descriptions {
  margin-top: 20px;
}
.cell-item {
  display: flex;
  align-items: center;
}
.margin-top {
  margin-top: 20px;
}
</style>
