| | |
| | | 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"; |
| | |
| | | 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(() => { |
| | |
| | | if (form.value.sysDeptId === 0) { |
| | | form.value.sysDeptId = undefined; |
| | | } |
| | | form.value.age = calcAge(form.value.birthDate); |
| | | }); |
| | | } |
| | | }; |