Merge branch 'main' of github.com:Frappet/bma-ehr-checkin

This commit is contained in:
Kittapath 2024-07-09 17:05:36 +07:00
commit b60eb0f557
5 changed files with 134 additions and 111 deletions

View file

@ -1,10 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import type { QTableProps } from 'quasar'
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import type { QTableProps } from 'quasar'
import { useCounterMixin } from '@/stores/mixin'
import { useChekIn } from '@/stores/chekin' import { useChekIn } from '@/stores/chekin'
import Popup from '@/components/PopUp.vue' // dialog / import Popup from '@/components/PopUp.vue' // dialog /
const mixin = useCounterMixin()
const { date2Thai } = mixin
const stores = useChekIn() const stores = useChekIn()
const selected = ref<string[]>([]) const selected = ref<string[]>([])
@ -50,43 +54,6 @@ const tab = ref<string>(props.tab?.toString())
const emit = defineEmits(['update:change-page']) const emit = defineEmits(['update:change-page'])
// Pagination - initial pagination
const initialPagination = ref<any>({
sortBy: null,
descending: false,
page: 1,
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
async function updatePagination(newPagination: any) {
initialPagination.value = newPagination
currentPage.value = 1 // set current page 1 per row
}
async function filterFn() {
emit(
'update:change-page',
1,
initialPagination.value.rowsPerPage,
keyword.value
)
}
/** column history table */ /** column history table */
const columns = ref<QTableProps['columns']>( const columns = ref<QTableProps['columns']>(
props.tab == 'history' props.tab == 'history'
@ -157,11 +124,11 @@ const columns = ref<QTableProps['columns']>(
] ]
: [ : [
{ {
name: 'checkInDate', name: 'checkInDateTime',
align: 'left', align: 'left',
label: 'วัน/เดือน/ปี', label: 'วัน/เดือน/ปี',
sortable: true, sortable: true,
field: 'checkInDate', field: (v) => date2Thai(v.checkInDateTime),
headerStyle: 'font-size: 14px', headerStyle: 'font-size: 14px',
style: 'font-size: 14px; width:15%;', style: 'font-size: 14px; width:15%;',
}, },
@ -204,6 +171,7 @@ const columns = ref<QTableProps['columns']>(
] ]
) )
const visibleColumns = ref<string[]>([ const visibleColumns = ref<string[]>([
'checkInDateTime',
'checkInDate', 'checkInDate',
'checkInTime', 'checkInTime',
'checkInLocation', 'checkInLocation',
@ -212,11 +180,51 @@ const visibleColumns = ref<string[]>([
'checkOutLocation', 'checkOutLocation',
'checkOutStatus', 'checkOutStatus',
]) ])
// Pagination - initial pagination
const initialPagination = ref({
sortBy: null,
descending: false,
page: 1,
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
async function updatePagination(newPagination: any) {
initialPagination.value = newPagination
currentPage.value = 1 // set current page 1 per row
}
async function filterFn() {
emit(
'update:change-page',
1,
initialPagination.value.rowsPerPage,
keyword.value
)
}
// popup // popup
const modalPopup = ref<boolean>(false) const modalPopup = ref<boolean>(false)
const titlePopup = ref<string>('') const titlePopup = ref<string>('')
const dataRow = ref<any>() const dataRow = ref<any>()
function openPopup(data: any) { function openPopup(data: any) {
console.log(data)
const title = 'แก้ไขลงเวลา' const title = 'แก้ไขลงเวลา'
modalPopup.value = true modalPopup.value = true
titlePopup.value = title titlePopup.value = title
@ -327,7 +335,7 @@ function onClickOpenPopupRejrct(data: any) {
{{ props.row.checkOutStatus }} {{ props.row.checkOutStatus }}
</div> </div>
<div v-else> <div v-else>
{{ col.value }} {{ col.value ?? '-' }}
</div> </div>
</q-td> </q-td>
<q-td v-if="tab === 'history'"> <q-td v-if="tab === 'history'">

View file

@ -25,10 +25,18 @@ interface LocationObject {
longitude: number longitude: number
} }
interface Pagination {
sortBy: string
descending: boolean
page: number
rowsPerPage: number
}
export type { export type {
DataOption, DataOption,
FormRef, FormRef,
notiType, notiType,
DataDateMonthObject, DataDateMonthObject,
LocationObject, LocationObject,
Pagination,
} }

View file

@ -7,6 +7,7 @@ interface FormRef {
interface FormData { interface FormData {
checkInId: string checkInId: string
checkInDate: Date | null checkInDate: Date | null
checkOutDate: Date | null
checkInDateTime: Date checkInDateTime: Date
checkInTime: string checkInTime: string
checkOutTime: string checkOutTime: string

View file

@ -2,14 +2,14 @@ import { defineStore } from 'pinia'
import { ref } from 'vue' import { ref } from 'vue'
import type { FormData, Datalist } from '@/interface/response/checkin' import type { FormData, Datalist } from '@/interface/response/checkin'
import { useCounterMixin } from '@/stores/mixin' import { useCounterMixin } from '@/stores/mixin'
import moment from 'moment'
const mixin = useCounterMixin() const mixin = useCounterMixin()
const { date2Thai } = mixin const { date2Thai } = mixin
/** store for checkin history*/ /** store for checkin history*/
export const useChekIn = defineStore('checkin', () => { export const useChekIn = defineStore('checkin', () => {
const year = ref<number>(new Date().getFullYear()) const year = ref<number>(new Date().getFullYear())
const rows = ref<Datalist[]>() const rows = ref<Datalist[]>([])
const tab = ref<string>('history') const tab = ref<string>('history')
/** /**
@ -22,7 +22,7 @@ export const useChekIn = defineStore('checkin', () => {
const dataList: Datalist[] = await 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, checkInDateTime: e.checkInDate ? e.checkInDate : e.checkOutDate,
checkInTime: e.checkInTime, checkInTime: e.checkInTime,
checkOutTime: e.checkOutTime != '' ? e.checkOutTime : '-', checkOutTime: e.checkOutTime != '' ? e.checkOutTime : '-',
checkInStatus: e.checkInStatus ? convertStatus(e.checkInStatus) : '-', checkInStatus: e.checkInStatus ? convertStatus(e.checkInStatus) : '-',

View file

@ -1,17 +1,25 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, computed, 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 config from '@/app.config'
/**
* import Components
*/
import TableHistory from '@/components/TableHistory.vue' import TableHistory from '@/components/TableHistory.vue'
import ToolBar from '@/components/ToolBar.vue' import ToolBar from '@/components/ToolBar.vue'
import http from '@/plugins/http' /**
import config from '@/app.config' * importStores
import { useCounterMixin } from '@/stores/mixin' */
// importStores
import { useChekIn } from '@/stores/chekin' import { useChekIn } from '@/stores/chekin'
import { useCounterMixin } from '@/stores/mixin'
/**
* use
*/
const mixin = useCounterMixin() const mixin = useCounterMixin()
const router = useRouter() const router = useRouter()
const stores = useChekIn() const stores = useChekIn()
@ -19,8 +27,6 @@ const { showLoader, hideLoader, messageError } = mixin
const { fetchHistoryList } = stores const { fetchHistoryList } = stores
const $q = useQuasar() // noti quasar const $q = useQuasar() // noti quasar
const tab = ref<string>('history')
// paging // paging
const page = ref<number>(1) const page = ref<number>(1)
const year = ref<number>(new Date().getFullYear()) const year = ref<number>(new Date().getFullYear())
@ -130,73 +136,73 @@ watch(
<div <div
class="bg-secondary text-white col-12 row items-center q-px-md q-py-sm" class="bg-secondary text-white col-12 row items-center q-px-md q-py-sm"
> >
<q-btn <q-btn
icon="arrow_back" icon="arrow_back"
round round
dense dense
flat flat
color="white" color="white"
@click="router.go(-1)" @click="router.go(-1)"
/> />
<span class="text-body1 text-weight-bold q-pl-md" <span class="text-body1 text-weight-bold q-pl-md"
>ประวการลงเวลา >ประวการลงเวลา
</span> </span>
</div> </div>
<div class="col-12 text-grey-9"> <div class="col-12 text-grey-9">
<q-tabs <q-tabs
v-model="stores.tab" v-model="stores.tab"
dense dense
align="left" align="left"
inline-label inline-label
class="rounded-borders" class="rounded-borders"
indicator-color="primary" indicator-color="primary"
active-bg-color="teal-1" active-bg-color="teal-1"
active-class="text-primary" active-class="text-primary"
> >
<q-tab name="history" label="ประวัติการลงเวลา" /> <q-tab name="history" label="ประวัติการลงเวลา" />
<q-tab name="time" label="รายการลงเวลากรณีพิเศษ" /> <q-tab name="time" label="รายการลงเวลากรณีพิเศษ" />
</q-tabs> </q-tabs>
<q-separator /> <q-separator />
<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" :fetchData="functionFetch"
@update:year="updateYear" @update:year="updateYear"
:tab="stores.tab" :tab="stores.tab"
/> />
<TableHistory <TableHistory
:fetchData="functionFetch" :fetchData="functionFetch"
:page-size="pageSize" :page-size="pageSize"
:total="total" :total="total"
:page="page" :page="page"
:paging="true" :paging="true"
@update:change-page="changePage" @update:change-page="changePage"
:max-page="maxPage" :max-page="maxPage"
:tab="stores.tab" :tab="stores.tab"
/> />
</q-tab-panel> </q-tab-panel>
<q-tab-panel name="time"> <q-tab-panel name="time">
<ToolBar <ToolBar
:fetchData="functionFetch" :fetchData="functionFetch"
@update:year="updateYear" @update:year="updateYear"
:tab="stores.tab" :tab="stores.tab"
/> />
<TableHistory <TableHistory
:fetchData="functionFetch" :fetchData="functionFetch"
:page-size="pageSize" :page-size="pageSize"
:total="total" :total="total"
:page="page" :page="page"
:paging="true" :paging="true"
@update:change-page="changePage" @update:change-page="changePage"
:max-page="maxPage" :max-page="maxPage"
:tab="stores.tab" :tab="stores.tab"
/> />
</q-tab-panel> </q-tab-panel>
</q-tab-panels> </q-tab-panels>
<!-- </q-card> --> <!-- </q-card> -->
<!-- <Table <!-- <Table
:fetchData="fetchlistHistory" :fetchData="fetchlistHistory"
:page-size="pageSize" :page-size="pageSize"