refector code
This commit is contained in:
parent
067ac5f173
commit
23d6801f80
9 changed files with 338 additions and 217 deletions
|
|
@ -2,17 +2,18 @@
|
||||||
import { onMounted, 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 type { LocationObject } from '@/interface/index/Main'
|
import type { LocationObject } from '@/interface/index/Main'
|
||||||
|
|
||||||
const emit = defineEmits(['update:location'])
|
const emit = defineEmits(['update:location'])
|
||||||
|
|
||||||
function updateLocation(latitude: any, longitude: any, namePOI: string) {
|
function updateLocation(latitude: number, longitude: number, namePOI: string) {
|
||||||
// ส่ง event ไปยัง parent component เพื่ออัพเดทค่า props
|
// ส่ง event ไปยัง parent component เพื่ออัพเดทค่า props
|
||||||
emit('update:location', latitude, longitude, namePOI)
|
emit('update:location', latitude, longitude, namePOI)
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentPosition = ref<LocationObject>()
|
const currentPosition = ref<LocationObject>() //ตำแหน่งปัจจุบัน
|
||||||
const poiPlaceName = ref<string>('')
|
const poiPlaceName = ref<string>('') // ชื่อพื้นที่ใกล้เคียง
|
||||||
|
|
||||||
// Replace ArcGIS api key
|
// Replace ArcGIS api key
|
||||||
const apiKey = ref<string>(
|
const apiKey = ref<string>(
|
||||||
|
|
@ -123,7 +124,7 @@ async function initializeMap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
initializeMap()
|
await initializeMap()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,32 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch, onMounted } from 'vue'
|
import { ref, watch, onMounted } from 'vue'
|
||||||
|
import { PropType } from 'vue'
|
||||||
import { useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
import http from '@/plugins/http'
|
import http from '@/plugins/http'
|
||||||
import config from '@/app.config'
|
import config from '@/app.config'
|
||||||
|
import { useCounterMixin } from '@/stores/mixin'
|
||||||
|
|
||||||
import type { FormRef } from '@/interface/index/Main'
|
import type { FormRef, DataCheckIn } from '@/interface/index/Main'
|
||||||
import type { FormTimeStemp } from '@/interface/response/checkin'
|
import type { FormTimeStemp } from '@/interface/response/checkin'
|
||||||
|
|
||||||
// importStores
|
|
||||||
import { useCounterMixin } from '@/stores/mixin'
|
|
||||||
// importType
|
|
||||||
|
|
||||||
const $q = useQuasar()
|
const $q = useQuasar()
|
||||||
const mixin = useCounterMixin()
|
const {
|
||||||
const { date2Thai, success, dialogConfirm, showLoader, hideLoader } = mixin
|
date2Thai,
|
||||||
|
success,
|
||||||
|
dialogConfirm,
|
||||||
|
showLoader,
|
||||||
|
hideLoader,
|
||||||
|
messageError,
|
||||||
|
} = useCounterMixin()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* props จาก components Popup
|
||||||
|
*/
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dataById: {
|
dataById: {
|
||||||
type: Object,
|
type: Object as PropType<DataCheckIn>,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
closePopup: {
|
closePopup: {
|
||||||
|
|
@ -34,16 +42,25 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const dataByIdVal = ref<any>([])
|
const dataByIdVal = ref<DataCheckIn>() //ข้อมูลประวัติการลงเวลา
|
||||||
const date = ref<Date | string>(new Date())
|
const date = ref<Date | string>(new Date()) //วันที่ข้อแก้ไข
|
||||||
const checkboxIn = ref<boolean>(false)
|
const checkboxIn = ref<boolean>(false) //ขอแก้ไขเวลาเข้างาน
|
||||||
const checkboxOut = ref<boolean>(false)
|
const checkboxOut = ref<boolean>(false) //ขอแก้ไขเวลาออกงาน
|
||||||
const reason = ref<string>('')
|
const reason = ref<string>('') // เหตุผล
|
||||||
const statusAction = ref<boolean>(false)
|
const statusAction = ref<boolean>(false) //สถานะ เพิ่ม,แก้ไข
|
||||||
|
const dateNow = ref<Date>(new Date()) // วันปัจจุบัน
|
||||||
const dateNow = ref<Date>(new Date())
|
const timeNoew = ref<string>('') //เวลาปัจจุบัน
|
||||||
const timeNoew = ref<string>('')
|
const dateRef = ref<object | null>(null) //ref วันที่ข้อแก้ไข
|
||||||
|
const reasonRef = ref<object | null>(null) //ref เหตุผล
|
||||||
|
const objectRef: FormRef = {
|
||||||
|
date: dateRef,
|
||||||
|
reason: reasonRef,
|
||||||
|
}
|
||||||
|
const checkstatusBox = ref<boolean>(false) //สถานะการเลือกเวลาเข้า,ออก
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันอัปเดตเวลา
|
||||||
|
*/
|
||||||
function updateClock() {
|
function updateClock() {
|
||||||
const date = Date.now()
|
const date = Date.now()
|
||||||
const hh = moment(date).format('HH')
|
const hh = moment(date).format('HH')
|
||||||
|
|
@ -51,16 +68,9 @@ function updateClock() {
|
||||||
timeNoew.value = `${hh}:${mm} น.`
|
timeNoew.value = `${hh}:${mm} น.`
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateRef = ref<object | null>(null)
|
/**
|
||||||
const reasonRef = ref<object | null>(null)
|
* function checkValidate
|
||||||
|
*/
|
||||||
const objectRef: FormRef = {
|
|
||||||
date: dateRef,
|
|
||||||
reason: reasonRef,
|
|
||||||
}
|
|
||||||
const checkstatusBox = ref<boolean>(false)
|
|
||||||
|
|
||||||
/** function checkValidate*/
|
|
||||||
function onCkickSave() {
|
function onCkickSave() {
|
||||||
const hasError = []
|
const hasError = []
|
||||||
for (const key in objectRef) {
|
for (const key in objectRef) {
|
||||||
|
|
@ -81,12 +91,13 @@ function onCkickSave() {
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
dialogConfirm($q, async () => {
|
dialogConfirm($q, async () => {
|
||||||
const data: FormTimeStemp = await {
|
const data: FormTimeStemp = {
|
||||||
checkDate: date.value,
|
checkDate: date.value,
|
||||||
checkInEdit: checkboxIn.value,
|
checkInEdit: checkboxIn.value,
|
||||||
checkOutEdit: checkboxOut.value,
|
checkOutEdit: checkboxOut.value,
|
||||||
description: reason.value,
|
description: reason.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
createListTime(data)
|
createListTime(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -100,20 +111,37 @@ async function createListTime(data: FormTimeStemp) {
|
||||||
showLoader()
|
showLoader()
|
||||||
await http
|
await http
|
||||||
.post(config.API.createTimeStamp(), data)
|
.post(config.API.createTimeStamp(), data)
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
success($q, 'บันทึกข้อมูลสำเร็จ')
|
// เรียก function fetch รายการประวัติการลงเวลา
|
||||||
|
await props.fetchData()
|
||||||
|
await success($q, 'บันทึกข้อมูลสำเร็จ')
|
||||||
|
props.closePopup?.()
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err)
|
messageError($q, err)
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
props.closePopup?.()
|
|
||||||
hideLoader()
|
hideLoader()
|
||||||
props.fetchData()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hook */
|
/**
|
||||||
|
* watch การเปลี่ยนแปลงของ checkboxIn และ checkboxOut
|
||||||
|
*/
|
||||||
|
watch(
|
||||||
|
[() => checkboxIn.value, () => checkboxOut.value],
|
||||||
|
([newCheckboxIn, newCheckboxOut]) => {
|
||||||
|
if (checkstatusBox.value) {
|
||||||
|
if (newCheckboxIn || newCheckboxOut) {
|
||||||
|
checkstatusBox.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook
|
||||||
|
*/
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
updateClock()
|
updateClock()
|
||||||
dataByIdVal.value = props.dataById
|
dataByIdVal.value = props.dataById
|
||||||
|
|
@ -126,17 +154,6 @@ onMounted(() => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
|
||||||
[() => checkboxIn.value, () => checkboxOut.value],
|
|
||||||
([newCheckboxIn, newCheckboxOut]) => {
|
|
||||||
if (checkstatusBox.value) {
|
|
||||||
if (newCheckboxIn || newCheckboxOut) {
|
|
||||||
checkstatusBox.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="col-12 row">
|
<div class="col-12 row">
|
||||||
|
|
@ -149,7 +166,7 @@ watch(
|
||||||
<q-card-section class="bg-primary text-white q-pa-sm">
|
<q-card-section class="bg-primary text-white q-pa-sm">
|
||||||
<div class="text-center text-bold">เวลาปัจจุบัน</div>
|
<div class="text-center text-bold">เวลาปัจจุบัน</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<!-- <div class="q-pa-sm text-primary">เวลาปัจจุบัน</div> -->
|
|
||||||
<q-card-section class="text-center q-pa-sm">
|
<q-card-section class="text-center q-pa-sm">
|
||||||
<div class="row q-gutter-md">
|
<div class="row q-gutter-md">
|
||||||
<div class="col">{{ date2Thai(dateNow) }}</div>
|
<div class="col">{{ date2Thai(dateNow) }}</div>
|
||||||
|
|
@ -187,7 +204,7 @@ watch(
|
||||||
:label="`${'วันที่ขอแก้ไข'}`"
|
:label="`${'วันที่ขอแก้ไข'}`"
|
||||||
format-header="YYYY-MM-DD"
|
format-header="YYYY-MM-DD"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
|
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่']"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
|
|
@ -203,15 +220,6 @@ watch(
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
<!-- <q-card flat bordered class="q-pa-sm col-12 bg-grey-1 q-mt-sm" v-else>
|
|
||||||
<div class="row q-gutter-md text-grey-5">
|
|
||||||
<div class="col-1">
|
|
||||||
<q-icon color="grey-5" name="calendar_today" />
|
|
||||||
</div>
|
|
||||||
<div class="col">{{ dataByIdVal.checkInDate }}</div>
|
|
||||||
</div>
|
|
||||||
</q-card> -->
|
|
||||||
|
|
||||||
<q-card
|
<q-card
|
||||||
flat
|
flat
|
||||||
bordered
|
bordered
|
||||||
|
|
@ -259,7 +267,7 @@ watch(
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="4"
|
:rows="4"
|
||||||
label-color="grey-5"
|
label-color="grey-5"
|
||||||
:rules="[(val) => !!val || 'กรุณากรอกเหตุผล']"
|
:rules="[(val:string) => !!val || 'กรุณากรอกเหตุผล']"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="custom-aqua-border"
|
class="custom-aqua-border"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,15 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
|
import { PropType } from 'vue'
|
||||||
|
|
||||||
import HeaderPopup from '@/components/HeaderPopup.vue'
|
import type { DataCheckIn } from '@/interface/index/Main'
|
||||||
import FormTime from '@/components/FormTime.vue'
|
|
||||||
|
|
||||||
|
import HeaderPopup from '@/components/HeaderPopup.vue' // หัว popup
|
||||||
|
import FormTime from '@/components/FormTime.vue' //
|
||||||
|
|
||||||
|
/**
|
||||||
|
* props จาก components TableHistory
|
||||||
|
*/
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modal: {
|
modal: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
@ -18,7 +24,7 @@ const props = defineProps({
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
dataById: {
|
dataById: {
|
||||||
type: Object,
|
type: Object as PropType<DataCheckIn>,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
fetchData: {
|
fetchData: {
|
||||||
|
|
@ -27,15 +33,25 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const data = ref<any>()
|
const data = ref<DataCheckIn>() // ข้อมูลลงเวลา
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ปิด popup
|
||||||
|
* เรียกใช้ฟังก์ชัน props.clickClose()
|
||||||
|
*/
|
||||||
function clickClosePopup() {
|
function clickClosePopup() {
|
||||||
props.clickClose()
|
props.clickClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* watch การเปลี่ยนแปลงของ props.modal
|
||||||
|
*/
|
||||||
watch(
|
watch(
|
||||||
() => props.modal,
|
() => props.modal,
|
||||||
() => {
|
() => {
|
||||||
data.value = props.modal ? props.dataById : null
|
if (props.modal) {
|
||||||
|
data.value = props?.dataById
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -43,10 +59,11 @@ watch(
|
||||||
<q-dialog v-model="props.modal" persistent>
|
<q-dialog v-model="props.modal" persistent>
|
||||||
<q-card :style="$q.screen.lt.sm ? 'width: 100%;' : 'width: 320px;'">
|
<q-card :style="$q.screen.lt.sm ? 'width: 100%;' : 'width: 320px;'">
|
||||||
<HeaderPopup :title="props.title" :clickClose="clickClosePopup" />
|
<HeaderPopup :title="props.title" :clickClose="clickClosePopup" />
|
||||||
|
|
||||||
<FormTime
|
<FormTime
|
||||||
:dataById="data"
|
:data-byId="data"
|
||||||
:closePopup="clickClosePopup"
|
:close-popup="clickClosePopup"
|
||||||
:fetchData="props.fetchData"
|
:fetch-data="props.fetchData"
|
||||||
/>
|
/>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,20 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import type { QTableProps } from 'quasar'
|
|
||||||
import { useCounterMixin } from '@/stores/mixin'
|
import { useCounterMixin } from '@/stores/mixin'
|
||||||
|
|
||||||
import { useChekIn } from '@/stores/chekin'
|
import { useChekIn } from '@/stores/chekin'
|
||||||
import Popup from '@/components/PopUp.vue' // dialog เพิ่ม/ขอแก้ไขลงเวลากรณีพิเศษ
|
|
||||||
|
|
||||||
const mixin = useCounterMixin()
|
import type { QTableProps } from 'quasar'
|
||||||
const { date2Thai } = mixin
|
import type { Pagination, DataCheckIn } from '@/interface/index/Main'
|
||||||
|
|
||||||
|
import Popup from '@/components/PopUp.vue' // dialog เพิ่ม/ขอแก้ไขลงเวลากรณีพิเศษ
|
||||||
|
const { date2Thai } = useCounterMixin()
|
||||||
|
|
||||||
const stores = useChekIn()
|
const stores = useChekIn()
|
||||||
const selected = ref<string[]>([])
|
|
||||||
|
|
||||||
/** props from page */
|
/**
|
||||||
|
* props ข้อมูลจาก Components Page HistoryView
|
||||||
|
*/
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
paging: {
|
paging: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
@ -48,13 +50,13 @@ const props = defineProps({
|
||||||
default: () => console.log('not function'),
|
default: () => console.log('not function'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
const emit = defineEmits(['update:change-page'])
|
||||||
|
|
||||||
const keyword = ref<string>('')
|
const keyword = ref<string>('')
|
||||||
const tab = ref<string>(props.tab?.toString())
|
const tab = ref<string>(props.tab?.toString())
|
||||||
|
const selected = ref<string[]>([])
|
||||||
|
|
||||||
const emit = defineEmits(['update:change-page'])
|
// column history table
|
||||||
|
|
||||||
/** column history table */
|
|
||||||
const columns = ref<QTableProps['columns']>(
|
const columns = ref<QTableProps['columns']>(
|
||||||
props.tab == 'history'
|
props.tab == 'history'
|
||||||
? [
|
? [
|
||||||
|
|
@ -181,35 +183,23 @@ const visibleColumns = ref<string[]>([
|
||||||
'checkOutStatus',
|
'checkOutStatus',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const currentPage = ref<number>(1) //หน้าปัจจุบัน
|
||||||
// Pagination - initial pagination
|
// Pagination - initial pagination
|
||||||
const initialPagination = ref({
|
const initialPagination = ref<Pagination>({
|
||||||
sortBy: null,
|
sortBy: null,
|
||||||
descending: false,
|
descending: false,
|
||||||
page: 1,
|
page: 1,
|
||||||
rowsPerPage: props.pageSize, // set ตาม page หลักส่งมา
|
rowsPerPage: props.pageSize, // set ตาม page หลักส่งมา
|
||||||
})
|
})
|
||||||
|
|
||||||
// Pagination - page & change page & get new data
|
|
||||||
const currentPage = ref<number>(1)
|
|
||||||
watch(
|
|
||||||
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
|
||||||
() => {
|
|
||||||
emit(
|
|
||||||
'update:change-page',
|
|
||||||
currentPage.value,
|
|
||||||
initialPagination.value.rowsPerPage,
|
|
||||||
keyword.value
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Pagination - update rowsPerPage
|
// Pagination - update rowsPerPage
|
||||||
async function updatePagination(newPagination: any) {
|
async function updatePagination(newPagination: Pagination) {
|
||||||
initialPagination.value = newPagination
|
initialPagination.value = newPagination
|
||||||
currentPage.value = 1 // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
currentPage.value = 1 // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
||||||
}
|
}
|
||||||
|
|
||||||
async function filterFn() {
|
async function filterFn() {
|
||||||
|
// ส่งอีเวนต์ 'update:change-page' เมื่อหน้าเปลี่ยนแปลง
|
||||||
emit(
|
emit(
|
||||||
'update:change-page',
|
'update:change-page',
|
||||||
1,
|
1,
|
||||||
|
|
@ -217,24 +207,34 @@ async function filterFn() {
|
||||||
keyword.value
|
keyword.value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
const modalPopup = ref<boolean>(false) // popup แก้ไขลงเวลา
|
||||||
|
const titlePopup = ref<string>('') // หัวขข้อ popup แก้ไขลงเวลา
|
||||||
|
const dataRow = ref<DataCheckIn>() // ข้อมูลการลงเวลา
|
||||||
|
|
||||||
// popup
|
/**
|
||||||
const modalPopup = ref<boolean>(false)
|
* เปิด popup แก้ไขลงเวลา
|
||||||
const titlePopup = ref<string>('')
|
* กำหนดค่า titlePopup เป็น แก้ไขลงเวลา
|
||||||
const dataRow = ref<any>()
|
* @param data ข้อมูลการลงเวลา
|
||||||
function openPopup(data: any) {
|
*/
|
||||||
console.log(data)
|
function openPopup(data: DataCheckIn) {
|
||||||
|
|
||||||
const title = 'แก้ไขลงเวลา'
|
const title = 'แก้ไขลงเวลา'
|
||||||
modalPopup.value = true
|
modalPopup.value = true
|
||||||
titlePopup.value = title
|
titlePopup.value = title
|
||||||
dataRow.value = data
|
dataRow.value = data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ปิด popup แก้ไขลงเวลา
|
||||||
|
*/
|
||||||
function closePopup() {
|
function closePopup() {
|
||||||
modalPopup.value = false
|
modalPopup.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชั่นสำหรับ convert ข้อความสถานะของการลงเวลา ปกติ, ขาดราชการ หรือสาย
|
||||||
|
* @param status ฟิลด์สถานะ
|
||||||
|
* @returns ข้อความสถานะ ปกติ, ขาดราชการ ,สาย หรือปฏิบัติงานไม่ครบตามกำหนดเวลา
|
||||||
|
*/
|
||||||
function classStatus(status: string) {
|
function classStatus(status: string) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 'ขาดราชการ':
|
case 'ขาดราชการ':
|
||||||
|
|
@ -250,14 +250,35 @@ function classStatus(status: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const modalReject = ref<boolean>(false)
|
const modalReject = ref<boolean>(false) // modal popup หมายเหตุการไม่อนุมัติ
|
||||||
const reasonRejrct = ref<string>('')
|
const reasonRejrct = ref<string>('') // หมายเหตุการไม่อนุมัติ
|
||||||
function onClickOpenPopupRejrct(data: any) {
|
|
||||||
|
/**
|
||||||
|
* เปิด popup หมายเหตุการไม่อนุมัติ
|
||||||
|
* @param data ข้อมูลการลงเวลา
|
||||||
|
*/
|
||||||
|
function onClickOpenPopupRejrct(data: DataCheckIn) {
|
||||||
if (data.editStatus === 'ไม่อนุมัติ') {
|
if (data.editStatus === 'ไม่อนุมัติ') {
|
||||||
reasonRejrct.value = data.editReason
|
reasonRejrct.value = data.editReason
|
||||||
modalReject.value = true
|
modalReject.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* watch currentPage และ rowsPerPage
|
||||||
|
*/
|
||||||
|
watch(
|
||||||
|
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
||||||
|
() => {
|
||||||
|
// ส่งอีเวนต์ 'update:change-page' เมื่อหน้าเปลี่ยนแปลง
|
||||||
|
emit(
|
||||||
|
'update:change-page',
|
||||||
|
currentPage.value,
|
||||||
|
initialPagination.value.rowsPerPage,
|
||||||
|
keyword.value
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -295,6 +316,7 @@ function onClickOpenPopupRejrct(data: any) {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-table
|
<q-table
|
||||||
flat
|
flat
|
||||||
bordered
|
bordered
|
||||||
|
|
@ -442,6 +464,7 @@ function onClickOpenPopupRejrct(data: any) {
|
||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
|
|
||||||
|
<!-- หมายเหตุการไม่อนุมัติ -->
|
||||||
<q-dialog v-model="modalReject">
|
<q-dialog v-model="modalReject">
|
||||||
<q-card style="width: 35vw; max-width: 35vw">
|
<q-card style="width: 35vw; max-width: 35vw">
|
||||||
<q-toolbar>
|
<q-toolbar>
|
||||||
|
|
@ -466,12 +489,13 @@ function onClickOpenPopupRejrct(data: any) {
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
||||||
|
<!-- แก้ไขลงเวลา -->
|
||||||
<Popup
|
<Popup
|
||||||
:fetchData="props.fetchData"
|
:fetch-data="props.fetchData"
|
||||||
:modal="modalPopup"
|
:modal="modalPopup"
|
||||||
:clickClose="closePopup"
|
:click-close="closePopup"
|
||||||
:title="titlePopup"
|
:title="titlePopup"
|
||||||
:dataById="dataRow"
|
:data-ById="dataRow"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
|
import { useCounterMixin } from '@/stores/mixin'
|
||||||
|
import { useChekIn } from '@/stores/chekin'
|
||||||
|
|
||||||
import type { DataDateMonthObject } from '@/interface/index/Main'
|
import type { DataDateMonthObject } from '@/interface/index/Main'
|
||||||
|
|
||||||
import Popup from '@/components/PopUp.vue'
|
import Popup from '@/components/PopUp.vue'
|
||||||
// import HeaderPopup from "@/components/HeaderPopup.vue";
|
|
||||||
// import FormTime from "@/components/FormTime.vue";
|
|
||||||
import { useCounterMixin } from '@/stores/mixin'
|
|
||||||
import { useChekIn } from '@/stores/chekin'
|
|
||||||
|
|
||||||
const mixin = useCounterMixin() //เรียกฟังก์ชันกลาง
|
|
||||||
const stores = useChekIn()
|
const stores = useChekIn()
|
||||||
const { monthYear2Thai } = mixin
|
const { monthYear2Thai } = useCounterMixin()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* props จาก components HistoryView
|
||||||
|
*/
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
fetchData: {
|
fetchData: {
|
||||||
type: Function,
|
type: Function,
|
||||||
|
|
@ -25,37 +26,57 @@ const props = defineProps({
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['update:year'])
|
const emit = defineEmits(['update:year'])
|
||||||
|
|
||||||
const filterYear = ref<number>(stores.year)
|
const filterYear = ref<number>(stores.year) //ปีงบประมาณ
|
||||||
const titleName = ref<string>('เพิ่มรายการลงเวลากรณีพิเศษ')
|
const titleName = ref<string>('เพิ่มรายการลงเวลากรณีพิเศษ') //หัว popup
|
||||||
const dateMonth = ref<DataDateMonthObject>({
|
const dateMonth = ref<DataDateMonthObject>({
|
||||||
month: new Date().getMonth(),
|
month: new Date().getMonth(),
|
||||||
year: stores.year,
|
year: stores.year,
|
||||||
})
|
})
|
||||||
|
const modalPopup = ref<boolean>(false) // modal เพิ่มรายการลงเวลากรณีพิเศษ
|
||||||
|
|
||||||
watch(
|
/**
|
||||||
() => stores.year,
|
* ฟังก์ชันอัปเดทปีงบประมาณ
|
||||||
() => {
|
* @param type ประเภท year,mount
|
||||||
dateMonth.value.year = stores.year
|
*/
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
function filterYearFn(type: string) {
|
function filterYearFn(type: string) {
|
||||||
const year = type === 'year' ? filterYear.value : dateMonth.value.year
|
const year = type === 'year' ? filterYear.value : dateMonth.value.year
|
||||||
|
//ส่งค่า ปีงบประมาณ กลับ
|
||||||
emit('update:year', year, dateMonth.value.month)
|
emit('update:year', year, dateMonth.value.month)
|
||||||
}
|
}
|
||||||
|
|
||||||
const modalPopup = ref<boolean>(false)
|
/**
|
||||||
|
* เปิด popup เพิ่มรายการลงเวลากรณีพิเศษ
|
||||||
|
*/
|
||||||
function onClickopen() {
|
function onClickopen() {
|
||||||
modalPopup.value = true
|
modalPopup.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ปิด popup เพิ่มรายการลงเวลากรณีพิเศษ
|
||||||
|
*/
|
||||||
function onClickClose() {
|
function onClickClose() {
|
||||||
modalPopup.value = false
|
modalPopup.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* แปลงวันเดือนปีเป็นเดือนและปีในภาษาไทย
|
||||||
|
* @param val วันเดือนปี
|
||||||
|
* @returns เดือนและปีในภาษาไทย
|
||||||
|
*/
|
||||||
const monthYearThai = (val: DataDateMonthObject) => {
|
const monthYearThai = (val: DataDateMonthObject) => {
|
||||||
if (val == null) return ''
|
if (val == null) return ''
|
||||||
else return monthYear2Thai(val.month, val.year)
|
else return monthYear2Thai(val.month, val.year)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* watch การเปลี่ยนแปลงของ stores.year
|
||||||
|
*/
|
||||||
|
watch(
|
||||||
|
() => stores.year,
|
||||||
|
(newYear) => {
|
||||||
|
dateMonth.value.year = newYear
|
||||||
|
}
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="items-center col-12 row q-pb-sm">
|
<div class="items-center col-12 row q-pb-sm">
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,24 @@ interface LocationObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Pagination {
|
interface Pagination {
|
||||||
sortBy: string
|
sortBy: string | null
|
||||||
descending: boolean
|
descending: boolean
|
||||||
page: number
|
page: number
|
||||||
rowsPerPage: number
|
rowsPerPage: number | undefined
|
||||||
|
}
|
||||||
|
interface DataCheckIn {
|
||||||
|
checkInDate: string
|
||||||
|
checkInDateTime: string
|
||||||
|
checkInId: string
|
||||||
|
checkInLocation: string
|
||||||
|
checkInStatus: string
|
||||||
|
checkInTime: string
|
||||||
|
checkOutLocation: string
|
||||||
|
checkOutStatus: string
|
||||||
|
checkOutTime: string
|
||||||
|
editReason: string
|
||||||
|
editStatus: string
|
||||||
|
isEdit: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
|
|
@ -39,4 +53,5 @@ export type {
|
||||||
DataDateMonthObject,
|
DataDateMonthObject,
|
||||||
LocationObject,
|
LocationObject,
|
||||||
Pagination,
|
Pagination,
|
||||||
|
DataCheckIn,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@ export const useChekIn = defineStore('checkin', () => {
|
||||||
*/
|
*/
|
||||||
async function fetchHistoryList(data: FormData[]) {
|
async function fetchHistoryList(data: FormData[]) {
|
||||||
rows.value = []
|
rows.value = []
|
||||||
|
const dataList: Datalist[] = data.map((e: FormData) => ({
|
||||||
const dataList: Datalist[] = await data.map((e: FormData) => ({
|
|
||||||
checkInId: e.checkInId,
|
checkInId: e.checkInId,
|
||||||
checkInDate: e.checkInDate ? date2Thai(e.checkInDate) : null,
|
checkInDate: e.checkInDate ? date2Thai(e.checkInDate) : null,
|
||||||
checkInDateTime: e.checkInDate ? e.checkInDate : e.checkOutDate,
|
checkInDateTime: e.checkInDate ? e.checkInDate : e.checkOutDate,
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,28 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, watch } from 'vue'
|
import { ref, onMounted, watch } from 'vue'
|
||||||
import { useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
|
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import http from '@/plugins/http'
|
import http from '@/plugins/http'
|
||||||
import config from '@/app.config'
|
import config from '@/app.config'
|
||||||
|
|
||||||
/**
|
|
||||||
* import Components
|
|
||||||
*/
|
|
||||||
import TableHistory from '@/components/TableHistory.vue'
|
|
||||||
import ToolBar from '@/components/ToolBar.vue'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* importStores
|
|
||||||
*/
|
|
||||||
import { useChekIn } from '@/stores/chekin'
|
import { useChekIn } from '@/stores/chekin'
|
||||||
import { useCounterMixin } from '@/stores/mixin'
|
import { useCounterMixin } from '@/stores/mixin'
|
||||||
|
|
||||||
/**
|
import TableHistory from '@/components/TableHistory.vue' //ตารางประวัติการลงเวลา
|
||||||
* use
|
import ToolBar from '@/components/ToolBar.vue' // เมนู Herder
|
||||||
*/
|
|
||||||
const mixin = useCounterMixin()
|
const $q = useQuasar() //ใช้ noti quasar
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const stores = useChekIn()
|
const stores = useChekIn()
|
||||||
const { showLoader, hideLoader, messageError } = mixin
|
const { showLoader, hideLoader, messageError } = useCounterMixin()
|
||||||
const { fetchHistoryList } = stores
|
const { fetchHistoryList } = stores
|
||||||
const $q = useQuasar() //ใช้ noti quasar
|
|
||||||
|
|
||||||
// paging
|
const year = ref<number>(new Date().getFullYear()) // ปีงบปรมาณ
|
||||||
const page = ref<number>(1)
|
const month = ref<number>(new Date().getMonth()) // เดือน
|
||||||
const year = ref<number>(new Date().getFullYear())
|
const page = ref<number>(1) // หน้าปัจจุบัน
|
||||||
const month = ref<number>(new Date().getMonth())
|
const pageSize = ref<number>(10) // จำนวนแถวต่อหน้า
|
||||||
const pageSize = ref<number>(10)
|
const total = ref<number>(0) // จำนวนทั้งหมด
|
||||||
const total = ref<number>(0)
|
const maxPage = ref<number>(1) // จำนวนวหน้าทั้งหมด
|
||||||
const maxPage = ref<number>(1)
|
|
||||||
const filter = ref<string>('') //search data table
|
const filter = ref<string>('') //search data table
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,17 +32,22 @@ const filter = ref<string>('') //search data table
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async function changePage(pageVal: number, pageSizeVal: number, key: string) {
|
async function changePage(pageVal: number, pageSizeVal: number, key: string) {
|
||||||
page.value = await pageVal
|
page.value = pageVal
|
||||||
pageSize.value = await pageSizeVal
|
pageSize.value = pageSizeVal
|
||||||
filter.value = await key
|
filter.value = key
|
||||||
functionFetch()
|
await functionFetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
function functionFetch() {
|
/**
|
||||||
stores.tab === 'history' ? fetchlistHistory() : fetchlistTime()
|
* ฟังก์ชันสำหรับดึงข้อมูลตามประเภทแท็บที่เลือก
|
||||||
|
*/
|
||||||
|
async function functionFetch() {
|
||||||
|
stores.tab === 'history' ? await fetchlistHistory() : await fetchlistTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** ฟังก์ชั่นดึงข้อมูลรายการประวัติการลงเวลาจาก api มาแสดง */
|
/***
|
||||||
|
* ฟังก์ชั่นดึงข้อมูลรายการประวัติการลงเวลา
|
||||||
|
*/
|
||||||
async function fetchlistHistory() {
|
async function fetchlistHistory() {
|
||||||
showLoader()
|
showLoader()
|
||||||
await http
|
await http
|
||||||
|
|
@ -64,10 +58,14 @@ async function fetchlistHistory() {
|
||||||
}&keyword=${filter.value ? filter.value : ''}`
|
}&keyword=${filter.value ? filter.value : ''}`
|
||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = res.data.result.data
|
// ดึงข้อมูลและจำนวนทั้งหมด
|
||||||
total.value = res.data.result.total
|
const data = await res.data.result.data
|
||||||
maxPage.value = await Math.ceil(total.value / pageSize.value)
|
total.value = await res.data.result.total
|
||||||
fetchHistoryList(data) // ปิดกรณีมี total
|
|
||||||
|
// คำนวณจำนวนหน้า
|
||||||
|
maxPage.value = Math.ceil(total.value / pageSize.value)
|
||||||
|
|
||||||
|
await fetchHistoryList(data)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err)
|
messageError($q, err)
|
||||||
|
|
@ -77,7 +75,9 @@ async function fetchlistHistory() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ฟังก์ชั่นดึงรายการลงเวลากรณีพิเศษ */
|
/**
|
||||||
|
* ฟังก์ชั่นดึงรายการลงเวลากรณีพิเศษ
|
||||||
|
*/
|
||||||
async function fetchlistTime() {
|
async function fetchlistTime() {
|
||||||
showLoader()
|
showLoader()
|
||||||
await http
|
await http
|
||||||
|
|
@ -90,10 +90,14 @@ async function fetchlistTime() {
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = res.data.result.data
|
// ดึงข้อมูลและจำนวนทั้งหมด
|
||||||
total.value = res.data.result.total
|
const data = await res.data.result.data
|
||||||
maxPage.value = await Math.ceil(total.value / pageSize.value)
|
total.value = await res.data.result.total
|
||||||
fetchHistoryList(data) // ปิดกรณีมี total
|
|
||||||
|
// คำนวณจำนวนหน้า
|
||||||
|
maxPage.value = Math.ceil(total.value / pageSize.value)
|
||||||
|
|
||||||
|
await fetchHistoryList(data)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err)
|
messageError($q, err)
|
||||||
|
|
@ -104,21 +108,22 @@ async function fetchlistTime() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function updateYear
|
* ฟังก์ชันสำหรับอัปเดตปีและเดือน
|
||||||
* @param y ปีที่อัปเดท
|
* @param y ปีที่ต้องการอัปเดต
|
||||||
|
* @param m เดือนที่ต้องการอัปเดต
|
||||||
*/
|
*/
|
||||||
async function updateYear(y: number, m: number) {
|
async function updateYear(y: number, m: number) {
|
||||||
year.value = y
|
year.value = y
|
||||||
month.value = m
|
month.value = m
|
||||||
stores.year = y
|
stores.year = y
|
||||||
functionFetch()
|
await functionFetch() // เรียกใช้งานฟังก์ชัน functionFetch เพื่อดึงข้อมูลใหม่
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hook*/
|
/**
|
||||||
onMounted(async () => {
|
* ดูการเปลี่ยนแปลงใน stores.tab เมื่อ stores.tab เปลี่ยนไป
|
||||||
await functionFetch()
|
* จะรีเซ็ตค่า page , filter เป็นสถานะเริ่มต้น
|
||||||
})
|
* แล้วเรียก functionFetch เพื่อดึงประวัติการลงเวลาใหม่
|
||||||
|
*/
|
||||||
watch(
|
watch(
|
||||||
() => stores.tab,
|
() => stores.tab,
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -127,6 +132,12 @@ watch(
|
||||||
functionFetch()
|
functionFetch()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
/**
|
||||||
|
* Hook
|
||||||
|
*/
|
||||||
|
onMounted(() => {
|
||||||
|
functionFetch()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -168,12 +179,12 @@ watch(
|
||||||
<q-tab-panels v-model="stores.tab" animated>
|
<q-tab-panels v-model="stores.tab" animated>
|
||||||
<q-tab-panel name="history">
|
<q-tab-panel name="history">
|
||||||
<ToolBar
|
<ToolBar
|
||||||
:fetchData="functionFetch"
|
:fetch-data="functionFetch"
|
||||||
@update:year="updateYear"
|
@update:year="updateYear"
|
||||||
:tab="stores.tab"
|
:tab="stores.tab"
|
||||||
/>
|
/>
|
||||||
<TableHistory
|
<TableHistory
|
||||||
:fetchData="functionFetch"
|
:fetch-data="functionFetch"
|
||||||
:page-size="pageSize"
|
:page-size="pageSize"
|
||||||
:total="total"
|
:total="total"
|
||||||
:page="page"
|
:page="page"
|
||||||
|
|
@ -186,7 +197,7 @@ watch(
|
||||||
|
|
||||||
<q-tab-panel name="time">
|
<q-tab-panel name="time">
|
||||||
<ToolBar
|
<ToolBar
|
||||||
:fetchData="functionFetch"
|
:fetch-data="functionFetch"
|
||||||
@update:year="updateYear"
|
@update:year="updateYear"
|
||||||
:tab="stores.tab"
|
:tab="stores.tab"
|
||||||
/>
|
/>
|
||||||
|
|
@ -202,16 +213,6 @@ watch(
|
||||||
/>
|
/>
|
||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
</q-tab-panels>
|
</q-tab-panels>
|
||||||
<!-- </q-card> -->
|
|
||||||
<!-- <Table
|
|
||||||
:fetchData="fetchlistHistory"
|
|
||||||
:page-size="pageSize"
|
|
||||||
:total="total"
|
|
||||||
:page="page"
|
|
||||||
:paging="true"
|
|
||||||
@update:change-page="changePage"
|
|
||||||
:max-page="maxPage"
|
|
||||||
/> -->
|
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3,26 +3,31 @@ import { ref, reactive, onMounted } from 'vue'
|
||||||
import { useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import Camera from 'simple-vue-camera'
|
import Camera from 'simple-vue-camera'
|
||||||
import http from '@/plugins/http'
|
|
||||||
import config from '@/app.config'
|
import config from '@/app.config'
|
||||||
import type { FormRef } from '@/interface/response/checkin'
|
import http from '@/plugins/http'
|
||||||
import MapCheck from '@/components/AscGISMap.vue'
|
|
||||||
import { useCounterMixin } from '@/stores/mixin'
|
import { useCounterMixin } from '@/stores/mixin'
|
||||||
|
|
||||||
|
import type { FormRef } from '@/interface/response/checkin'
|
||||||
|
|
||||||
|
import MapCheck from '@/components/AscGISMap.vue'
|
||||||
|
|
||||||
const mixin = useCounterMixin()
|
const mixin = useCounterMixin()
|
||||||
const { date2Thai, showLoader, hideLoader, messageError } = mixin
|
const { date2Thai, showLoader, hideLoader, messageError } = mixin
|
||||||
const $q = useQuasar()
|
const $q = useQuasar()
|
||||||
|
|
||||||
const dialogTime = ref<boolean>(false)
|
const modalTime = ref<boolean>(false) // Dailog ลงเวลาเข้างานของคุณ
|
||||||
const stetusCheckin = ref<boolean>(true)
|
const stetusCheckin = ref<boolean>(true) // สถานะเวลา เข้า,ออก
|
||||||
|
|
||||||
/** function เช็คเวลาต้องลงเวลาเข้าหรือออกงาน */
|
/**
|
||||||
|
* fetch เช็คเวลาต้องลงเวลาเข้าหรือออกงาน
|
||||||
|
*/
|
||||||
async function fetchCheckTime() {
|
async function fetchCheckTime() {
|
||||||
showLoader()
|
showLoader()
|
||||||
await http
|
await http
|
||||||
.get(config.API.checkTime())
|
.get(config.API.checkTime())
|
||||||
.then((res) => {
|
.then(async (res) => {
|
||||||
const data = res.data.result
|
const data = await res.data.result
|
||||||
stetusCheckin.value = data.checkInId ? false : true
|
stetusCheckin.value = data.checkInId ? false : true
|
||||||
checkInId.value = data.checkInId ? data.checkInId : ''
|
checkInId.value = data.checkInId ? data.checkInId : ''
|
||||||
})
|
})
|
||||||
|
|
@ -40,7 +45,10 @@ const Thai = ref<Date>(dateNow.value)
|
||||||
const formattedS = ref()
|
const formattedS = ref()
|
||||||
const formattedM = ref()
|
const formattedM = ref()
|
||||||
const formattedH = ref()
|
const formattedH = ref()
|
||||||
/** function อัพเดทเวลา*/
|
|
||||||
|
/**
|
||||||
|
* function อัพเดทเวลา
|
||||||
|
*/
|
||||||
function updateClock() {
|
function updateClock() {
|
||||||
const date = Date.now()
|
const date = Date.now()
|
||||||
const hh = moment(date).format('HH')
|
const hh = moment(date).format('HH')
|
||||||
|
|
@ -69,16 +77,19 @@ const checkInId = ref<string>('') //Id ลงเวลา check-in ล่าส
|
||||||
* @param location พิกัดละติจูด พิกัดลองติจูด
|
* @param location พิกัดละติจูด พิกัดลองติจูด
|
||||||
* @param namePOI ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์
|
* @param namePOI ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์
|
||||||
*/
|
*/
|
||||||
async function updateLocation(latitude: any, longitude: any, namePOI: string) {
|
async function updateLocation(
|
||||||
|
latitude: number,
|
||||||
|
longitude: number,
|
||||||
|
namePOI: string
|
||||||
|
) {
|
||||||
formLocation.lat = latitude
|
formLocation.lat = latitude
|
||||||
formLocation.lng = longitude
|
formLocation.lng = longitude
|
||||||
formLocation.POI = namePOI
|
formLocation.POI = namePOI
|
||||||
}
|
}
|
||||||
|
|
||||||
//location
|
const location = ref<string>('') // พื้นที่ใกล้เคียง
|
||||||
const location = ref<string>('')
|
const model = ref<string>('') // สถานที่ทำงาน
|
||||||
// const coordinates = ref<string>('')
|
// ตัวเลือกสถานที่ทำงาน
|
||||||
const model = ref<string>('')
|
|
||||||
const options = ref<string[]>([
|
const options = ref<string[]>([
|
||||||
'ปฏิบัติงานที่บ้าน',
|
'ปฏิบัติงานที่บ้าน',
|
||||||
'ลืมลงเวลาปฏิบัติงาน',
|
'ลืมลงเวลาปฏิบัติงาน',
|
||||||
|
|
@ -87,7 +98,9 @@ const options = ref<string[]>([
|
||||||
'อื่นๆ',
|
'อื่นๆ',
|
||||||
])
|
])
|
||||||
|
|
||||||
/** function เลือกสถานที่*/
|
/**
|
||||||
|
* function เลือกสถานที่
|
||||||
|
*/
|
||||||
function selectLocation() {
|
function selectLocation() {
|
||||||
if (model.value === 'อื่นๆ') {
|
if (model.value === 'อื่นๆ') {
|
||||||
useLocation.value = ''
|
useLocation.value = ''
|
||||||
|
|
@ -103,7 +116,9 @@ const img = ref<any>(undefined)
|
||||||
const photoWidth = ref<number>(350)
|
const photoWidth = ref<number>(350)
|
||||||
const photoHeight = ref<number>(350)
|
const photoHeight = ref<number>(350)
|
||||||
|
|
||||||
/** function เปิดกล้อง */
|
/**
|
||||||
|
* function เปิดกล้อง
|
||||||
|
*/
|
||||||
async function openCamera() {
|
async function openCamera() {
|
||||||
// change camera device
|
// change camera device
|
||||||
if (cameraIsOn.value) {
|
if (cameraIsOn.value) {
|
||||||
|
|
@ -115,14 +130,18 @@ async function openCamera() {
|
||||||
cameraIsOn.value = !cameraIsOn.value
|
cameraIsOn.value = !cameraIsOn.value
|
||||||
}
|
}
|
||||||
|
|
||||||
/** change camera device */
|
/**
|
||||||
|
* change camera device
|
||||||
|
*/
|
||||||
async function changeCamera() {
|
async function changeCamera() {
|
||||||
const devices: any = await camera.value?.devices(['videoinput'])
|
const devices: any = await camera.value?.devices(['videoinput'])
|
||||||
const device = await devices[0]
|
const device = await devices[0]
|
||||||
camera.value?.changeCamera(device.deviceId)
|
camera.value?.changeCamera(device.deviceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function ถ่ายรูป*/
|
/**
|
||||||
|
* function ถ่ายรูป
|
||||||
|
*/
|
||||||
async function capturePhoto() {
|
async function capturePhoto() {
|
||||||
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 },
|
||||||
|
|
@ -139,7 +158,9 @@ async function capturePhoto() {
|
||||||
img.value = url
|
img.value = url
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function เปลี่ยนรูปภาพ*/
|
/**
|
||||||
|
* function เปลี่ยนรูปภาพ
|
||||||
|
*/
|
||||||
function refreshPhoto() {
|
function refreshPhoto() {
|
||||||
img.value = undefined
|
img.value = undefined
|
||||||
camera.value?.start()
|
camera.value?.start()
|
||||||
|
|
@ -153,7 +174,9 @@ const objectRef: FormRef = {
|
||||||
useLocation: useLocationRef,
|
useLocation: useLocationRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function ตรวจสอบค่าว่างของ input*/
|
/**
|
||||||
|
* function ตรวจสอบค่าว่างของ input
|
||||||
|
*/
|
||||||
function validateForm() {
|
function validateForm() {
|
||||||
const hasError = []
|
const hasError = []
|
||||||
for (const key in objectRef) {
|
for (const key in objectRef) {
|
||||||
|
|
@ -170,8 +193,11 @@ function validateForm() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeChickin = ref<string>()
|
const timeChickin = ref<string>('') //เวลาเข้างาน,เวลาออกงาน
|
||||||
/** function ยืนยันการลงเวลาเข้า - ออก*/
|
|
||||||
|
/**
|
||||||
|
* function ยืนยันการลงเวลาเข้า - ออก
|
||||||
|
*/
|
||||||
async function confirm() {
|
async function confirm() {
|
||||||
showLoader()
|
showLoader()
|
||||||
const isLocation = workplace.value === 'in-place' //*true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง
|
const isLocation = workplace.value === 'in-place' //*true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง
|
||||||
|
|
@ -188,7 +214,7 @@ async function confirm() {
|
||||||
await http
|
await http
|
||||||
.post(config.API.checkin(), formdata)
|
.post(config.API.checkin(), formdata)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = res.data.result
|
const data = await res.data.result
|
||||||
const dateObject = new Date(data.date)
|
const dateObject = new Date(data.date)
|
||||||
const options: Intl.DateTimeFormatOptions = {
|
const options: Intl.DateTimeFormatOptions = {
|
||||||
hour12: false,
|
hour12: false,
|
||||||
|
|
@ -199,8 +225,7 @@ async function confirm() {
|
||||||
dateObject
|
dateObject
|
||||||
)
|
)
|
||||||
timeChickin.value = timeString
|
timeChickin.value = timeString
|
||||||
dialogTime.value = true
|
modalTime.value = true
|
||||||
// await fetchCheckTime()
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err)
|
messageError($q, err)
|
||||||
|
|
@ -210,19 +235,28 @@ async function confirm() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ปิด popup แสดงการลงเวลา
|
||||||
|
*/
|
||||||
async function onClickConfirm() {
|
async function onClickConfirm() {
|
||||||
await fetchCheckTime()
|
await fetchCheckTime()
|
||||||
cameraIsOn.value = false
|
cameraIsOn.value = false
|
||||||
img.value = undefined
|
img.value = undefined
|
||||||
dialogTime.value = false
|
modalTime.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* เลือกสถานที่ทำงาน
|
||||||
|
*/
|
||||||
function updateWorkplace() {
|
function updateWorkplace() {
|
||||||
useLocation.value = ''
|
useLocation.value = ''
|
||||||
model.value = ''
|
model.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// class
|
/**
|
||||||
|
* รี้เทินร์ class สีพื้นหลัง
|
||||||
|
* @param val ค่า stetusCheckin
|
||||||
|
*/
|
||||||
const getClass = (val: boolean) => {
|
const getClass = (val: boolean) => {
|
||||||
return {
|
return {
|
||||||
'bg-primary text-white col-12 row items-center q-px-md q-py-sm': val,
|
'bg-primary text-white col-12 row items-center q-px-md q-py-sm': val,
|
||||||
|
|
@ -230,7 +264,6 @@ const getClass = (val: boolean) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fullName = ref<string>('')
|
|
||||||
/** Hook*/
|
/** Hook*/
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchCheckTime()
|
await fetchCheckTime()
|
||||||
|
|
@ -426,6 +459,7 @@ onMounted(async () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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">
|
||||||
|
|
@ -456,7 +490,8 @@ onMounted(async () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-dialog v-model="dialogTime" persistent>
|
<!-- แสดงการลงเวลา -->
|
||||||
|
<q-dialog v-model="modalTime" persistent>
|
||||||
<q-card class="full-width cardNone">
|
<q-card class="full-width cardNone">
|
||||||
<div :class="getClass(stetusCheckin)">
|
<div :class="getClass(stetusCheckin)">
|
||||||
<div class="text-body1 text-center col-12 text-weight-bold">
|
<div class="text-body1 text-center col-12 text-weight-bold">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue