รายละเอียดการลงเวลา

This commit is contained in:
setthawutttty 2025-06-16 10:45:28 +07:00
parent b47a13be32
commit 7d00ea2fb8
2 changed files with 139 additions and 10 deletions

View file

@ -77,6 +77,7 @@ async function fetchDetailByid(id: string, type: string) {
.get(config.API.recordById(id, type))
.then((res) => {
const data = res.data.result;
stores.getData(data);
formData.checkInDate = data.checkInDate && date2Thai(data.checkInDate);
formData.checkInImg = data.checkInImg;
formData.checkInLat = data.checkInLat ? data.checkInLat : "";
@ -122,9 +123,34 @@ async function fetchDetailByid(id: string, type: string) {
/** Function ปิด popup */
function closePopup() {
clear();
props.close ? props.close() : false;
}
function clear() {
formData.checkInDate = null;
formData.checkInImg = "";
formData.checkInLat = null;
formData.checkInLon = null;
formData.checkInLocation = "";
formData.checkInTime = "";
formData.checkInStatus = "";
formData.checkInDescription = "";
formData.checkOutDate = null;
formData.checkOutImg = "";
formData.checkOutLat = null;
formData.checkOutLon = null;
formData.checkOutLocation = "";
formData.checkOutTime = "";
formData.checkOutStatus = "";
formData.fullName = "";
formData.checkOutDescription = "";
formData.isLocationCheckIn = false;
formData.checkInLocationName = "";
formData.isLocationCheckOut = false;
formData.checkOutLocationName = "";
}
const modalMap = ref<boolean>(false);
const titleMap = ref<string>("");
function onClickMap(title: string) {
@ -133,11 +159,35 @@ function onClickMap(title: string) {
}
watch(
() => props.modal,
() => {
props.modal === true &&
props.detail &&
fetchDetailByid(props.detail.id, props.typeTab as string);
() => [props.modal, props.detail && props.detail.id],
([newModal, newId], [oldModal, oldId]) => {
if (props.modal && props.detail) {
if (newId !== oldId) {
fetchDetailByid(props.detail.id, props.typeTab as string);
} else {
formData.checkInDate = stores.formData.checkInDate;
formData.checkInImg = stores.formData.checkInImg;
formData.checkInLat = stores.formData.checkInLat;
formData.checkInLon = stores.formData.checkInLon;
formData.checkInLocation = stores.formData.checkInLocation;
formData.checkInTime = stores.formData.checkInTime;
formData.checkInStatus = stores.formData.checkInStatus;
formData.checkInDescription = stores.formData.checkInDescription;
formData.checkOutDate = stores.formData.checkOutDate;
formData.checkOutImg = stores.formData.checkOutImg;
formData.checkOutLat = stores.formData.checkOutLat;
formData.checkOutLon = stores.formData.checkOutLon;
formData.checkOutLocation = stores.formData.checkOutLocation;
formData.checkOutTime = stores.formData.checkOutTime;
formData.checkOutStatus = stores.formData.checkOutStatus;
formData.fullName = stores.formData.fullName;
formData.checkOutDescription = stores.formData.checkOutDescription;
formData.isLocationCheckIn = stores.formData.isLocationCheckIn;
formData.checkInLocationName = stores.formData.checkInLocationName;
formData.isLocationCheckOut = stores.formData.isLocationCheckOut;
formData.checkOutLocationName = stores.formData.checkOutLocationName;
}
}
}
);
</script>
@ -224,7 +274,11 @@ watch(
ในสถานท
</div>
<div class="col" v-else>
นอกสถานท ({{ formData.checkInLocationName }})
{{
formData.checkInLocationName
? `นอกสถานที่ (${formData.checkInLocationName})`
: ""
}}
</div>
</div>
<div class="row">
@ -270,7 +324,9 @@ watch(
</div>
<div class="row">
<div class="col text-grey-8">หมายเหต</div>
<div class="col">{{ formData.checkInDescription }}</div>
<div class="col">
{{ formData.checkInDescription }}
</div>
</div>
</div>
</q-card>
@ -288,7 +344,11 @@ watch(
ในสถานท
</div>
<div class="col" v-else>
นอกสถานท ({{ formData.checkOutLocationName }})
{{
formData.checkInLocationName
? `นอกสถานที่ (${formData.checkInLocationName})`
: ""
}}
</div>
</div>
<div class="row">
@ -334,7 +394,9 @@ watch(
</div>
<div class="row">
<div class="col text-grey-8">หมายเหต</div>
<div class="col">{{ formData.checkOutDescription }}</div>
<div class="col">
{{ formData.checkOutDescription }}
</div>
</div>
</div>
</q-card>