update ปฎิทิน

This commit is contained in:
AnandaTon 2023-11-03 14:53:02 +07:00
parent a00b9313ed
commit 83dc2d90a5
2 changed files with 62 additions and 5 deletions

View file

@ -80,7 +80,7 @@
</q-dialog>
</template>
<script setup lang="ts">
import { ref } from "vue"
import { ref, watch, onMounted } from "vue"
import FullCalendar from "@fullcalendar/vue3"
import dayGridPlugin from "@fullcalendar/daygrid"
import type { CalendarOptions } from "@fullcalendar/core"
@ -88,7 +88,7 @@ import timeGridPlugin from "@fullcalendar/timegrid"
import interactionPlugin from "@fullcalendar/interaction"
import allLocales from "@fullcalendar/core/locales-all"
import listPlugin from "@fullcalendar/list"
const fullCalendar = ref<InstanceType<typeof FullCalendar>>()
const fullCalendar = ref<any>() //ref calendar
const calendarOptions = ref<CalendarOptions>({
plugins: [
dayGridPlugin,
@ -140,7 +140,45 @@ const phone = ref("000-00000000")
const reason = ref("ยกเลิกการลา")
const model = ref(null)
const modeCancel = ref(true)
const props = defineProps({
dateYear: {
//filter
type: Number,
default: () => new Date().getFullYear(),
},
dateMonth: {
//filter
type: Number,
default: () => new Date().getMonth(),
},
refreshData: {
// main refresh data
type: Boolean,
required: true,
},
fetchDataSummaryCalendar: {
//
type: Function,
default: () => console.log("not function"),
},
})
/**
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/
onMounted(async () => {
if (fullCalendar !== undefined) {
const calen = fullCalendar.value.getApi()
const date = new Date(props.dateYear, props.dateMonth)
calen.gotoDate(date)
}
})
/**
* props(นเดอนปเลอก) ตอนอพเดท าฏนใหพเดทใหม
*/
watch(props, async (count, prevCount) => {
const date = new Date(props.dateYear, props.dateMonth)
})
const cancel = async (text: string) => {
title.value = text
modalCancel.value = true

View file

@ -13,11 +13,11 @@
<div class="row col-12">
<div class="row items-center">
<!-- filter เลอกเดอนป -->
<datepicker v-model="dateMonth" :locale="'th'" autoApply month-picker :enableTimePicker="false" v-if="currentTab === 'calendar'">
<datepicker v-model="dateMonth" :locale="'th'" autoApply month-picker :enableTimePicker="false" v-if="currentTab === 'calendar'" @update:modelValue="updateMonth">
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{ parseInt(value + 543) }}</template>
<template #trigger>
<q-input :model-value="monthYearThai(dateMonth)" dense outlined hide-bottom-space style="width: 130px">
<q-input :model-value="monthYearThai(dateMonth)" dense outlined style="width: 130px">
<template v-slot:prepend>
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)"> </q-icon>
</template>
@ -179,8 +179,17 @@ const dateMonth = ref<DataDateMonthObject>({
month: new Date().getMonth(),
year: new Date().getFullYear(),
})
console.log(dateMonth.value)
const props = defineProps({
dateYear: Number, // parent
fetchDataSummaryCalendar: {
//
type: Function,
default: () => console.log("not function"),
},
})
const dateYear = ref<number>(new Date().getFullYear())
const emit = defineEmits(["update:dateYear"])
const mixin = useCounterMixin() //
const { monthYear2Thai } = mixin
/**
@ -192,6 +201,16 @@ const monthYearThai = (val: DataDateMonthObject) => {
else return monthYear2Thai(val.month, val.year)
}
const updateMonth = async (e: DataDateMonthObject) => {
console.log(dateMonth.value)
if (e != null) {
dateYear.value = e.year
emit("update:dateYear", e.year)
await props.fetchDataSummaryCalendar()
}
console.log(dateMonth.value)
}
const value = ref(90)
const itemPie = ref([
{ text: "ลาป่วย", color: "text-pink-5", value: 90, all: "10", use: "9", remain: "1" },