แก้ไขการแสดงผลประวัติการลงเวลา

This commit is contained in:
Warunee Tamkoo 2023-11-21 10:56:37 +07:00
parent 31e5cf13f9
commit a95c320cf5
3 changed files with 94 additions and 131 deletions

View file

@ -9,6 +9,8 @@ import { useChekIn } from '@/stores/chekin'
import Popup from '@/components/PopUp.vue' import Popup from '@/components/PopUp.vue'
const stores = useChekIn() const stores = useChekIn()
/** props from page */
const props = defineProps({ const props = defineProps({
paging: { paging: {
type: Boolean, type: Boolean,
@ -16,7 +18,7 @@ const props = defineProps({
}, },
pageSize: { pageSize: {
type: Number, type: Number,
defualt: 25, defualt: 10,
}, },
page: { page: {
type: Number, type: Number,
@ -90,79 +92,72 @@ async function updatePagination(newPagination: any) {
props.changePage(1, newPagination.rowsPerPage, true) props.changePage(1, newPagination.rowsPerPage, true)
initialPagination.value = newPagination initialPagination.value = newPagination
} }
/** column history table */
const columns = ref<QTableProps['columns']>([ const columns = ref<QTableProps['columns']>([
{ {
name: 'date', name: 'checkInDate',
align: 'left', align: 'left',
label: 'วัน/เดือน/ปี', label: 'วัน/เดือน/ปี',
sortable: true, sortable: true,
field: 'date', field: 'checkInDate',
headerStyle: 'font-size: 14px', headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;', style: 'font-size: 14px; width:15%;',
}, },
{ {
name: 'in', name: 'checkInTime',
align: 'left', align: 'left',
label: 'เวลาเข้างาน', label: 'เวลาเข้างาน',
sortable: true, sortable: true,
field: 'in', field: 'checkInTime',
headerStyle: 'font-size: 14px', headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;', style: 'font-size: 14px; width:15%;',
}, },
{ {
name: 'loIn', name: 'checkInLocation',
align: 'left', align: 'left',
label: 'พิกัด', label: 'พิกัด',
sortable: true, sortable: true,
field: 'loIn', field: 'checkInLocation',
headerStyle: 'font-size: 14px', headerStyle: 'font-size: 14px',
style: 'font-size: 14px', style: 'font-size: 14px',
}, },
{ {
name: 'out', name: 'checkInStatus',
align: 'left',
label: 'เวลาออกงาน',
sortable: true,
field: 'out',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;',
},
{
name: 'loOut',
align: 'left',
label: 'พิกัด',
sortable: true,
field: 'loOut',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px',
},
{
name: 'Morningstatus',
align: 'left', align: 'left',
label: 'สถานะช่วงเช้า', label: 'สถานะช่วงเช้า',
sortable: true, sortable: true,
field: 'Morningstatus', field: 'checkInStatus',
headerStyle: 'font-size: 14px', headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;', style: 'font-size: 14px; width:15%;',
}, },
{ {
name: 'AfternoonStatus', name: 'checkOutTime',
align: 'left',
label: 'เวลาออกงาน',
sortable: true,
field: 'checkOutTime',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;',
},
{
name: 'checkOutLocation',
align: 'left',
label: 'พิกัด',
sortable: true,
field: 'checkOutLocation',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px',
},
{
name: 'checkOutStatus',
align: 'left', align: 'left',
label: 'สถานะช่วงบ่าย', label: 'สถานะช่วงบ่าย',
sortable: true, sortable: true,
field: 'AfternoonStatus', field: 'checkOutStatus',
headerStyle: 'font-size: 14px', headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;', style: 'font-size: 14px; width:15%;',
}, }
{
name: 'status',
align: 'left',
label: 'สถานะ',
sortable: true,
field: 'status',
headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:10%;',
},
]) ])
// popup // popup
const modalPopup = ref<boolean>(false) const modalPopup = ref<boolean>(false)
@ -174,9 +169,11 @@ function openPopup(data: any) {
titlePopup.value = title titlePopup.value = title
dataRow.value = data dataRow.value = data
} }
function closePopup() { function closePopup() {
modalPopup.value = false modalPopup.value = false
} }
function classStatus(status: string) { function classStatus(status: string) {
switch (status) { switch (status) {
case 'ขาดราชการ': case 'ขาดราชการ':
@ -189,11 +186,24 @@ function classStatus(status: string) {
break break
} }
} }
const pagination = ref({ const pagination = ref({
page: 1, page: 1,
rowsPerPage: 10, rowsPerPage: 2,
}) })
const checkRequestEdit = (checkInStatus: string, checkOutStatus: string) => {
if (
checkInStatus === 'ขาด' ||
checkInStatus === 'สาย' ||
checkOutStatus === 'ขาด' ||
checkOutStatus === 'สาย'
)
return true
else false
}
</script> </script>
<template> <template>
<q-table <q-table
flat flat
@ -220,16 +230,16 @@ const pagination = ref({
<q-tr :props="props" class="cursor-pointer"> <q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.name" :props="props"> <q-td v-for="col in props.cols" :key="col.name" :props="props">
<div <div
v-if="col.name === 'Morningstatus'" v-if="col.name === 'checkInStatus'"
:class="classStatus(props.row.Morningstatus)" :class="classStatus(props.row.checkInStatus)"
> >
{{ props.row.Morningstatus }} {{ props.row.checkInStatus }}
</div> </div>
<div <div
v-else-if="col.name === 'AfternoonStatus'" v-else-if="col.name === 'checkOutStatus'"
:class="classStatus(props.row.AfternoonStatus)" :class="classStatus(props.row.checkOutStatus)"
> >
{{ props.row.AfternoonStatus }} {{ props.row.checkOutStatus }}
</div> </div>
<div v-else> <div v-else>
{{ col.value }} {{ col.value }}
@ -237,7 +247,13 @@ const pagination = ref({
</q-td> </q-td>
<q-td> <q-td>
<q-btn <q-btn
v-if="props.row.statusEdit === 'edit'" v-if="
checkRequestEdit(
props.row.checkInStatus,
props.row.checkOutStatus
)
"
style="min-width: 110px"
outline outline
icon="edit" icon="edit"
size="12px" size="12px"
@ -249,11 +265,13 @@ const pagination = ref({
v-else v-else
:color="`${stores.classColorStatus(props.row.statusEdit)}-1`" :color="`${stores.classColorStatus(props.row.statusEdit)}-1`"
:text-color="`${stores.classColorStatus(props.row.statusEdit)}-7`" :text-color="`${stores.classColorStatus(props.row.statusEdit)}-7`"
>{{ props.row.statusEditName }}</q-chip >{{ props.row.statusEdit }}</q-chip
> >
</q-td> </q-td>
</q-tr> </q-tr>
</template> </template>
<!-- กรณแสดงผลบน mobile -->
<template #item="props"> <template #item="props">
<div <div
class="q-pa-xs col-xs-12 col-sm-6 col-md-4 col-lg-3 grid-style-transition" class="q-pa-xs col-xs-12 col-sm-6 col-md-4 col-lg-3 grid-style-transition"
@ -267,13 +285,13 @@ const pagination = ref({
<q-item-section side> <q-item-section side>
<q-item-label> <q-item-label>
<span <span
v-if="col.name == 'Morningstatus'" v-if="col.name == 'checkInStatus'"
:class="classStatus(props.row.Morningstatus)" :class="classStatus(props.row.checkInStatus)"
>{{ col.value }}</span >{{ col.value }}</span
> >
<span <span
v-else-if="col.name == 'AfternoonStatus'" v-else-if="col.name == 'checkOutStatus'"
:class="classStatus(props.row.AfternoonStatus)" :class="classStatus(props.row.checkOutStatus)"
>{{ col.value }}</span >{{ col.value }}</span
> >
<span v-else class="text-black">{{ col.value }} </span> <span v-else class="text-black">{{ col.value }} </span>
@ -284,11 +302,18 @@ const pagination = ref({
</q-list> </q-list>
<q-card-section> <q-card-section>
<div class="row"> <div class="row">
<div class="col" v-if="props.row.statusEdit === 'edit'"> <div
class="col"
v-if="
checkRequestEdit(
props.row.checkInStatus,
props.row.checkOutStatus
)
"
>
<q-btn <q-btn
class="full-width text-cen" class="full-width text-cen"
outline outline
rounded
icon="edit" icon="edit"
label="ขอแก้ไข" label="ขอแก้ไข"
color="info" color="info"
@ -303,7 +328,7 @@ const pagination = ref({
props.row.statusEdit props.row.statusEdit
)}-7`" )}-7`"
> >
{{ props.row.statusEditName }} {{ props.row.statusEdit }}
</q-chip> </q-chip>
</div> </div>
</div> </div>

View file

@ -16,23 +16,16 @@ export const useChekIn = defineStore('checkin', () => {
// console.log(data) // console.log(data)
rows.value = [] rows.value = []
const datalist = await data.map((e: any) => ({ const datalist = await data.map((e: any) => ({
id: e.checkInId, checkInId: e.checkInId,
date: date2Thai(e.checkInDate), checkInDate: date2Thai(e.checkInDate),
no: e.no, checkInTime: e.checkInTime,
in: e.checkInTime, checkOutTime: e.checkOutTime != '' ? e.checkOutTime : '-',
out: e.checkOutTime, checkInStatus: convertStatus(e.checkInStatus),
Morningstatus: convertStatus(e.checkInStatus), checkOutStatus:
AfternoonStatus: convertStatus(e.checkOutStatus), e.checkOutStatus != null ? convertStatus(e.checkOutStatus) : '-',
loIn: e.checkInLocation, checkInLocation: e.checkInLocation,
loOut: e.checkOutLocation, checkOutLocation: e.checkOutLocation != '' ? e.checkOutLocation : '-',
status: e.statusEdit,
// statusEditName: convertStatusEdit(e.statusEdit), // statusEditName: convertStatusEdit(e.statusEdit),
// checkInTime: e.checkInTime,
// checkInLocation: e.checkInLocation,
// checkOutTime: e.checkOutTime,
// checkOutLocation: e.checkOutLocation,
// checkInStatus: convertStatus(e.checkInStatus),
// checkOutStatus: convertStatus(e.checkOutStatus),
})) }))
rows.value = datalist rows.value = datalist
} }
@ -65,6 +58,8 @@ export const useChekIn = defineStore('checkin', () => {
return 'orange' return 'orange'
case 'approve': case 'approve':
return 'green' return 'green'
case 'reject':
return 'red'
} }
} }

View file

@ -1,5 +1,4 @@
<script setup lang="ts"> <script setup lang="ts">
import type { QTableProps } from 'quasar'
import { ref, 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'
@ -19,7 +18,6 @@ const { fetchHistoryList } = stores
const $q = useQuasar() // noti quasar const $q = useQuasar() // noti quasar
onMounted(() => { onMounted(() => {
// fetchlist()
fetchlistHistory() fetchlistHistory()
}) })
@ -33,7 +31,7 @@ const filter = ref<string>('') //search data table
async function changePage( async function changePage(
pageVal: number, pageVal: number,
pageSizeVal: number, pageSizeVal: number,
loading: boolean = false loading: false
) { ) {
page.value = await pageVal page.value = await pageVal
pageSize.value = await pageSizeVal pageSize.value = await pageSizeVal
@ -41,7 +39,7 @@ async function changePage(
} }
// //
const fetchlistHistory = async (loading: boolean = true) => { const fetchlistHistory = async (loading = true) => {
loading === true ?? showLoader() loading === true ?? showLoader()
await http await http
.get( .get(
@ -61,60 +59,6 @@ const fetchlistHistory = async (loading: boolean = true) => {
hideLoader() hideLoader()
}) })
} }
// function fetchlist() {
// const listData = [
// {
// no: '1',
// date: '13/08/66',
// in: '11:20',
// loIn: ' . ',
// out: '',
// loOut: '',
// status: '',
// Morningstatus: '1',
// AfternoonStatus: '1',
// statusEdit: 'wait',
// },
// {
// no: '2',
// date: '12/08/66',
// in: '08:04',
// loIn: ' . ',
// out: '17:01',
// loOut: ' . ',
// status: '',
// Morningstatus: '2',
// AfternoonStatus: '2',
// statusEdit: 'edit',
// },
// {
// no: '3',
// date: '11/08/66',
// in: '08:34',
// loIn: ' . ',
// out: '17:36',
// loOut: ' . ',
// status: ' ',
// Morningstatus: '3',
// AfternoonStatus: '2',
// statusEdit: 'edit',
// },
// {
// no: '4',
// date: '10/08/66',
// in: '08:48',
// loIn: ' . ',
// out: '17:00',
// loOut: ' . ',
// status: ' ',
// Morningstatus: '3',
// AfternoonStatus: '3',
// statusEdit: 'approve',
// },
// ]
// stores.fetchHistoryList(listData)
// }
</script> </script>
<template> <template>
<div class="col-12 row justify-center"> <div class="col-12 row justify-center">
@ -125,8 +69,7 @@ const fetchlistHistory = async (loading: boolean = true) => {
> >
<div class="col-2"> <div class="col-2">
<q-btn <q-btn
icon="arrow_backt" icon="arrow_back"
unelevated
round round
dense dense
flat flat