- run by vite

- change camera
This commit is contained in:
Warunee Tamkoo 2023-11-14 17:47:43 +07:00
parent 782fa7f59f
commit 85d163fb64
57 changed files with 1494 additions and 1375 deletions

View file

@ -35,44 +35,43 @@
</template>
<script setup lang="ts">
import { defineEmits, defineProps } from "vue";
import { useDialogPluginComponent } from "quasar";
import { useDialogPluginComponent } from 'quasar'
const props = defineProps({
color: {
type: String,
default: "primary",
default: 'primary',
},
textOk: {
type: String,
default: "ตกลง",
default: 'ตกลง',
},
title: {
type: String,
default: "หัวข้อ?",
default: 'หัวข้อ?',
},
message: {
type: String,
default: "ข้อความ",
default: 'ข้อความ',
},
icon: {
type: String,
default: "question_mark",
default: 'question_mark',
},
onlycancel: {
type: Boolean,
default: false,
},
});
})
defineEmits([
// REQUIRED; need to specify some events that your
// component will emit through useDialogPluginComponent()
...useDialogPluginComponent.emits,
]);
])
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
useDialogPluginComponent();
useDialogPluginComponent()
// dialogRef - Vue ref to be applied to QDialog
// onDialogHide - Function to be used as handler for @hide on QDialog
// onDialogOK - Function to call to settle dialog with "ok" outcome
@ -84,7 +83,7 @@ const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
function onOKClick() {
// on OK, it is REQUIRED to
// call onDialogOK (with optional payload)
onDialogOK();
onDialogOK()
// or with payload: onDialogOK({ ... })
// ...and it will also hide the dialog automatically
}

View file

