Compare commits
No commits in common. "dev" and "v1.1.20" have entirely different histories.
33 changed files with 616 additions and 2613 deletions
|
|
@ -1,14 +0,0 @@
|
||||||
# HRMS Check-in Expert Memory
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- [No Position Assignment Page](feature_no_position_page.md) - Implementation for users without organization position assignment
|
|
||||||
|
|
||||||
## Project Issues & Fixes
|
|
||||||
|
|
||||||
- [Position Orientation Change Fix](issue_position_orientation_change_fix.md) - Fix for position map not displaying on screen orientation changes
|
|
||||||
- [Active Camera Scope](project_active_camera_scope.md) - Current camera issue work should stay in HomeView.vue, not legacy MapView.vue
|
|
||||||
- [Front Camera Preview Alignment](issue_front_camera_preview_alignment.md) - Keep popup preview orientation aligned with normalized saved photos
|
|
||||||
- [iOS Native Photo Mirroring](issue_ios_native_photo_mirroring.md) - Do not flip iOS native-capture photos during normalization
|
|
||||||
- [iOS Native Camera Popup](issue_ios_native_camera_popup_control.md) - Inline-first on iOS; native activates only after inline fails (prior native-first seed was reverted)
|
|
||||||
- [iOS 16 Inline White Preview](issue_ios16_inline_camera_white_preview.md) - Safari iOS 16 white preview needs single mount plus explicit video readiness
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
---
|
|
||||||
name: No Position Assignment Page
|
|
||||||
description: Feature implementation for users without organization position assignment
|
|
||||||
type: reference
|
|
||||||
---
|
|
||||||
|
|
||||||
## No Position Assignment Page Feature
|
|
||||||
|
|
||||||
When a user doesn't have a position assignment (สังกัด), they are redirected to a dedicated page explaining they are not part of the organization structure.
|
|
||||||
|
|
||||||
### Files Created/Modified
|
|
||||||
|
|
||||||
1. **Created:** `/Users/waruneeta/Desktop/ChamomindWorking/HRMSProject/hrms-checkin/src/views/NoPositionView.vue`
|
|
||||||
- Displays message in Thai: "ไม่พบข้อมูลสังกัด"
|
|
||||||
- Shows icon and explanation text
|
|
||||||
- "ตกลง" (OK) button that shows confirmation dialog
|
|
||||||
- After confirmation, performs logout and clears positionKeycloak store
|
|
||||||
|
|
||||||
2. **Modified:** `/Users/waruneeta/Desktop/ChamomindWorking/HRMSProject/hrms-checkin/src/router/index.ts`
|
|
||||||
- Added new route `/no-position` with `Auth: false`
|
|
||||||
- Enhanced router guard to check for position data
|
|
||||||
- Redirects to `/no-position` if user has no organization assignment
|
|
||||||
|
|
||||||
3. **Modified:** `/Users/waruneeta/Desktop/ChamomindWorking/HRMSProject/hrms-checkin/src/views/MainView.vue`
|
|
||||||
- Updated `fetchKeycloakPosition()` function
|
|
||||||
- Checks if `organization` object exists and has any data
|
|
||||||
- Redirects to `/no-position` if no organization data found
|
|
||||||
|
|
||||||
### Logic Flow
|
|
||||||
|
|
||||||
1. User logs in successfully
|
|
||||||
2. `MainView.vue` calls `fetchKeycloakPosition()` in `onMounted()`
|
|
||||||
3. API returns position data from `/org/profile/keycloak/position`
|
|
||||||
4. System checks if `organization` object has any non-null values (root, child1-4)
|
|
||||||
5. If no organization data exists:
|
|
||||||
- User is redirected to `/no-position`
|
|
||||||
- User sees message explaining they need to contact staff
|
|
||||||
- User clicks "ตกลง" to logout
|
|
||||||
- Staff adds them to organization structure
|
|
||||||
- User can login again
|
|
||||||
|
|
||||||
### Position Data Structure
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface KeycloakPosition {
|
|
||||||
privacyCheckin: boolean
|
|
||||||
avatarName?: string
|
|
||||||
profileId: string
|
|
||||||
organization?: Organization
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Organization {
|
|
||||||
root?: string
|
|
||||||
child1?: string
|
|
||||||
child2?: string
|
|
||||||
child3?: string
|
|
||||||
child4?: string
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
A user is considered to have "no position" when all organization fields (root, child1, child2, child3, child4) are null or undefined.
|
|
||||||
|
|
||||||
### Thai UI Messages
|
|
||||||
|
|
||||||
- Page title: "ไม่พบข้อมูลสังกัด"
|
|
||||||
- Description: "ท่านยังไม่มีสังกัดในโครงสร้างองค์กร กรุณาติดต่อเจ้าหน้าที่เพื่อดำเนินการเพิ่มข้อมูล"
|
|
||||||
- Confirmation dialog: "ยืนยันการออกจากระบบ" - "ท่านจะถูกนำออกจากระบบเพื่อให้เจ้าหน้าที่ดำเนินการเพิ่มข้อมูลสังกัดในโครงสร้างองค์กร"
|
|
||||||
- Button: "ตกลง"
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
---
|
|
||||||
name: front_camera_preview_alignment
|
|
||||||
description: HomeView inline camera flow should show a non-mirrored preview and keep the saved/uploaded image in the same orientation the user saw while shooting
|
|
||||||
type: project
|
|
||||||
---
|
|
||||||
|
|
||||||
When fixing front-camera capture issues in `HomeView.vue`, keep the in-page preview and the final saved/uploaded image in the same non-mirrored orientation.
|
|
||||||
|
|
||||||
**Why:** Users rejected flows where the live in-page preview looked mirrored or differed from the final image. The expected behavior is “what I see while shooting is what gets used.”
|
|
||||||
|
|
||||||
**How to apply:** In the inline `simple-vue-camera` flow, avoid extra front-camera mirroring in either preview styling or snapshot normalization. Treat the in-page preview as the canonical orientation for `img`/`fileImg`.
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
---
|
|
||||||
name: ios16-inline-camera-white-preview
|
|
||||||
description: Safari iOS 16 inline preview can stay white when multiple simple-vue-camera instances mount and playback readiness is assumed too early
|
|
||||||
type: project
|
|
||||||
---
|
|
||||||
|
|
||||||
In `HomeView.vue`, Safari on iOS 16.x can show a white in-page camera preview when more than one `simple-vue-camera` instance is mounted for responsive layouts and the app treats `camera.start()` as sufficient proof that the preview is rendering.
|
|
||||||
|
|
||||||
**Why:** `simple-vue-camera` uses a hard-coded `id="video"` internally and does not explicitly call `video.play()` during `start()`. On mobile/xs, mounting both desktop and mobile camera components at once creates a fragile setup for Safari, where the active preview can remain white even though permission and stream startup succeeded.
|
|
||||||
|
|
||||||
**How to apply:** Keep only the active responsive camera instance mounted in `HomeView.vue`, and after `camera.start()` explicitly prepare/check the underlying video element (`playsinline`, `muted`, `play()`, non-zero dimensions, ready state). If the preview still does not become render-ready, remount once and then fall back to native capture.
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
---
|
|
||||||
name: ios_native_camera_popup_control
|
|
||||||
description: iOS uses inline camera first (same as Android); native fallback triggers only after inline fails. The prior "native-first on iOS" approach was reverted per product requirement.
|
|
||||||
type: project
|
|
||||||
---
|
|
||||||
|
|
||||||
In `HomeView.vue`, the inline camera is **always attempted first** on iOS (and every other platform). The hidden `<input type="file" capture="user">` is only activated by `switchToNativePhotoCapture()` / `enableNativePhotoCaptureFallback()` after inline capture is proven to fail.
|
|
||||||
|
|
||||||
**Why:** The product requirement is "use inline camera whenever the device supports inline capture; use native device capture only when inline is not supported or fails." iOS Safari supports `getUserMedia` since iOS 14.3, so inline-first is viable. A prior session hard-coded `useNativePhotoCapture = computed(() => isIOSDevice || preferNativePhotoCapture.value)`, bypassing inline on iOS entirely — that line was reverted.
|
|
||||||
|
|
||||||
**How to apply:** `preferNativePhotoCapture` must start `false` on all devices. Never seed it with `isIOSDevice`. All failure paths (`openCamera` permission denied, `camera.start()` throw, invalid snapshot blob, invalid image on submit) already call `switchToNativePhotoCapture()` which sets `preferNativePhotoCapture = true` so subsequent taps go directly to native — covering the first-tap fallback automatically.
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
---
|
|
||||||
name: ios_native_photo_mirroring
|
|
||||||
description: Native photo capture on iOS in HomeView should not be horizontally mirrored during normalization
|
|
||||||
type: project
|
|
||||||
---
|
|
||||||
|
|
||||||
For `HomeView.vue`, native photo capture on iOS should not apply horizontal mirroring during image normalization.
|
|
||||||
|
|
||||||
**Why:** The iOS fallback uses the native still-photo picker, and the returned photo can already be in the correct orientation. Applying the same mirror correction used for other front-camera paths flips the image incorrectly on iOS.
|
|
||||||
|
|
||||||
**How to apply:** Keep platform-specific normalization for native capture. Do not assume the iOS file-input photo path behaves the same as `simple-vue-camera` snapshots or Android fallback capture.
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
---
|
|
||||||
name: position_orientation_change_fix
|
|
||||||
description: Fix for position map not displaying on screen orientation changes
|
|
||||||
type: project
|
|
||||||
---
|
|
||||||
|
|
||||||
## Issue: Position/Geolocation Not Displaying on Screen Orientation Changes
|
|
||||||
|
|
||||||
**Problem:**
|
|
||||||
The ArcGIS map component (`AscGISMap.vue`) failed to display or update position when the screen orientation changed between portrait and landscape modes.
|
|
||||||
|
|
||||||
**Root Cause:**
|
|
||||||
1. The component uses `v-if="$q.screen.gt.xs"` for conditional rendering of different layouts
|
|
||||||
2. When orientation changes, the ArcGIS MapView doesn't automatically resize to fit the new container dimensions
|
|
||||||
3. ArcGIS MapView requires manual `resize()` call when its container's size changes
|
|
||||||
|
|
||||||
**Solution Implemented:**
|
|
||||||
Added screen resize handling to `src/components/AscGISMap.vue`:
|
|
||||||
|
|
||||||
1. **Added state tracking:**
|
|
||||||
- `isMapInitialized` ref to track when map is ready
|
|
||||||
- `isInitializing` ref to prevent concurrent initializations
|
|
||||||
|
|
||||||
2. **Added `handleMapResize()` function:**
|
|
||||||
- Checks if mapView exists and isn't destroyed
|
|
||||||
- Uses `nextTick()` to ensure DOM updates complete before resizing
|
|
||||||
- Calls `mapView.value.resize()` to update map dimensions
|
|
||||||
|
|
||||||
3. **Added watcher on `$q.screen.gt.xs`:**
|
|
||||||
- Triggers when screen size crosses the xs breakpoint
|
|
||||||
- Waits for DOM update via `nextTick()`
|
|
||||||
- Calls `handleMapResize()` to adjust map
|
|
||||||
|
|
||||||
4. **Added window resize event listener:**
|
|
||||||
- Falls back for orientation changes that might not trigger Quasar's screen watcher
|
|
||||||
- Debounced with 300ms timeout to avoid excessive calls
|
|
||||||
- Properly cleaned up on component unmount
|
|
||||||
|
|
||||||
**Files Modified:**
|
|
||||||
- `src/components/AscGISMap.vue` - Added resize handling logic
|
|
||||||
|
|
||||||
**Best Practices Applied:**
|
|
||||||
- Proper cleanup of event listeners in `onBeforeUnmount`
|
|
||||||
- Debouncing resize events for performance
|
|
||||||
- Using `nextTick()` to ensure DOM synchronization
|
|
||||||
- Checking for destroyed state before calling map methods
|
|
||||||
|
|
||||||
**Note:** The Google Maps component (`MapCheckin.vue`) was not affected as `vue3-google-map` handles resize automatically.
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
---
|
|
||||||
name: Active camera investigation scope
|
|
||||||
description: Current camera issue investigations should focus on HomeView.vue; the legacy Google Map MapView.vue flow is not in active use
|
|
||||||
type: project
|
|
||||||
---
|
|
||||||
|
|
||||||
Current camera issue work should focus on `HomeView.vue`; do not investigate or modify the legacy Google Map `MapView.vue` flow for this issue.
|
|
||||||
|
|
||||||
**Why:** The user clarified that `MapView.vue` is an older Google Map implementation from earlier work and is not the path currently used in production for this check-in flow.
|
|
||||||
|
|
||||||
**How to apply:** For follow-up debugging or fixes related to the current camera/upload issue, scope analysis and implementation to `HomeView.vue` unless the user explicitly re-opens `MapView.vue`.
|
|
||||||
|
|
@ -34,7 +34,6 @@
|
||||||
"quasar": "^2.11.1",
|
"quasar": "^2.11.1",
|
||||||
"register-service-worker": "^1.7.2",
|
"register-service-worker": "^1.7.2",
|
||||||
"simple-vue-camera": "^1.1.3",
|
"simple-vue-camera": "^1.1.3",
|
||||||
"socket.io-client": "^4.8.3",
|
|
||||||
"vite-plugin-pwa": "^0.16.7",
|
"vite-plugin-pwa": "^0.16.7",
|
||||||
"vue": "^3.4.15",
|
"vue": "^3.4.15",
|
||||||
"vue-router": "^4.1.6",
|
"vue-router": "^4.1.6",
|
||||||
|
|
|
||||||
124
src/App.vue
124
src/App.vue
|
|
@ -1,64 +1,5 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, onMounted, ref } from 'vue'
|
|
||||||
import { useSocketStore } from '@/stores/socket'
|
|
||||||
import {
|
|
||||||
getExternalBrowserUrl,
|
|
||||||
shouldShowIOSLineFallback,
|
|
||||||
} from '@/utils/forceExternalBrowser'
|
|
||||||
|
|
||||||
const showExternalBrowserFallback = computed(() => shouldShowIOSLineFallback())
|
|
||||||
const fallbackUrl = computed(() => getExternalBrowserUrl())
|
|
||||||
const copied = ref(false)
|
|
||||||
|
|
||||||
const tryOpenAgain = () => {
|
|
||||||
window.location.href = fallbackUrl.value
|
|
||||||
}
|
|
||||||
|
|
||||||
const copyLink = async () => {
|
|
||||||
copied.value = false
|
|
||||||
|
|
||||||
if (!navigator.clipboard?.writeText) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await navigator.clipboard.writeText(fallbackUrl.value)
|
|
||||||
copied.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
useSocketStore()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<router-view />
|
<router-view />
|
||||||
|
|
||||||
<div v-if="showExternalBrowserFallback" class="external-browser-overlay">
|
|
||||||
<div class="external-browser-card">
|
|
||||||
<h2>แนะนำให้เปิดด้วย Safari</h2>
|
|
||||||
<p>
|
|
||||||
LINE Browser อาจทำให้กล้องหรือตำแหน่งทำงานไม่ครบ กรุณาเปิดหน้านี้ใน
|
|
||||||
Safari เพื่อใช้งานระบบลงเวลาได้เสถียรกว่าเดิม
|
|
||||||
</p>
|
|
||||||
<ol>
|
|
||||||
<li>แตะปุ่ม เมนู ใน LINE Browser</li>
|
|
||||||
<li>เลือก เปิดใน Safari</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
<div class="external-browser-actions">
|
|
||||||
<button type="button" class="primary" @click="tryOpenAgain">
|
|
||||||
ลองเปิดอีกครั้ง
|
|
||||||
</button>
|
|
||||||
<button type="button" class="secondary" @click="copyLink">
|
|
||||||
คัดลอกลิงก์
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p v-if="copied" class="copy-success">
|
|
||||||
คัดลอกลิงก์แล้ว สามารถวางใน Safari ได้ทันที
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -82,69 +23,4 @@ nav a {
|
||||||
nav a.router-link-exact-active {
|
nav a.router-link-exact-active {
|
||||||
color: #42b983;
|
color: #42b983;
|
||||||
}
|
}
|
||||||
|
|
||||||
.external-browser-overlay {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 9999;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 16px;
|
|
||||||
background: rgba(0, 0, 0, 0.45);
|
|
||||||
}
|
|
||||||
|
|
||||||
.external-browser-card {
|
|
||||||
width: min(520px, 100%);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 20px;
|
|
||||||
background: #ffffff;
|
|
||||||
text-align: left;
|
|
||||||
box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
|
|
||||||
}
|
|
||||||
|
|
||||||
.external-browser-card h2 {
|
|
||||||
margin: 0 0 10px;
|
|
||||||
font-size: 24px;
|
|
||||||
color: #0d3b66;
|
|
||||||
}
|
|
||||||
|
|
||||||
.external-browser-card p {
|
|
||||||
margin: 0 0 12px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.external-browser-card ol {
|
|
||||||
margin: 0 0 16px;
|
|
||||||
padding-left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.external-browser-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.external-browser-actions button {
|
|
||||||
border: 0;
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 10px 14px;
|
|
||||||
font-size: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.external-browser-actions .primary {
|
|
||||||
background: #1976d2;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.external-browser-actions .secondary {
|
|
||||||
background: #edf2f7;
|
|
||||||
color: #1f2937;
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy-success {
|
|
||||||
margin-top: 12px;
|
|
||||||
color: #0b7a3f;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
import env from "./index";
|
|
||||||
|
|
||||||
const socket = `${env.API_URI}/org-socket`;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
socket,
|
|
||||||
};
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
import leave from '@/api/api.checkin'
|
import leave from '@/api/api.checkin'
|
||||||
import history from '@/api/api.history'
|
import history from '@/api/api.history'
|
||||||
import message from '@/api/api.message'
|
import message from '@/api/api.message'
|
||||||
import socket from '@/api/socket'
|
|
||||||
|
|
||||||
const API = {
|
const API = {
|
||||||
/**leave */
|
/**leave */
|
||||||
|
|
@ -13,7 +12,6 @@ const API = {
|
||||||
...history,
|
...history,
|
||||||
/**message */
|
/**message */
|
||||||
...message,
|
...message,
|
||||||
...socket,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none">
|
|
||||||
<path d="M12 2c-3.866 0-7 3.134-7 7 0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7Z" fill="#1E88E5"/>
|
|
||||||
<circle cx="12" cy="9" r="3" fill="#fff"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 254 B |
|
|
@ -1,4 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none">
|
|
||||||
<path d="M12 2c-3.866 0-7 3.134-7 7 0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7Z" fill="#E53935"/>
|
|
||||||
<circle cx="12" cy="9" r="3" fill="#fff"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 254 B |
|
|
@ -1,44 +1,22 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import { ref, shallowRef, onBeforeUnmount } from 'vue'
|
||||||
computed,
|
|
||||||
ref,
|
|
||||||
shallowRef,
|
|
||||||
onBeforeUnmount,
|
|
||||||
onMounted,
|
|
||||||
watch,
|
|
||||||
nextTick,
|
|
||||||
} from 'vue'
|
|
||||||
import { loadModules } from 'esri-loader'
|
import { loadModules } from 'esri-loader'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { useCounterMixin } from '@/stores/mixin'
|
import { useCounterMixin } from '@/stores/mixin'
|
||||||
import { useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
import { usePrivacyStore } from '@/stores/privacy'
|
import { usePrivacyStore } from '@/stores/privacy'
|
||||||
import markerRedUrl from '@/assets/markers/marker-red.svg?url'
|
|
||||||
import markerBlueUrl from '@/assets/markers/marker-blue.svg?url'
|
|
||||||
|
|
||||||
const mixin = useCounterMixin()
|
const mixin = useCounterMixin()
|
||||||
const { messageError } = mixin
|
const { messageError } = mixin
|
||||||
const privacyStore = usePrivacyStore()
|
const privacyStore = usePrivacyStore()
|
||||||
|
|
||||||
const emit = defineEmits(['update:location'])
|
const emit = defineEmits(['update:location'])
|
||||||
|
|
||||||
// Accept initial POI from parent to prevent skeleton on re-mount
|
|
||||||
const props = defineProps<{
|
|
||||||
initialPOI?: string
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const $q = useQuasar()
|
const $q = useQuasar()
|
||||||
|
|
||||||
// Throttle mechanism to prevent excessive location updates
|
// Throttle mechanism to prevent excessive location updates
|
||||||
const LOCATION_UPDATE_THROTTLE_MS = 500
|
const LOCATION_UPDATE_THROTTLE_MS = 500
|
||||||
let lastLocationUpdate = 0
|
let lastLocationUpdate = 0
|
||||||
|
|
||||||
// Track if map is initialized to prevent re-initialization
|
|
||||||
const isMapInitialized = ref<boolean>(false)
|
|
||||||
const isInitializing = ref<boolean>(false)
|
|
||||||
const currentScreenSize = ref<boolean>($q.screen.gt.xs) // Track screen size to detect changes
|
|
||||||
const mobileMapExpanded = ref<boolean>(true)
|
|
||||||
|
|
||||||
function updateLocation(latitude: number, longitude: number, namePOI: string) {
|
function updateLocation(latitude: number, longitude: number, namePOI: string) {
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
// Skip update if called too frequently (within throttle period)
|
// Skip update if called too frequently (within throttle period)
|
||||||
|
|
@ -50,18 +28,8 @@ function updateLocation(latitude: number, longitude: number, namePOI: string) {
|
||||||
emit('update:location', latitude, longitude, namePOI)
|
emit('update:location', latitude, longitude, namePOI)
|
||||||
}
|
}
|
||||||
|
|
||||||
const poiPlaceName = ref<string>(props.initialPOI || '') // ชื่อพื้นที่ใกล้เคียง - use initialPOI if provided
|
const poiPlaceName = ref<string>('') // ชื่อพื้นที่ใกล้เคียง
|
||||||
const mapView = shallowRef<any>(null) // Store mapView reference for cleanup (use shallowRef to avoid reactivity issues)
|
const mapView = shallowRef<any>(null) // Store mapView reference for cleanup (use shallowRef to avoid reactivity issues)
|
||||||
const desktopMapContainerRef = ref<HTMLElement | null>(null)
|
|
||||||
const mobileMapContainerRef = ref<HTMLElement | null>(null)
|
|
||||||
const isMapVisible = computed(
|
|
||||||
() => !!mapView.value && !mapView.value.destroyed && isMapInitialized.value
|
|
||||||
)
|
|
||||||
|
|
||||||
// Unique container ID for each component instance to avoid conflicts
|
|
||||||
const mapContainerId = `mapViewDisplay_${Math.random()
|
|
||||||
.toString(36)
|
|
||||||
.substring(2, 9)}`
|
|
||||||
|
|
||||||
// ArcGIS API key from environment variable
|
// ArcGIS API key from environment variable
|
||||||
const apiKey = ref<string>(
|
const apiKey = ref<string>(
|
||||||
|
|
@ -71,370 +39,174 @@ const zoomMap = ref<number>(18)
|
||||||
const textTooltip = ref<string>(
|
const textTooltip = ref<string>(
|
||||||
'พื้นที่ใกล้เคียงคือ สถานที่สำคัญรอบตัวคุณ (ไม่ใช่ตำแหน่งปัจจุบัน)'
|
'พื้นที่ใกล้เคียงคือ สถานที่สำคัญรอบตัวคุณ (ไม่ใช่ตำแหน่งปัจจุบัน)'
|
||||||
)
|
)
|
||||||
let attachRetryTimer: number | undefined
|
|
||||||
let mapInitVersion = 0
|
|
||||||
let isRecoveryReinitializing = false
|
|
||||||
|
|
||||||
function getActiveMapContainer() {
|
|
||||||
return $q.screen.gt.xs
|
|
||||||
? desktopMapContainerRef.value
|
|
||||||
: mobileMapContainerRef.value
|
|
||||||
}
|
|
||||||
|
|
||||||
async function waitForActiveMapContainer(maxAttempts = 25, delayMs = 120) {
|
|
||||||
for (let i = 0; i < maxAttempts; i += 1) {
|
|
||||||
await nextTick()
|
|
||||||
const container = getActiveMapContainer()
|
|
||||||
|
|
||||||
if (container && container.clientWidth > 0 && container.clientHeight > 0) {
|
|
||||||
return container
|
|
||||||
}
|
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, delayMs))
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearAttachRetryTimer() {
|
|
||||||
if (attachRetryTimer) {
|
|
||||||
clearTimeout(attachRetryTimer)
|
|
||||||
attachRetryTimer = undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function recoverMapByReinitialize() {
|
|
||||||
if (isRecoveryReinitializing) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
isRecoveryReinitializing = true
|
|
||||||
|
|
||||||
try {
|
|
||||||
mapInitVersion += 1
|
|
||||||
isInitializing.value = false
|
|
||||||
clearAttachRetryTimer()
|
|
||||||
|
|
||||||
if (mapView.value && !mapView.value.destroyed) {
|
|
||||||
mapView.value.destroy()
|
|
||||||
mapView.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
isMapInitialized.value = false
|
|
||||||
await nextTick()
|
|
||||||
await initializeMap()
|
|
||||||
} finally {
|
|
||||||
isRecoveryReinitializing = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function reattachAndResizeMap(retry = 0) {
|
|
||||||
if (!mapView.value || mapView.value.destroyed) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const activeContainer = getActiveMapContainer()
|
|
||||||
|
|
||||||
if (
|
|
||||||
!activeContainer ||
|
|
||||||
activeContainer.clientWidth === 0 ||
|
|
||||||
activeContainer.clientHeight === 0
|
|
||||||
) {
|
|
||||||
if (retry < 15) {
|
|
||||||
clearAttachRetryTimer()
|
|
||||||
attachRetryTimer = window.setTimeout(() => {
|
|
||||||
reattachAndResizeMap(retry + 1)
|
|
||||||
}, 140)
|
|
||||||
} else if (!isRecoveryReinitializing) {
|
|
||||||
void recoverMapByReinitialize()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
clearAttachRetryTimer()
|
|
||||||
|
|
||||||
nextTick(() => {
|
|
||||||
if (!mapView.value || mapView.value.destroyed) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mapView.value.container !== activeContainer) {
|
|
||||||
mapView.value.container = null
|
|
||||||
mapView.value.container = activeContainer
|
|
||||||
}
|
|
||||||
|
|
||||||
// เรียก resize() อย่างปลอดภัยด้วยการตรวจสอบว่ามี method นี้หรือไม่
|
|
||||||
try {
|
|
||||||
if (typeof mapView.value.resize === 'function') {
|
|
||||||
mapView.value.resize()
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('Map resize failed:', error)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof mapView.value.requestRender === 'function') {
|
|
||||||
mapView.value.requestRender?.()
|
|
||||||
}
|
|
||||||
|
|
||||||
mapView.value
|
|
||||||
.goTo(
|
|
||||||
{
|
|
||||||
center: mapView.value.center,
|
|
||||||
zoom: mapView.value.zoom,
|
|
||||||
},
|
|
||||||
{ animate: false }
|
|
||||||
)
|
|
||||||
.catch(() => {
|
|
||||||
// Ignore interrupted goTo during rapid orientation changes.
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initializeMap() {
|
async function initializeMap() {
|
||||||
if (isInitializing.value || (mapView.value && !mapView.value.destroyed)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const initVersion = ++mapInitVersion
|
|
||||||
|
|
||||||
isInitializing.value = true
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load modules of ArcGIS
|
// Load modules of ArcGIS
|
||||||
const [esriConfig, Map, MapView, Point, Graphic, TileLayer] =
|
loadModules([
|
||||||
await loadModules([
|
'esri/config',
|
||||||
'esri/config',
|
'esri/Map',
|
||||||
'esri/Map',
|
'esri/views/MapView',
|
||||||
'esri/views/MapView',
|
'esri/geometry/Point',
|
||||||
'esri/geometry/Point',
|
'esri/Graphic',
|
||||||
'esri/Graphic',
|
'esri/layers/TileLayer',
|
||||||
// 'esri/layers/TileLayer',
|
]).then(async ([esriConfig, Map, MapView, Point, Graphic, TileLayer]) => {
|
||||||
])
|
// Set apiKey
|
||||||
// Set apiKey
|
// esriConfig.apiKey =
|
||||||
// esriConfig.apiKey =
|
// 'AAPK4f700a4324d04e9f8a1a134e0771ac45FXWawdCl-OotFfr52gz9XKxTDJTpDzw_YYcwbmKDDyAJswf14FoPyw0qBkN64DvP'
|
||||||
// 'AAPK4f700a4324d04e9f8a1a134e0771ac45FXWawdCl-OotFfr52gz9XKxTDJTpDzw_YYcwbmKDDyAJswf14FoPyw0qBkN64DvP'
|
|
||||||
|
|
||||||
// Create a FeatureLayer using a custom server URL
|
// Create a FeatureLayer using a custom server URL
|
||||||
// const hillshadeLayer = new TileLayer({
|
// const hillshadeLayer = new TileLayer({
|
||||||
// url: `https://bmagis.bangkok.go.th/arcgis/rest/services/cache/BMA_3D_2D_Cache/MapServer`,
|
// url: `https://bmagis.bangkok.go.th/arcgis/rest/services/cache/BMA_3D_2D_Cache/MapServer`,
|
||||||
// })
|
// })
|
||||||
|
|
||||||
const map = new Map({
|
const map = new Map({
|
||||||
basemap: 'streets',
|
basemap: 'streets',
|
||||||
// basemap: 'arcgis-topographic',
|
// basemap: 'arcgis-topographic',
|
||||||
// layers: [hillshadeLayer],
|
// layers: [hillshadeLayer],
|
||||||
})
|
})
|
||||||
|
|
||||||
if (initVersion !== mapInitVersion) {
|
navigator.geolocation.getCurrentPosition(async (position) => {
|
||||||
return
|
const { latitude, longitude } = position.coords
|
||||||
}
|
|
||||||
|
|
||||||
const position = await new Promise<GeolocationPosition>(
|
mapView.value = new MapView({
|
||||||
(resolve, reject) => {
|
container: 'mapViewDisplay',
|
||||||
navigator.geolocation.getCurrentPosition(resolve, reject, {
|
map: map,
|
||||||
enableHighAccuracy: true,
|
center: {
|
||||||
timeout: 10000,
|
latitude: latitude,
|
||||||
})
|
longitude: longitude,
|
||||||
}
|
}, // Set the initial map center current position
|
||||||
)
|
|
||||||
|
|
||||||
if (initVersion !== mapInitVersion) {
|
zoom: zoomMap.value,
|
||||||
return
|
constraints: {
|
||||||
}
|
snapToZoom: false, // Disables snapping to the zoom level
|
||||||
|
minZoom: zoomMap.value, // Set minimum zoom level
|
||||||
const { latitude, longitude } = position.coords
|
maxZoom: zoomMap.value, // Set maximum zoom level (same as minZoom for fixed zoom)
|
||||||
|
|
||||||
const mapContainer = await waitForActiveMapContainer()
|
|
||||||
|
|
||||||
if (!mapContainer || initVersion !== mapInitVersion) {
|
|
||||||
isMapInitialized.value = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
mapView.value = new MapView({
|
|
||||||
container: mapContainer,
|
|
||||||
map: map,
|
|
||||||
center: {
|
|
||||||
latitude: latitude,
|
|
||||||
longitude: longitude,
|
|
||||||
}, // Set the initial map center current position
|
|
||||||
|
|
||||||
zoom: zoomMap.value,
|
|
||||||
constraints: {
|
|
||||||
snapToZoom: false, // Disables snapping to the zoom level
|
|
||||||
minZoom: zoomMap.value, // Set minimum zoom level
|
|
||||||
maxZoom: zoomMap.value, // Set maximum zoom level (same as minZoom for fixed zoom)
|
|
||||||
},
|
|
||||||
|
|
||||||
ui: {
|
|
||||||
components: [], // Empty array to remove all default UI components
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
await mapView.value.when()
|
|
||||||
|
|
||||||
if (initVersion !== mapInitVersion) {
|
|
||||||
if (mapView.value && !mapView.value.destroyed) {
|
|
||||||
mapView.value.destroy()
|
|
||||||
}
|
|
||||||
mapView.value = null
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
isMapInitialized.value = true
|
|
||||||
reattachAndResizeMap()
|
|
||||||
|
|
||||||
// ตำแหน่งของผู้ใช้
|
|
||||||
const userPoint = new Point({ longitude, latitude })
|
|
||||||
const userSymbol = {
|
|
||||||
type: 'picture-marker',
|
|
||||||
url: markerRedUrl,
|
|
||||||
width: '32px',
|
|
||||||
height: '32px',
|
|
||||||
}
|
|
||||||
const userGraphic = new Graphic({
|
|
||||||
geometry: userPoint,
|
|
||||||
symbol: userSymbol,
|
|
||||||
})
|
|
||||||
|
|
||||||
// เพิ่มการตรวจสอบความปลอดภัยก่อนเข้าถึง graphics
|
|
||||||
if (mapView.value && mapView.value.graphics && !mapView.value.destroyed) {
|
|
||||||
mapView.value.graphics.add(userGraphic)
|
|
||||||
}
|
|
||||||
// Get POI place ยิงไปขอที่ server ของกทม.ก่อน
|
|
||||||
// await axios
|
|
||||||
// .get(
|
|
||||||
// 'https://bmagis.bangkok.go.th/portal/sharing/servers/e4732c3a9fe549ab8bc697573b468f68/rest/services/World/GeocodeServer/reverseGeocode/',
|
|
||||||
// {
|
|
||||||
// params: {
|
|
||||||
// f: 'json', // Format JSON response
|
|
||||||
// distance: 2000,
|
|
||||||
// category: 'POI',
|
|
||||||
// location: {
|
|
||||||
// spatialReference: { wkid: 4326 },
|
|
||||||
// x: longitude,
|
|
||||||
// y: latitude,
|
|
||||||
// },
|
|
||||||
// token: apiKey.value,
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
// .then((response) => {
|
|
||||||
// // console.log('poi', response.data.location)
|
|
||||||
// poiPlaceName.value = response.data.address
|
|
||||||
// ? response.data.address.PlaceName === ''
|
|
||||||
// ? response.data.address.ShortLabel
|
|
||||||
// : response.data.address.PlaceName
|
|
||||||
// : 'ไม่พบข้อมูล'
|
|
||||||
// const poiPoint = new Point({
|
|
||||||
// longitude: response.data.location.x,
|
|
||||||
// latitude: response.data.location.y,
|
|
||||||
// })
|
|
||||||
// const poiSymbol = {
|
|
||||||
// type: 'picture-marker',
|
|
||||||
// url: markerBlueUrl,
|
|
||||||
// width: '32px',
|
|
||||||
// height: '32px',
|
|
||||||
// }
|
|
||||||
// const poiGraphic = new Graphic({
|
|
||||||
// geometry: poiPoint,
|
|
||||||
// symbol: poiSymbol,
|
|
||||||
// })
|
|
||||||
// mapView.value.graphics.add(poiGraphic)
|
|
||||||
// // อัปเดตการแสดงผลให้แสดงทั้งตำแหน่งของผู้ใช้และ POI
|
|
||||||
// mapView.value.goTo({
|
|
||||||
// target: [userPoint, poiPoint],
|
|
||||||
// zoom: zoomMap.value,
|
|
||||||
// })
|
|
||||||
|
|
||||||
// // Mark map as initialized
|
|
||||||
// isMapInitialized.value = true
|
|
||||||
|
|
||||||
// updateLocation(latitude, longitude, poiPlaceName.value)
|
|
||||||
// })
|
|
||||||
// .catch(async (error) => {
|
|
||||||
// console.error('Error fetching points of interest:', error)
|
|
||||||
// Get POI place ยิงไปขอที่ server arcgis ไม่ต้องใช้ token
|
|
||||||
await axios
|
|
||||||
.get(
|
|
||||||
'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode/',
|
|
||||||
{
|
|
||||||
params: {
|
|
||||||
f: 'json', // Format JSON response
|
|
||||||
distance: 2000,
|
|
||||||
category: 'POI',
|
|
||||||
location: {
|
|
||||||
spatialReference: { wkid: 4326 },
|
|
||||||
x: longitude,
|
|
||||||
y: latitude,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
|
||||||
)
|
|
||||||
.then((response) => {
|
|
||||||
if (initVersion !== mapInitVersion || !mapView.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log('poi', response.data.location)
|
ui: {
|
||||||
poiPlaceName.value = response.data.address
|
components: [], // Empty array to remove all default UI components
|
||||||
? response.data.address.PlaceName === ''
|
},
|
||||||
? response.data.address.ShortLabel
|
|
||||||
: response.data.address.PlaceName
|
|
||||||
: 'ไม่พบข้อมูล'
|
|
||||||
const poiPoint = new Point({
|
|
||||||
longitude: response.data.location.x,
|
|
||||||
latitude: response.data.location.y,
|
|
||||||
})
|
})
|
||||||
const poiSymbol = {
|
|
||||||
|
// ตำแหน่งของผู้ใช้
|
||||||
|
const userPoint = new Point({ longitude, latitude })
|
||||||
|
const userSymbol = {
|
||||||
type: 'picture-marker',
|
type: 'picture-marker',
|
||||||
url: markerBlueUrl,
|
url: 'http://maps.google.com/mapfiles/ms/icons/red.png',
|
||||||
width: '32px',
|
width: '32px',
|
||||||
height: '32px',
|
height: '32px',
|
||||||
}
|
}
|
||||||
const poiGraphic = new Graphic({
|
const userGraphic = new Graphic({
|
||||||
geometry: poiPoint,
|
geometry: userPoint,
|
||||||
symbol: poiSymbol,
|
symbol: userSymbol,
|
||||||
})
|
})
|
||||||
|
mapView.value.graphics.add(userGraphic)
|
||||||
// เพิ่มการตรวจสอบความปลอดภัยก่อนเข้าถึง graphics และ goTo
|
// Get POI place ยิงไปขอที่ server ของกทม.ก่อน
|
||||||
if (mapView.value && !mapView.value.destroyed) {
|
await axios
|
||||||
if (mapView.value.graphics) {
|
.get(
|
||||||
|
'https://bmagis.bangkok.go.th/portal/sharing/servers/e4732c3a9fe549ab8bc697573b468f68/rest/services/World/GeocodeServer/reverseGeocode/',
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
f: 'json', // Format JSON response
|
||||||
|
distance: 2000,
|
||||||
|
category: 'POI',
|
||||||
|
location: {
|
||||||
|
spatialReference: { wkid: 4326 },
|
||||||
|
x: longitude,
|
||||||
|
y: latitude,
|
||||||
|
},
|
||||||
|
token: apiKey.value,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((response) => {
|
||||||
|
// console.log('poi', response.data.location)
|
||||||
|
poiPlaceName.value = response.data.address
|
||||||
|
? response.data.address.PlaceName === ''
|
||||||
|
? response.data.address.ShortLabel
|
||||||
|
: response.data.address.PlaceName
|
||||||
|
: 'ไม่พบข้อมูล'
|
||||||
|
const poiPoint = new Point({
|
||||||
|
longitude: response.data.location.x,
|
||||||
|
latitude: response.data.location.y,
|
||||||
|
})
|
||||||
|
const poiSymbol = {
|
||||||
|
type: 'picture-marker',
|
||||||
|
url: 'http://maps.google.com/mapfiles/ms/icons/blue.png',
|
||||||
|
width: '32px',
|
||||||
|
height: '32px',
|
||||||
|
}
|
||||||
|
const poiGraphic = new Graphic({
|
||||||
|
geometry: poiPoint,
|
||||||
|
symbol: poiSymbol,
|
||||||
|
})
|
||||||
mapView.value.graphics.add(poiGraphic)
|
mapView.value.graphics.add(poiGraphic)
|
||||||
}
|
// อัปเดตการแสดงผลให้แสดงทั้งตำแหน่งของผู้ใช้และ POI
|
||||||
// อัปเดตการแสดงผลให้แสดงทั้งตำแหน่งของผู้ใช้และ POI
|
|
||||||
if (typeof mapView.value.goTo === 'function') {
|
|
||||||
mapView.value.goTo({
|
mapView.value.goTo({
|
||||||
target: [userPoint, poiPoint],
|
target: [userPoint, poiPoint],
|
||||||
zoom: zoomMap.value,
|
zoom: zoomMap.value,
|
||||||
}).catch(() => {
|
|
||||||
// Ignore goTo errors
|
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLocation(latitude, longitude, poiPlaceName.value)
|
updateLocation(latitude, longitude, poiPlaceName.value)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(async (error) => {
|
||||||
if (initVersion !== mapInitVersion) {
|
// console.error('Error fetching points of interest:', error)
|
||||||
return
|
// Get POI place ยิงไปขอที่ server arcgis ไม่ต้องใช้ token
|
||||||
}
|
await axios
|
||||||
poiPlaceName.value = poiPlaceName.value || 'ไม่พบข้อมูล'
|
.get(
|
||||||
updateLocation(latitude, longitude, poiPlaceName.value)
|
'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode/',
|
||||||
})
|
{
|
||||||
|
params: {
|
||||||
|
f: 'json', // Format JSON response
|
||||||
|
distance: 2000,
|
||||||
|
category: 'POI',
|
||||||
|
location: {
|
||||||
|
spatialReference: { wkid: 4326 },
|
||||||
|
x: longitude,
|
||||||
|
y: latitude,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((response) => {
|
||||||
|
// console.log('poi', response.data.location)
|
||||||
|
poiPlaceName.value = response.data.address
|
||||||
|
? response.data.address.PlaceName === ''
|
||||||
|
? response.data.address.ShortLabel
|
||||||
|
: response.data.address.PlaceName
|
||||||
|
: 'ไม่พบข้อมูล'
|
||||||
|
const poiPoint = new Point({
|
||||||
|
longitude: response.data.location.x,
|
||||||
|
latitude: response.data.location.y,
|
||||||
|
})
|
||||||
|
const poiSymbol = {
|
||||||
|
type: 'picture-marker',
|
||||||
|
url: 'http://maps.google.com/mapfiles/ms/icons/blue.png',
|
||||||
|
width: '32px',
|
||||||
|
height: '32px',
|
||||||
|
}
|
||||||
|
const poiGraphic = new Graphic({
|
||||||
|
geometry: poiPoint,
|
||||||
|
symbol: poiSymbol,
|
||||||
|
})
|
||||||
|
mapView.value.graphics.add(poiGraphic)
|
||||||
|
// อัปเดตการแสดงผลให้แสดงทั้งตำแหน่งของผู้ใช้และ POI
|
||||||
|
mapView.value.goTo({
|
||||||
|
target: [userPoint, poiPoint],
|
||||||
|
zoom: zoomMap.value,
|
||||||
|
})
|
||||||
|
|
||||||
if (initVersion === mapInitVersion) {
|
updateLocation(latitude, longitude, poiPlaceName.value)
|
||||||
reattachAndResizeMap()
|
})
|
||||||
}
|
.catch((error) => {
|
||||||
|
// console.error('Error fetching points of interest:', error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (initVersion === mapInitVersion) {
|
|
||||||
isMapInitialized.value = false
|
|
||||||
}
|
|
||||||
console.error('Error loading the map', error)
|
console.error('Error loading the map', error)
|
||||||
} finally {
|
|
||||||
if (initVersion === mapInitVersion) {
|
|
||||||
isInitializing.value = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -509,116 +281,12 @@ const requestLocationPermission = () => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also add a resize event listener as a fallback for orientation changes
|
|
||||||
// that might not trigger the Quasar screen watcher
|
|
||||||
let resizeTimeout: number | undefined
|
|
||||||
const handleWindowResize = () => {
|
|
||||||
// Debounce resize events to avoid excessive calls
|
|
||||||
if (resizeTimeout) {
|
|
||||||
clearTimeout(resizeTimeout)
|
|
||||||
}
|
|
||||||
resizeTimeout = window.setTimeout(() => {
|
|
||||||
handleMapResize()
|
|
||||||
}, 300)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle map resize when screen orientation changes
|
|
||||||
* ArcGIS MapView needs to be manually resized when its container changes dimensions
|
|
||||||
* Only call resize() if the map is fully initialized
|
|
||||||
*/
|
|
||||||
function handleMapResize() {
|
|
||||||
if (mapView.value && !mapView.value.destroyed && isMapInitialized.value) {
|
|
||||||
// Use nextTick to ensure the DOM has finished updating before resizing
|
|
||||||
reattachAndResizeMap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Watch for screen size/orientation changes
|
|
||||||
* When the screen size changes (e.g., portrait to landscape), we need to re-initialize the map
|
|
||||||
* because the container div changes between desktop and mobile versions
|
|
||||||
*/
|
|
||||||
watch(
|
|
||||||
() => $q.screen.gt.xs,
|
|
||||||
async (newValue) => {
|
|
||||||
// Skip if no actual change (same layout)
|
|
||||||
if (newValue === currentScreenSize.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
currentScreenSize.value = newValue
|
|
||||||
if (!newValue) {
|
|
||||||
mobileMapExpanded.value = true
|
|
||||||
}
|
|
||||||
mapInitVersion += 1
|
|
||||||
isInitializing.value = false
|
|
||||||
clearAttachRetryTimer()
|
|
||||||
|
|
||||||
// Always destroy and re-initialize when screen size changes
|
|
||||||
// This ensures the map is attached to the correct container
|
|
||||||
if (mapView.value && !mapView.value.destroyed) {
|
|
||||||
mapView.value.destroy()
|
|
||||||
mapView.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset initialization state
|
|
||||||
isMapInitialized.value = false
|
|
||||||
|
|
||||||
// Wait for DOM to update with new layout
|
|
||||||
await nextTick()
|
|
||||||
await waitForActiveMapContainer(30, 100)
|
|
||||||
|
|
||||||
// Re-initialize the map
|
|
||||||
if (privacyStore.isAccepted) {
|
|
||||||
await initializeMap()
|
|
||||||
|
|
||||||
if (!mapView.value || mapView.value.destroyed) {
|
|
||||||
await recoverMapByReinitialize()
|
|
||||||
}
|
|
||||||
|
|
||||||
reattachAndResizeMap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Watch for initialPOI prop changes to update poiPlaceName
|
|
||||||
watch(
|
|
||||||
() => props.initialPOI,
|
|
||||||
(newValue) => {
|
|
||||||
if (newValue && newValue !== poiPlaceName.value) {
|
|
||||||
poiPlaceName.value = newValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Set up resize event listener on mount
|
|
||||||
onMounted(async () => {
|
|
||||||
window.addEventListener('resize', handleWindowResize)
|
|
||||||
|
|
||||||
// Component can be remounted after orientation/layout switches.
|
|
||||||
// Recreate map automatically when consent is already granted.
|
|
||||||
if (privacyStore.isAccepted && (!mapView.value || mapView.value.destroyed)) {
|
|
||||||
await waitForActiveMapContainer(30, 100)
|
|
||||||
await initializeMap()
|
|
||||||
reattachAndResizeMap()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Cleanup map resources when component unmounts
|
// Cleanup map resources when component unmounts
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
clearAttachRetryTimer()
|
|
||||||
|
|
||||||
if (mapView.value) {
|
if (mapView.value) {
|
||||||
mapView.value.destroy()
|
mapView.value.destroy()
|
||||||
mapView.value = null
|
mapView.value = null
|
||||||
}
|
}
|
||||||
// Clean up resize event listener
|
|
||||||
window.removeEventListener('resize', handleWindowResize)
|
|
||||||
// Clear timeout if it exists
|
|
||||||
if (resizeTimeout) {
|
|
||||||
clearTimeout(resizeTimeout)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|
@ -627,8 +295,8 @@ defineExpose({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<!-- Loading skeleton - show until map is visible -->
|
<!-- Loading skeleton -->
|
||||||
<div v-if="!isMapVisible" class="col-12">
|
<div v-if="!poiPlaceName" class="col-12">
|
||||||
<q-skeleton
|
<q-skeleton
|
||||||
:height="$q.screen.gt.xs ? '35vh' : '45px'"
|
:height="$q.screen.gt.xs ? '35vh' : '45px'"
|
||||||
width="100%"
|
width="100%"
|
||||||
|
|
@ -638,16 +306,16 @@ defineExpose({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-card
|
<q-card
|
||||||
|
v-show="poiPlaceName"
|
||||||
bordered
|
bordered
|
||||||
flat
|
flat
|
||||||
class="col-12 bg-grey-2 shadow-0"
|
class="col-12 bg-grey-2 shadow-0"
|
||||||
:class="{ 'map-hidden': !isMapVisible }"
|
|
||||||
:style="$q.screen.gt.xs ? ';' : 'border-radius: 20px'"
|
:style="$q.screen.gt.xs ? ';' : 'border-radius: 20px'"
|
||||||
>
|
>
|
||||||
<div v-if="$q.screen.gt.xs">
|
<div v-if="$q.screen.gt.xs">
|
||||||
<div
|
<div
|
||||||
:id="mapContainerId"
|
id="mapViewDisplay"
|
||||||
ref="desktopMapContainerRef"
|
ref="mapElement"
|
||||||
style="height: 35vh; pointer-events: none"
|
style="height: 35vh; pointer-events: none"
|
||||||
></div>
|
></div>
|
||||||
|
|
||||||
|
|
@ -671,7 +339,6 @@ defineExpose({
|
||||||
|
|
||||||
<q-card v-else style="border-radius: 20px">
|
<q-card v-else style="border-radius: 20px">
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
v-model="mobileMapExpanded"
|
|
||||||
class="shadow-1 overflow-hidden bg-grey-4 text-left q-pa-xs"
|
class="shadow-1 overflow-hidden bg-grey-4 text-left q-pa-xs"
|
||||||
style="border-radius: 20px"
|
style="border-radius: 20px"
|
||||||
dense
|
dense
|
||||||
|
|
@ -688,20 +355,16 @@ defineExpose({
|
||||||
name="mdi-information-outline"
|
name="mdi-information-outline"
|
||||||
size="xs"
|
size="xs"
|
||||||
class="q-mr-xs cursor-pointer"
|
class="q-mr-xs cursor-pointer"
|
||||||
@click.stop="$q.dialog({ message: textTooltip, ok: 'ตกลง' })"
|
@click.stop="$q.dialog({ message: textTooltip, ok: 'ปิด' })"
|
||||||
/>
|
/>
|
||||||
</q-item-label>
|
</q-item-label>
|
||||||
<q-item-label class="text-weight-medium text-grey-9">
|
<q-item-label class="text-weight-medium text-grey-9">
|
||||||
{{ poiPlaceName || '-' }}
|
{{ poiPlaceName }}
|
||||||
</q-item-label>
|
</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div
|
<div id="mapViewDisplay" style="height: 20vh"></div>
|
||||||
:id="mapContainerId"
|
|
||||||
ref="mobileMapContainerRef"
|
|
||||||
style="height: 20vh"
|
|
||||||
></div>
|
|
||||||
</q-expansion-item>
|
</q-expansion-item>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
@ -711,8 +374,4 @@ defineExpose({
|
||||||
.expanAS.q-item__section--avatar {
|
.expanAS.q-item__section--avatar {
|
||||||
min-width: 40px !important;
|
min-width: 40px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-hidden {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { nextTick, onBeforeUnmount, onMounted, shallowRef, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { loadModules } from 'esri-loader'
|
import { loadModules } from 'esri-loader'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import markerRedUrl from '@/assets/markers/marker-red.svg?url'
|
|
||||||
|
import type { LocationObject } from '@/interface/index/Main'
|
||||||
|
|
||||||
const emit = defineEmits(['update:location'])
|
const emit = defineEmits(['update:location'])
|
||||||
|
|
||||||
|
|
@ -19,67 +20,8 @@ const apiKey = ref<string>(
|
||||||
// 'AAPK4f700a4324d04e9f8a1a134e0771ac45FXWawdCl-OotFfr52gz9XKxTDJTpDzw_YYcwbmKDDyAJswf14FoPyw0qBkN64DvP'
|
// 'AAPK4f700a4324d04e9f8a1a134e0771ac45FXWawdCl-OotFfr52gz9XKxTDJTpDzw_YYcwbmKDDyAJswf14FoPyw0qBkN64DvP'
|
||||||
)
|
)
|
||||||
const zoomMap = ref<number>(18)
|
const zoomMap = ref<number>(18)
|
||||||
const mapViewRef = shallowRef<any>(null)
|
|
||||||
const mapContainerRef = ref<HTMLElement | null>(null)
|
|
||||||
const mapRenderKey = ref<number>(0)
|
|
||||||
let resizeTimer: ReturnType<typeof setTimeout> | null = null
|
|
||||||
let resizeRetryCount = 0
|
|
||||||
const MAX_RESIZE_RETRY = 8
|
|
||||||
const isRecreatingMap = ref<boolean>(false)
|
|
||||||
|
|
||||||
function scheduleMapResize() {
|
|
||||||
if (resizeTimer) {
|
|
||||||
clearTimeout(resizeTimer)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delay a little to wait for viewport + CSS layout to settle after rotation.
|
|
||||||
resizeTimer = setTimeout(async () => {
|
|
||||||
await nextTick()
|
|
||||||
|
|
||||||
if (!mapViewRef.value || !mapContainerRef.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const container = mapContainerRef.value
|
|
||||||
const mapView = mapViewRef.value
|
|
||||||
|
|
||||||
if (container.clientWidth === 0 || container.clientHeight === 0) {
|
|
||||||
if (resizeRetryCount < MAX_RESIZE_RETRY) {
|
|
||||||
resizeRetryCount += 1
|
|
||||||
scheduleMapResize()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resizeRetryCount = 0
|
|
||||||
|
|
||||||
// Force canvas to bind to the current element after repeated rotations.
|
|
||||||
if (mapView.container !== container) {
|
|
||||||
mapView.container = null
|
|
||||||
await nextTick()
|
|
||||||
mapView.container = container
|
|
||||||
}
|
|
||||||
|
|
||||||
mapView.resize()
|
|
||||||
mapView
|
|
||||||
.goTo(
|
|
||||||
{
|
|
||||||
center: mapView.center,
|
|
||||||
zoom: mapView.zoom,
|
|
||||||
},
|
|
||||||
{ animate: false }
|
|
||||||
)
|
|
||||||
.catch(() => {
|
|
||||||
// Ignore interruption errors from rapid orientation changes.
|
|
||||||
})
|
|
||||||
}, 300)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initializeMap() {
|
async function initializeMap() {
|
||||||
if (mapViewRef.value || !mapContainerRef.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load modules of ArcGIS
|
// Load modules of ArcGIS
|
||||||
loadModules([
|
loadModules([
|
||||||
|
|
@ -125,7 +67,7 @@ async function initializeMap() {
|
||||||
|
|
||||||
// สร้าง MapView
|
// สร้าง MapView
|
||||||
const mapView = new MapView({
|
const mapView = new MapView({
|
||||||
container: mapContainerRef.value, // div ที่จะแสดงแผนที่
|
container: 'mapViewDisplay', // div ที่จะแสดงแผนที่
|
||||||
map: map,
|
map: map,
|
||||||
center: {
|
center: {
|
||||||
latitude: latitude,
|
latitude: latitude,
|
||||||
|
|
@ -137,11 +79,10 @@ async function initializeMap() {
|
||||||
components: [], // Empty array to remove all default UI components
|
components: [], // Empty array to remove all default UI components
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
mapViewRef.value = mapView
|
|
||||||
|
|
||||||
// สร้างสัญลักษณ์ของหมุด
|
// สร้างสัญลักษณ์ของหมุด
|
||||||
const markerSymbol = new PictureMarkerSymbol({
|
const markerSymbol = new PictureMarkerSymbol({
|
||||||
url: markerRedUrl,
|
url: 'https://maps.google.com/mapfiles/ms/icons/red-dot.png', // รูปหมุด
|
||||||
width: '32px',
|
width: '32px',
|
||||||
height: '32px',
|
height: '32px',
|
||||||
})
|
})
|
||||||
|
|
@ -157,42 +98,9 @@ async function initializeMap() {
|
||||||
position: 'top-right', // ตำแหน่งของ Search widget
|
position: 'top-right', // ตำแหน่งของ Search widget
|
||||||
})
|
})
|
||||||
|
|
||||||
// ถ้าได้ token จาก กทม. มา
|
|
||||||
// await axios
|
|
||||||
// .get(
|
|
||||||
// 'https://bmagis.bangkok.go.th/portal/sharing/servers/e4732c3a9fe549ab8bc697573b468f68/rest/services/World/GeocodeServer/reverseGeocode/',
|
|
||||||
// {
|
|
||||||
// params: {
|
|
||||||
// f: 'json', // Format JSON response
|
|
||||||
// distance: 2000,
|
|
||||||
// category: 'POI',
|
|
||||||
// location: {
|
|
||||||
// spatialReference: { wkid: 4326 },
|
|
||||||
// x: longitude,
|
|
||||||
// y: latitude,
|
|
||||||
// },
|
|
||||||
// token: apiKey.value,
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
// .then((response) => {
|
|
||||||
// console.log('poi', response.data.location)
|
|
||||||
// poiPlaceName.value = response.data.address
|
|
||||||
// ? response.data.address.PlaceName === ''
|
|
||||||
// ? response.data.address.ShortLabel
|
|
||||||
// : response.data.address.PlaceName
|
|
||||||
// : 'ไม่พบข้อมูล'
|
|
||||||
// const poiPoint = new Point({
|
|
||||||
// longitude: response.data.location.x,
|
|
||||||
// latitude: response.data.location.y,
|
|
||||||
// })
|
|
||||||
|
|
||||||
// updateLocation(latitude, longitude, poiPlaceName.value)
|
|
||||||
// })
|
|
||||||
// .catch(async () => {
|
|
||||||
await axios
|
await axios
|
||||||
.get(
|
.get(
|
||||||
'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode/',
|
'https://bmagis.bangkok.go.th/portal/sharing/servers/e4732c3a9fe549ab8bc697573b468f68/rest/services/World/GeocodeServer/reverseGeocode/',
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
f: 'json', // Format JSON response
|
f: 'json', // Format JSON response
|
||||||
|
|
@ -203,20 +111,52 @@ async function initializeMap() {
|
||||||
x: longitude,
|
x: longitude,
|
||||||
y: latitude,
|
y: latitude,
|
||||||
},
|
},
|
||||||
|
token: apiKey.value,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// console.log('poi', response.data.location)
|
console.log('poi', response.data.location)
|
||||||
poiPlaceName.value = response.data.address
|
poiPlaceName.value = response.data.address
|
||||||
? response.data.address.PlaceName === ''
|
? response.data.address.PlaceName === ''
|
||||||
? response.data.address.ShortLabel
|
? response.data.address.ShortLabel
|
||||||
: response.data.address.PlaceName
|
: response.data.address.PlaceName
|
||||||
: 'ไม่พบข้อมูล'
|
: 'ไม่พบข้อมูล'
|
||||||
|
const poiPoint = new Point({
|
||||||
|
longitude: response.data.location.x,
|
||||||
|
latitude: response.data.location.y,
|
||||||
|
})
|
||||||
|
|
||||||
updateLocation(longitude, latitude, poiPlaceName.value)
|
updateLocation(latitude, longitude, poiPlaceName.value)
|
||||||
|
})
|
||||||
|
.catch(async () => {
|
||||||
|
await axios
|
||||||
|
.get(
|
||||||
|
'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode/',
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
f: 'json', // Format JSON response
|
||||||
|
distance: 2000,
|
||||||
|
category: 'POI',
|
||||||
|
location: {
|
||||||
|
spatialReference: { wkid: 4326 },
|
||||||
|
x: longitude,
|
||||||
|
y: latitude,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((response) => {
|
||||||
|
// console.log('poi', response.data.location)
|
||||||
|
poiPlaceName.value = response.data.address
|
||||||
|
? response.data.address.PlaceName === ''
|
||||||
|
? response.data.address.ShortLabel
|
||||||
|
: response.data.address.PlaceName
|
||||||
|
: 'ไม่พบข้อมูล'
|
||||||
|
|
||||||
|
updateLocation(longitude, latitude, poiPlaceName.value)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
// })
|
|
||||||
|
|
||||||
let searchMarker: any = null
|
let searchMarker: any = null
|
||||||
|
|
||||||
|
|
@ -246,41 +186,9 @@ async function initializeMap() {
|
||||||
symbol: markerSymbol,
|
symbol: markerSymbol,
|
||||||
})
|
})
|
||||||
if (searchMarker) {
|
if (searchMarker) {
|
||||||
// await axios
|
|
||||||
// .get(
|
|
||||||
// 'https://bmagis.bangkok.go.th/portal/sharing/servers/e4732c3a9fe549ab8bc697573b468f68/rest/services/World/GeocodeServer/reverseGeocode/',
|
|
||||||
// {
|
|
||||||
// params: {
|
|
||||||
// f: 'json', // Format JSON response
|
|
||||||
// distance: 2000,
|
|
||||||
// category: 'POI',
|
|
||||||
// location: {
|
|
||||||
// spatialReference: { wkid: 4326 },
|
|
||||||
// x: longitude,
|
|
||||||
// y: latitude,
|
|
||||||
// },
|
|
||||||
// token: apiKey.value,
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
// .then((response) => {
|
|
||||||
// console.log('poi', response.data.location)
|
|
||||||
// poiPlaceName.value = response.data.address
|
|
||||||
// ? response.data.address.PlaceName === ''
|
|
||||||
// ? response.data.address.ShortLabel
|
|
||||||
// : response.data.address.PlaceName
|
|
||||||
// : 'ไม่พบข้อมูล'
|
|
||||||
// const poiPoint = new Point({
|
|
||||||
// longitude: response.data.location.x,
|
|
||||||
// latitude: response.data.location.y,
|
|
||||||
// })
|
|
||||||
|
|
||||||
// updateLocation(latitude, longitude, poiPlaceName.value)
|
|
||||||
// })
|
|
||||||
// .catch(async () => {
|
|
||||||
await axios
|
await axios
|
||||||
.get(
|
.get(
|
||||||
'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode/',
|
'https://bmagis.bangkok.go.th/portal/sharing/servers/e4732c3a9fe549ab8bc697573b468f68/rest/services/World/GeocodeServer/reverseGeocode/',
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
f: 'json', // Format JSON response
|
f: 'json', // Format JSON response
|
||||||
|
|
@ -291,20 +199,52 @@ async function initializeMap() {
|
||||||
x: longitude,
|
x: longitude,
|
||||||
y: latitude,
|
y: latitude,
|
||||||
},
|
},
|
||||||
|
token: apiKey.value,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// console.log('poi', response.data.location)
|
console.log('poi', response.data.location)
|
||||||
poiPlaceName.value = response.data.address
|
poiPlaceName.value = response.data.address
|
||||||
? response.data.address.PlaceName === ''
|
? response.data.address.PlaceName === ''
|
||||||
? response.data.address.ShortLabel
|
? response.data.address.ShortLabel
|
||||||
: response.data.address.PlaceName
|
: response.data.address.PlaceName
|
||||||
: 'ไม่พบข้อมูล'
|
: 'ไม่พบข้อมูล'
|
||||||
|
const poiPoint = new Point({
|
||||||
|
longitude: response.data.location.x,
|
||||||
|
latitude: response.data.location.y,
|
||||||
|
})
|
||||||
|
|
||||||
updateLocation(longitude, latitude, poiPlaceName.value)
|
updateLocation(latitude, longitude, poiPlaceName.value)
|
||||||
|
})
|
||||||
|
.catch(async () => {
|
||||||
|
await axios
|
||||||
|
.get(
|
||||||
|
'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode/',
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
f: 'json', // Format JSON response
|
||||||
|
distance: 2000,
|
||||||
|
category: 'POI',
|
||||||
|
location: {
|
||||||
|
spatialReference: { wkid: 4326 },
|
||||||
|
x: longitude,
|
||||||
|
y: latitude,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((response) => {
|
||||||
|
// console.log('poi', response.data.location)
|
||||||
|
poiPlaceName.value = response.data.address
|
||||||
|
? response.data.address.PlaceName === ''
|
||||||
|
? response.data.address.ShortLabel
|
||||||
|
: response.data.address.PlaceName
|
||||||
|
: 'ไม่พบข้อมูล'
|
||||||
|
|
||||||
|
updateLocation(longitude, latitude, poiPlaceName.value)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mapView.graphics.add(searchMarker)
|
mapView.graphics.add(searchMarker)
|
||||||
|
|
@ -335,41 +275,9 @@ async function initializeMap() {
|
||||||
} else {
|
} else {
|
||||||
searchMarker.geometry = point // ย้ายหมุดไปยังตำแหน่งใหม่
|
searchMarker.geometry = point // ย้ายหมุดไปยังตำแหน่งใหม่
|
||||||
if (searchMarker) {
|
if (searchMarker) {
|
||||||
// await axios
|
|
||||||
// .get(
|
|
||||||
// 'https://bmagis.bangkok.go.th/portal/sharing/servers/e4732c3a9fe549ab8bc697573b468f68/rest/services/World/GeocodeServer/reverseGeocode/',
|
|
||||||
// {
|
|
||||||
// params: {
|
|
||||||
// f: 'json', // Format JSON response
|
|
||||||
// distance: 2000,
|
|
||||||
// category: 'POI',
|
|
||||||
// location: {
|
|
||||||
// spatialReference: { wkid: 4326 },
|
|
||||||
// x: lon,
|
|
||||||
// y: lat,
|
|
||||||
// },
|
|
||||||
// token: apiKey.value,
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
// .then((response) => {
|
|
||||||
// console.log('poi', response.data.location)
|
|
||||||
// poiPlaceName.value = response.data.address
|
|
||||||
// ? response.data.address.PlaceName === ''
|
|
||||||
// ? response.data.address.ShortLabel
|
|
||||||
// : response.data.address.PlaceName
|
|
||||||
// : 'ไม่พบข้อมูล'
|
|
||||||
// const poiPoint = new Point({
|
|
||||||
// longitude: response.data.location.x,
|
|
||||||
// latitude: response.data.location.y,
|
|
||||||
// })
|
|
||||||
|
|
||||||
// updateLocation(latitude, longitude, poiPlaceName.value)
|
|
||||||
// })
|
|
||||||
// .catch(async () => {
|
|
||||||
await axios
|
await axios
|
||||||
.get(
|
.get(
|
||||||
'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode/',
|
'https://bmagis.bangkok.go.th/portal/sharing/servers/e4732c3a9fe549ab8bc697573b468f68/rest/services/World/GeocodeServer/reverseGeocode/',
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
f: 'json', // Format JSON response
|
f: 'json', // Format JSON response
|
||||||
|
|
@ -380,20 +288,52 @@ async function initializeMap() {
|
||||||
x: lon,
|
x: lon,
|
||||||
y: lat,
|
y: lat,
|
||||||
},
|
},
|
||||||
|
token: apiKey.value,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// console.log('poi', response.data.location)
|
console.log('poi', response.data.location)
|
||||||
poiPlaceName.value = response.data.address
|
poiPlaceName.value = response.data.address
|
||||||
? response.data.address.PlaceName === ''
|
? response.data.address.PlaceName === ''
|
||||||
? response.data.address.ShortLabel
|
? response.data.address.ShortLabel
|
||||||
: response.data.address.PlaceName
|
: response.data.address.PlaceName
|
||||||
: 'ไม่พบข้อมูล'
|
: 'ไม่พบข้อมูล'
|
||||||
|
const poiPoint = new Point({
|
||||||
|
longitude: response.data.location.x,
|
||||||
|
latitude: response.data.location.y,
|
||||||
|
})
|
||||||
|
|
||||||
updateLocation(lat, lon, poiPlaceName.value)
|
updateLocation(latitude, longitude, poiPlaceName.value)
|
||||||
|
})
|
||||||
|
.catch(async () => {
|
||||||
|
await axios
|
||||||
|
.get(
|
||||||
|
'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode/',
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
f: 'json', // Format JSON response
|
||||||
|
distance: 2000,
|
||||||
|
category: 'POI',
|
||||||
|
location: {
|
||||||
|
spatialReference: { wkid: 4326 },
|
||||||
|
x: lon,
|
||||||
|
y: lat,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((response) => {
|
||||||
|
// console.log('poi', response.data.location)
|
||||||
|
poiPlaceName.value = response.data.address
|
||||||
|
? response.data.address.PlaceName === ''
|
||||||
|
? response.data.address.ShortLabel
|
||||||
|
: response.data.address.PlaceName
|
||||||
|
: 'ไม่พบข้อมูล'
|
||||||
|
|
||||||
|
updateLocation(lat, lon, poiPlaceName.value)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -410,64 +350,14 @@ async function initializeMap() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function recreateMapOnOrientationChange() {
|
|
||||||
if (isRecreatingMap.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
isRecreatingMap.value = true
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (resizeTimer) {
|
|
||||||
clearTimeout(resizeTimer)
|
|
||||||
resizeTimer = null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mapViewRef.value) {
|
|
||||||
mapViewRef.value.destroy()
|
|
||||||
mapViewRef.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
mapRenderKey.value += 1
|
|
||||||
await nextTick()
|
|
||||||
await initializeMap()
|
|
||||||
scheduleMapResize()
|
|
||||||
} finally {
|
|
||||||
isRecreatingMap.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await initializeMap()
|
await initializeMap()
|
||||||
|
|
||||||
window.addEventListener('resize', scheduleMapResize)
|
|
||||||
window.addEventListener('orientationchange', recreateMapOnOrientationChange)
|
|
||||||
window.addEventListener('pageshow', scheduleMapResize)
|
|
||||||
})
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.removeEventListener('resize', scheduleMapResize)
|
|
||||||
window.removeEventListener(
|
|
||||||
'orientationchange',
|
|
||||||
recreateMapOnOrientationChange
|
|
||||||
)
|
|
||||||
window.removeEventListener('pageshow', scheduleMapResize)
|
|
||||||
|
|
||||||
if (resizeTimer) {
|
|
||||||
clearTimeout(resizeTimer)
|
|
||||||
resizeTimer = null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mapViewRef.value) {
|
|
||||||
mapViewRef.value.destroy()
|
|
||||||
mapViewRef.value = null
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<q-card bordered flat class="col-12 bg-grey-2 shadow-0">
|
<q-card bordered flat class="col-12 bg-grey-2 shadow-0">
|
||||||
<div :key="mapRenderKey" ref="mapContainerRef" style="height: 35vh"></div>
|
<div id="mapViewDisplay" style="height: 35vh"></div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
:class="
|
:class="
|
||||||
|
|
|
||||||
|
|
@ -16,26 +16,41 @@ const modal = defineModel<boolean>('modal', {
|
||||||
|
|
||||||
// Privacy content data
|
// Privacy content data
|
||||||
const privacyContent = {
|
const privacyContent = {
|
||||||
title: 'ประกาศความเป็นส่วนตัว',
|
title: 'การคุ้มครองข้อมูลส่วนบุคคล',
|
||||||
mainText:
|
mainText:
|
||||||
'ประกาศความเป็นส่วนตัวสำหรับการลงเวลาปฏิบัติราชการผ่านระบบอิเล็กทรอนิกส์ในระบบริหารทรัพยากรบุคคลของกรุงเทพมหานคร (BMA – HRMS)',
|
'ระบบนี้มีการเก็บ และใช้ภาพถ่ายของท่าน เพื่อยืนยันตัวตนในการลงเวลาปฏิบัติราชการ ข้อมูลจะถูกใช้เฉพาะตามวัตถุประสงค์ของระบบ และจัดเก็บอย่างปลอดภัยตามกฎหมายคุ้มครองข้อมูลส่วนบุคคล (PDPA)',
|
||||||
warningText: '* หากท่านไม่กดยอมรับ อาจทำให้ไม่สามารถใช้งานระบบได้',
|
warningText: '* หากท่านไม่กดยอมรับ อาจทำให้ไม่สามารถใช้งานระบบได้',
|
||||||
detailIntro:
|
detailIntro:
|
||||||
'กรุงเทพมหานครเก็บรวบรวมและใช้ข้อมูลส่วนบุคคลของท่าน ได้แก่ ข้อมูลวันและเวลาลงเวลาปฏิบัติราชการ พิกัดสถานที่ ณ ขณะลงเวลา ภาพถ่าย ณ ขณะลงเวลา ข้อมูลหน่วยงานหรือสถานที่ปฏิบัติงาน และข้อมูลทางเทคนิคที่จำเป็นต่อการใช้งานระบบ เพื่อวัตถุประสงค์ในการยืนยันการมาปฏิบัติราชการ ป้องกันการลงเวลาแทนกัน ตรวจสอบความถูกต้องของข้อมูล บริหารวันและเวลาปฏิบัติราชการ การลา การประเมินผลการปฏิบัติราชการ การพิจารณาเลื่อนเงินเดือน ตลอดจนการบริหารทรัพยากรบุคคลตามกฎหมาย กฎ ระเบียบ และหลักเกณฑ์ที่เกี่ยวข้อง',
|
'ข้าพเจ้าตกลงให้กรุงเทพมหานครเก็บ ใช้ และประมวลผลข้อมูลส่วนบุคคลประเภทภาพถ่ายของข้าพเจ้า ซึ่งได้มาจากการใช้งานระบบลงเวลาปฏิบัติราชการอิเล็กทรอนิกส์ ของระบบบริหารทรัพยากรบุคคลของกรุงเทพมหานคร (BMA - HRMS) ทั้งนี้ เพื่อวัตถุประสงค์ดังต่อไปนี้',
|
||||||
|
purposes: {
|
||||||
paragraphs: [
|
title: 'วัตถุประสงค์การใช้ข้อมูล',
|
||||||
'การเก็บรวบรวมและใช้ข้อมูลดังกล่าวเป็นการดำเนินการโดยอาศัยฐานการปฏิบัติหน้าที่ในการดำเนินภารกิจเพื่อประโยชน์สาธารณะหรือการใช้อำนาจรัฐตามมาตรา 24 (4) และฐานการปฏิบัติตามกฎหมายของ ผู้ควบคุมข้อมูลส่วนบุคคลตามมาตรา 24 (6) แห่งพระราชบัญญัติคุ้มครองข้อมูลส่วนบุคคล พ.ศ. 2562 โดยมิได้อาศัยความยินยอมของเจ้าของข้อมูลส่วนบุคคล',
|
items: [
|
||||||
'ระบบจะเข้าถึงข้อมูลพิกัดและกล้องถ่ายภาพเฉพาะในขณะที่ท่านดำเนินการลงเวลาเข้าและออกจากการปฏิบัติราชการเท่านั้น โดยไม่มีการติดตามหรือบันทึกพิกัดของท่านอย่างต่อเนื่องภายหลังจากการลงเวลาเสร็จสิ้น',
|
'เพื่อยืนยันตัวตนของผู้ปฏิบัติงานในการบันทึกเวลาเข้า-ออกการปฏิบัติราชการ',
|
||||||
'กรุงเทพมหานครจะเก็บรักษาข้อมูลภาพถ่าย พิกัด ณ ขณะลงเวลา และข้อมูลรายละเอียดการลงเวลาไว้ตามรอบการประเมินผลการปฏิบัติราชการเป็นระยะเวลาไม่เกิน 6 เดือนนับแต่วันที่เก็บรวบรวม หรือจนกว่าการตรวจสอบข้อมูลในรอบการประเมินนั้นจะแล้วเสร็จ แล้วแต่ระยะเวลาใดจะยาวกว่า เมื่อครบกำหนด กรุงเทพมหานครจะลบ ทำลาย หรือทำให้ข้อมูลดังกล่าวไม่สามารถระบุตัวบุคคลได้ตามวิธีการและมาตรการรักษาความมั่นคงปลอดภัยที่กำหนด',
|
'เพื่อใช้เป็นหลักฐานประกอบการบริหารงานด้านทรัพยากรบุคคล การจ่ายค่าตอบแทน และการกำกับ ดูแลการปฏิบัติราชการ',
|
||||||
'กรณีข้อมูลดังกล่าวเกี่ยวข้องกับการร้องเรียน การโต้แย้ง การตรวจสอบ การดำเนินการทางวินัยการอุทธรณ์ การดำเนินคดี หรือการใช้สิทธิเรียกร้องตามกฎหมาย กรุงเทพมหานครอาจเก็บรักษาข้อมูลไว้เกินกว่า 6 เดือนได้เท่าที่จำเป็น จนกว่ากระบวนการดังกล่าวจะถึงที่สุดหรือพ้นระยะเวลาที่กฎหมายกำหนด',
|
'เพื่อรักษาความถูกต้อง โปร่งใส และป้องกันการทุจริตในการบันทึกเวลาการปฏิบัติงาน',
|
||||||
'ทั้งนี้ ข้อมูลสรุปเกี่ยวกับวันเวลาปฏิบัติราชการ การลา การมาสาย การขาดราชการ ผลการประเมินผลการปฏิบัติราชการ และผลการพิจารณาเลื่อนเงินเดือน ซึ่งเป็นส่วนหนึ่งของทะเบียนประวัติหรือเอกสารด้านการบริหารทรัพยากรบุคคล อาจได้รับการเก็บรักษาตามระยะเวลาที่กฎหมาย ระเบียบ หลักเกณฑ์งานบุคคล และระเบียบงานสารบรรณกำหนด ซึ่งอาจมีระยะเวลาแตกต่างจากข้อมูลภาพถ่ายและพิกัดที่ใช้ประกอบการลงเวลา',
|
],
|
||||||
'กรุงเทพมหานครจะจำกัดการเข้าถึงข้อมูลเฉพาะเจ้าหน้าที่หรือผู้ปฏิบัติงานที่มีหน้าที่เกี่ยวข้อง และจะไม่นำข้อมูลไปใช้หรือเปิดเผยเพื่อวัตถุประสงค์อื่นที่ไม่สอดคล้องกับวัตถุประสงค์ที่ได้แจ้งไว้ เว้นแต่เป็นกรณีที่กฎหมายกำหนดหรืออนุญาตให้ดำเนินการได้',
|
},
|
||||||
'ท่านมีสิทธิขอเข้าถึง ขอรับสำเนา ขอแก้ไข ขอคัดค้าน ขอระงับการใช้ หรือขอให้ลบข้อมูลส่วนบุคคลของท่านได้ตามหลักเกณฑ์และเงื่อนไขที่พระราชบัญญัติคุ้มครองข้อมูลส่วนบุคคล พ.ศ. 2562 กำหนด โดยการใช้สิทธิดังกล่าวไม่กระทบต่อหน้าที่ในการลงเวลาปฏิบัติราชการและการปฏิบัติตามกฎหมาย กฎ ระเบียบ และหลักเกณฑ์ของกรุงเทพมหานคร',
|
understanding: {
|
||||||
],
|
items: [
|
||||||
|
'การเก็บ ใช้ และประมวลผลข้อมูลส่วนบุคคลดังกล่าว จะดำเนินการ เท่าที่จำเป็นตามวัตถุประสงค์ที่ระบุไว้เท่านั้น',
|
||||||
|
'หน่วยงานจะจัดให้มีมาตรการรักษาความมั่นคงปลอดภัยของข้อมูลส่วนบุคคล ตามที่กฎหมายกำหนด',
|
||||||
|
'ข้อมูลส่วนบุคคลของข้าพเจ้าจะถูกเก็บรักษา ตามระยะเวลาที่จำเป็น ต่อการปฏิบัติงานหรือเป็นไปตามที่กฎหมายกำหนด',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
rights: {
|
||||||
|
title:
|
||||||
|
'ข้าพเจ้าทราบถึง สิทธิของเจ้าของข้อมูลส่วนบุคคล ตามพระราชบัญญัติคุ้มครองข้อมูลส่วนบุคคล พ.ศ. ๒๕๖๒ ได้แก่',
|
||||||
|
items: [
|
||||||
|
'สิทธิขอเข้าถึงและขอรับสำเนาข้อมูล',
|
||||||
|
'สิทธิขอแก้ไขข้อมูลให้ถูกต้อง',
|
||||||
|
'สิทธิขอถอนความยินยอม (ทั้งนี้ การถอนความยินยอมอาจส่งผลต่อการใช้งานระบบลงเวลาการปฏิบัติราชการ)',
|
||||||
|
'สิทธิร้องเรียนต่อคณะกรรมการคุ้มครองข้อมูลส่วนบุคคล',
|
||||||
|
],
|
||||||
|
},
|
||||||
consentText:
|
consentText:
|
||||||
'ข้าพเจ้าได้รับทราบประกาศความเป็นส่วนตัวเกี่ยวกับการลงเวลาปฏิบัติราชการผ่านระบบอิเล็กทรอนิกส์แล้ว',
|
'ข้าพเจ้าได้อ่านและเข้าใจรายละเอียดทั้งหมดแล้ว และยินยอมให้เก็บ ใช้ และประมวลผลข้อมูลส่วนบุคคล ประเภทภาพถ่ายของข้าพเจ้า ตามที่ระบุไว้ข้างต้นโดยสมัครใจ',
|
||||||
buttons: {
|
buttons: {
|
||||||
accept: 'รับทราบและดำเนินการต่อ',
|
accept: 'ยอมรับ',
|
||||||
decline: 'ไม่ยอมรับ',
|
decline: 'ไม่ยอมรับ',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -82,8 +97,7 @@ const toggleDetails = () => {
|
||||||
|
|
||||||
const checkIfScrollable = () => {
|
const checkIfScrollable = () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const container =
|
const container = (scrollContainer.value as any)?.$el || scrollContainer.value
|
||||||
(scrollContainer.value as any)?.$el || scrollContainer.value
|
|
||||||
if (container) {
|
if (container) {
|
||||||
const { scrollHeight, clientHeight } = container
|
const { scrollHeight, clientHeight } = container
|
||||||
|
|
||||||
|
|
@ -153,18 +167,50 @@ const checkIfScrollable = () => {
|
||||||
{{ privacyContent.detailIntro }}
|
{{ privacyContent.detailIntro }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- เนื้อหาประกาศความเป็นส่วนตัว -->
|
<!-- วัตถุประสงค์ -->
|
||||||
<div class="q-mb-md">
|
<div class="q-mb-md">
|
||||||
<p
|
<ol class="q-pl-lg list-style">
|
||||||
v-for="(paragraph, index) in privacyContent.paragraphs"
|
<li
|
||||||
:key="`p-${index}`"
|
v-for="(item, index) in privacyContent.purposes.items"
|
||||||
class="q-mb-sm"
|
:key="`p-${index}`"
|
||||||
>
|
class="q-mb-xs"
|
||||||
{{ paragraph }}
|
>
|
||||||
</p>
|
{{ item }}
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="consent-text q-mt-lg">{{ privacyContent.consentText }}</p>
|
<!-- ข้าพเจ้าทราบและเข้าใจว่า -->
|
||||||
|
<div class="q-mx-sm">
|
||||||
|
ข้าพเจ้าทราบและเข้าใจว่า
|
||||||
|
<ul class="q-mt-sm">
|
||||||
|
<li
|
||||||
|
v-for="(item, index) in privacyContent.understanding.items"
|
||||||
|
:key="`u-${index}`"
|
||||||
|
class="q-mb-xs"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- สิทธิ์ของเจ้าของข้อมูล -->
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
{{ privacyContent.rights.title }}
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li
|
||||||
|
v-for="(item, index) in privacyContent.rights.items"
|
||||||
|
:key="`r-${index}`"
|
||||||
|
class="q-mb-xs"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p class="consent-text q-mt-lg">{{ privacyContent.consentText }}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,20 @@ import SkeletonTable from '@/components/SkeletonTable.vue' // skeleton table
|
||||||
const { date2Thai } = useCounterMixin()
|
const { date2Thai } = useCounterMixin()
|
||||||
const stores = useCheckIn()
|
const stores = useCheckIn()
|
||||||
|
|
||||||
const page = defineModel<number>('page', { required: true })
|
|
||||||
const pageSize = defineModel<number>('pageSize', { required: true })
|
|
||||||
|
|
||||||
/** props ข้อมูลจาก Components Page HistoryView */
|
/** props ข้อมูลจาก Components Page HistoryView */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
paging: {
|
paging: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
pageSize: {
|
||||||
|
type: Number,
|
||||||
|
default: 10,
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
type: Number,
|
||||||
|
default: 1,
|
||||||
|
},
|
||||||
maxPage: {
|
maxPage: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 1,
|
default: 1,
|
||||||
|
|
@ -189,20 +194,31 @@ const visibleColumns = ref<string[]>([
|
||||||
'checkOutLocation',
|
'checkOutLocation',
|
||||||
'checkOutStatus',
|
'checkOutStatus',
|
||||||
])
|
])
|
||||||
const pagination = ref({
|
|
||||||
page: page.value,
|
const currentPage = ref<number>(1) //หน้าปัจจุบัน
|
||||||
rowsPerPage: pageSize.value,
|
// Pagination - initial pagination
|
||||||
|
const initialPagination = ref<Pagination>({
|
||||||
|
sortBy: null,
|
||||||
|
descending: false,
|
||||||
|
page: 1,
|
||||||
|
rowsPerPage: props.pageSize, // set ตาม page หลักส่งมา
|
||||||
})
|
})
|
||||||
|
|
||||||
// Pagination - update rowsPerPage
|
// Pagination - update rowsPerPage
|
||||||
async function updatePagination(newPagination: Pagination) {
|
async function updatePagination(newPagination: Pagination) {
|
||||||
pageSize.value = newPagination.rowsPerPage
|
initialPagination.value = newPagination
|
||||||
|
currentPage.value = 1 // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
||||||
}
|
}
|
||||||
|
|
||||||
async function filterFn() {
|
async function filterFn() {
|
||||||
emit('update:change-page', 1, pageSize.value, keyword.value)
|
// ส่งอีเวนต์ 'update:change-page' เมื่อหน้าเปลี่ยนแปลง
|
||||||
|
emit(
|
||||||
|
'update:change-page',
|
||||||
|
1,
|
||||||
|
initialPagination.value.rowsPerPage,
|
||||||
|
keyword.value
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const modalPopup = ref<boolean>(false) // popup แก้ไขลงเวลา
|
const modalPopup = ref<boolean>(false) // popup แก้ไขลงเวลา
|
||||||
const titlePopup = ref<string>('') // หัวขข้อ popup แก้ไขลงเวลา
|
const titlePopup = ref<string>('') // หัวขข้อ popup แก้ไขลงเวลา
|
||||||
const dataRow = ref<DataCheckIn>() // ข้อมูลการลงเวลา
|
const dataRow = ref<DataCheckIn>() // ข้อมูลการลงเวลา
|
||||||
|
|
@ -260,15 +276,17 @@ function onClickOpenPopupRejrct(data: DataCheckIn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUpdatePage(val: number) {
|
/** watch currentPage และ rowsPerPage*/
|
||||||
emit('update:change-page', val, pageSize.value, keyword.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** watch pageSize*/
|
|
||||||
watch(
|
watch(
|
||||||
() => pageSize.value,
|
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
||||||
() => {
|
() => {
|
||||||
emit('update:change-page', 1, pageSize.value, keyword.value)
|
// ส่งอีเวนต์ 'update:change-page' เมื่อหน้าเปลี่ยนแปลง
|
||||||
|
emit(
|
||||||
|
'update:change-page',
|
||||||
|
currentPage.value,
|
||||||
|
initialPagination.value.rowsPerPage,
|
||||||
|
keyword.value
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -322,10 +340,10 @@ watch(
|
||||||
v-model:selected="selected"
|
v-model:selected="selected"
|
||||||
:virtual-scroll-sticky-size-start="48"
|
:virtual-scroll-sticky-size-start="48"
|
||||||
:style="$q.screen.gt.xs ? 'max-height: 64vh' : ''"
|
:style="$q.screen.gt.xs ? 'max-height: 64vh' : ''"
|
||||||
:rows-per-page-options="[1, 10, 25, 50, 100]"
|
:rows-per-page-options="[10, 25, 50, 100]"
|
||||||
:grid="$q.screen.gt.xs ? false : true"
|
:grid="$q.screen.gt.xs ? false : true"
|
||||||
|
:pagination="initialPagination"
|
||||||
@update:pagination="updatePagination"
|
@update:pagination="updatePagination"
|
||||||
v-model:pagination="pagination"
|
|
||||||
>
|
>
|
||||||
<template v-slot:header="props">
|
<template v-slot:header="props">
|
||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
|
|
@ -458,11 +476,10 @@ watch(
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:pagination>
|
<template v-slot:pagination>
|
||||||
ทั้งหมด {{ props.total }} รายการ
|
ทั้งหมด {{ props.total }} รายการ
|
||||||
<q-pagination
|
<q-pagination
|
||||||
v-model="page"
|
v-model="currentPage"
|
||||||
active-color="primary"
|
active-color="primary"
|
||||||
color="dark"
|
color="dark"
|
||||||
:max-pages="5"
|
:max-pages="5"
|
||||||
|
|
@ -470,7 +487,6 @@ watch(
|
||||||
boundary-links
|
boundary-links
|
||||||
direction-links
|
direction-links
|
||||||
:max="Number(props.maxPage)"
|
:max="Number(props.maxPage)"
|
||||||
@update:model-value="onUpdatePage"
|
|
||||||
></q-pagination>
|
></q-pagination>
|
||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
|
|
|
||||||
|
|
@ -1,171 +1,52 @@
|
||||||
import { onBeforeUnmount, ref } from 'vue'
|
import { useQuasar } from 'quasar'
|
||||||
import { usePrivacyStore } from '@/stores/privacy'
|
import { usePrivacyStore } from '@/stores/privacy'
|
||||||
|
|
||||||
type BrowserPermissionState = PermissionState | 'unsupported'
|
|
||||||
|
|
||||||
type PermissionQueryName = 'camera' | 'geolocation'
|
|
||||||
|
|
||||||
export function usePermissions() {
|
export function usePermissions() {
|
||||||
|
const $q = useQuasar()
|
||||||
const privacyStore = usePrivacyStore()
|
const privacyStore = usePrivacyStore()
|
||||||
const cameraPermissionState = ref<BrowserPermissionState>('prompt')
|
|
||||||
const locationPermissionState = ref<BrowserPermissionState>('prompt')
|
|
||||||
|
|
||||||
let cameraPermissionStatus: PermissionStatus | null = null
|
// const checkCameraPermission = (): boolean => {
|
||||||
let locationPermissionStatus: PermissionStatus | null = null
|
// if (!privacyStore.isAccepted) {
|
||||||
|
// privacyStore.modalPrivacy = true
|
||||||
|
// $q.notify({
|
||||||
|
// type: 'warning',
|
||||||
|
// message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานกล้อง',
|
||||||
|
// position: 'top',
|
||||||
|
// })
|
||||||
|
// return false
|
||||||
|
// }
|
||||||
|
// return true
|
||||||
|
// }
|
||||||
|
|
||||||
const isPermissionsApiSupported = () =>
|
// const checkLocationPermission = (): boolean => {
|
||||||
typeof navigator !== 'undefined' && 'permissions' in navigator
|
// if (!privacyStore.isAccepted) {
|
||||||
|
// privacyStore.modalPrivacy = true
|
||||||
const setPermissionState = (
|
// $q.notify({
|
||||||
target: typeof cameraPermissionState | typeof locationPermissionState,
|
// type: 'warning',
|
||||||
state: BrowserPermissionState
|
// message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานแผนที่',
|
||||||
) => {
|
// position: 'top',
|
||||||
target.value = state
|
// })
|
||||||
}
|
// return false
|
||||||
|
// }
|
||||||
const setPermissionChangeListener = (
|
// return true
|
||||||
name: PermissionQueryName,
|
// }
|
||||||
status: PermissionStatus
|
|
||||||
) => {
|
|
||||||
status.onchange = () => {
|
|
||||||
const target =
|
|
||||||
name === 'camera' ? cameraPermissionState : locationPermissionState
|
|
||||||
setPermissionState(target, status.state)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function queryPermissionState(name: PermissionQueryName) {
|
|
||||||
if (!isPermissionsApiSupported()) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return await navigator.permissions.query({ name } as PermissionDescriptor)
|
|
||||||
} catch (error) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function syncPermissionState(name: PermissionQueryName) {
|
|
||||||
const target =
|
|
||||||
name === 'camera' ? cameraPermissionState : locationPermissionState
|
|
||||||
const previousStatus =
|
|
||||||
name === 'camera' ? cameraPermissionStatus : locationPermissionStatus
|
|
||||||
|
|
||||||
if (previousStatus) {
|
|
||||||
previousStatus.onchange = null
|
|
||||||
}
|
|
||||||
|
|
||||||
const status = await queryPermissionState(name)
|
|
||||||
if (!status) {
|
|
||||||
if (target.value === 'prompt') {
|
|
||||||
setPermissionState(target, 'unsupported')
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name === 'camera') {
|
|
||||||
cameraPermissionStatus = status
|
|
||||||
} else {
|
|
||||||
locationPermissionStatus = status
|
|
||||||
}
|
|
||||||
|
|
||||||
setPermissionState(target, status.state)
|
|
||||||
setPermissionChangeListener(name, status)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function syncPermissionStates() {
|
|
||||||
await Promise.all([
|
|
||||||
syncPermissionState('camera'),
|
|
||||||
syncPermissionState('geolocation'),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
const checkPrivacyAccepted = (): boolean => {
|
const checkPrivacyAccepted = (): boolean => {
|
||||||
if (!privacyStore.isAccepted) {
|
if (!privacyStore.isAccepted) {
|
||||||
privacyStore.modalPrivacy = true
|
privacyStore.modalPrivacy = true
|
||||||
|
// $q.notify({
|
||||||
|
// type: 'warning',
|
||||||
|
// message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งาน',
|
||||||
|
// position: 'center',
|
||||||
|
// })
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function requestCameraPermission() {
|
|
||||||
if (!checkPrivacyAccepted()) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cameraPermissionState.value === 'granted') {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!navigator.mediaDevices?.getUserMedia) {
|
|
||||||
setPermissionState(cameraPermissionState, 'unsupported')
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({
|
|
||||||
video: { facingMode: 'user' },
|
|
||||||
audio: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
stream.getTracks().forEach((track) => track.stop())
|
|
||||||
setPermissionState(cameraPermissionState, 'granted')
|
|
||||||
return true
|
|
||||||
} catch (error) {
|
|
||||||
setPermissionState(cameraPermissionState, 'denied')
|
|
||||||
return false
|
|
||||||
} finally {
|
|
||||||
await syncPermissionState('camera')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function requestLocationPermission() {
|
|
||||||
if (!checkPrivacyAccepted()) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (locationPermissionState.value === 'granted') {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!navigator.geolocation) {
|
|
||||||
setPermissionState(locationPermissionState, 'unsupported')
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise<boolean>((resolve) => {
|
|
||||||
navigator.geolocation.getCurrentPosition(
|
|
||||||
async () => {
|
|
||||||
setPermissionState(locationPermissionState, 'granted')
|
|
||||||
await syncPermissionState('geolocation')
|
|
||||||
resolve(true)
|
|
||||||
},
|
|
||||||
async () => {
|
|
||||||
setPermissionState(locationPermissionState, 'denied')
|
|
||||||
await syncPermissionState('geolocation')
|
|
||||||
resolve(false)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
if (cameraPermissionStatus) {
|
|
||||||
cameraPermissionStatus.onchange = null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (locationPermissionStatus) {
|
|
||||||
locationPermissionStatus.onchange = null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cameraPermissionState,
|
// checkCameraPermission,
|
||||||
locationPermissionState,
|
// checkLocationPermission,
|
||||||
checkPrivacyAccepted,
|
checkPrivacyAccepted,
|
||||||
syncPermissionStates,
|
|
||||||
requestCameraPermission,
|
|
||||||
requestLocationPermission,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ interface Pagination {
|
||||||
sortBy: string | null
|
sortBy: string | null
|
||||||
descending: boolean
|
descending: boolean
|
||||||
page: number
|
page: number
|
||||||
rowsPerPage: number
|
rowsPerPage: number | undefined
|
||||||
}
|
}
|
||||||
interface DataCheckIn {
|
interface DataCheckIn {
|
||||||
checkInDate: string
|
checkInDate: string
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,6 @@ import 'quasar/src/css/index.sass'
|
||||||
import th from 'quasar/lang/th'
|
import th from 'quasar/lang/th'
|
||||||
|
|
||||||
import http from '@/plugins/http'
|
import http from '@/plugins/http'
|
||||||
import { forceOpenInExternalBrowser } from '@/utils/forceExternalBrowser'
|
|
||||||
|
|
||||||
forceOpenInExternalBrowser()
|
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import MainView from '@/views/MainView.vue'
|
||||||
|
|
||||||
const loginView = () => import('@/views/login.vue')
|
const loginView = () => import('@/views/login.vue')
|
||||||
const resetPasswordView = () => import('@/views/ResetPassword.vue')
|
const resetPasswordView = () => import('@/views/ResetPassword.vue')
|
||||||
const noPositionView = () => import('@/views/NoPositionView.vue')
|
|
||||||
|
|
||||||
import { authenticated, logout } from '@/plugins/auth'
|
import { authenticated, logout } from '@/plugins/auth'
|
||||||
|
|
||||||
|
|
@ -88,63 +87,19 @@ const router = createRouter({
|
||||||
Auth: false,
|
Auth: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/no-position',
|
|
||||||
name: 'no-position',
|
|
||||||
component: noPositionView,
|
|
||||||
meta: {
|
|
||||||
Auth: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
// authen with keycloak client
|
// authen with keycloak client
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
// ตรวจสอบเส้นทางพิเศษที่ไม่ต้องตรวจสอบสิทธิ์
|
|
||||||
const publicPaths = ['/login', '/auth', '/reset-password', '/no-position']
|
|
||||||
if (publicPaths.includes(to.path)) {
|
|
||||||
next()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// ตรวจสอบการ authenticate
|
|
||||||
if (to.meta.Auth) {
|
if (to.meta.Auth) {
|
||||||
const checkAuthen = await authenticated()
|
const checkAuthen = await authenticated()
|
||||||
if (!checkAuthen && to.meta.Auth) {
|
if (!checkAuthen && to.meta.Auth) {
|
||||||
logout()
|
logout()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ตรวจสอบว่าผู้ใช้มีข้อมูลสังกัดหรือไม่
|
|
||||||
// ต้องทำการ dynamic import เนื่องจากเป็นการใช้งาน Pinia store ใน router
|
|
||||||
if (to.path !== '/no-position') {
|
|
||||||
try {
|
|
||||||
const { usePositionKeycloakStore } = await import('@/stores/positionKeycloak')
|
|
||||||
const positionKeycloakStore = usePositionKeycloakStore()
|
|
||||||
const dataPositionKeycloak = positionKeycloakStore.dataPositionKeycloak
|
|
||||||
|
|
||||||
// ถ้ามีข้อมูล positionKeycloak แล้ว ให้ตรวจสอบว่ามี organization หรือไม่
|
|
||||||
if (dataPositionKeycloak) {
|
|
||||||
const hasOrganization =
|
|
||||||
dataPositionKeycloak.organization &&
|
|
||||||
(dataPositionKeycloak.organization.root ||
|
|
||||||
dataPositionKeycloak.organization.child1 ||
|
|
||||||
dataPositionKeycloak.organization.child2 ||
|
|
||||||
dataPositionKeycloak.organization.child3 ||
|
|
||||||
dataPositionKeycloak.organization.child4)
|
|
||||||
|
|
||||||
if (!hasOrganization) {
|
|
||||||
next('/no-position')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error checking position:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,26 +11,16 @@ export const usePositionKeycloakStore = defineStore(
|
||||||
'รายการลงเวลากรณีพิเศษ',
|
'รายการลงเวลากรณีพิเศษ',
|
||||||
])
|
])
|
||||||
const dataPositionKeycloak = ref<KeycloakPosition | null>(null)
|
const dataPositionKeycloak = ref<KeycloakPosition | null>(null)
|
||||||
const profileImg = ref<string>('')
|
|
||||||
|
|
||||||
function setPositionKeycloak(data: KeycloakPosition) {
|
function setPositionKeycloak(data: KeycloakPosition) {
|
||||||
dataPositionKeycloak.value = data
|
dataPositionKeycloak.value = data
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ตั้งค่ารูปโปรไฟล์ผู้ใช้งาน
|
|
||||||
* @param url URL ของรูปโปรไฟล์
|
|
||||||
*/
|
|
||||||
function setProfileImg(url: string) {
|
|
||||||
profileImg.value = url
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ล้างข้อมูล Keycloak position (ใช้เมื่อ logout)
|
* ล้างข้อมูล Keycloak position (ใช้เมื่อ logout)
|
||||||
*/
|
*/
|
||||||
function clearPositionKeycloak() {
|
function clearPositionKeycloak() {
|
||||||
dataPositionKeycloak.value = null
|
dataPositionKeycloak.value = null
|
||||||
profileImg.value = ''
|
|
||||||
// ลบ localStorage ด้วยเพื่อให้แน่ใจว่าข้อมูลหายจริง
|
// ลบ localStorage ด้วยเพื่อให้แน่ใจว่าข้อมูลหายจริง
|
||||||
localStorage.removeItem('positionKeycloak')
|
localStorage.removeItem('positionKeycloak')
|
||||||
}
|
}
|
||||||
|
|
@ -62,9 +52,7 @@ export const usePositionKeycloakStore = defineStore(
|
||||||
return {
|
return {
|
||||||
setPositionKeycloak,
|
setPositionKeycloak,
|
||||||
clearPositionKeycloak,
|
clearPositionKeycloak,
|
||||||
setProfileImg,
|
|
||||||
dataPositionKeycloak,
|
dataPositionKeycloak,
|
||||||
profileImg,
|
|
||||||
findOrgName,
|
findOrgName,
|
||||||
menuData,
|
menuData,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
import { ref } from 'vue'
|
|
||||||
import config from '@/app.config'
|
|
||||||
import { getToken } from '@/plugins/auth'
|
|
||||||
import { defineStore } from 'pinia'
|
|
||||||
import { Notify } from 'quasar'
|
|
||||||
import { io, Socket } from 'socket.io-client'
|
|
||||||
interface sockeBackup {
|
|
||||||
message: string
|
|
||||||
success?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useSocketStore = defineStore('socket', () => {
|
|
||||||
let socket: Socket
|
|
||||||
const notificationCounter = ref(0);
|
|
||||||
|
|
||||||
async function init() {
|
|
||||||
socket = io(new URL(config.API.socket).origin, {
|
|
||||||
auth: { token: await getToken() },
|
|
||||||
path: '/api/v1/org-socket',
|
|
||||||
})
|
|
||||||
|
|
||||||
socket.on('socket-notification', (payload) => {
|
|
||||||
let body: sockeBackup = JSON.parse(payload)
|
|
||||||
notificationCounter.value++
|
|
||||||
notifyStatus(body.message, body.success)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function notifyStatus(message: string, success?: boolean) {
|
|
||||||
Notify.create({
|
|
||||||
group: false,
|
|
||||||
type: success === undefined || success ? 'positive' : 'negative',
|
|
||||||
message: `${message}`,
|
|
||||||
position: 'top',
|
|
||||||
classes: 'custom-notification-top', // ใส่ class ที่เราสร้างไว้
|
|
||||||
timeout: success === undefined || success ? 3000 : 0,
|
|
||||||
actions:
|
|
||||||
success === undefined || success
|
|
||||||
? []
|
|
||||||
: [
|
|
||||||
{
|
|
||||||
icon: 'close',
|
|
||||||
color: 'white',
|
|
||||||
round: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
progress: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function fnStyleNotiOrg() {
|
|
||||||
if (document.getElementById('notify-link-style')) return
|
|
||||||
const style = document.createElement('style')
|
|
||||||
style.id = 'notify-link-style'
|
|
||||||
style.textContent = `
|
|
||||||
.notify-link {
|
|
||||||
padding: 4px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
text-decoration: none;
|
|
||||||
color: #fff;
|
|
||||||
border: 1px solid #fff;
|
|
||||||
transition: all 0.3s;
|
|
||||||
cursor: pointer;
|
|
||||||
margin:0 0 0 5px;
|
|
||||||
}
|
|
||||||
.notify-link:hover {
|
|
||||||
background-color: #ffffff;
|
|
||||||
color: #21BA45;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
document.head.appendChild(style)
|
|
||||||
}
|
|
||||||
;(window as any).resetOrgPage = (type: string) => {
|
|
||||||
localStorage.setItem('org_type', type)
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
function notifyStatusOrg(type: string, message: string, success?: boolean) {
|
|
||||||
fnStyleNotiOrg()
|
|
||||||
Notify.create({
|
|
||||||
message: `${message} <a href="#" onclick="window.resetOrgPage('${type}')" class="notify-link">${
|
|
||||||
type == 'draft' ? 'ไปยังโครงสร้างแบบร่าง' : 'ไปยังโครงสร้างปัจจุบัน'
|
|
||||||
}</a>`,
|
|
||||||
html: true,
|
|
||||||
group: false,
|
|
||||||
type: success === undefined || success ? 'positive' : 'negative',
|
|
||||||
position: 'top',
|
|
||||||
timeout: 0,
|
|
||||||
actions: [
|
|
||||||
{
|
|
||||||
icon: 'close',
|
|
||||||
color: 'white',
|
|
||||||
round: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
init()
|
|
||||||
|
|
||||||
return { notificationCounter }
|
|
||||||
})
|
|
||||||
|
|
@ -69,30 +69,30 @@ div
|
||||||
$separator-color: #EDEDED !default
|
$separator-color: #EDEDED !default
|
||||||
|
|
||||||
.bg-teal-1
|
.bg-teal-1
|
||||||
background: #e0f2f1a6 !important
|
background: #e0f2f1a6 !important
|
||||||
|
|
||||||
.table_ellipsis
|
.table_ellipsis
|
||||||
max-width: 200px
|
max-width: 200px
|
||||||
white-space: nowrap
|
white-space: nowrap
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
text-overflow: ellipsis
|
text-overflow: ellipsis
|
||||||
|
|
||||||
.table_ellipsis:hover
|
.table_ellipsis:hover
|
||||||
word-wrap: break-word
|
word-wrap: break-word
|
||||||
overflow: visible
|
overflow: visible
|
||||||
white-space: normal
|
white-space: normal
|
||||||
|
|
||||||
.table_ellipsis2
|
.table_ellipsis2
|
||||||
max-width: 25vw
|
max-width: 25vw
|
||||||
white-space: nowrap
|
white-space: nowrap
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
text-overflow: ellipsis
|
text-overflow: ellipsis
|
||||||
|
|
||||||
.table_ellipsis2:hover
|
.table_ellipsis2:hover
|
||||||
word-wrap: break-word
|
word-wrap: break-word
|
||||||
overflow: visible
|
overflow: visible
|
||||||
white-space: normal
|
white-space: normal
|
||||||
transition: width 2s
|
transition: width 2s
|
||||||
|
|
||||||
$muti-tab: #87d4cc
|
$muti-tab: #87d4cc
|
||||||
.text-muti-tab
|
.text-muti-tab
|
||||||
|
|
@ -100,33 +100,35 @@ $muti-tab: #87d4cc
|
||||||
.bg-muti-tab
|
.bg-muti-tab
|
||||||
background: $muti-tab !important
|
background: $muti-tab !important
|
||||||
|
|
||||||
|
|
||||||
/* editor */
|
/* editor */
|
||||||
|
|
||||||
.q-editor
|
.q-editor
|
||||||
font-size: 1rem
|
font-size: 1rem
|
||||||
line-height: 1.5rem
|
line-height: 1.5rem
|
||||||
font-weight: 400
|
font-weight: 400
|
||||||
|
|
||||||
.q-editor h1, .q-menu h1
|
.q-editor h1, .q-menu h1
|
||||||
font-size: 1.5rem
|
font-size: 1.5rem
|
||||||
line-height: 2rem
|
line-height: 2rem
|
||||||
font-weight: 400
|
font-weight: 400
|
||||||
margin-block-start: 0em
|
margin-block-start: 0em
|
||||||
margin-block-end: 0em
|
margin-block-end: 0em
|
||||||
|
|
||||||
.q-editor h2, .q-menu h2
|
.q-editor h2, .q-menu h2
|
||||||
font-size: 1.25rem
|
font-size: 1.25rem
|
||||||
line-height: 1.5rem
|
line-height: 1.5rem
|
||||||
font-weight: 400
|
font-weight: 400
|
||||||
margin-block-start: 0em
|
margin-block-start: 0em
|
||||||
margin-block-end: 0em
|
margin-block-end: 0em
|
||||||
|
|
||||||
|
|
||||||
.q-editor h3, .q-menu h3
|
.q-editor h3, .q-menu h3
|
||||||
font-size: 1.1rem
|
font-size: 1.1rem
|
||||||
line-height: 1.5rem
|
line-height: 1.5rem
|
||||||
font-weight: 400
|
font-weight: 400
|
||||||
margin-block-start: 0em
|
margin-block-start: 0em
|
||||||
margin-block-end: 0em
|
margin-block-end: 0em
|
||||||
|
|
||||||
.q-editor p, .q-menu p
|
.q-editor p, .q-menu p
|
||||||
margin: 0
|
margin: 0
|
||||||
|
|
@ -134,7 +136,4 @@ $muti-tab: #87d4cc
|
||||||
/* q-tree */
|
/* q-tree */
|
||||||
|
|
||||||
.q-tree
|
.q-tree
|
||||||
color: #c8d3db
|
color: #c8d3db
|
||||||
|
|
||||||
.custom-notification-top
|
|
||||||
margin-top: 180px !important
|
|
||||||
|
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
const EXTERNAL_BROWSER_QUERY_KEY = 'openExternalBrowser'
|
|
||||||
|
|
||||||
const isLineBrowser = (userAgent: string) => /Line/i.test(userAgent)
|
|
||||||
|
|
||||||
const isAndroid = (userAgent: string) => /Android/i.test(userAgent)
|
|
||||||
|
|
||||||
const isIOS = (userAgent: string) => /iPhone|iPad|iPod/i.test(userAgent)
|
|
||||||
|
|
||||||
const hasExternalRedirectFlag = () => {
|
|
||||||
const params = new URLSearchParams(window.location.search)
|
|
||||||
return params.get(EXTERNAL_BROWSER_QUERY_KEY) === '1'
|
|
||||||
}
|
|
||||||
|
|
||||||
const buildIOSUrlWithFlag = () => {
|
|
||||||
const url = new URL(window.location.href)
|
|
||||||
url.searchParams.set(EXTERNAL_BROWSER_QUERY_KEY, '1')
|
|
||||||
return url.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
const buildUrlWithoutFlag = () => {
|
|
||||||
const url = new URL(window.location.href)
|
|
||||||
url.searchParams.delete(EXTERNAL_BROWSER_QUERY_KEY)
|
|
||||||
return url.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
const buildAndroidIntentUrl = () => {
|
|
||||||
const currentUrl = window.location.href
|
|
||||||
const strippedUrl = currentUrl.replace(/^https?:\/\//i, '')
|
|
||||||
return `intent://${strippedUrl}#Intent;scheme=https;package=com.android.chrome;end`
|
|
||||||
}
|
|
||||||
|
|
||||||
export const forceOpenInExternalBrowser = () => {
|
|
||||||
const userAgent = navigator.userAgent || ''
|
|
||||||
|
|
||||||
// Prevent redirect loops and only run in LINE browser.
|
|
||||||
if (!isLineBrowser(userAgent) || hasExternalRedirectFlag()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isAndroid(userAgent)) {
|
|
||||||
window.location.replace(buildAndroidIntentUrl())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isIOS(userAgent)) {
|
|
||||||
window.location.replace(buildIOSUrlWithFlag())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const shouldShowIOSLineFallback = () => {
|
|
||||||
const userAgent = navigator.userAgent || ''
|
|
||||||
return (
|
|
||||||
isLineBrowser(userAgent) && isIOS(userAgent) && hasExternalRedirectFlag()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getExternalBrowserUrl = () => buildUrlWithoutFlag()
|
|
||||||
|
|
@ -115,7 +115,6 @@ async function fetchlistTime() {
|
||||||
async function updateYear(y: number, m: number) {
|
async function updateYear(y: number, m: number) {
|
||||||
stores.tab === 'history' ? (year.value = y) : (year2.value = y)
|
stores.tab === 'history' ? (year.value = y) : (year2.value = y)
|
||||||
month.value = m
|
month.value = m
|
||||||
page.value = 1 // รีเซ็ตหน้าเป็นหน้าแรกเมื่อปีหรือเดือนเปลี่ยนแปลง
|
|
||||||
await functionFetch() // เรียกใช้งานฟังก์ชัน functionFetch เพื่อดึงข้อมูลใหม่
|
await functionFetch() // เรียกใช้งานฟังก์ชัน functionFetch เพื่อดึงข้อมูลใหม่
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,9 +177,9 @@ watch(
|
||||||
/>
|
/>
|
||||||
<TableHistory
|
<TableHistory
|
||||||
:fetch-data="functionFetch"
|
:fetch-data="functionFetch"
|
||||||
v-model:page-size="pageSize"
|
:page-size="pageSize"
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:page="page"
|
:page="page"
|
||||||
:paging="true"
|
:paging="true"
|
||||||
@update:change-page="changePage"
|
@update:change-page="changePage"
|
||||||
:max-page="maxPage"
|
:max-page="maxPage"
|
||||||
|
|
@ -197,9 +196,9 @@ watch(
|
||||||
/>
|
/>
|
||||||
<TableHistory
|
<TableHistory
|
||||||
:fetch-data="functionFetch"
|
:fetch-data="functionFetch"
|
||||||
v-model:page-size="pageSize"
|
:page-size="pageSize"
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:page="page"
|
:page="page"
|
||||||
:paging="true"
|
:paging="true"
|
||||||
@update:change-page="changePage"
|
@update:change-page="changePage"
|
||||||
:max-page="maxPage"
|
:max-page="maxPage"
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
|
@ -178,32 +178,21 @@ const landingPageUrl = ref<string>(configParam.landingPageUrl)
|
||||||
/** ฟังก์ชันเรียกข้อมูลผู้ใช่งาน*/
|
/** ฟังก์ชันเรียกข้อมูลผู้ใช่งาน*/
|
||||||
async function fetchKeycloakPosition() {
|
async function fetchKeycloakPosition() {
|
||||||
// เช็คว่ามีข้อมูลใน store อยู่แล้วหรือไม่ (จาก localStorage)
|
// เช็คว่ามีข้อมูลใน store อยู่แล้วหรือไม่ (จาก localStorage)
|
||||||
// จะช่วยลดจำนวนครั้งในการเรียก API และปรับปรุงประสิทธิภาพของแอปพลิเคชัน
|
const existingData = positionKeycloakStore.dataPositionKeycloak
|
||||||
// const existingData = positionKeycloakStore.dataPositionKeycloak
|
|
||||||
|
|
||||||
// if (existingData) {
|
if (existingData) {
|
||||||
// // มีข้อมูลอยู่แล้ว ใช้ข้อมูลเดิม
|
// มีข้อมูลอยู่แล้ว ใช้ข้อมูลเดิม
|
||||||
|
privacyStore.modalPrivacy = !existingData.privacyCheckin
|
||||||
|
privacyStore.setAccepted(existingData.privacyCheckin)
|
||||||
|
|
||||||
// // เช็คว่ามีข้อมูลสังกัด (organization) หรือไม่
|
//เช็คว่ามีรูปไหม ถ้ามีรูปเรียกข้อมูลรูป
|
||||||
// const hasOrganization =
|
if (existingData.avatarName) {
|
||||||
// existingData.organization &&
|
getImg(existingData.profileId, existingData.avatarName)
|
||||||
// (existingData.organization.root ||
|
} else {
|
||||||
// existingData.organization.child1 ||
|
profileImg.value = avatar
|
||||||
// existingData.organization.child2 ||
|
}
|
||||||
// existingData.organization.child3 ||
|
return
|
||||||
// existingData.organization.child4)
|
}
|
||||||
|
|
||||||
// if (!hasOrganization) {
|
|
||||||
// // ไม่มีข้อมูลสังกัด redirect ไปหน้า NoPosition
|
|
||||||
// router.replace('/no-position')
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// privacyStore.modalPrivacy = !existingData.privacyCheckin
|
|
||||||
// privacyStore.setAccepted(existingData.privacyCheckin)
|
|
||||||
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ไม่มีข้อมูล ให้ fetch จาก API
|
// ไม่มีข้อมูล ให้ fetch จาก API
|
||||||
await http
|
await http
|
||||||
|
|
@ -225,24 +214,6 @@ async function fetchKeycloakPosition() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// เช็คว่ามีข้อมูลสังกัด (organization) หรือไม่
|
|
||||||
// ถ้าไม่มีข้อมูลสังกัด ให้ redirect ไปหน้า NoPosition
|
|
||||||
const hasOrganization =
|
|
||||||
keycloakData.organization &&
|
|
||||||
(keycloakData.organization.root ||
|
|
||||||
keycloakData.organization.child1 ||
|
|
||||||
keycloakData.organization.child2 ||
|
|
||||||
keycloakData.organization.child3 ||
|
|
||||||
keycloakData.organization.child4)
|
|
||||||
|
|
||||||
if (!hasOrganization) {
|
|
||||||
// บันทึกข้อมูลที่ได้รับไว้ก่อน (เผื่อใช้ในอนาคต)
|
|
||||||
positionKeycloakStore.setPositionKeycloak(keycloakData)
|
|
||||||
// Redirect ไปหน้า NoPosition
|
|
||||||
router.replace('/no-position')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
positionKeycloakStore.setPositionKeycloak(keycloakData)
|
positionKeycloakStore.setPositionKeycloak(keycloakData)
|
||||||
privacyStore.modalPrivacy = !keycloakData.privacyCheckin
|
privacyStore.modalPrivacy = !keycloakData.privacyCheckin
|
||||||
privacyStore.setAccepted(keycloakData.privacyCheckin)
|
privacyStore.setAccepted(keycloakData.privacyCheckin)
|
||||||
|
|
@ -251,7 +222,7 @@ async function fetchKeycloakPosition() {
|
||||||
if (keycloakData.avatarName) {
|
if (keycloakData.avatarName) {
|
||||||
getImg(keycloakData.profileId, keycloakData.avatarName)
|
getImg(keycloakData.profileId, keycloakData.avatarName)
|
||||||
} else {
|
} else {
|
||||||
positionKeycloakStore.setProfileImg(avatar)
|
profileImg.value = avatar
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
@ -259,15 +230,12 @@ async function fetchKeycloakPosition() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileImg = computed({
|
const profileImg = ref<string>('')
|
||||||
get: () => positionKeycloakStore.profileImg,
|
|
||||||
set: (value) => positionKeycloakStore.setProfileImg(value),
|
|
||||||
})
|
|
||||||
function getImg(id: string, pathName: string) {
|
function getImg(id: string, pathName: string) {
|
||||||
http
|
http
|
||||||
.get(config.API.fileByFile('ทะเบียนประวัติ', 'โปรไฟล์', id, pathName))
|
.get(config.API.fileByFile('ทะเบียนประวัติ', 'โปรไฟล์', id, pathName))
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
positionKeycloakStore.setProfileImg(res.data.downloadUrl)
|
profileImg.value = res.data.downloadUrl
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,19 +133,14 @@ const photoHeight = ref<number>(350)
|
||||||
|
|
||||||
/** function เปิดกล้อง */
|
/** function เปิดกล้อง */
|
||||||
async function openCamera() {
|
async function openCamera() {
|
||||||
try {
|
// change camera device
|
||||||
// change camera device
|
if (cameraIsOn.value) {
|
||||||
if (cameraIsOn.value) {
|
camera.value?.stop()
|
||||||
camera.value?.stop()
|
} else {
|
||||||
} else {
|
await camera.value?.start()
|
||||||
await camera.value?.start()
|
changeCamera()
|
||||||
changeCamera()
|
|
||||||
}
|
|
||||||
cameraIsOn.value = !cameraIsOn.value
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error opening camera:', error)
|
|
||||||
messageError($q, error, 'ไม่สามารถเปิดกล้องได้ กรุณาลองใหม่อีกครั้ง')
|
|
||||||
}
|
}
|
||||||
|
cameraIsOn.value = !cameraIsOn.value
|
||||||
}
|
}
|
||||||
|
|
||||||
/** change camera device */
|
/** change camera device */
|
||||||
|
|
@ -157,49 +152,25 @@ async function changeCamera() {
|
||||||
|
|
||||||
/** function ถ่ายรูป*/
|
/** function ถ่ายรูป*/
|
||||||
async function capturePhoto() {
|
async function capturePhoto() {
|
||||||
try {
|
const imageBlob: any = await camera.value?.snapshot(
|
||||||
const imageBlob: any = await camera.value?.snapshot(
|
{ width: photoWidth.value, height: photoHeight.value },
|
||||||
{ width: photoWidth.value, height: photoHeight.value },
|
'image/png',
|
||||||
'image/jpeg',
|
0.5
|
||||||
0.8
|
)
|
||||||
)
|
const fileName = 'photo.png'
|
||||||
if (!imageBlob) {
|
//ไฟล์รูป
|
||||||
messageError($q, '', 'ไม่สามารถถ่ายรูปได้ กรุณาลองใหม่อีกครั้ง')
|
const file = new File([imageBlob], fileName, { type: 'image/png' })
|
||||||
return
|
fileImg.value = file
|
||||||
}
|
//แสดงรูป
|
||||||
const fileName = `photo_${Date.now()}.jpg`
|
camera.value?.stop()
|
||||||
//ไฟล์รูป
|
const url = URL.createObjectURL(imageBlob)
|
||||||
const file = new File([imageBlob], fileName, { type: 'image/jpeg' })
|
img.value = url
|
||||||
fileImg.value = file
|
|
||||||
|
|
||||||
// ยกเลิก URL เก่าก่อนสร้างใหม่ (ป้องกัน memory leak)
|
|
||||||
if (img.value) {
|
|
||||||
URL.revokeObjectURL(img.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
//แสดงรูป
|
|
||||||
camera.value?.stop()
|
|
||||||
const url = URL.createObjectURL(imageBlob)
|
|
||||||
img.value = url
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error capturing photo:', error)
|
|
||||||
messageError($q, error, 'ไม่สามารถถ่ายรูปได้ กรุณาลองใหม่อีกครั้ง')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function เปลี่ยนรูปภาพ*/
|
/** function เปลี่ยนรูปภาพ*/
|
||||||
async function refreshPhoto() {
|
function refreshPhoto() {
|
||||||
try {
|
img.value = undefined
|
||||||
// ยกเลิก URL เก่า (ป้องกัน memory leak)
|
camera.value?.start()
|
||||||
if (img.value) {
|
|
||||||
URL.revokeObjectURL(img.value)
|
|
||||||
img.value = undefined
|
|
||||||
}
|
|
||||||
await camera.value?.start()
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error refreshing photo:', error)
|
|
||||||
messageError($q, error, 'ไม่สามารถเปิดกล้องได้ กรุณาลองใหม่อีกครั้ง')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ref validate*/
|
/** ref validate*/
|
||||||
|
|
@ -364,8 +335,7 @@ onMounted(async () => {
|
||||||
:resolution="{ width: photoWidth, height: photoHeight }"
|
:resolution="{ width: photoWidth, height: photoHeight }"
|
||||||
ref="camera"
|
ref="camera"
|
||||||
:autoplay="false"
|
:autoplay="false"
|
||||||
:playsinline="true"
|
:style="!img ? 'display: block' : 'display: none'"
|
||||||
:facingMode="'user'"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- แสดงรูปเมื่อกด capture -->
|
<!-- แสดงรูปเมื่อกด capture -->
|
||||||
|
|
@ -490,7 +460,7 @@ onMounted(async () => {
|
||||||
<div class="col-12 text-right">
|
<div class="col-12 text-right">
|
||||||
<q-separator />
|
<q-separator />
|
||||||
<div class="col-12 q-pa-md">
|
<div class="col-12 q-pa-md">
|
||||||
<!-- <p
|
<p
|
||||||
:class="
|
:class="
|
||||||
$q.screen.gt.xs
|
$q.screen.gt.xs
|
||||||
? 'text-red text-caption '
|
? 'text-red text-caption '
|
||||||
|
|
@ -498,7 +468,7 @@ onMounted(async () => {
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
*หมายเหตุ คลิกลงเวลาเข้างานแล้วระบบจะลงเวลาทันที
|
*หมายเหตุ คลิกลงเวลาเข้างานแล้วระบบจะลงเวลาทันที
|
||||||
</p> -->
|
</p>
|
||||||
<q-btn
|
<q-btn
|
||||||
:label="
|
:label="
|
||||||
stetusCheckin == true ? 'ลงเวลาเข้างาน' : 'ลงเวลาออกงาน'
|
stetusCheckin == true ? 'ลงเวลาเข้างาน' : 'ลงเวลาออกงาน'
|
||||||
|
|
@ -599,12 +569,4 @@ onMounted(async () => {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* iOS-specific video fixes */
|
|
||||||
.card-container video {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
-webkit-object-fit: cover;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,106 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import { useQuasar } from 'quasar'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import { useCounterMixin } from '@/stores/mixin'
|
|
||||||
import { usePositionKeycloakStore } from '@/stores/positionKeycloak'
|
|
||||||
import { logout } from '@/plugins/auth'
|
|
||||||
import CustomComponent from '@/components/CustomDialog.vue'
|
|
||||||
|
|
||||||
const $q = useQuasar()
|
|
||||||
const router = useRouter()
|
|
||||||
const mixin = useCounterMixin()
|
|
||||||
const positionKeycloakStore = usePositionKeycloakStore()
|
|
||||||
const { showLoader, hideLoader } = mixin
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ฟังก์ชันจัดการเมื่อผู้ใช้กดปุ่มตกลง
|
|
||||||
* ดำเนินการ logout โดยตรง
|
|
||||||
*/
|
|
||||||
function handleOkClick() {
|
|
||||||
performLogout()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ฟังก์ชันดำเนินการออกจากระบบ
|
|
||||||
*/
|
|
||||||
async function performLogout() {
|
|
||||||
showLoader()
|
|
||||||
try {
|
|
||||||
// ล้างข้อมูล positionKeycloak ก่อน logout
|
|
||||||
positionKeycloakStore.clearPositionKeycloak()
|
|
||||||
await logout()
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Logout error:', error)
|
|
||||||
} finally {
|
|
||||||
setTimeout(() => {
|
|
||||||
hideLoader()
|
|
||||||
}, 1000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div
|
|
||||||
class="fullscreen bg-secondary text-white text-center q-pa-sm flex flex-center"
|
|
||||||
>
|
|
||||||
<div class="no-position-container">
|
|
||||||
<!-- Icon แสดงความผิดปกติ -->
|
|
||||||
<div class="icon-container">
|
|
||||||
<q-icon name="mdi-account-off-outline" size="100px" color="white" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- หัวข้อหลัก -->
|
|
||||||
<div class="text-h4 q-mt-lg q-mb-md">ไม่พบข้อมูลสังกัด</div>
|
|
||||||
|
|
||||||
<!-- รายละเอียด -->
|
|
||||||
<div class="text-h6 q-mb-lg text-weight-regular">
|
|
||||||
ท่านยังไม่มีสังกัดในโครงสร้างองค์กร<br />
|
|
||||||
กรุณาติดต่อเจ้าหน้าที่ที่เบอร์ 1171
|
|
||||||
<br />เพื่อดำเนินการเพิ่มข้อมูล
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text-weight-regular">
|
|
||||||
เมื่อเจ้าหน้าที่ได้เพิ่มท่านในโครงสร้างองค์กรเรียบร้อยแล้ว
|
|
||||||
กรุณาเข้าสู่ระบบใหม่อีกครั้ง
|
|
||||||
</div>
|
|
||||||
<!-- ปุ่มตกลง -->
|
|
||||||
<q-btn
|
|
||||||
class="q-mt-xl"
|
|
||||||
color="white"
|
|
||||||
text-color="secondary"
|
|
||||||
unelevated
|
|
||||||
label="ตกลง"
|
|
||||||
no-caps
|
|
||||||
size="lg"
|
|
||||||
padding="md xl"
|
|
||||||
@click="handleOkClick"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.no-position-container {
|
|
||||||
max-width: 600px;
|
|
||||||
padding: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-container {
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-h4 {
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-h6 {
|
|
||||||
line-height: 1.8;
|
|
||||||
opacity: 0.95;
|
|
||||||
}
|
|
||||||
|
|
||||||
.q-btn {
|
|
||||||
border-radius: 8px;
|
|
||||||
font-weight: 600;
|
|
||||||
min-width: 150px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
@ -20,7 +20,7 @@ const password = ref<string>('')
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
showLoader()
|
showLoader()
|
||||||
const formdata = new URLSearchParams()
|
const formdata = new URLSearchParams()
|
||||||
formdata.append('username', username.value.trim())
|
formdata.append('username', username.value)
|
||||||
formdata.append('password', password.value)
|
formdata.append('password', password.value)
|
||||||
|
|
||||||
await axios
|
await axios
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export default defineConfig({
|
||||||
cleanupOutdatedCaches: true,
|
cleanupOutdatedCaches: true,
|
||||||
globPatterns: ['**/*.*'],
|
globPatterns: ['**/*.*'],
|
||||||
},
|
},
|
||||||
includeAssets: ['icons/safari-pinned-tab.svg', 'src/assets/markers/*.svg'],
|
includeAssets: ['icons/safari-pinned-tab.svg'],
|
||||||
manifest: {
|
manifest: {
|
||||||
name: 'HRMS-Checkin',
|
name: 'HRMS-Checkin',
|
||||||
short_name: 'HRMS Checkin',
|
short_name: 'HRMS Checkin',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue