2023-11-14 17:47:43 +07:00
|
|
|
<script setup lang="ts">
|
2023-11-29 17:46:19 +07:00
|
|
|
import { ref, watch } from 'vue'
|
|
|
|
|
|
2024-09-02 17:37:08 +07:00
|
|
|
import { useCounterMixin } from '@/stores/mixin'
|
|
|
|
|
import { useChekIn } from '@/stores/chekin'
|
|
|
|
|
|
2023-11-29 17:46:19 +07:00
|
|
|
import type { DataDateMonthObject } from '@/interface/index/Main'
|
2023-11-24 16:39:55 +07:00
|
|
|
|
2023-11-14 17:47:43 +07:00
|
|
|
import Popup from '@/components/PopUp.vue'
|
2023-11-29 17:46:19 +07:00
|
|
|
|
|
|
|
|
const stores = useChekIn()
|
2024-09-02 17:37:08 +07:00
|
|
|
const { monthYear2Thai } = useCounterMixin()
|
2023-11-14 17:47:43 +07:00
|
|
|
|
2024-09-02 17:37:08 +07:00
|
|
|
/**
|
|
|
|
|
* props จาก components HistoryView
|
|
|
|
|
*/
|
2023-11-24 16:39:55 +07:00
|
|
|
const props = defineProps({
|
|
|
|
|
fetchData: {
|
|
|
|
|
type: Function,
|
|
|
|
|
require: true,
|
|
|
|
|
},
|
2023-11-29 17:46:19 +07:00
|
|
|
tab: {
|
|
|
|
|
type: String,
|
|
|
|
|
require: true,
|
|
|
|
|
},
|
2023-11-24 16:39:55 +07:00
|
|
|
})
|
|
|
|
|
const emit = defineEmits(['update:year'])
|
|
|
|
|
|
2024-09-02 17:37:08 +07:00
|
|
|
const filterYear = ref<number>(stores.year) //ปีงบประมาณ
|
|
|
|
|
const titleName = ref<string>('เพิ่มรายการลงเวลากรณีพิเศษ') //หัว popup
|
2023-11-29 17:46:19 +07:00
|
|
|
const dateMonth = ref<DataDateMonthObject>({
|
|
|
|
|
month: new Date().getMonth(),
|
|
|
|
|
year: stores.year,
|
|
|
|
|
})
|
2024-09-02 17:37:08 +07:00
|
|
|
const modalPopup = ref<boolean>(false) // modal เพิ่มรายการลงเวลากรณีพิเศษ
|
2023-11-14 17:47:43 +07:00
|
|
|
|
2024-09-02 17:37:08 +07:00
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันอัปเดทปีงบประมาณ
|
|
|
|
|
* @param type ประเภท year,mount
|
|
|
|
|
*/
|
2023-11-29 17:46:19 +07:00
|
|
|
function filterYearFn(type: string) {
|
|
|
|
|
const year = type === 'year' ? filterYear.value : dateMonth.value.year
|
2024-09-02 17:37:08 +07:00
|
|
|
//ส่งค่า ปีงบประมาณ กลับ
|
2023-11-29 17:46:19 +07:00
|
|
|
emit('update:year', year, dateMonth.value.month)
|
2023-11-23 13:40:16 +07:00
|
|
|
}
|
|
|
|
|
|
2024-09-02 17:37:08 +07:00
|
|
|
/**
|
|
|
|
|
* เปิด popup เพิ่มรายการลงเวลากรณีพิเศษ
|
|
|
|
|
*/
|
2023-11-14 17:47:43 +07:00
|
|
|
function onClickopen() {
|
|
|
|
|
modalPopup.value = true
|
|
|
|
|
}
|
2024-09-02 17:37:08 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ปิด popup เพิ่มรายการลงเวลากรณีพิเศษ
|
|
|
|
|
*/
|
2023-11-14 17:47:43 +07:00
|
|
|
function onClickClose() {
|
|
|
|
|
modalPopup.value = false
|
|
|
|
|
}
|
2023-11-29 17:46:19 +07:00
|
|
|
|
2024-09-02 17:37:08 +07:00
|
|
|
/**
|
|
|
|
|
* แปลงวันเดือนปีเป็นเดือนและปีในภาษาไทย
|
|
|
|
|
* @param val วันเดือนปี
|
|
|
|
|
* @returns เดือนและปีในภาษาไทย
|
|
|
|
|
*/
|
2023-11-29 17:46:19 +07:00
|
|
|
const monthYearThai = (val: DataDateMonthObject) => {
|
|
|
|
|
if (val == null) return ''
|
|
|
|
|
else return monthYear2Thai(val.month, val.year)
|
|
|
|
|
}
|
2024-09-02 17:37:08 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* watch การเปลี่ยนแปลงของ stores.year
|
|
|
|
|
*/
|
|
|
|
|
watch(
|
|
|
|
|
() => stores.year,
|
|
|
|
|
(newYear) => {
|
|
|
|
|
dateMonth.value.year = newYear
|
|
|
|
|
}
|
|
|
|
|
)
|
2023-11-14 17:47:43 +07:00
|
|
|
</script>
|
|
|
|
|
<template>
|
2024-01-19 15:34:09 +07:00
|
|
|
<div class="items-center col-12 row q-pb-sm">
|
|
|
|
|
<datepicker
|
|
|
|
|
v-if="tab === 'history'"
|
|
|
|
|
menu-class-name="modalfix"
|
|
|
|
|
v-model="filterYear"
|
|
|
|
|
class="col-xs-5 col-sm-3 col-md-2"
|
|
|
|
|
:locale="'th'"
|
|
|
|
|
autoApply
|
|
|
|
|
year-picker
|
2025-03-10 09:33:24 +07:00
|
|
|
:transitions="false"
|
2024-01-19 15:34:09 +07:00
|
|
|
:enableTimePicker="false"
|
|
|
|
|
@update:modelValue="filterYearFn('year')"
|
|
|
|
|
>
|
|
|
|
|
<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="filterYear + 543"
|
|
|
|
|
:label="`${'ปีงบประมาณ'}`"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="event"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
style="color: var(--q-primary)"
|
|
|
|
|
>
|
|
|
|
|
</q-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
2023-11-24 16:39:55 +07:00
|
|
|
|
2024-01-19 15:34:09 +07:00
|
|
|
<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
|
2025-03-10 09:33:24 +07:00
|
|
|
:transitions="false"
|
2024-01-19 15:34:09 +07:00
|
|
|
: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>
|
2023-11-29 17:46:19 +07:00
|
|
|
|
2024-01-19 15:34:09 +07:00
|
|
|
<q-space />
|
|
|
|
|
<q-btn
|
|
|
|
|
unelevated
|
|
|
|
|
icon="add"
|
|
|
|
|
:dense="$q.screen.lt.sm"
|
|
|
|
|
color="secondary"
|
|
|
|
|
:label="$q.screen.gt.xs ? 'เพิ่มรายการลงเวลากรณีพิเศษ' : ''"
|
|
|
|
|
@click="onClickopen"
|
|
|
|
|
/>
|
2023-11-14 17:47:43 +07:00
|
|
|
</div>
|
|
|
|
|
|
2023-11-27 09:23:43 +07:00
|
|
|
<Popup
|
|
|
|
|
:modal="modalPopup"
|
|
|
|
|
:title="titleName"
|
|
|
|
|
:clickClose="onClickClose"
|
|
|
|
|
:fetchData="props.fetchData"
|
|
|
|
|
/>
|
2023-11-14 17:47:43 +07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|