ปรับค้นงานปีงบประมาณ ประวัติการลงเวลา

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-11-29 17:46:19 +07:00
parent a51042d48a
commit 9aef54609d
5 changed files with 134 additions and 10 deletions

View file

@ -1,24 +1,47 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref, watch } from 'vue'
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 HeaderPopup from "@/components/HeaderPopup.vue";
// import FormTime from "@/components/FormTime.vue"; // import FormTime from "@/components/FormTime.vue";
import { useCounterMixin } from '@/stores/mixin'
import { useChekIn } from '@/stores/chekin'
const mixin = useCounterMixin() //
const stores = useChekIn()
const { monthYear2Thai } = mixin
const props = defineProps({ const props = defineProps({
fetchData: { fetchData: {
type: Function, type: Function,
require: true, require: true,
}, },
tab: {
type: String,
require: true,
},
}) })
const emit = defineEmits(['update:year']) const emit = defineEmits(['update:year'])
const filterYear = ref<number>(new Date().getFullYear()) const filterYear = ref<number>(stores.year)
// const yearOption = ref<DataOption[]>([{ id: '2566', name: '2566' }])
const titleName = ref<string>('เพิ่มรายการลงเวลากรณีพิเศษ') const titleName = ref<string>('เพิ่มรายการลงเวลากรณีพิเศษ')
const dateMonth = ref<DataDateMonthObject>({
month: new Date().getMonth(),
year: stores.year,
})
function filterYearFn() { watch(
emit('update:year', filterYear.value) () => stores.year,
() => {
dateMonth.value.year = stores.year
}
)
function filterYearFn(type: string) {
const year = type === 'year' ? filterYear.value : dateMonth.value.year
emit('update:year', year, dateMonth.value.month)
} }
const modalPopup = ref<boolean>(false) const modalPopup = ref<boolean>(false)
@ -28,11 +51,17 @@ function onClickopen() {
function onClickClose() { function onClickClose() {
modalPopup.value = false modalPopup.value = false
} }
const monthYearThai = (val: DataDateMonthObject) => {
if (val == null) return ''
else return monthYear2Thai(val.month, val.year)
}
</script> </script>
<template> <template>
<div class="q-pb-sm row"> <div class="q-pb-sm row">
<div class="items-center col-12 row q-gutter-sm"> <div class="items-center col-12 row q-gutter-sm">
<datepicker <datepicker
v-if="tab === 'history'"
menu-class-name="modalfix" menu-class-name="modalfix"
v-model="filterYear" v-model="filterYear"
class="col-xs-5 col-sm-3 col-md-2" class="col-xs-5 col-sm-3 col-md-2"
@ -40,7 +69,7 @@ function onClickClose() {
autoApply autoApply
year-picker year-picker
:enableTimePicker="false" :enableTimePicker="false"
@update:modelValue="filterYearFn" @update:modelValue="filterYearFn('year')"
> >
<template #year="{ year }">{{ year + 543 }}</template> <template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{ <template #year-overlay-value="{ value }">{{
@ -66,6 +95,41 @@ function onClickClose() {
</template> </template>
</datepicker> </datepicker>
<datepicker
v-else-if="tab === 'time'"
menu-class-name="modalfix"
v-model="dateMonth"
class="col-xs-5 col-sm-3 col-md-2"
:locale="'th'"
autoApply
month-picker
:enableTimePicker="false"
@update:modelValue="filterYearFn('mount')"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
lazy-rules
outlined
:model-value="monthYearThai(dateMonth)"
:label="`${'ปีงบประมาณ'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
<q-space /> <q-space />
<q-btn <q-btn
unelevated unelevated

View file

@ -2,6 +2,11 @@ interface DataOption {
id: string id: string
name: string name: string
} }
interface DataDateMonthObject {
month: number
year: number
}
interface FormRef { interface FormRef {
date: object | null date: object | null
reason: object | null reason: object | null
@ -14,4 +19,4 @@ interface notiType {
timereceive: Date timereceive: Date
} }
export type { DataOption, FormRef, notiType } export type { DataOption, FormRef, notiType, DataDateMonthObject }

View file

@ -7,6 +7,7 @@ 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 rows = ref<Datalist[]>() const rows = ref<Datalist[]>()
/** /**
@ -90,6 +91,7 @@ export const useChekIn = defineStore('checkin', () => {
return { return {
rows, rows,
year,
fetchHistoryList, fetchHistoryList,
classColorStatus, classColorStatus,
} }

View file

@ -267,8 +267,54 @@ export const useCounterMixin = defineStore('mixin', () => {
}) })
} }
function monthYear2Thai(month: number, year: number, isFullMonth = false) {
const date = new Date(`${year}-${month + 1}-1`)
const fullMonthThai = [
'มกราคม',
'กุมภาพันธ์',
'มีนาคม',
'เมษายน',
'พฤษภาคม',
'มิถุนายน',
'กรกฎาคม',
'สิงหาคม',
'กันยายน',
'ตุลาคม',
'พฤศจิกายน',
'ธันวาคม',
]
const abbrMonthThai = [
'ม.ค.',
'ก.พ.',
'มี.ค.',
'เม.ย.',
'พ.ค.',
'มิ.ย.',
'ก.ค.',
'ส.ค.',
'ก.ย.',
'ต.ค.',
'พ.ย.',
'ธ.ค.',
]
let dstYear = 0
if (date.getFullYear() > 2500) {
dstYear = date.getFullYear()
} else {
dstYear = date.getFullYear() + 543
}
let dstMonth = ''
if (isFullMonth) {
dstMonth = fullMonthThai[date.getMonth()]
} else {
dstMonth = abbrMonthThai[date.getMonth()]
}
return dstMonth + ' ' + dstYear
}
return { return {
date2Thai, date2Thai,
monthYear2Thai,
showLoader, showLoader,
hideLoader, hideLoader,
covertDateObject, covertDateObject,

View file

@ -104,9 +104,11 @@ async function fetchlistTime() {
* function updateYear * function updateYear
* @param y ปเดท * @param y ปเดท
*/ */
async function updateYear(y: number) { async function updateYear(y: number, m: number) {
year.value = y year.value = y
y && functionFetch.value month.value = m
stores.year = y
functionFetch.value
} }
/** Hook*/ /** Hook*/
@ -118,6 +120,7 @@ watch(
() => tab.value, () => tab.value,
() => { () => {
page.value = 1 page.value = 1
filter.value = ''
functionFetch.value functionFetch.value
} }
) )
@ -146,7 +149,11 @@ watch(
<div class="col-2"></div> <div class="col-2"></div>
</div> </div>
<div class="col-12 q-pa-md text-grey-9"> <div class="col-12 q-pa-md text-grey-9">
<ToolBar :fetchData="fetchlistHistory" @update:year="updateYear" /> <ToolBar
:fetchData="fetchlistHistory"
@update:year="updateYear"
:tab="tab"
/>
<q-card bordered flat> <q-card bordered flat>
<q-tabs <q-tabs
v-model="tab" v-model="tab"