From 308b9d0617c303509ac9b000ee872b8bdfbf9086 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 8 Dec 2023 14:24:53 +0700 Subject: [PATCH] check in check out --- src/components/AscGISMap.vue | 9 +++++++++ src/views/MapView.vue | 21 ++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/components/AscGISMap.vue b/src/components/AscGISMap.vue index a9678d3..72192fc 100644 --- a/src/components/AscGISMap.vue +++ b/src/components/AscGISMap.vue @@ -4,6 +4,13 @@ import { loadModules } from 'esri-loader' import axios from 'axios' import type { LocationObject } from '@/interface/index/Main' +const emit = defineEmits(['update:location']) + +function updateLocation(latitude: any, longitude: any, namePOI: string) { + // ส่ง event ไปยัง parent component เพื่ออัพเดทค่า props + emit('update:location', latitude, longitude, namePOI) +} + const currentPosition = ref() const poiPlaceName = ref('') @@ -103,6 +110,8 @@ async function initializeMap() { poiPlaceName.value = response.data.address ? response.data.address.PlaceName : 'ไม่พบข้อมูล' + + updateLocation(latitude, longitude, poiPlaceName.value) }) .catch((error) => { console.error('Error fetching points of interest:', error) diff --git a/src/views/MapView.vue b/src/views/MapView.vue index 09cc1e1..dcddc72 100644 --- a/src/views/MapView.vue +++ b/src/views/MapView.vue @@ -18,7 +18,14 @@ import MapCheck from '@/components/AscGISMap.vue' import { useCounterMixin } from '@/stores/mixin' const mixin = useCounterMixin() -const { date2Thai, showLoader, hideLoader, messageError, dialogRemove } = mixin +const { + date2Thai, + showLoader, + hideLoader, + messageError, + dialogRemove, + success, +} = mixin const router = useRouter() const $q = useQuasar() @@ -130,9 +137,9 @@ const checkInId = ref('') //Id ลงเวลา check-in ล่าส * @param location พิกัดละติจูด พิกัดลองติจูด * @param namePOI ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ */ -async function updateLocation(location: any, namePOI: string) { - formLocation.lat = location.lat - formLocation.lng = location.lng +async function updateLocation(latitude: any, longitude: any, namePOI: string) { + formLocation.lat = latitude + formLocation.lng = longitude formLocation.POI = namePOI } @@ -236,6 +243,7 @@ function validateForm() { const timeChickin = ref() /** function ยืนยันการลงเวลาเข้า - ออก*/ async function confirm() { + showLoader() const isLocation = workplace.value === 'in-place' //*true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง const formdata = new FormData() formdata.append('lat', formLocation.lat.toString()) @@ -267,6 +275,9 @@ async function confirm() { console.log(err) messageError($q, err) }) + .finally(() => { + hideLoader() + }) } async function onClickConfirm() { @@ -656,4 +667,4 @@ onMounted(async () => { width: 100%; height: 100%; } - \ No newline at end of file +