fix:function_calculateAge

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-01-21 16:16:00 +07:00
parent 8867829211
commit 6f40ee330c
10 changed files with 41 additions and 152 deletions

View file

@ -8,13 +8,13 @@ import config from "@/app.config";
import type { DataOption } from "@/modules/08_registryEmployee/interface/index/Main";
import type { FormDataEmployee } from "@/modules/08_registryEmployee/interface/request/Employee";
import type { ResOptionPerson } from "@/modules/08_registryEmployee/interface/response/Employee";
import { calculateAge } from "@/utils/function";
/** importComponents*/
import DialogHeader from "@/components/DialogHeader.vue";
/** importStore*/
import { useCounterMixin } from "@/stores/mixin";
import { useRegistryEmp } from "@/modules/08_registryEmployee/stores/registry-employee";
/** use*/
const $q = useQuasar();
@ -27,7 +27,6 @@ const {
dialogMessageNotify,
date2Thai,
} = useCounterMixin();
const { calculateAge } = useRegistryEmp();
/** props*/
const modal = defineModel<boolean>("modal", { required: true });

View file

@ -1,32 +1,6 @@
import { defineStore } from "pinia";
export const useRegistryEmp = defineStore("registryEmployeeTemp", () => {
/**
* function
* @param birthDate
* @returns
*/
function calculateAge(birthDate: Date | null) {
if (!birthDate) return null;
const birthDateTimeStamp = new Date(birthDate).getTime();
const now = new Date();
const diff = now.getTime() - birthDateTimeStamp;
const ageDate = new Date(diff);
const years = ageDate.getUTCFullYear() - 1970;
const months = ageDate.getUTCMonth();
const days = ageDate.getUTCDate() - 1;
const retire = new Date(birthDate);
retire.setFullYear(retire.getFullYear() + 60);
// retireDate.value = retire;
if (years > 60) {
return "อายุเกิน 60 ปี";
}
return `${years} ปี ${months} เดือน ${days} วัน`;
}
/**
* function convertstatus
* @param val
@ -53,7 +27,6 @@ export const useRegistryEmp = defineStore("registryEmployeeTemp", () => {
}
};
return {
calculateAge,
statusText,
};
});