refector code

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-02 17:37:08 +07:00
parent 067ac5f173
commit 23d6801f80
9 changed files with 338 additions and 217 deletions

View file

@ -1,18 +1,19 @@
<script setup lang="ts">
import { ref, watch } from 'vue'
import { useCounterMixin } from '@/stores/mixin'
import { useChekIn } from '@/stores/chekin'
import type { DataDateMonthObject } from '@/interface/index/Main'
import Popup from '@/components/PopUp.vue'
// import HeaderPopup from "@/components/HeaderPopup.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 { monthYear2Thai } = useCounterMixin()
/**
* props จาก components HistoryView
*/
const props = defineProps({
fetchData: {
type: Function,
@ -25,37 +26,57 @@ const props = defineProps({
})
const emit = defineEmits(['update:year'])
const filterYear = ref<number>(stores.year)
const titleName = ref<string>('เพิ่มรายการลงเวลากรณีพิเศษ')
const filterYear = ref<number>(stores.year) //
const titleName = ref<string>('เพิ่มรายการลงเวลากรณีพิเศษ') // popup
const dateMonth = ref<DataDateMonthObject>({
month: new Date().getMonth(),
year: stores.year,
})
const modalPopup = ref<boolean>(false) // modal
watch(
() => stores.year,
() => {
dateMonth.value.year = stores.year
}
)
/**
* งกนอปเดทปงบประมาณ
* @param type ประเภท year,mount
*/
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)
/**
* เป popup เพมรายการลงเวลากรณเศษ
*/
function onClickopen() {
modalPopup.value = true
}
/**
* popup เพมรายการลงเวลากรณเศษ
*/
function onClickClose() {
modalPopup.value = false
}
/**
* แปลงวนเดอนปเปนเดอนและปในภาษาไทย
* @param val นเดอนป
* @returns เดอนและปในภาษาไทย
*/
const monthYearThai = (val: DataDateMonthObject) => {
if (val == null) return ''
else return monthYear2Thai(val.month, val.year)
}
/**
* watch การเปลยนแปลงของ stores.year
*/
watch(
() => stores.year,
(newYear) => {
dateMonth.value.year = newYear
}
)
</script>
<template>
<div class="items-center col-12 row q-pb-sm">