@ -1,225 +1,225 @@
<script setup lang="ts">
import { ref, watch, onMounted, defineProps } from "vue";
import { useQuasar } from "quasar";
import moment, { Moment } from "moment";
// importStores
import { useCounterMixin } from "@/stores/mixin";
// importType
import type { FormRef } from "@/interface/index/Main";
const $q = useQuasar();
const mixin = useCounterMixin();
const { date2Thai, covertDateObject, dialogConfirm } = mixin;
const props = defineProps({
dataById: {
type: Object,
default: null,
},
closePopup: {
type: Function,
required: true,
},
});
const dataById = ref<any>([]);
const date = ref<Date | null>(null);
const checkboxIn = ref<boolean>(false);
const checkboxOut = ref<boolean>(false);
const reason = ref<string>("");
const statusAction = ref<boolean>(false);
onMounted(() => {
updateClock();
dataById.value = props.dataById;
if (dataById.value == null) {
statusAction.value = true;
}
});
const dateNow = ref<Date>(new Date());
const timeNoew = ref<string>("");
function updateClock() {
const date = Date.now();
let hh = moment(date).format("HH");
let mm = moment(date).format("mm");
timeNoew.value = `${hh}:${mm} น.`;
}
const dateRef = ref<object | null>(null);
const reasonRef = ref<object | null>(null);
const objectRef: FormRef = {
date: dateRef,
reason: reasonRef,
};
const checkstatusBox = ref<boolean>(false);
function onCkickSave() {
const hasError = [];
for (const key in objectRef) {
if (Object.prototype.hasOwnProperty.call(objectRef, key)) {
const property = objectRef[key];
if (property.value && typeof property.value.validate === "function") {
const isValid = property.value.validate();
hasError.push(isValid);
}
}
}
if (checkboxIn.value === false && checkboxOut.value === false) {
checkstatusBox.value = true;
}
if (
hasError.every(
(result) => result === true && checkstatusBox.value === false
)
) {
dialogConfirm($q, async () => {
console.log("save");
props.closePopup();
});
} else {
console.log("ไม่ผ่าน ");
}
}
watch(
[() => checkboxIn.value, () => checkboxOut.value],
([newCheckboxIn, newCheckboxOut]) => {
if (checkstatusBox.value) {
if (newCheckboxIn || newCheckboxOut) {
checkstatusBox.value = false;
}
}
}
);
</script>
<template>
<q-card-section class="col q-pt-none">
<div class="row q-pa-sm q-col-q-gutter-sm">
<q-card
flat
bordered
:class="$q.screen.gt.xs ? 'col-12 bg-grey-1' : 'col-12 '"
>
<q-card-section class="bg-primary text-white q-pa-sm">
<div class="text-center text-bold">เวลาปจจ</div>
</q-card-section>
<!-- <div class="q-pa-sm text-primary">เวลาปจจ</div> -->
<q-card-section class="text-center q-pa-sm">
<div class="row q-gutter-md">
<div class="col">{{ date2Thai(dateNow) }}</div>
<div class="col">{{ timeNoew }}</div>
</div>
</q-card-section>
</q-card>
<q-card flat bordered class="col-12 q-mt-sm" v-if="statusAction">
<div class="q-pa-sm">
<VueDatePicker
v-model="date"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
outlined
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
ref="dateRef"
outlined
dense
:model-value="date !== null ? date2Thai(date) : null"
:label="`${'กรอกวันที่'}`"
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
lazy-rules
hide-bottom-space
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input> </template
></VueDatePicker>
</div>
</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">{{ covertDateObject(dataById.date) }}</div>
</div>
</q-card>
<q-card
flat
bordered
class="q-pa-sm col-12 q-mt-sm"
:style="{
borderColor: checkstatusBox ? '#B22222' : '',
borderWidth: checkstatusBox ? '2px' : '',
}"
>
<div class="row q-gutter-xs">
<div class="col-12">
<q-checkbox
keep-color
color="primary"
v-model="checkboxIn"
label="ขอแก้ไขเวลาเข้างาน"
/>
</div>
<div class="col-12">
<q-checkbox
keep-color
v-model="checkboxOut"
color="primary"
label="ขอแก้ไขเวลาออกงาน"
/>
</div>
</div>
</q-card>
<div
v-if="checkstatusBox"
class="text-red-9 q-pa-sm"
style="font-size: 10px"
>
กรณาเลอก
</div>
<q-card flat bordered class="q-pa-sm col-12 q-mt-sm">
<q-input
ref="reasonRef"
dense
outlined
v-model="reason"
label="เหตุผล"
type="textarea"
:rows="$q.screen.gt.xs ? '5' : '1'"
label-color="grey-5"
:rules="[(val) => !!val || 'กรุณากรอกเหตุผล']"
lazy-rules
hide-bottom-space
class="custom-aqua-border"
/>
</q-card>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn dense color="secondary" label="บันทึก" @click="onCkickSave" />
</q-card-actions>
</template>
<style scoped></style>
<script setup lang="ts">
import { ref, watch, onMounted } from 'vue'
import { useQuasar } from 'quasar'
import moment from 'moment'
// importStores
import { useCounterMixin } from '@/stores/mixin'
// importType
import type { FormRef } from '@/interface/index/Main'
const $q = useQuasar()
const mixin = useCounterMixin()
const { date2Thai, covertDateObject, dialogConfirm } = mixin
const props = defineProps({
dataById: {
type: Object,
default: null,
},
closePopup: {
type: Function,
required: true,
},
})
const dataById = ref<any>([])
const date = ref<Date | null>(null)
const checkboxIn = ref<boolean>(false)
const checkboxOut = ref<boolean>(false)
const reason = ref<string>('')
const statusAction = ref<boolean>(false)
onMounted(() => {
updateClock()
dataById.value = props.dataById
if (dataById.value == null) {
statusAction.value = true
}
})
const dateNow = ref<Date>(new Date())
const timeNoew = ref<string>('')
function updateClock() {
const date = Date.now()
const hh = moment(date).format('HH')
const mm = moment(date).format('mm')
timeNoew.value = `${hh}:${mm} น.`
}
const dateRef = ref<object | null>(null)
const reasonRef = ref<object | null>(null)
const objectRef: FormRef = {
date: dateRef,
reason: reasonRef,
}
const checkstatusBox = ref<boolean>(false)
function onCkickSave() {
const hasError = []
for (const key in objectRef) {
if (Object.prototype.hasOwnProperty.call(objectRef, key)) {
const property = objectRef[key]
if (property.value && typeof property.value.validate === 'function') {
const isValid = property.value.validate()
hasError.push(isValid)
}
}
}
if (checkboxIn.value === false && checkboxOut.value === false) {
checkstatusBox.value = true
}
if (
hasError.every(
(result) => result === true && checkstatusBox.value === false
)
) {
dialogConfirm($q, async () => {
console.log('save')
props.closePopup()
})
} else {
console.log('ไม่ผ่าน ')
}
}
watch(
[() => checkboxIn.value, () => checkboxOut.value],
([newCheckboxIn, newCheckboxOut]) => {
if (checkstatusBox.value) {
if (newCheckboxIn || newCheckboxOut) {
checkstatusBox.value = false
}
}
}
)
</script>
<template>
<q-card-section class="col q-pt-none">
<div class="row q-pa-sm q-col-q-gutter-sm">
<q-card
flat
bordered
:class="$q.screen.gt.xs ? 'col-12 bg-grey-1' : 'col-12 '"
>
<q-card-section class="bg-primary text-white q-pa-sm">
<div class="text-center text-bold">เวลาปจจ</div>
</q-card-section>
<!-- <div class="q-pa-sm text-primary">เวลาปจจ</div> -->
<q-card-section class="text-center q-pa-sm">
<div class="row q-gutter-md">
<div class="col">{{ date2Thai(dateNow) }}</div>
<div class="col">{{ timeNoew }}</div>
</div>
</q-card-section>
</q-card>
<q-card flat bordered class="col-12 q-mt-sm" v-if="statusAction">
<div class="q-pa-sm">
<VueDatePicker
v-model="date"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
outlined
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
ref="dateRef"
outlined
dense
:model-value="date !== null ? date2Thai(date) : null"
:label="`${'กรอกวันที่'}`"
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
lazy-rules
hide-bottom-space
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input> </template
></VueDatePicker>
</div>
</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">{{ covertDateObject(dataById.date) }}</div>
</div>
</q-card>
<q-card
flat
bordered
class="q-pa-sm col-12 q-mt-sm"
:style="{
borderColor: checkstatusBox ? '#B22222' : '',
borderWidth: checkstatusBox ? '2px' : '',
}"
>
<div class="row q-gutter-xs">
<div class="col-12">
<q-checkbox
keep-color
color="primary"
v-model="checkboxIn"
label="ขอแก้ไขเวลาเข้างาน"
/>
</div>
<div class="col-12">
<q-checkbox
keep-color
v-model="checkboxOut"
color="primary"
label="ขอแก้ไขเวลาออกงาน"
/>
</div>
</div>
</q-card>
<div
v-if="checkstatusBox"
class="text-red-9 q-pa-sm"
style="font-size: 10px"
>
กรณาเลอก
</div>
<q-card flat bordered class="q-pa-sm col-12 q-mt-sm">
<q-input
ref="reasonRef"
dense
outlined
v-model="reason"
label="เหตุผล"
type="textarea"
:rows="$q.screen.gt.xs ? '5' : '1'"
label-color="grey-5"
:rules="[(val) => !!val || 'กรุณากรอกเหตุผล']"
lazy-rules
hide-bottom-space
class="custom-aqua-border"
/>
</q-card>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn dense color="secondary" label="บันทึก" @click="onCkickSave" />
</q-card-actions>
</template>
<style scoped></style>

