5 天以前 77fdbcc67ba81d2394b02ab4247eb741d220fbcc
feat(dimission): 离职表单增加日期限制功能

- 添加离职日期禁用未来日期的功能
- 实现获取当前日期的工具函数
- 设置默认离职日期为当天日期
- 防止用户选择未来的离职日期
已修改1个文件
17 ■■■■■ 文件已修改
src/views/personnelManagement/dimission/components/formDia.vue 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/personnelManagement/dimission/components/formDia.vue
@@ -102,6 +102,7 @@
                    v-model="form.leaveDate"
                    type="date"
                    :disabled="operationType === 'edit'"
                    :disabled-date="disabledFutureDate"
                    placeholder="请选择离职日期"
                    value-format="YYYY-MM-DD"
                    format="YYYY-MM-DD"
@@ -180,6 +181,19 @@
const dialogFormVisible = ref(false);
const operationType = ref('')
const getTodayDate = () => {
  const now = new Date();
  const year = now.getFullYear();
  const month = `${now.getMonth() + 1}`.padStart(2, '0');
  const day = `${now.getDate()}`.padStart(2, '0');
  return `${year}-${month}-${day}`;
};
const disabledFutureDate = (time) => {
  const todayEnd = new Date();
  todayEnd.setHours(23, 59, 59, 999);
  return time.getTime() > todayEnd.getTime();
};
const data = reactive({
  form: {
    staffOnJobId: undefined,
@@ -220,6 +234,7 @@
      }
    ]
  } else {
    form.value.leaveDate = getTodayDate()
    getList()
  }
}
@@ -329,4 +344,4 @@
  color: #303133;
  font-size: 14px;
}
</style>
</style>