<!--
@ 作者: 秦东
@ 时间: 2023-06-16 15:26:19
@ 备注: 集团内部工作经历
-->
<script lang='ts' setup>
import { innerWorkCont } from '@/api/hr/people/type'
import { getInnerWork,editGroupInnerWorkState } from '@/api/hr/people/index'
import { dutiesCont } from '@/api/hr/duties/type'
import { getDuitesList } from '@/api/hr/duties/index'
/**
 * 引入页面
 */
 import AddInnerWork from '@/views/hr/archives/basicinformation/innerworkadd.vue'
 import EditInnerWork from '@/views/hr/archives/basicinformation/innerworkedit.vue'
const props = defineProps({
	tabsid:{
		type:String,
		default:"1"
	},
	usercont:{
		type:Object,
		default(){
			return {}
		}
	}
});
const addJtnbgzBoxPage = ref(false)			//新增集团外部工作经历
const editJtnbgzBoxPage = ref(false)			//编辑集团外部工作经历
const tableLoading = ref(false)
const jtnbgzjlList = ref<innerWorkCont[]>([])
const jtnbgzjlCont = ref<innerWorkCont>({id:""})
	const dutiesInfo = ref<dutiesCont[]>([])	//职务列表
function getjtnbgzjlList(){
	tableLoading.value = true;
	getInnerWork({id:props.usercont.keystr})
		.then(( data )=>{
			jtnbgzjlList.value = data.data
			
		})
		.finally(()=>{tableLoading.value = false;})
}
/**
 * 获取职务列表
 */
 function getDutiesList(){
	getDuitesList({page:1,pagesize:100000})
		.then(( {data} )=>{
			dutiesInfo.value = data.list;
		})
}
/**
 * 监听数据
 */
 watch(() => props.tabsid,() => {
	if(props.tabsid == "8"){
		getjtnbgzjlList()
		getDutiesList()
	}
 })
 /**
  * 添加数据
  */
function addXueLiBox(){
	addJtnbgzBoxPage.value = true
}
/**
 * 编辑集团内部工作经历
 */
function editXueLiBox(cont:innerWorkCont){
	jtnbgzjlCont.value = cont
	editJtnbgzBoxPage.value = true
}
/**
 * 删除集团内部工作经历
 */
 function delXueLiBox(cont:innerWorkCont){
	ElMessageBox.confirm("确认删除<"+cont.allorgname+">此数据项?", "警告", {
		confirmButtonText: "确定",
		cancelButtonText: "取消",
		type: "warning",
	}).then(() => {
		editGroupInnerWorkState({id:cont.id.toString(),state:3,isdel:1}).then(() => {
			ElMessage.success("删除成功");
			getjtnbgzjlList()
		});
	});
}
</script>
<template>
	<AddInnerWork v-model:addisshow="addJtnbgzBoxPage" :dutieslist="dutiesInfo" :keyval="props.usercont.keystr" @restdata="getjtnbgzjlList" />
	<EditInnerWork v-model:editisshow="editJtnbgzBoxPage" :dutieslist="dutiesInfo" :keyval="props.usercont.keystr" :datacont="jtnbgzjlCont" @restdata="getjtnbgzjlList" />
	<el-row>
		<el-col v-for="(item, index) in jtnbgzjlList" :key="index" :span="24" class="colBox">
			<el-descriptions
				class="margin-top"
				:column="3"
				border
			>
				<template #extra>
					<el-button
						type="primary"
						link
						size="small"
						@click.stop="editXueLiBox(item)"
					>
						<i-ep-edit />编辑
					</el-button>
					<el-button
						type="primary"
						link
						size="small"
						@click.stop="delXueLiBox(item)"
					>
						<i-ep-delete />删除
					</el-button>
				</template>

				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="yunxing" class="svg_box"></svg-icon> 开始日期</el-text>
                        </template>
                        {{ item.starttimg }}
                </el-descriptions-item>
				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="stop" class="svg_box"></svg-icon> 结束日期</el-text>
                        </template>
                        {{ item.endtimg }}
                </el-descriptions-item>
				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="sj" class="svg_box"></svg-icon> 调动类型</el-text>
                        </template>
                        {{ item.bdlx }}
                </el-descriptions-item>
				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="dutiescont" class="svg_box"></svg-icon> 变动原因</el-text>
                        </template>
                        {{ item.changeReason }}
                </el-descriptions-item>
				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="peoples" class="svg_box"></svg-icon> 班组</el-text>
                        </template>
						{{ item.teamname }}
                </el-descriptions-item>
				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="jianzhi" class="svg_box"></svg-icon> 职位</el-text>
                        </template>
                        {{ item.zhiwei }}
                </el-descriptions-item>
				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="jianzhi" class="svg_box"></svg-icon> 职等</el-text>
                        </template>
                        {{ item.dengji }}
                </el-descriptions-item>
				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="jianzhi" class="svg_box"></svg-icon> 上级职位</el-text>
                        </template>
                        {{ item.superiorpostname }}
                </el-descriptions-item>
				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="jianzhi" class="svg_box"></svg-icon> 上级姓名</el-text>
                        </template>
                        {{ item.superiormanname }}
                </el-descriptions-item>
				<el-descriptions-item>
						<template #label>
                            <el-text><svg-icon icon-class="jianzhi" class="svg_box"></svg-icon> 下属人数</el-text>
                        </template>
						<el-text v-if="item.subordinatescount!=0">{{item.subordinatescount}}</el-text>
                </el-descriptions-item>
				<el-descriptions-item :span="2">
						<template #label>
                            <el-text><svg-icon icon-class="iconfont-jixieqimo" class="svg_box"></svg-icon> 职务性质</el-text>
                        </template>
						<el-text v-if="item.assigntype == 1">主职</el-text>
                        <el-text v-if="item.assigntype != 1">兼职</el-text>
                </el-descriptions-item>
				<el-descriptions-item :span="3">
						<template #label>
                            <el-text><svg-icon icon-class="tree" class="svg_box"></svg-icon> 行政组织</el-text>
                        </template>
						<el-text v-if="item.gsmc">{{item.gsmc}}</el-text><el-text v-if="item.yjbm">/{{item.yjbm}}</el-text><el-text v-if="item.ejbm">/{{item.ejbm}}</el-text><el-text v-if="item.gongduan">/{{item.gongduan}}</el-text>
						
                </el-descriptions-item>
			</el-descriptions>
		</el-col>
		<el-col :span="24" class="colBut">
			<el-button type="primary" @click="addXueLiBox"><i-ep-plus />新增工作经历</el-button>
		</el-col>
	</el-row>
</template>
<style  lang='scss' scoped>
.colBox{
	margin-top:25px;
}
.colBut{
	margin-top:25px;
	text-align:right
}
</style>