View file

@ -1,35 +1,34 @@
<script setup lang="ts">
import { defineProps } from "vue";
const props = defineProps({
title: {
type: String,
default: "",
},
clickClose: {
type: Function,
default: null,
},
});
function clickClosePopup() {
props.clickClose();
}
</script>
<template>
<q-toolbar>
<q-toolbar-title class="text-subtitle2 text-bold">{{
props.title
}}</q-toolbar-title>
<q-btn
icon="close"
unelevated
round
dense
@click="clickClosePopup"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
<q-separator />
</template>
<style scoped></style>
<script setup lang="ts">
const props = defineProps({
title: {
type: String,
default: '',
},
clickClose: {
type: Function,
default: null,
},
})
function clickClosePopup() {
props.clickClose()
}
</script>
<template>
<q-toolbar>
<q-toolbar-title class="text-subtitle2 text-bold">{{
props.title
}}</q-toolbar-title>
<q-btn
icon="close"
unelevated
round
dense
@click="clickClosePopup"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
<q-separator />
</template>
<style scoped></style>

View file

@ -1,101 +1,101 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { GoogleMap, Marker } from "vue3-google-map";
declare var google: any;
const center = ref<any>();
const location = ref<string>("");
const test = ref();
// hook
onMounted(() => {
findNearestPlace();
});
//
function findNearestPlace() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
const userLocation = {
lat: position.coords.latitude,
lng: position.coords.longitude,
};
// Location API
findNearestPlaceFromAPI(userLocation);
center.value = userLocation;
console.log(center.value);
},
(error) => {
console.error(error);
console.log("erroe");
}
);
} else {
console.error("เบราว์เซอร์ไม่รองรับการระบุตำแหน่ง");
}
}
function findNearestPlaceFromAPI(userLocation: any) {
const placesService = new google.maps.places.PlacesService(
document.createElement("div")
);
const request = {
location: userLocation,
radius: 1000, //
types: ["point_of_interest"], //
};
placesService.nearbySearch(request, (results: any, status: any) => {
if (status === google.maps.places.PlacesServiceStatus.OK) {
console.log("Nearby places:", results[0]);
const place = results[0];
location.value = place.name;
test.value = place.geometry.location;
} else {
console.error("Error fetching nearby places:", status);
}
});
}
</script>
<template>
<q-card
bordered
flat
class="col-12 bg-grey-2 shadow-0"
:style="$q.screen.gt.xs ? 'height: 350px;' : 'height: 360px;'"
>
<div style="width: 100%; height: 90%">
<GoogleMap
api-key="AIzaSyBzPSF5NxUZ1G8DKBnJvJPTqCR0Ct2xf58"
style="width: 100%; height: 100%"
:center="center"
:zoom="17"
>
<Marker :options="{ position: center }" />
<Marker
:options="{
position: test,
icon: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
}"
/>
</GoogleMap>
</div>
<div
:class="
$q.screen.gt.xs
? 'q-pa-sm text-weight-medium text-grey-8'
: ' text-weight-medium text-grey-8'
"
>
นทใกลเคยง
<span class="q-px-sm">:</span>
{{ location }}
</div>
</q-card>
</template>
<style scoped></style>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { GoogleMap, Marker } from 'vue3-google-map'
declare var google: any
const center = ref<any>()
const location = ref<string>('')
const test = ref()
// hook
onMounted(() => {
findNearestPlace()
})
//
function findNearestPlace() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
const userLocation = {
lat: position.coords.latitude,
lng: position.coords.longitude,
}
// Location API
findNearestPlaceFromAPI(userLocation)
center.value = userLocation
console.log(center.value)
},
(error) => {
console.error(error)
console.log('erroe')
}
)
} else {
console.error('เบราว์เซอร์ไม่รองรับการระบุตำแหน่ง')
}
}
function findNearestPlaceFromAPI(userLocation: any) {
const placesService = new google.maps.places.PlacesService(
document.createElement('div')
)
const request = {
location: userLocation,
radius: 1000, //
types: ['point_of_interest'], //
}
placesService.nearbySearch(request, (results: any, status: any) => {
if (status === google.maps.places.PlacesServiceStatus.OK) {
console.log('Nearby places:', results[0])
const place = results[0]
location.value = place.name
test.value = place.geometry.location
} else {
console.error('Error fetching nearby places:', status)
}
})
}
</script>
<template>
<q-card
bordered
flat
class="col-12 bg-grey-2 shadow-0"
:style="$q.screen.gt.xs ? 'height: 350px;' : 'height: 360px;'"
>
<div style="width: 100%; height: 90%">
<GoogleMap
api-key="AIzaSyBzPSF5NxUZ1G8DKBnJvJPTqCR0Ct2xf58"
style="width: 100%; height: 100%"
:center="center"
:zoom="17"
>
<Marker :options="{ position: center }" />
<Marker
:options="{
position: test,
icon: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
}"
/>
</GoogleMap>
</div>
<div
:class="
$q.screen.gt.xs
? 'q-pa-sm text-weight-medium text-grey-8'
: ' text-weight-medium text-grey-8'
"
>
นทใกลเคยง
<span class="q-px-sm">:</span>
{{ location }}
</div>
</q-card>
</template>
<style scoped></style>

