แก้การกรอกวันที่ในทะเบียนประวัติ

This commit is contained in:
Warunee Tamkoo 2024-02-09 15:35:21 +07:00
parent 5a27893af8
commit 59e91afd84
3 changed files with 80 additions and 14 deletions

View file

@ -123,7 +123,39 @@
</div>
<div class="col-12 q-py-md"><q-separator /></div>
<div class="col-xs-6 col-sm-3 col-md-3">
<!-- เปลยนเปนเลอกปฏ -->
<q-input
v-if="edit"
v-model="govermentData.containDate"
:rules="[
(val) =>
!!val ||
`${
profileType == 'officer'
? 'กรุณาเลือกวันที่บรรจุ'
: 'กรุณาเลือกวันที่แต่งตั้ง'
}`,
]"
:label="`${
profileType == 'officer' ? 'วันที่บรรจุ' : 'วันที่แต่งตั้ง'
}`"
type="date"
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
dense
lazy-rules
stack-label
:readonly="!edit"
:borderless="!edit"
@update:model-value="
(val:any) => {
handleDate(new Date(val));
}
"
/>
<datepicker
v-else
v-model="govermentData.containDate"
:locale="'th'"
autoApply
@ -150,7 +182,7 @@
:borderless="!edit"
:model-value="
govermentData.containDate !== null
? date2Thai(govermentData.containDate)
? date2Thai(new Date(govermentData.containDate))
: null
"
:rules="[
@ -181,7 +213,37 @@
</datepicker>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<!-- เปลยนเปนเลอกปฏ -->
<q-input
v-if="edit"
v-model="govermentData.workDate"
:rules="[
(val) =>
!!val ||
`${
profileType == 'officer'
? 'กรุณาเลือกเริ่มปฎิบัติราชการ'
: 'กรุณาเลือกวันที่จ้างและแต่งตั้งมีผล'
}`,
]"
:label="`${
profileType == 'officer'
? 'เริ่มปฎิบัติราชการ'
: 'วันที่จ้างและแต่งตั้งมีผล'
}`"
type="date"
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
dense
lazy-rules
stack-label
:readonly="!edit"
:borderless="!edit"
/>
<datepicker
v-else
v-model="govermentData.workDate"
:locale="'th'"
autoApply
@ -207,7 +269,7 @@
:borderless="!edit"
:model-value="
govermentData.workDate !== null
? date2Thai(govermentData.workDate)
? date2Thai(new Date(govermentData.workDate))
: null
"
:rules="[
@ -633,8 +695,8 @@ const fetchData = async () => {
govermentData.value.numberId = data.posNo;
govermentData.value.positionExecutive = data.positionExecutive;
govermentData.value.positionExecutiveSide = data.positionExecutiveSide;
govermentData.value.containDate = data.dateAppoint;
govermentData.value.workDate = data.dateStart;
govermentData.value.containDate = dateToISO(new Date(data.dateAppoint));
govermentData.value.workDate = dateToISO(new Date(data.dateStart));
govermentData.value.retireDate = data.retireDate;
govermentData.value.absent = data.govAgeAbsent;
govermentData.value.age = data.govAgePlus;
@ -659,8 +721,8 @@ const editData = async () => {
showLoader();
await http
.put(config.API.profileGovId(route.params.id.toString()), {
dateAppoint: dateToISO(govermentData.value.containDate),
dateStart: dateToISO(govermentData.value.workDate),
dateAppoint: dateToISO(new Date(govermentData.value.containDate)),
dateStart: dateToISO(new Date(govermentData.value.workDate)),
reasonSameDate: govermentData.value.reasonSameDate,
})
.then((res) => {
@ -686,7 +748,7 @@ const saveData = async () => {
};
const handleDate = async (modelData: Date) => {
govermentData.value.containDate = modelData;
// govermentData.value.containDate = dateToISO(modelData);
await fetchCalAgeGov(modelData);
};

View file

@ -1135,7 +1135,11 @@ const editData = async () => {
edit.value = false;
emit("update:statusEdit", false);
await fetchData();
await changeBirth(new Date(informaData.value.birthDate) ?? new Date());
await changeBirth(
informaData.value.birthDate
? new Date(informaData.value.birthDate)
: new Date()
);
});
};

View file

@ -14,7 +14,7 @@ interface Information {
prefixId: string | null;
firstname: string | null;
lastname: string | null;
birthDate: string;
birthDate: string | null;
genderId: string | null;
bloodId: string | null;
nationality: string | null;
@ -78,8 +78,8 @@ interface Goverment {
numberId: string | null;
positionExecutive: string | null;
positionExecutiveSide: string | null;
containDate: Date;
workDate: Date;
containDate: string;
workDate: string;
retireDate: string | null;
absent: number | null;
age: number | null;
@ -118,8 +118,8 @@ const defaultGoverment: Goverment = {
numberId: null,
positionExecutive: null,
positionExecutiveSide: null,
containDate: new Date(),
workDate: new Date(),
containDate: "",
workDate: "",
retireDate: null,
absent: 0,
age: 0,
@ -217,5 +217,5 @@ export type {
DataOption,
zipCodeOption,
DataOptioninfo,
docList
docList,
};