no message

This commit is contained in:
Warunee Tamkoo 2024-02-12 10:47:34 +07:00
parent 335d500e11
commit 84d61cbb6d

View file

@ -21,6 +21,8 @@ const {
dateToISO, dateToISO,
dialogConfirm, dialogConfirm,
success, success,
dateToPost,
dateToDisplay,
} = useCounterMixin(); } = useCounterMixin();
const $q = useQuasar(); const $q = useQuasar();
@ -33,13 +35,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: null, nationality: "ไทย",
ethnicity: null, ethnicity: "ไทย",
statusId: null, statusId: null,
religionId: null, religionId: "ceaec498-71b4-4f82-b5a2-7d6ec988b753",
tel: null, tel: null,
employeeType: null, employeeType: null,
employeeClass: null, employeeClass: null,
@ -170,26 +172,26 @@ const calculateMaxDate = () => {
// //
const calRetire = async (birth: Date) => { const calRetire = async (birth: Date) => {
const body = { const body = {
birthDate: dateToISO(birth), birthDate: dateToPost(birth),
}; };
if (dateToISO(dateBefore.value) != dateToISO(birth)) { if (dateToISO(dateBefore.value) > dateToPost(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();
}); });
} }
}; };
@ -242,20 +244,24 @@ const addData = async () => {
if (informaData.value.employeeClass != undefined) if (informaData.value.employeeClass != undefined)
formData.append("employeeClass", informaData.value.employeeClass); formData.append("employeeClass", informaData.value.employeeClass);
showLoader(); console.log("informaData===>", informaData.value);
await http // showLoader();
.post(config.API.createProfileOfficer(), formData) // await http
.then((res) => { // .post(config.API.createProfileOfficer(), formData)
success($q, "บันทึกข้อมูลสำเร็จ"); // .then((res) => {
}) // success($q, "");
.catch((e) => { // })
messageError($q, e); // .catch((e) => {
}) // messageError($q, e);
.finally(async () => { // })
modal.value = false; // .finally(async () => {
await changeBirth(informaData.value.birthDate ?? new Date()); // modal.value = false;
hideLoader(); // await changeBirth(
}); // new Date(dateToPost(new Date(informaData.value.birthDate))) ??
// new Date()
// );
// hideLoader();
// });
}; };
/*** get รายการข้อมูลเกี่ยวกับบุคคล (dropdown list) */ /*** get รายการข้อมูลเกี่ยวกับบุคคล (dropdown list) */
@ -321,6 +327,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,6 +410,22 @@ 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">
<!-- เปลยนเปนเลอกปฏ -->
<!-- <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 <datepicker
v-model="informaData.birthDate" v-model="informaData.birthDate"
:locale="'th'" :locale="'th'"
@ -418,8 +441,8 @@ 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
@ -578,12 +601,6 @@ const fetchPerson = async () => {
:label="`${'เบอร์โทร'}`" :label="`${'เบอร์โทร'}`"
mask="##########" mask="##########"
/> />
<!-- :rules="[
(val: string) => !!val || `${'กรุณากรอก เบอร์โทร'}`,
(val: string) =>
val.length >= 10 ||
`${'กรุณากรอกเบอร์โทรให้ครบ'}`,
]" -->
</div> </div>
</div> </div>
</div> </div>