fix:#13 start end get

This commit is contained in:
Elmar Kresse
2024-06-06 00:38:35 +02:00
parent 4e73eddf50
commit f68d4ae445

View File

@@ -2,7 +2,7 @@
import FullCalendar from "@fullcalendar/vue3"; import FullCalendar from "@fullcalendar/vue3";
import { computed, ComputedRef, inject, Ref, ref, watch } from "vue"; import { computed, ComputedRef, inject, Ref, ref, watch } from "vue";
import { CalendarOptions, DatesSetArg } from "@fullcalendar/core"; import { CalendarOptions, DatesSetArg, EventClickArg } from "@fullcalendar/core";
import allLocales from "@fullcalendar/core/locales-all"; import allLocales from "@fullcalendar/core/locales-all";
import dayGridPlugin from "@fullcalendar/daygrid"; import dayGridPlugin from "@fullcalendar/daygrid";
import interactionPlugin from "@fullcalendar/interaction"; import interactionPlugin from "@fullcalendar/interaction";
@@ -28,9 +28,7 @@ const props = defineProps({
const op = ref(); const op = ref();
const clickedEvent = ref(); const clickedEvent = ref();
const toggle = (info: any) => { const toggle = (info: EventClickArg) => {
if (op.value.visible) { if (op.value.visible) {
clickedEvent.value = null; clickedEvent.value = null;
@@ -38,21 +36,35 @@ const toggle = (info: any) => {
return; return;
} else { } else {
const start = info.event._instance.range.start; const start = info.event.start
const end = info.event._instance.range.end; const end = info.event.end
const timeZoneOffsetStart = start.getTimezoneOffset() * 60000;
const timeZoneOffsetEnd = end.getTimezoneOffset() * 60000;
clickedEvent.value = { if (!start || !end) {
title: info.event._def.title, clickedEvent.value = {
start: new Date(start.getTime() + timeZoneOffsetStart), title: info.event._def.title,
end: new Date(end.getTime() + timeZoneOffsetEnd), start: "",
notes: info.event._def.extendedProps.notes, end: "",
allDay: info.event._def.allDay, notes: info.event._def.extendedProps.notes,
location: info.event._def.extendedProps.location, allDay: info.event._def.allDay,
}; location: info.event._def.extendedProps.location,
};
op.value.show(info.jsEvent); op.value.show(info.jsEvent);
op.value.target = info.el; op.value.target = info.el;
} else {
const timeZoneOffsetStart = start.getTimezoneOffset() * 60000;
const timeZoneOffsetEnd = end.getTimezoneOffset() * 60000;
clickedEvent.value = {
title: info.event._def.title,
start: new Date(start.getTime() + timeZoneOffsetStart),
end: new Date(end.getTime() + timeZoneOffsetEnd),
notes: info.event._def.extendedProps.notes,
allDay: info.event._def.allDay,
location: info.event._def.extendedProps.location,
};
op.value.show(info.jsEvent);
op.value.target = info.el;
}
} }
@@ -169,8 +181,8 @@ watch(mobilePage, () => {
<div> <div>
<h3>{{ clickedEvent.title }}</h3> <h3>{{ clickedEvent.title }}</h3>
<p>Location: {{ clickedEvent.location }}</p> <p>Location: {{ clickedEvent.location }}</p>
<p>Start: {{ clickedEvent.start.toLocaleString()}}</p> <p>Start: {{ clickedEvent.start?.toLocaleString()}}</p>
<p>End: {{ clickedEvent.end.toLocaleString() }}</p> <p>End: {{ clickedEvent.end?.toLocaleString() }}</p>
<p>Notes: {{ clickedEvent.notes }}</p> <p>Notes: {{ clickedEvent.notes }}</p>
</div> </div>
</OverlayPanel> </OverlayPanel>