View file

@ -1,45 +1,45 @@
<script setup lang="ts">
import { ref, defineProps, watch } from "vue";
import HeaderPopup from "@/components/HeaderPopup.vue";
import FormTime from "@/components/FormTime.vue";
const props = defineProps({
modal: {
type: Boolean,
default: false,
},
title: {
type: String,
default: "",
},
clickClose: {
type: Function,
default: null,
},
dataById: {
type: Object,
default: null,
},
});
// -
const data = ref<any>();
function clickClosePopup() {
props.clickClose();
}
watch(props, () => {
if (props.modal === true) {
data.value = props.dataById;
}
});
</script>
<template>
<q-dialog v-model="props.modal" full-height>
<q-card class="column full-height" style="width: 300px">
<HeaderPopup :title="props.title" :clickClose="clickClosePopup" />
<FormTime :dataById="data" :closePopup="clickClosePopup" />
</q-card>
</q-dialog>
</template>
<style scoped></style>
<script setup lang="ts">
import { ref, watch } from 'vue'
import HeaderPopup from '@/components/HeaderPopup.vue'
import FormTime from '@/components/FormTime.vue'
const props = defineProps({
modal: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '',
},
clickClose: {
type: Function,
default: null,
},
dataById: {
type: Object,
default: null,
},
})
// -
const data = ref<any>()
function clickClosePopup() {
props.clickClose()
}
watch(props, () => {
if (props.modal === true) {
data.value = props.dataById
}
})
</script>
<template>
<q-dialog v-model="props.modal" full-height>
<q-card class="column full-height" style="width: 300px">
<HeaderPopup :title="props.title" :clickClose="clickClosePopup" />
<FormTime :dataById="data" :closePopup="clickClosePopup" />
</q-card>
</q-dialog>
</template>
<style scoped></style>

