zhang_nuo
8 天以前 d420578cb8bc076be2f0c7dd5a4dbfca335d7cdb
src/views/personnelManagement/employeeRecord/components/NewOrEditFormDia.vue
@@ -40,7 +40,9 @@
  onMounted,
  getCurrentInstance,
  nextTick,
  computed,
} from "vue";
import dayjs from "dayjs";
import FormDialog from "@/components/Dialog/FormDialog.vue";
import { findPostOptions } from "@/api/system/post.js";
import { deptTreeSelect, getUser } from "@/api/system/user.js";
@@ -160,6 +162,17 @@
const { form, rules, postOptions, deptOptions } = toRefs(state);
const roleOptions = ref([]);
const calcAge = (birth) => {
  if (!birth) return undefined;
  const birthDay = dayjs(birth);
  const now = dayjs();
  let age = now.year() - birthDay.year();
  if (now.month() < birthDay.month() || (now.month() === birthDay.month() && now.date() < birthDay.date())) {
    age--;
  }
  return age;
};
const resetForm = () => {
  Object.assign(form.value, createDefaultForm());
  nextTick(() => {
@@ -238,6 +251,7 @@
      if (form.value.sysDeptId === 0) {
        form.value.sysDeptId = undefined;
      }
      form.value.age = calcAge(form.value.birthDate);
    });
  }
};