<!--
@ 作者: 袁纪菲
@ 时间: 2024-4-28
@ 备注: 职称信息
-->
<script lang="ts" setup>
import { zhichengxinxi } from "@/api/hr/people/type";
import {
	getJobtitleCont,
	editJobtitleContState,
} from "@/api/hr/people/index";

/**
 * 引入页面
 */
import EditJobtitle from "@/views/hr/archives/basicinformation/jobtitleedit.vue";
import AddJobtitle from "@/views/hr/archives/basicinformation/jobtitleadd.vue";

const props = defineProps({
	tabsid: {
		type: String,
		default: "1",
	},
	usercont: {
		type: Object,
		default() {
			return {};
		},
	},
});
const totalVal = ref(0)
const addzcxxBoxPage = ref(false); 
const editzcxxBoxPage = ref(false); 
const tableLoading = ref(false);
const zcxxList = ref<any[]>([]);
const zcxxInfo = ref<zhichengxinxi>();
const getzcxxList = () => {
	tableLoading.value = true;
	getJobtitleCont({ id: props.usercont.keystr })
		.then((data) => {
			zcxxList.value = data.data.list;
			totalVal.value = data.data.total
		})
		.finally(() => {
			tableLoading.value = false;
		});
}
/**
 * 监听数据
 */
watch(
	() => props.tabsid,
	() => {
		if (props.tabsid == "14") {
			getzcxxList();
		}
	}
);
/**
 * 添加数据
 */
const addzcxxBox = (key: string) => {
	addzcxxBoxPage.value = true;
}
/**
 * 编辑职称信息
 */
const editzcxxBox = (cont: zhichengxinxi) => {
	zcxxInfo.value = cont;
	editzcxxBoxPage.value = true;
}
/**
 * 删除职称信息
 */
const delzcxxBox = (cont: zhichengxinxi) => {
	ElMessageBox.confirm("确认删除<" + cont.id + ">此数据项?", "警告", {
		confirmButtonText: "确定",
		cancelButtonText: "取消",
		type: "warning",
	}).then(() => {
		editJobtitleContState({ id: toString(), state: 3, isdel: 1 }).then(
      () => {
        ElMessage.success("删除成功");
		getzcxxList();
		});
	});
}
</script>
<template>
    <AddJobtitle
	v-model:addisshow="addzcxxBoxPage" 
	:keyval="props.usercont.keystr"
	@restdata="getzcxxList" />
	<EditJobtitle
	v-model:editisshow="editzcxxBoxPage" 
	:keyval="props.usercont.keystr"
	:datacont="zcxxInfo" 
	@restdata="getzcxxList" 
    />
	<el-table 
	v-loading="tableLoading" 
	highlight-current-row 
	:data="zcxxList" border
	:header-cell-style="{ background: '#F5F7FA' }">
		<el-table-column label="职称级别" prop="types" align="center"/>
		<el-table-column label="职称系列" prop="series" align="center"/>
		<el-table-column label="职称专业" prop="speciality" align="center" />
		<el-table-column label="资格证书编号" prop="number" align="center" />
		<el-table-column label="生效时间" prop="timeDataStr" align="center" />
		<el-table-column fixed="right" align="right" >
			<template #header>
				<el-button type="primary" link size="small" @click.stop="addzcxxBox(props.usercont.keystr)">
					<i-ep-plus /> 新增
				</el-button>
			</template>
			<template #default="scope">
				<el-button type="primary" link size="small" @click.stop="editzcxxBox(scope.row)">
					<i-ep-edit />编辑
				</el-button>
				<el-button type="primary" link size="small" @click.stop="delzcxxBox(scope.row)">
					<i-ep-delete />删除
				</el-button>
			</template>
		</el-table-column>
	</el-table>
	<div class="pageCalss">
		<el-pagination background layout="prev, pager, next" :total="totalVal" />
	</div>
</template>
<style lang="scss" scoped>
.pageCalss{
	margin-top:15px;
	text-align: center;
	width:100%;
}
</style>
