zouyu
6 天以前 32f10392ab00b07e85c0b4229037c30af7c3f28e
src/views/personnelManagement/onboarding/index.vue
@@ -4,12 +4,12 @@
      <div>
        <span class="search_title">姓名:</span>
        <el-input
          v-model="searchForm.staffName"
          style="width: 240px"
          placeholder="请输入姓名搜索"
          @change="handleQuery"
          clearable
          :prefix-icon="Search"
            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
@@ -28,7 +28,7 @@
            @change="(date) => handleDateChange(date,2)"
        />
        <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
          >搜索</el-button
        >搜索</el-button
        >
      </div>
      <div>
@@ -39,15 +39,15 @@
    </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"
          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>
@@ -151,8 +151,39 @@
    width:150
  },
  {
    label: "合同年限",
    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: "合同开始日期",
@@ -222,10 +253,43 @@
    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;