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