hrms-checkin/src/components/PopUp.vue

78 lines
1.6 KiB
Vue
Raw Normal View History

2023-11-14 17:47:43 +07:00
<script setup lang="ts">
import { ref, watch } from 'vue'
2026-04-27 19:21:23 +07:00
import type { PropType } from 'vue'
2024-09-02 17:37:08 +07:00
import type { DataCheckIn } from '@/interface/index/Main'
2023-11-14 17:47:43 +07:00
2024-09-02 17:37:08 +07:00
import HeaderPopup from '@/components/HeaderPopup.vue' // หัว popup
import FormTime from '@/components/FormTime.vue' //
/**
* props จาก components TableHistory
*/
2023-11-14 17:47:43 +07:00
const props = defineProps({
modal: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '',
},
clickClose: {
type: Function,
default: null,
},
dataById: {
2024-09-02 17:37:08 +07:00
type: Object as PropType<DataCheckIn>,
2023-11-14 17:47:43 +07:00
default: null,
},
fetchData: {
type: Function,
default: () => console.log('not function'),
},
action: {
type: String,
default: '',
},
2023-11-14 17:47:43 +07:00
})
2024-09-02 17:37:08 +07:00
const data = ref<DataCheckIn>() // ข้อมูลลงเวลา
/**
* popup
* เรยกใชงก props.clickClose()
*/
2023-11-14 17:47:43 +07:00
function clickClosePopup() {
props.clickClose()
}
2024-09-02 17:37:08 +07:00
/**
* watch การเปลยนแปลงของ props.modal
*/
watch(
() => props.modal,
() => {
2024-09-02 17:37:08 +07:00
if (props.modal) {
data.value = props?.dataById
}
2023-11-14 17:47:43 +07:00
}
)
2023-11-14 17:47:43 +07:00
</script>
<template>
2025-03-19 16:05:25 +07:00
<q-dialog v-model="props.modal" persistent m>
2025-05-14 16:51:58 +07:00
<q-card :style="$q.screen.lt.sm ? 'width: 100%;' : 'min-width: 80vh;'">
2023-11-14 17:47:43 +07:00
<HeaderPopup :title="props.title" :clickClose="clickClosePopup" />
2024-09-02 17:37:08 +07:00
<FormTime
2024-09-02 17:37:08 +07:00
:data-byId="data"
:close-popup="clickClosePopup"
:fetch-data="props.fetchData"
:action="props.action"
/>
2023-11-14 17:47:43 +07:00
</q-card>
</q-dialog>
</template>
<style scoped></style>