fix:function_calculateAge
This commit is contained in:
parent
8867829211
commit
6f40ee330c
10 changed files with 41 additions and 152 deletions
|
|
@ -16,7 +16,6 @@ const mixin = useCounterMixin();
|
|||
const { showLoader, hideLoader } = mixin;
|
||||
|
||||
export const useDataLinkCenter = defineStore("DataLinkCenter", () => {
|
||||
const retireDate = ref<Date>();
|
||||
const optionRelationshipMain = ref<DataOption[]>([]);
|
||||
const optionRelationship = ref<DataOption[]>([]);
|
||||
//รายการตัวเลือก
|
||||
|
|
@ -70,32 +69,6 @@ export const useDataLinkCenter = defineStore("DataLinkCenter", () => {
|
|||
subdistrictCOps: [],
|
||||
});
|
||||
|
||||
/**
|
||||
* ฟังก์ชันคำนวนอายุด้วยวันเดิอนปีเกิด
|
||||
* @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} วัน`;
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันดึงข้อมูลตัวเลือกข้อมูลหลัก
|
||||
*/
|
||||
|
|
@ -351,7 +324,7 @@ export const useDataLinkCenter = defineStore("DataLinkCenter", () => {
|
|||
OpsPerson,
|
||||
OpsAddress,
|
||||
OpsAddressFilter,
|
||||
calculateAge,
|
||||
|
||||
fetchProvince,
|
||||
filterSelector,
|
||||
fetchDistrict,
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ const mixin = useCounterMixin();
|
|||
const { showLoader, hideLoader } = mixin;
|
||||
|
||||
export const useProfileDataStore = defineStore("profile", () => {
|
||||
const retireDate = ref<Date>();
|
||||
|
||||
//ข้อมูลส่วนตัว
|
||||
const defaultProfile: RequestObject = {
|
||||
bloodGroup: null,
|
||||
|
|
@ -69,32 +67,6 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
],
|
||||
});
|
||||
|
||||
/**
|
||||
* ฟังก์ชันคำนวนอายุด้วยวันเดิอนปีเกิด
|
||||
* @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} วัน`;
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันดึงข้อมูลตัวเลือกข้อมูลหลัก
|
||||
*/
|
||||
|
|
@ -247,11 +219,9 @@ export const useProfileDataStore = defineStore("profile", () => {
|
|||
|
||||
return {
|
||||
defaultProfile,
|
||||
retireDate,
|
||||
Ops,
|
||||
OpsFilter,
|
||||
|
||||
calculateAge,
|
||||
fetchPerson,
|
||||
filterSelector,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue