แก้กรอกวันที่ในทะเบียนประวัติ
This commit is contained in:
parent
4c43a053eb
commit
5a27893af8
3 changed files with 76 additions and 35 deletions
|
|
@ -33,13 +33,13 @@ const informaData = ref<any>({
|
||||||
prefixId: null,
|
prefixId: null,
|
||||||
firstname: null,
|
firstname: null,
|
||||||
lastname: null,
|
lastname: null,
|
||||||
birthDate: null,
|
birthDate: "",
|
||||||
genderId: null,
|
genderId: null,
|
||||||
bloodId: null,
|
bloodId: null,
|
||||||
nationality: "ไทย",
|
nationality: "ไทย",
|
||||||
ethnicity: "ไทย",
|
ethnicity: "ไทย",
|
||||||
statusId: null,
|
statusId: null,
|
||||||
religionId: 'ceaec498-71b4-4f82-b5a2-7d6ec988b753',
|
religionId: "ceaec498-71b4-4f82-b5a2-7d6ec988b753",
|
||||||
tel: null,
|
tel: null,
|
||||||
employeeType: null,
|
employeeType: null,
|
||||||
employeeClass: null,
|
employeeClass: null,
|
||||||
|
|
@ -173,23 +173,23 @@ const calRetire = async (birth: Date) => {
|
||||||
birthDate: dateToISO(birth),
|
birthDate: dateToISO(birth),
|
||||||
};
|
};
|
||||||
if (dateToISO(dateBefore.value) != dateToISO(birth)) {
|
if (dateToISO(dateBefore.value) != dateToISO(birth)) {
|
||||||
showLoader();
|
// showLoader();
|
||||||
await http
|
await http
|
||||||
.post(config.API.profileCalRetire, body)
|
.post(config.API.profileCalRetire, body)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
const data = res.data.result;
|
const data = res.data.result;
|
||||||
informaData.value.age = data.age;
|
informaData.value.age = data.age;
|
||||||
informaData.value.birthDate = birth;
|
// informaData.value.birthDate = birth;
|
||||||
changeRetireText(data.retireDate);
|
changeRetireText(data.retireDate);
|
||||||
dateBefore.value = birth;
|
dateBefore.value = birth;
|
||||||
})
|
})
|
||||||
.catch((e: any) => {
|
// .catch((e: any) => {
|
||||||
messageError($q, e);
|
// messageError($q, e);
|
||||||
informaData.value.birthDate = null;
|
// informaData.value.birthDate = null;
|
||||||
informaData.value.age = "";
|
// informaData.value.age = "";
|
||||||
})
|
// })
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
hideLoader();
|
// hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -321,6 +321,7 @@ const fetchPerson = async () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<q-dialog v-model="modal">
|
<q-dialog v-model="modal">
|
||||||
<q-card style="min-width: 60vw">
|
<q-card style="min-width: 60vw">
|
||||||
|
|
@ -403,7 +404,23 @@ const fetchPerson = async () => {
|
||||||
</div>
|
</div>
|
||||||
<div class="row col-12 q-col-gutter-x-sm q-mb-xs">
|
<div class="row col-12 q-col-gutter-x-sm q-mb-xs">
|
||||||
<div class="col-xs-6 col-sm-2 col-md-2">
|
<div class="col-xs-6 col-sm-2 col-md-2">
|
||||||
<datepicker
|
<!-- เปลี่ยนเป็นเลือกปฏิทิน -->
|
||||||
|
<q-input
|
||||||
|
v-model="informaData.birthDate"
|
||||||
|
:rules="[(val: string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี เกิด'}`]"
|
||||||
|
:label="`${'วัน/เดือน/ปี เกิด'}`"
|
||||||
|
type="date"
|
||||||
|
hide-bottom-space
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
lazy-rules
|
||||||
|
@update:model-value="
|
||||||
|
(val:any) => {
|
||||||
|
calRetire(new Date(val));
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<!-- <datepicker
|
||||||
v-model="informaData.birthDate"
|
v-model="informaData.birthDate"
|
||||||
:locale="'th'"
|
:locale="'th'"
|
||||||
autoApply
|
autoApply
|
||||||
|
|
@ -418,8 +435,7 @@ const fetchPerson = async () => {
|
||||||
<template #year-overlay-value="{ value }">
|
<template #year-overlay-value="{ value }">
|
||||||
{{ parseInt(value + 543) }}
|
{{ parseInt(value + 543) }}
|
||||||
</template>
|
</template>
|
||||||
<template #trigger>
|
<template #trigger><q-input
|
||||||
<q-input
|
|
||||||
for="#birthDate"
|
for="#birthDate"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
outlined
|
outlined
|
||||||
|
|
@ -441,9 +457,9 @@ const fetchPerson = async () => {
|
||||||
>
|
>
|
||||||
</q-icon>
|
</q-icon>
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input> -->
|
||||||
</template>
|
<!-- </template>
|
||||||
</datepicker>
|
</datepicker> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-2 col-md-2">
|
<div class="col-xs-6 col-sm-2 col-md-2">
|
||||||
<q-input
|
<q-input
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,32 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-2 col-md-2">
|
<div class="col-xs-6 col-sm-2 col-md-2">
|
||||||
|
<!-- เปลี่ยนเป็นเลือกปฏิทิน -->
|
||||||
|
<q-input
|
||||||
|
v-if="edit"
|
||||||
|
v-model="informaData.birthDate"
|
||||||
|
:rules="[(val: string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี เกิด'}`]"
|
||||||
|
:label="`${'วัน/เดือน/ปี เกิด'}`"
|
||||||
|
type="date"
|
||||||
|
:class="getClass(edit)"
|
||||||
|
hide-bottom-space
|
||||||
|
:outlined="edit"
|
||||||
|
dense
|
||||||
|
lazy-rules
|
||||||
|
stack-label
|
||||||
|
:readonly="!edit"
|
||||||
|
:borderless="!edit"
|
||||||
|
:disabled="!edit"
|
||||||
|
:max-date="new Date()"
|
||||||
|
@update:model-value="
|
||||||
|
(val:any) => {
|
||||||
|
calRetire(new Date(val));
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
|
||||||
<datepicker
|
<datepicker
|
||||||
|
v-else
|
||||||
v-model="informaData.birthDate"
|
v-model="informaData.birthDate"
|
||||||
:locale="'th'"
|
:locale="'th'"
|
||||||
autoApply
|
autoApply
|
||||||
|
|
@ -118,7 +143,7 @@
|
||||||
:borderless="!edit"
|
:borderless="!edit"
|
||||||
:model-value="
|
:model-value="
|
||||||
informaData.birthDate !== null
|
informaData.birthDate !== null
|
||||||
? date2Thai(informaData.birthDate)
|
? date2Thai(new Date(informaData.birthDate))
|
||||||
: null
|
: null
|
||||||
"
|
"
|
||||||
:rules="[(val: string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี เกิด'}`]"
|
:rules="[(val: string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี เกิด'}`]"
|
||||||
|
|
@ -286,14 +311,14 @@
|
||||||
:borderless="!edit"
|
:borderless="!edit"
|
||||||
v-model="informaData.tel"
|
v-model="informaData.tel"
|
||||||
:label="`${'เบอร์โทร'}`"
|
:label="`${'เบอร์โทร'}`"
|
||||||
:rules="[
|
mask="##########"
|
||||||
|
/>
|
||||||
|
<!-- :rules="[
|
||||||
(val: string) => !!val || `${'กรุณากรอก เบอร์โทร'}`,
|
(val: string) => !!val || `${'กรุณากรอก เบอร์โทร'}`,
|
||||||
(val: string) =>
|
(val: string) =>
|
||||||
val.length >= 10 ||
|
val.length >= 10 ||
|
||||||
`${'กรุณากรอกเบอร์โทรให้ครบ'}`,
|
`${'กรุณากรอกเบอร์โทรให้ครบ'}`,
|
||||||
]"
|
]" -->
|
||||||
mask="##########"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="col-xs-6 col-sm-3 col-md-3"
|
class="col-xs-6 col-sm-3 col-md-3"
|
||||||
|
|
@ -730,7 +755,7 @@ const defaultAdd = () => {
|
||||||
prefixId: null,
|
prefixId: null,
|
||||||
firstname: null,
|
firstname: null,
|
||||||
lastname: null,
|
lastname: null,
|
||||||
birthDate: new Date(),
|
birthDate: "",
|
||||||
genderId: null,
|
genderId: null,
|
||||||
bloodId: null,
|
bloodId: null,
|
||||||
nationality: null,
|
nationality: null,
|
||||||
|
|
@ -977,7 +1002,7 @@ const filterSelector = (val: any, update: Function, refData: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDate = async (modelData: Date) => {
|
const handleDate = async (modelData: Date) => {
|
||||||
informaData.value.birthDate = modelData;
|
informaData.value.birthDate = modelData.toDateString();
|
||||||
await calRetire(modelData);
|
await calRetire(modelData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -991,7 +1016,7 @@ const calRetire = async (birth: Date) => {
|
||||||
birthDate: dateToISO(birth),
|
birthDate: dateToISO(birth),
|
||||||
};
|
};
|
||||||
if (dateToISO(dateBefore.value) != dateToISO(birth)) {
|
if (dateToISO(dateBefore.value) != dateToISO(birth)) {
|
||||||
showLoader();
|
// showLoader();
|
||||||
await http
|
await http
|
||||||
.post(config.API.profileCalRetire, body)
|
.post(config.API.profileCalRetire, body)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
|
|
@ -1000,14 +1025,14 @@ const calRetire = async (birth: Date) => {
|
||||||
changeRetireText(data.retireDate);
|
changeRetireText(data.retireDate);
|
||||||
dateBefore.value = birth;
|
dateBefore.value = birth;
|
||||||
})
|
})
|
||||||
.catch((e: any) => {
|
// .catch((e: any) => {
|
||||||
messageError($q, e);
|
// messageError($q, e);
|
||||||
const retire = new Date(`${birth.getFullYear() + 60}-09-30`);
|
// const retire = new Date(`${birth.getFullYear() + 60}-09-30`);
|
||||||
informaData.value.birthDate = dateBefore.value;
|
// informaData.value.birthDate = dateBefore.value.toDateString();
|
||||||
changeRetireText(date2Thai(retire));
|
// changeRetireText(date2Thai(retire));
|
||||||
})
|
// })
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
hideLoader();
|
// hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1028,7 +1053,7 @@ const fetchData = async () => {
|
||||||
: "";
|
: "";
|
||||||
informaData.value.firstname = data.firstName;
|
informaData.value.firstname = data.firstName;
|
||||||
informaData.value.lastname = data.lastName;
|
informaData.value.lastname = data.lastName;
|
||||||
informaData.value.birthDate = new Date(data.birthDate);
|
informaData.value.birthDate = dateToISO(new Date(data.birthDate));
|
||||||
informaData.value.genderId =
|
informaData.value.genderId =
|
||||||
data.genderId !== "00000000-0000-0000-0000-000000000000"
|
data.genderId !== "00000000-0000-0000-0000-000000000000"
|
||||||
? data.genderId
|
? data.genderId
|
||||||
|
|
@ -1085,7 +1110,7 @@ const editData = async () => {
|
||||||
religionId: informaData.value.religionId,
|
religionId: informaData.value.religionId,
|
||||||
birthDate:
|
birthDate:
|
||||||
informaData.value.birthDate != null
|
informaData.value.birthDate != null
|
||||||
? dateToISO(informaData.value.birthDate)
|
? dateToISO(new Date(informaData.value.birthDate))
|
||||||
: dateToISO(new Date()),
|
: dateToISO(new Date()),
|
||||||
bloodGroupId: informaData.value.bloodId,
|
bloodGroupId: informaData.value.bloodId,
|
||||||
relationshipId: informaData.value.statusId,
|
relationshipId: informaData.value.statusId,
|
||||||
|
|
@ -1110,7 +1135,7 @@ const editData = async () => {
|
||||||
edit.value = false;
|
edit.value = false;
|
||||||
emit("update:statusEdit", false);
|
emit("update:statusEdit", false);
|
||||||
await fetchData();
|
await fetchData();
|
||||||
await changeBirth(informaData.value.birthDate ?? new Date());
|
await changeBirth(new Date(informaData.value.birthDate) ?? new Date());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ interface Information {
|
||||||
prefixId: string | null;
|
prefixId: string | null;
|
||||||
firstname: string | null;
|
firstname: string | null;
|
||||||
lastname: string | null;
|
lastname: string | null;
|
||||||
birthDate: Date | null;
|
birthDate: string;
|
||||||
genderId: string | null;
|
genderId: string | null;
|
||||||
bloodId: string | null;
|
bloodId: string | null;
|
||||||
nationality: string | null;
|
nationality: string | null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue