Создание события

This commit is contained in:
iriska-gri committed 2024-04-22 16:59:47 +03:00
1 parent efeca2d1ef
commit d6623fbec0
2 files changed
+285 -113

No files matched your search

@@ -3,51 +3,74 @@
<v-col class="flex-column pr-0"> <v-col class="flex-column pr-0">
<v-card class="h-100"> <v-card class="h-100">
<my-helper :pretext="selectedEvent" /> <my-helper :pretext="selectedEvent" />
<!-- <vue-cal
selected-date="2024-04-01"
:time-from="9 * 60"
:time-to="19 * 60"
:disable-views="['years', 'year']"
hide-weekends
:events="events"
:on-event-click="onEventClick"
@cell-focus="selectedDate = $event">
</vue-cal> -->
<vue-cal <vue-cal
selected-date="2024-04-01" :selected-date="new Date()"
:time-from="8 * 60" :time-from="8 * 60"
:time-to="23 * 60" :time-to="23 * 60"
hide-weekends hide-weekends
hide-view-selector hide-view-selector
events-count-on-year-view events-count-on-year-view
editable-events editable-events
show-all-day-events show-all-day-events
xsmall xsmall
locale="ru" locale="ru"
:events="events" :events="events"
:on-event-click="onEventClick" :on-event-click="onEventClick"
:disable-views="['years', 'year', 'week', 'day']" active-view="month"
@cell-focus="selectedDate = $event"> :disable-views="['years', 'year', 'week', 'day']"
</vue-cal> @cell-focus="selectedDate = $event"
<v-dialog v-model="showDialog"> @event-drag-create="showEventCreationDialog = true"
<v-card> />
<v-card-title>
<v-icon>{{ selectedEvent.icon }}</v-icon> <event-dialog
<span>{{ selectedEvent.title }}</span> :event="selectedEvent"
<v-spacer/> :opendialog="showDialog"
<strong>{{ selectedEvent.start && selectedEvent.start.format('DD/MM/YYYY') }}</strong> @update:opendialog="showDialog = $event"
</v-card-title> />
<v-card-text>
<p v-html="selectedEvent.contentFull" /> <v-dialog
<strong>Event details:</strong> v-model="showEventCreationDialog"
<ul> :persistent="true"
<li>Event starts at: {{ selectedEvent.start && selectedEvent.start.formatTime() }}</li> max-width="420"
<li>Event ends at: {{ selectedEvent.end && selectedEvent.end.formatTime() }}</li> >
</ul> <v-card>
</v-card-text> <v-card-title>
</v-card>
</v-dialog> </v-card-title>
<v-card-text>
<v-input
v-model="selectedEvent.title"
label="Event Title"
/>
<v-textarea
v-model="selectedEvent.content"
placeholder="Event Content"
/>
<v-textarea
v-model="selectedEvent.content"
placeholder="Event Content"
/>
<v-flex>
<v-select
:items="eventsCssClasses"
placeholder="Event CSS Class"
@change="selectedEvent.class = $event"
:value="selectedEvent.class"
/>
<v-switch
v-model="selectedEvent.background"
label="background Event"
/>
</v-flex>
<v-flex>
<v-btn @click="cancelEventCreation()">Cancel</v-btn>
<v-btn @click="closeCreationDialog()">Save</v-btn>
</v-flex>
</v-card-text>
</v-card>
</v-dialog>
<!-- <vue-cal <!-- <vue-cal
locale="ru" locale="ru"
xsmall xsmall
@@ -89,10 +112,33 @@
<v-card-title class="text-center" <v-card-title class="text-center"
>События на {{ dayformat(selectedDate) }}</v-card-title >События на {{ dayformat(selectedDate) }}</v-card-title
> >
<!-- editable-events -->
<vue-cal <vue-cal
locale="ru"
hideTitleBar
split
header-format="DD"
active-view="day"
:disable-views="['years', 'year', 'month', 'week']"
:selected-date="selectedDate"
small
:time-from="8 * 60"
:time-to="20 * 60"
hide-view-selector
hide-title-bar
hide-weekends
:events="events"
:on-event-create="onEventCreate"
:on-event-click="onEventClick"
@event-drag-create="showEventCreationDialog = true"
>
</vue-cal>
<!-- <vue-cal
locale="ru" locale="ru"
xsmall xsmall
:time="false" :time-from="8 * 60"
:time-to="20 * 60"
hide-view-selector hide-view-selector
hideTitleBar hideTitleBar
split split
@@ -101,15 +147,15 @@
active-view="day" active-view="day"
:disable-views="['years', 'year', 'month', 'week']" :disable-views="['years', 'year', 'month', 'week']"
:selected-date="selectedDate" :selected-date="selectedDate"
:time="false"
:cell-click-hold="false" :cell-click-hold="false"
:drag-to-create-event="false" :drag-to-create-event="false"
editable-events editable-events
:on-event-click="onEventClick" :on-event-click="onEventClick"
@cell-dblclick="$refs.vuecal.createEvent( @event-drag-create="showEventCreationDialog = true"
$event, :on-event-create="onEventCreate"
120,
{ title: 'New Event', class: 'blue-event' }
)"
> >
<template #arrow-prev> <template #arrow-prev>
<v-icon icon="mdi-menu-left"></v-icon> <v-icon icon="mdi-menu-left"></v-icon>
@@ -118,55 +164,81 @@
<v-icon icon="mdi-menu-right"></v-icon> <v-icon icon="mdi-menu-right"></v-icon>
</template> </template>
<template #today-button> </template> <template #today-button> </template>
</vue-cal> </vue-cal> -->
</v-card> </v-card>
</v-col> </v-col>
</v-row> </v-row>
</template> </template>
<!-- @cell-dblclick="
$refs.vuecal.createEvent($event, 120, {
title: 'New Event',
class: 'blue-event',
})
" -->
<script> <script>
import VueCal from "vue-cal"; import VueCal from "vue-cal";
import "vue-cal/dist/vuecal.css"; import "vue-cal/dist/vuecal.css";
import { ref } from "vue"; import { ref } from "vue";
import { axiosApiInstance } from "@/utils/axios-api"; import { axiosApiInstance } from "@/utils/axios-api";
import {formaDashTime} from '@/utils/universal_functions' import { formaDashTime } from "@/utils/universal_functions";
import EventDialog from "@/components/calendar_of_events/event-dialog.vue";
export default { export default {
components: { VueCal }, components: { VueCal, EventDialog },
setup() { setup() {
const selectedEvent= ref({}) const selectedEvent = ref({});
const showDialog =ref(false) const selectedEventCreate = ref(null);
const eventsCssClasses = ["bg-red", "bg-blue", "bg-green"];
const showDialog = ref(false);
const showEventCreationDialog = ref(false);
const events = ref([ const events = ref([
// { // {
// start: '2024-04-15 14:00', // start: '2024-04-15 14:00',
// end: '2024-04-25 18:00', // end: '2024-04-25 18:00',
// title: 'Need to go shopping', // title: 'Need to go shopping',
// icon: 'shopping_cart', // Custom attribute. // icon: 'shopping_cart', // Custom attribute.
// content: 'Click to see my shopping list', // content: 'Click to see my shopping list',
// contentFull: 'My shopping list is rather long:<br><ul><li>Avocados</li><li>Tomatoes</li><li>Potatoes</li><li>Mangoes</li></ul>', // Custom attribute. // contentFull: 'My shopping list is rather long:<br><ul><li>Avocados</li><li>Tomatoes</li><li>Potatoes</li><li>Mangoes</li></ul>', // Custom attribute.
// class: 'leisure', // class: 'leisure',
// repeat: { // repeat: {
// every: 'week', // You can repeat on multiple days of the week. // every: 'week', // You can repeat on multiple days of the week.
// until: '2024-05-30' // Don't need a time here as it will take the same as original event date. // until: '2024-05-30' // Don't need a time here as it will take the same as original event date.
// } // }
// }, // },
// { // {
// start: '2024-04-15 10:00', // start: '2024-04-15 10:00',
// end: '2024-04-25 15:00', // end: '2024-04-25 15:00',
// title: 'Golf with John', // title: 'Golf with John',
// icon: 'golf_course', // Custom attribute. // icon: 'golf_course', // Custom attribute.
// content: 'Do I need to tell how many holes?', // content: 'Do I need to tell how many holes?',
// contentFull: 'Okay.<br>It will be a 18 hole golf course.', // Custom attribute. // contentFull: 'Okay.<br>It will be a 18 hole golf course.', // Custom attribute.
// class: 'sport' // class: 'sport'
// } // }
]) ]);
const onEventClick = (event, e) => { const onEventClick = (event, e) => {
selectedEvent.value = event selectedEvent.value = event;
showDialog.value = true showDialog.value = true;
e.stopPropagation() e.stopPropagation();
} };
const onEventCreate = (event, deleteEventFunction) => {
console.log(event, deleteEventFunction, 'event, deleteEventFunction')
selectedEvent.value = event;
showEventCreationDialog.value = true;
deleteEventFunction.value = deleteEventFunction;
return event;
};
const cancelEventCreation = () => {
closeCreationDialog();
deleteEventFunction();
};
const closeCreationDialog = () => {
showEventCreationDialog.value = false;
selectedEvent.value = {};
};
function f_generalvacation() { function f_generalvacation() {
axiosApiInstance axiosApiInstance
@@ -174,30 +246,34 @@ export default {
.then((data) => { .then((data) => {
for (let x in data.data[0].event) { for (let x in data.data[0].event) {
events.value.push({ events.value.push({
start: formaDashTime(data.data[0].event[x].cdate), start: formaDashTime(data.data[0].event[x].cdate),
end: formaDashTime(data.data[0].event[x].enddate), end: formaDashTime(data.data[0].event[x].enddate),
title: data.data[0].event[x].name, title: data.data[0].event[x].name,
contentFull: data.data[0].event[x].description, contentFull: data.data[0].event[x].description,
}); icon: "mdi-book-open",
console.log(formaDashTime(data.data[0].event[x].cdate), 'data.data[0].event[x]') class: "bg-indigo-lighten-5 border-sm",
console.log(data.data[0].event[x], 'xxxxxxxxxx') });
// console.log(
// formaDashTime(data.data[0].event[x].cdate),
// "data.data[0].event[x]"
// );
// console.log(data.data[0].event[x], "xxxxxxxxxx");
} }
// {
// { // start: '2024-04-15 14:00',
// start: '2024-04-15 14:00', // end: '2024-04-25 18:00',
// end: '2024-04-25 18:00', // title: 'Need to go shopping',
// title: 'Need to go shopping', // icon: 'shopping_cart', // Custom attribute.
// icon: 'shopping_cart', // Custom attribute. // content: 'Click to see my shopping list',
// content: 'Click to see my shopping list', // contentFull: 'My shopping list is rather long:<br><ul><li>Avocados</li><li>Tomatoes</li><li>Potatoes</li><li>Mangoes</li></ul>', // Custom attribute.
// contentFull: 'My shopping list is rather long:<br><ul><li>Avocados</li><li>Tomatoes</li><li>Potatoes</li><li>Mangoes</li></ul>', // Custom attribute. // class: 'leisure',
// class: 'leisure', // repeat: {
// repeat: { // every: 'week', // You can repeat on multiple days of the week.
// every: 'week', // You can repeat on multiple days of the week. // until: '2024-05-30' // Don't need a time here as it will take the same as original event date.
// until: '2024-05-30' // Don't need a time here as it will take the same as original event date. // }
// } // console.log(data.data, "dataaaaaaaaaaaaa");
console.log(data.data, 'dataaaaaaaaaaaaa'); });
})
// for (let x in data.data) { // for (let x in data.data) {
// if (x == "План-график") { // if (x == "План-график") {
// data.data[x].map((e) => { // data.data[x].map((e) => {
@@ -213,9 +289,7 @@ export default {
// }); // });
} }
f_generalvacation();
f_generalvacation();
const selectedDate = ref(null); const selectedDate = ref(null);
@@ -229,7 +303,20 @@ export default {
return mess; return mess;
} }
return {selectedEvent, events, selectedDate, f_generalvacation, dayformat, showDialog, onEventClick }; return {
selectedEvent,
events,
selectedDate,
f_generalvacation,
dayformat,
showDialog,
onEventClick,
showEventCreationDialog,
eventsCssClasses,
onEventCreate,
closeCreationDialog,
cancelEventCreation,
};
}, },
}; };
</script> </script>
@@ -255,7 +342,7 @@ export default {
.vuecal__title-bar { .vuecal__title-bar {
background: var(--cards); background: var(--cards);
/* background: linear-gradient(to top right, rgba(19,84,122,.8), rgba(128,208,199,.8)); */
} }
.vuecal__flex .vuecal__title { .vuecal__flex .vuecal__title {
font-family: sans-serif; font-family: sans-serif;
@@ -280,7 +367,7 @@ export default {
box-sizing: border-box; box-sizing: border-box;
} }
.vuecal__event { /* .vuecal__event {
color: #666; color: #666;
background-color: transparent; background-color: transparent;
padding: 10px; padding: 10px;
@@ -292,7 +379,7 @@ export default {
transition: box-shadow 0.3s, left 0.3s, width 0.3s; transition: box-shadow 0.3s, left 0.3s, width 0.3s;
overflow: hidden; overflow: hidden;
text-align: justify; text-align: justify;
} } */
.vuecal--rounded-theme .vuecal__cell-content { .vuecal--rounded-theme .vuecal__cell-content {
width: 30px; width: 30px;
@@ -335,4 +422,25 @@ export default {
background-color: #3a97694a; background-color: #3a97694a;
z-index: 2; z-index: 2;
} }
.vuecal__event {
cursor: pointer;
}
.vuecal__event-title {
font-size: 1.2em;
font-weight: bold;
margin: 4px 0 8px;
}
.vuecal__event-time {
display: inline-block;
margin-bottom: 12px;
padding-bottom: 12px;
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
.vuecal__event-content {
font-style: italic;
}
</style> </style>
@@ -0,0 +1,64 @@
<template>
<v-dialog v-model="mydialog" max-width="700">
<v-card>
<v-card-title>
<v-icon color="indigo-darken-3" class="pb-1">{{ event.icon }}</v-icon>
<v-text-field
v-model="event.title"
placeholder="Заголовок"
/>
<span class="pl-3"> {{ event.title }}</span>
<v-icon :icon="mdi-pencil" color="indigo-darken-3" class="pb-1" />
</v-card-title>
<v-card-subtitle>
<strong>{{ event.start && event.start.format("DD.MM.YYYY") }}</strong>
</v-card-subtitle>
<v-card-text class="pt-2">
<p class="pb-3" v-html="event.contentFull" />
<strong>Время:</strong>
<ul class="pl-5">
<li>
Начало:
{{ event.start && event.start.formatTime() }}
</li>
<li>
Окончание:
{{ event.end && event.end.formatTime() }}
</li>
</ul>
</v-card-text>
</v-card>
</v-dialog>
</template>
<script>
import { computed } from "vue";
export default {
props: {
opendialog: {
type: Boolean,
default: false,
},
event: {
type: Object,
default: () => {},
},
},
setup(props, { emit }) {
const mydialog = computed({
get: () => props.opendialog,
set: (value) => emit("update:opendialog", value),
});
return {
mydialog,
};
},
};
</script>
<style></style>