View file

@ -1,311 +1,311 @@
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { ref } from "vue";
// importStores
import { useChekIn } from "@/stores/chekin";
// importComponent
import Popup from "@/components/PopUp.vue";
const stores = useChekIn();
const columns = ref<QTableProps["columns"]>([
{
name: "date",
align: "left",
label: "วัน/เดือน/ปี",
sortable: true,
field: "date",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:15%;",
},
{
name: "in",
align: "left",
label: "เวลาเข้างาน",
sortable: true,
field: "in",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:15%;",
},
{
name: "out",
align: "left",
label: "เวลาออกงาน",
sortable: true,
field: "out",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:15%;",
},
{
name: "Morningstatus",
align: "left",
label: "สถานะช่วงเช้า",
sortable: true,
field: "Morningstatus",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:15%;",
},
{
name: "AfternoonStatus",
align: "left",
label: "สถานะช่วงบ่าย",
sortable: true,
field: "AfternoonStatus",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:15%;",
},
// {
// name: "loIn",
// align: "left",
// label: "",
// sortable: true,
// field: "loIn",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// },
// {
// name: "loOut",
// align: "left",
// label: "",
// sortable: true,
// field: "loOut",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// },
// {
// name: "status",
// align: "left",
// label: "",
// sortable: true,
// field: "status",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px; width:10%;",
// },
]);
// popup
const modalPopup = ref<boolean>(false);
const titlePopup = ref<string>("");
const dataRow = ref<any>();
function openPopup(data: any) {
const title = "แก้ไขลงเวลา";
modalPopup.value = true;
titlePopup.value = title;
dataRow.value = data;
}
function closePopup() {
modalPopup.value = false;
}
function classStatus(status: string) {
switch (status) {
case "ขาดราชการ":
return "text-red";
case "ปกติ":
return "text-blue";
case "สาย":
return "text-yellow-8";
default:
break;
}
}
const pagination = ref({
page: 1,
rowsPerPage: 10,
});
</script>
<template>
<q-table
flat
bordered
class="custom-table2"
:columns="columns"
:rows="stores.rows"
virtual-scroll
:virtual-scroll-sticky-size-start="48"
:style="$q.screen.gt.xs ? 'max-height: 64vh' : ''"
:grid="$q.screen.gt.xs ? false : true"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width> </q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div
v-if="col.name === 'Morningstatus'"
:class="classStatus(props.row.Morningstatus)"
>
{{ props.row.Morningstatus }}
</div>
<div
v-else-if="col.name === 'AfternoonStatus'"
:class="classStatus(props.row.AfternoonStatus)"
>
{{ props.row.AfternoonStatus }}
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
<q-td>
<q-btn
v-if="props.row.statusEdit === 'edit'"
outline
icon="edit"
size="12px"
label="ขอแก้ไข"
color="cyan-6"
@click="openPopup(props.row)"
/>
<q-chip
v-else
:color="`${stores.classColorStatus(props.row.statusEdit)}-1`"
:text-color="`${stores.classColorStatus(props.row.statusEdit)}-7`"
>{{ props.row.statusEditName }}</q-chip
>
</q-td>
</q-tr>
</template>
<template #item="props">
<div
class="q-pa-xs col-xs-12 col-sm-6 col-md-4 col-lg-3 grid-style-transition"
>
<q-card bordered flat class="q-py-sm shadow-0">
<q-list dense>
<q-item v-for="col in props.cols" :key="col.name" :props="props">
<q-item-section>
<q-item-label caption>{{ col.label }}</q-item-label>
</q-item-section>
<q-item-section side>
<q-item-label>
<span
v-if="col.name == 'Morningstatus'"
:class="classStatus(props.row.Morningstatus)"
>{{ col.value }}</span
>
<span
v-else-if="col.name == 'AfternoonStatus'"
:class="classStatus(props.row.AfternoonStatus)"
>{{ col.value }}</span
>
<span v-else class="text-black">{{ col.value }} </span>
</q-item-label>
</q-item-section>
<q-separator />
</q-item>
</q-list>
<q-card-section>
<div class="row">
<div class="col" v-if="props.row.statusEdit === 'edit'">
<q-btn
class="full-width text-cen"
outline
rounded
icon="edit"
label="ขอแก้ไข"
color="info"
size="sm"
@click="openPopup(props.row)"
/>
</div>
<div class="col" v-else>
<q-chip
:color="`${stores.classColorStatus(props.row.statusEdit)}-1`"
:text-color="`${stores.classColorStatus(
props.row.statusEdit
)}-7`"
>
{{ props.row.statusEditName }}
</q-chip>
</div>
</div>
</q-card-section>
</q-card>
</div>
</template>
<template v-slot:pagination="scope">
<q-pagination
v-model="pagination.page"
active-color="primary"
color="dark"
:max="scope.pagesNumber"
:max-pages="5"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
</q-table>
<Popup
:modal="modalPopup"
:clickClose="closePopup"
:title="titlePopup"
:dataById="dataRow"
/>
</template>
<style scoped lang="scss">
.icon-color {
color: #4154b3;
}
.items-center {
align-items: center;
justify-content: center;
}
.custom-table2 {
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
}
.q-table td:nth-of-type(2) {
z-index: 3 !important;
}
.q-table th:nth-of-type(2),
.q-table td:nth-of-type(2) {
position: sticky;
left: 0;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
.text-caption {
text-align: left;
}
}
.q-card-section-last {
display: flex;
justify-content: flex-end;
}
</style>
<script setup lang="ts">
import type { QTableProps } from 'quasar'
import { ref } from 'vue'
// importStores
import { useChekIn } from '@/stores/chekin'
// importComponent
import Popup from '@/components/PopUp.vue'
const stores = useChekIn()
const columns = ref<QTableProps['columns']>([
{
name: 'date',
align: 'left',
label: 'วัน/เดือน/ปี',
sortable: true,
field: 'date',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;',
},
{
name: 'in',
align: 'left',
label: 'เวลาเข้างาน',
sortable: true,
field: 'in',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;',
},
{
name: 'out',
align: 'left',
label: 'เวลาออกงาน',
sortable: true,
field: 'out',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;',
},
{
name: 'Morningstatus',
align: 'left',
label: 'สถานะช่วงเช้า',
sortable: true,
field: 'Morningstatus',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;',
},
{
name: 'AfternoonStatus',
align: 'left',
label: 'สถานะช่วงบ่าย',
sortable: true,
field: 'AfternoonStatus',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;',
},
// {
// name: "loIn",
// align: "left",
// label: "",
// sortable: true,
// field: "loIn",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// },
// {
// name: "loOut",
// align: "left",
// label: "",
// sortable: true,
// field: "loOut",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// },
// {
// name: "status",
// align: "left",
// label: "",
// sortable: true,
// field: "status",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px; width:10%;",
// },
])
// popup
const modalPopup = ref<boolean>(false)
const titlePopup = ref<string>('')
const dataRow = ref<any>()
function openPopup(data: any) {
const title = 'แก้ไขลงเวลา'
modalPopup.value = true
titlePopup.value = title
dataRow.value = data
}
function closePopup() {
modalPopup.value = false
}
function classStatus(status: string) {
switch (status) {
case 'ขาดราชการ':
return 'text-red'
case 'ปกติ':
return 'text-blue'
case 'สาย':
return 'text-yellow-8'
default:
break
}
}
const pagination = ref({
page: 1,
rowsPerPage: 10,
})
</script>
<template>
<q-table
flat
bordered
class="custom-table2"
:columns="columns"
:rows="stores.rows"
virtual-scroll
:virtual-scroll-sticky-size-start="48"
:style="$q.screen.gt.xs ? 'max-height: 64vh' : ''"
:grid="$q.screen.gt.xs ? false : true"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width> </q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div
v-if="col.name === 'Morningstatus'"
:class="classStatus(props.row.Morningstatus)"
>
{{ props.row.Morningstatus }}
</div>
<div
v-else-if="col.name === 'AfternoonStatus'"
:class="classStatus(props.row.AfternoonStatus)"
>
{{ props.row.AfternoonStatus }}
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
<q-td>
<q-btn
v-if="props.row.statusEdit === 'edit'"
outline
icon="edit"
size="12px"
label="ขอแก้ไข"
color="cyan-6"
@click="openPopup(props.row)"
/>
<q-chip
v-else
:color="`${stores.classColorStatus(props.row.statusEdit)}-1`"
:text-color="`${stores.classColorStatus(props.row.statusEdit)}-7`"
>{{ props.row.statusEditName }}</q-chip
>
</q-td>
</q-tr>
</template>
<template #item="props">
<div
class="q-pa-xs col-xs-12 col-sm-6 col-md-4 col-lg-3 grid-style-transition"
>
<q-card bordered flat class="q-py-sm shadow-0">
<q-list dense>
<q-item v-for="col in props.cols" :key="col.name" :props="props">
<q-item-section>
<q-item-label caption>{{ col.label }}</q-item-label>
</q-item-section>
<q-item-section side>
<q-item-label>
<span
v-if="col.name == 'Morningstatus'"
:class="classStatus(props.row.Morningstatus)"
>{{ col.value }}</span
>
<span
v-else-if="col.name == 'AfternoonStatus'"
:class="classStatus(props.row.AfternoonStatus)"
>{{ col.value }}</span
>
<span v-else class="text-black">{{ col.value }} </span>
</q-item-label>
</q-item-section>
<q-separator />
</q-item>
</q-list>
<q-card-section>
<div class="row">
<div class="col" v-if="props.row.statusEdit === 'edit'">
<q-btn
class="full-width text-cen"
outline
rounded
icon="edit"
label="ขอแก้ไข"
color="info"
size="sm"
@click="openPopup(props.row)"
/>
</div>
<div class="col" v-else>
<q-chip
:color="`${stores.classColorStatus(props.row.statusEdit)}-1`"
:text-color="`${stores.classColorStatus(
props.row.statusEdit
)}-7`"
>
{{ props.row.statusEditName }}
</q-chip>
</div>
</div>
</q-card-section>
</q-card>
</div>
</template>
<template v-slot:pagination="scope">
<q-pagination
v-model="pagination.page"
active-color="primary"
color="dark"
:max="scope.pagesNumber"
:max-pages="5"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
</q-table>
<Popup
:modal="modalPopup"
:clickClose="closePopup"
:title="titlePopup"
:dataById="dataRow"
/>
</template>
<style scoped lang="scss">
.icon-color {
color: #4154b3;
}
.items-center {
align-items: center;
justify-content: center;
}
.custom-table2 {
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
}
.q-table td:nth-of-type(2) {
z-index: 3 !important;
}
.q-table th:nth-of-type(2),
.q-table td:nth-of-type(2) {
position: sticky;
left: 0;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
.text-caption {
text-align: left;
}
}
.q-card-section-last {
display: flex;
justify-content: flex-end;
}
</style>

View file

@ -1,49 +1,49 @@
<script setup lang="ts">
import { ref } from "vue";
import type { DataOption } from "@/interface/index/Main";
import Popup from "@/components/PopUp.vue";
// import HeaderPopup from "@/components/HeaderPopup.vue";
// import FormTime from "@/components/FormTime.vue";
const filterYear = ref<string>("");
const yearOption = ref<DataOption[]>([{ id: "2566", name: "2566" }]);
const titleName = ref<string>("เพิ่มรายการลงเวลากรณีพิเศษ");
const modalPopup = ref<boolean>(false);
function onClickopen() {
modalPopup.value = true;
}
function onClickClose() {
modalPopup.value = false;
}
</script>
<template>
<div class="q-pb-sm row">
<div class="items-center col-12 row q-gutter-sm">
<q-select
dense
outlined
style="width: 180px"
label="ปีประวัติลงเวลา"
v-model="filterYear"
:options="yearOption"
option-label="name"
option-value="id"
/>
<q-space />
<q-btn
unelevated
outline
icon="add"
color="light-blue"
:class="$q.screen.gt.xs ? 'q-px-sm bg-blue-1' : ''"
:label="$q.screen.gt.xs ? 'เพิ่มรายการลงเวลากรณีพิเศษ' : ''"
@click="onClickopen"
/>
</div>
</div>
<Popup :modal="modalPopup" :title="titleName" :clickClose="onClickClose" />
</template>
<style scoped></style>
<script setup lang="ts">
import { ref } from 'vue'
import type { DataOption } from '@/interface/index/Main'
import Popup from '@/components/PopUp.vue'
// import HeaderPopup from "@/components/HeaderPopup.vue";
// import FormTime from "@/components/FormTime.vue";
const filterYear = ref<string>('')
const yearOption = ref<DataOption[]>([{ id: '2566', name: '2566' }])
const titleName = ref<string>('เพิ่มรายการลงเวลากรณีพิเศษ')
const modalPopup = ref<boolean>(false)
function onClickopen() {
modalPopup.value = true
}
function onClickClose() {
modalPopup.value = false
}
</script>
<template>
<div class="q-pb-sm row">
<div class="items-center col-12 row q-gutter-sm">
<q-select
dense
outlined
style="width: 180px"
label="ปีประวัติลงเวลา"
v-model="filterYear"
:options="yearOption"
option-label="name"
option-value="id"
/>
<q-space />
<q-btn
unelevated
outline
icon="add"
color="light-blue"
:class="$q.screen.gt.xs ? 'q-px-sm bg-blue-1' : ''"
:label="$q.screen.gt.xs ? 'เพิ่มรายการลงเวลากรณีพิเศษ' : ''"
@click="onClickopen"
/>
</div>
</div>
<Popup :modal="modalPopup" :title="titleName" :clickClose="onClickClose" />
</template>
<style scoped></style>