<template>
|
<div class="app-container">
|
<div class="search_form">
|
<div>
|
<span class="search_title">姓名:</span>
|
<el-input
|
v-model="searchForm.staffName"
|
style="width: 240px"
|
placeholder="请输入姓名搜索"
|
@change="handleQuery"
|
clearable
|
:prefix-icon="Search"
|
/>
|
<span style="margin-left: 10px;" class="search_title">合同开始日期:</span>
|
<el-date-picker
|
v-model="searchForm.entryDateStart"
|
type="date"
|
placeholder="请选择合同开始日期"
|
size="default"
|
@change="(date) => handleDateChange(date,1)"
|
/>
|
<span style="margin-left: 10px;" class="search_title">合同结束日期:</span>
|
<el-date-picker
|
v-model="searchForm.entryDateEnd"
|
type="date"
|
placeholder="请选择合同结束日期"
|
size="default"
|
@change="(date) => handleDateChange(date,2)"
|
/>
|
<el-button type="primary" @click="handleQuery" style="margin-left: 10px"
|
>搜索</el-button
|
>
|
</div>
|
<div>
|
<el-button type="primary" @click="openForm('add')">新增入职</el-button>
|
<el-button @click="handleOut">导出</el-button>
|
<el-button type="danger" plain @click="handleDelete">删除</el-button>
|
</div>
|
</div>
|
<div class="table_list">
|
<PIMTable
|
rowKey="id"
|
:column="tableColumn"
|
:tableData="tableData"
|
:page="page"
|
:isSelection="true"
|
@selection-change="handleSelectionChange"
|
:tableLoading="tableLoading"
|
@pagination="pagination"
|
:total="page.total"
|
></PIMTable>
|
</div>
|
<form-dia ref="formDia" @close="handleQuery"></form-dia>
|
</div>
|
</template>
|
|
<script setup>
|
import { Search } from "@element-plus/icons-vue";
|
import {onMounted, ref} from "vue";
|
import FormDia from "@/views/personnelManagement/onboarding/components/formDia.vue";
|
import {staffJoinDel, staffJoinListPage} from "@/api/personnelManagement/onboarding.js";
|
import {ElMessageBox} from "element-plus";
|
import dayjs from "dayjs";
|
|
const data = reactive({
|
searchForm: {
|
staffName: "",
|
},
|
});
|
const { searchForm } = toRefs(data);
|
const tableColumn = ref([
|
{
|
label: "状态",
|
prop: "staffState",
|
dataType: "tag",
|
formatData: (params) => {
|
if (params == 0) {
|
return "离职";
|
} else if (params == 1) {
|
return "入职";
|
} else {
|
return null;
|
}
|
},
|
formatType: (params) => {
|
if (params == 0) {
|
return "danger";
|
} else if (params == 1) {
|
return "primary";
|
} else {
|
return null;
|
}
|
},
|
},
|
{
|
label: "员工编号",
|
prop: "staffNo",
|
},
|
{
|
label: "姓名",
|
prop: "staffName",
|
},
|
{
|
label: "性别",
|
prop: "sex",
|
},
|
{
|
label: "籍贯",
|
prop: "nativePlace",
|
},
|
{
|
label: "岗位",
|
prop: "postJob",
|
},
|
{
|
label: "家庭住址",
|
prop: "adress",
|
width:200
|
},
|
{
|
label: "第一学历",
|
prop: "firstStudy",
|
},
|
{
|
label: "专业",
|
prop: "profession",
|
width:100
|
},
|
{
|
label: "身份证号",
|
prop: "identityCard",
|
width:200
|
},
|
{
|
label: "年龄",
|
prop: "age",
|
},
|
{
|
label: "联系电话",
|
prop: "phone",
|
width:150
|
},
|
{
|
label: "紧急联系人",
|
prop: "emergencyContact",
|
width: 120
|
},
|
{
|
label: "联系电话",
|
prop: "emergencyContactPhone",
|
width:150
|
},
|
{
|
label: "试用期(月)",
|
prop: "probationPeriod",
|
width: 120,
|
},
|
// {
|
// label: "转正日期",
|
// prop: "probationEndDate",
|
// width: 120,
|
// formatData: (row) => {
|
// // 修改为使用合同开始日期计算转正日期
|
// if (row.contractStartTime && row.probationPeriod) {
|
// // 计算转正日期(合同开始日期加上试用期月数)
|
// return dayjs(row.contractStartTime).add(row.probationPeriod, 'month').format('YYYY-MM-DD');
|
// }
|
// return '';
|
// },
|
// formatType: (row) => {
|
// // 修改为使用合同开始日期检查是否临近转正(7天内)
|
// if (row.contractStartTime && row.probationPeriod) {
|
// const probationEndDate = dayjs(row.contractStartTime).add(row.probationPeriod, 'month');
|
// const daysUntilProbationEnd = probationEndDate.diff(dayjs(), 'day');
|
|
// if (daysUntilProbationEnd >= 0 && daysUntilProbationEnd <= 7) {
|
// return 'warning'; // 使用警告样式标记临近转正的员工
|
// }
|
// }
|
// return '';
|
// }
|
// },
|
{
|
label: "合同年限(年)",
|
prop: "contractTerm",
|
width: 120,
|
},
|
{
|
label: "合同开始日期",
|
prop: "contractStartTime",
|
width: 120
|
},
|
{
|
label: "合同结束日期",
|
prop: "contractEndTime",
|
width: 120
|
},
|
{
|
dataType: "action",
|
label: "操作",
|
align: "center",
|
fixed: 'right',
|
operation: [
|
{
|
name: "编辑",
|
type: "text",
|
clickFun: (row) => {
|
openForm("edit", row);
|
},
|
},
|
],
|
},
|
]);
|
const tableData = ref([]);
|
const selectedRows = ref([]);
|
const tableLoading = ref(false);
|
const page = reactive({
|
current: 1,
|
size: 100,
|
total: 0,
|
});
|
const formDia = ref()
|
const { proxy } = getCurrentInstance()
|
|
const handleDateChange = (value,type) => {
|
searchForm.value.entryDateEnd = null
|
searchForm.value.entryDateStart = null
|
if(type === 1){
|
if (value) {
|
searchForm.value.entryDateStart = dayjs(value).format("YYYY-MM-DD");
|
}
|
}else{
|
if (value) {
|
searchForm.value.entryDateEnd = dayjs(value).format("YYYY-MM-DD");
|
}
|
}
|
getList();
|
};
|
// 查询列表
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
page.current = 1;
|
getList();
|
};
|
const pagination = (obj) => {
|
page.current = obj.page;
|
page.size = obj.limit;
|
getList();
|
};
|
const getList = () => {
|
tableLoading.value = true;
|
staffJoinListPage({...page, ...searchForm.value, staffState: 1}).then(res => {
|
tableLoading.value = false;
|
tableData.value = res.data.records
|
page.total = res.data.total;
|
|
// 检查是否有临近转正的员工并提醒
|
checkProbationEnding(tableData.value);
|
}).catch(err => {
|
tableLoading.value = false;
|
})
|
};
|
// 检查临近转正的员工并提醒
|
const checkProbationEnding = (data) => {
|
const probationEndingSoon = [];
|
|
data.forEach(item => {
|
// 修改为使用合同开始日期检查
|
if (item.contractStartTime && item.probationPeriod) {
|
const probationEndDate = dayjs(item.contractStartTime).add(item.probationPeriod, 'month');
|
const daysUntilProbationEnd = probationEndDate.diff(dayjs(), 'day');
|
|
if (daysUntilProbationEnd >= 0 && daysUntilProbationEnd <= 7) {
|
probationEndingSoon.push({
|
staffName: item.staffName,
|
probationEndDate: probationEndDate.format('YYYY-MM-DD'),
|
daysLeft: daysUntilProbationEnd
|
});
|
}
|
}
|
});
|
|
if (probationEndingSoon.length > 0) {
|
let message = '以下员工将在7天内转正:\n';
|
probationEndingSoon.forEach(item => {
|
message += `${item.staffName}(${item.probationEndDate},还有${item.daysLeft}天)\n`;
|
});
|
|
// 显示提醒消息
|
proxy.$modal.msgInfo(message);
|
}
|
};
|
// 表格选择数据
|
const handleSelectionChange = (selection) => {
|
selectedRows.value = selection;
|
};
|
|
// 打开弹框
|
const openForm = (type, row) => {
|
nextTick(() => {
|
formDia.value?.openDialog(type, row)
|
})
|
};
|
|
// 删除
|
const handleDelete = () => {
|
let ids = [];
|
if (selectedRows.value.length > 0) {
|
ids = selectedRows.value.map((item) => item.id);
|
} else {
|
proxy.$modal.msgWarning("请选择数据");
|
return;
|
}
|
ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "导出", {
|
confirmButtonText: "确认",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
staffJoinDel(ids).then((res) => {
|
proxy.$modal.msgSuccess("删除成功");
|
getList();
|
});
|
})
|
.catch(() => {
|
proxy.$modal.msg("已取消");
|
});
|
};
|
// 导出
|
const handleOut = () => {
|
ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
|
confirmButtonText: "确认",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
proxy.download("/staff/staffJoinLeaveRecord/export", {staffState: 1}, "人员入职.xlsx");
|
})
|
.catch(() => {
|
proxy.$modal.msg("已取消");
|
});
|
};
|
onMounted(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped></style>
|