This commit is contained in:
iriska-gri committed 2024-07-16 14:54:43 +03:00
1 parent 13bdc5ab3f
commit 7305705e44
3 files changed
+140 -64

No files matched your search

@@ -73,8 +73,13 @@
</v-row> </v-row>
</v-card> </v-card>
</v-col> </v-col>
<v-col > <v-col>
<calendar-full /> <calendar-full
:allEvent="calendarForMy.filter((e) => e.events.length > 0)"
@getEvent="createEvent"
@update:allEvent="infoEvent($event)"
/>
<!-- @update:allEvent="calendarForMy = $event" -->
<!-- <v-btn @click="drawer_right = !drawer_right"> <!-- <v-btn @click="drawer_right = !drawer_right">
{{ drawer_right }}y {{ drawer_right }}y
</v-btn> --> </v-btn> -->
@@ -91,9 +96,9 @@
</v-navigation-drawer> --> </v-navigation-drawer> -->
<v-dialog v-model="showDialog" max-width="700"> <v-dialog v-model="showDialog" max-width="700">
<event-create <event-create
@closeDialog = "showDialog = false" @closeDialog="showDialog = false"
:eventCalendar="eventFromCalendar" :eventCalendar="eventFromCalendar"
@getCalendar="$emit('getCalendar')" @getCalendar="getCalendar"
/> />
</v-dialog> </v-dialog>
</v-row> </v-row>
@@ -106,14 +111,12 @@ import EventCreate from "@/components/calendar_of_events/event-create.vue";
import CalendarMy from "@/components/calendar_of_events/calendar-my.vue"; import CalendarMy from "@/components/calendar_of_events/calendar-my.vue";
import { axiosApiInstance } from "@/utils/axios-api"; import { axiosApiInstance } from "@/utils/axios-api";
import { useAccountStore } from "@/store/AccountStore"; import { useAccountStore } from "@/store/AccountStore";
import CalendarFull from '@/components/calendar_of_events/UI_calendar/calendarFull.vue'; import CalendarFull from "@/components/calendar_of_events/UI_calendar/calendarFull.vue";
export default { export default {
components: { EventCreate, CalendarMy, CalendarFull }, components: { EventCreate, CalendarMy, CalendarFull },
setup(props, {emit}) { setup(props, { emit }) {
const accountStore = useAccountStore(); const accountStore = useAccountStore();
const showDialog = ref(false); const showDialog = ref(false);
const week = useWeekendsStore(); const week = useWeekendsStore();
@@ -123,24 +126,22 @@ export default {
const MyYear = ref(selectdate.value.getFullYear()); const MyYear = ref(selectdate.value.getFullYear());
const MyMonth = ref(selectdate.value.getMonth() + 1); const MyMonth = ref(selectdate.value.getMonth() + 1);
const calendarForMy = ref([]); const calendarForMy = ref([]);
const eventFromCalendar = ref({}) const eventFromCalendar = ref({});
const idEvent = ref(null) const idEvent = ref(null);
// const idEvent = ref(2) // const idEvent = ref(4)
// const rule = new RRule({
// freq: RRule.WEEKLY,
// interval: 5,
// byweekday: [RRule.MO, RRule.FR],
// dtstart: datetime(2024, 7, 1),
// until: datetime(2024, 8, 15)
// })
// const dates = rule.all()
// const rule = new RRule({ // // const dates = rule.all();
// freq: RRule.WEEKLY, // console.log(dates, '===============================');
// interval: 5,
// byweekday: [RRule.MO, RRule.FR],
// dtstart: datetime(2024, 7, 1),
// until: datetime(2024, 8, 15)
// })
// const dates = rule.all()
// // const dates = rule.all();
// console.log(dates, '===============================');
const getMonth = (month) => { const getMonth = (month) => {
MyMonth.value = month + 1; MyMonth.value = month + 1;
@@ -150,7 +151,6 @@ export default {
}; };
const getCalendar = () => { const getCalendar = () => {
axiosApiInstance axiosApiInstance
.get(`api/calendar_of_events/my_calendars/`) .get(`api/calendar_of_events/my_calendars/`)
.then((res) => { .then((res) => {
@@ -159,35 +159,56 @@ export default {
(e.visible = accountStore.calendar.includes(e.id) ? false : true) (e.visible = accountStore.calendar.includes(e.id) ? false : true)
); );
calendarForMy.value = res.data; calendarForMy.value = res.data;
console.log(calendarForMy.value , 'eventFromCalendar.value-----------------------') // console.log(calendarForMy.value , 'eventFromCalendar.value-----------------------')
}); });
}; };
getCalendar(); getCalendar();
const getEvents = () => { const getEvents = () => {
console.log(
idEvent.value,
"idEvent.value------------------------------------------------------------------"
);
axiosApiInstance axiosApiInstance
.get(`api/calendar_of_events/my_events/${idEvent.value==null?'':`?id=${idEvent.value}`}`) .get(
`api/calendar_of_events/my_events/${
idEvent.value == null ? "" : `?id=${idEvent.value}`
}`
)
.then((res) => { .then((res) => {
eventFromCalendar.value = res.data eventFromCalendar.value = res.data;
if (idEvent.value == null) {
if (idEvent.value==null) { eventFromCalendar.value.event = {
eventFromCalendar.value.event = {name:'', participant: [accountStore.user.is_idEmployee], files: [], date_start: new Date(), date_end: new Date(), period: null, description: '', calendar: null} name: "",
participant: [accountStore.user.is_idEmployee],
files: [],
date_start: new Date(),
date_end: new Date(),
period: null,
description: "",
calendar: null,
};
}
console.log(eventFromCalendar.value, 'vvvvvvvvvvvvvvvvvvvvvvvvvvvvv')
} }
});
);
}; };
getEvents(); getEvents();
const createEvent = () => { const createEvent = (i) => {
showDialog.value = true if (i != undefined) {
emit("getCalendar"); idEvent.value = i;
getEvents()
} }
showDialog.value = true;
getCalendar();
// emit("getCalendar");
};
const weekendsData = () => { const weekendsData = () => {
cal.value.$el cal.value.$el
@@ -235,6 +256,10 @@ export default {
} }
}; };
const infoEvent = (i) => {
console.log(i, "iiiiiiiiii");
};
return { return {
drawer_right, drawer_right,
selectdate, selectdate,
@@ -249,7 +274,8 @@ export default {
accountStore, accountStore,
getCalendar, getCalendar,
eventFromCalendar, eventFromCalendar,
createEvent createEvent,
infoEvent,
}; };
}, },
}; };
@@ -8,8 +8,6 @@
:year="YearNow" :year="YearNow"
:model-value="selectDay" :model-value="selectDay"
> >
<!-- -->
<template v-slot:header="{ title }"> <template v-slot:header="{ title }">
<v-col class="d-flex flex-column p"> <v-col class="d-flex flex-column p">
<v-row no-gutters class="gap"> <v-row no-gutters class="gap">
@@ -32,7 +30,8 @@
{{ getMonthName(monthNow + 1) }} {{ getMonthName(monthNow + 1) }}
</span> </span>
{{ YearNow }} г. {{ YearNow }} г. <my-helper :pretext="returnPeriod" />
<my-helper :pretext="events" />
</v-col> </v-col>
<v-col class="text-end align-self-center"> <v-col class="text-end align-self-center">
<v-btn <v-btn
@@ -53,13 +52,15 @@
</v-col> </v-col>
</template> </template>
<template v-slot:event="{ day, allDay, event }"> <template v-slot:event="{ event }">
<v-btn @click="whatDay(day)"> </v-btn> <v-chip
--------------- class="w-100"
{{ allDay }} density="compact"
:color="event.color"
--------------------- @click="whatDay(event)"
{{ event }} >
{{ event.title }}
</v-chip>
</template> </template>
</v-calendar> </v-calendar>
</v-locale-provider> </v-locale-provider>
@@ -67,9 +68,17 @@
<script> <script>
import { ref, computed } from "vue"; import { ref, computed } from "vue";
import { datetime, RRule, RRuleSet, rrulestr } from "rrule";
export default { export default {
setup() { props: {
allEvent: {
type: Object,
default: () => {},
},
},
setup(props, { emit }) {
const type = ref("month"); const type = ref("month");
const types = [ const types = [
{ type: "day", text: "День" }, { type: "day", text: "День" },
@@ -83,6 +92,55 @@ export default {
type.value = t; type.value = t;
}; };
const propsAllEvent = computed({
get: () => props.allEvent,
set: (value) => emit("update:allEvent", value),
});
const events = ref([
]);
const returnPeriod = computed({
get() {
let select = [propsAllEvent.value];
propsAllEvent.value.forEach((e) => {
// console.log(e, 'e')
e.events.forEach((i) => {
// console.log(i, 'i')
let objRule = JSON.parse(i.period);
if (objRule != null) {
let rule = new RRule({
freq: objRule.origOptions.freq,
dtstart: new Date(objRule.origOptions.dtstart),
until: new Date(objRule.origOptions.until),
});
let actRule = rule.all();
actRule.forEach((r) => {
let ev = {
title: i.name,
color: e.cl_color,
start: new Date(r),
end: new Date(i.date_end),
id: i.id
}
events.value.push(ev)
// console.log(r , "rule");
// console.log(ev , "ev");
})
}
});
});
return select;
},
});
// const value = computed({ // const value = computed({
// get() { // get() {
@@ -108,7 +166,7 @@ export default {
// new Date().getDate() - 3 // new Date().getDate() - 3
// ) // )
// ) // )
const selectDay = ref(new Date()); const selectDay = ref([new Date()]);
const monthNow = ref(new Date().getMonth()); const monthNow = ref(new Date().getMonth());
const YearNow = ref(new Date().getFullYear()); const YearNow = ref(new Date().getFullYear());
const endWeek = computed({ const endWeek = computed({
@@ -118,15 +176,6 @@ export default {
}); });
// const endWeek = ref(); // const endWeek = ref();
const events = [
{
title: "Крот",
start: new Date("2024-07-16T15:00:00+03:00"),
end: new Date("2024-07-25T16:00:00+03:00"),
color: "green",
allDay: false,
},
];
const returnDate = () => { const returnDate = () => {
if (type.value == "month") { if (type.value == "month") {
@@ -190,7 +239,9 @@ export default {
}; };
const whatDay = (e) => { const whatDay = (e) => {
console.log(e, "------------------"); console.log(e.id, "---e.id---------------");
emit("getEvent", e.id)
}; };
// const controlDate = computed({ // const controlDate = computed({
@@ -216,11 +267,12 @@ export default {
YearNow, YearNow,
returnDate, returnDate,
getMonthName, getMonthName,
propsAllEvent,
whatDay, whatDay,
nextDay, nextDay,
todayDay, todayDay,
selectDay, selectDay,
returnPeriod,
// controlDate // controlDate
}; };
@@ -253,8 +253,6 @@ export default {
dtstart: new Date(propsEvent.value.event.date_start), dtstart: new Date(propsEvent.value.event.date_start),
until: new Date(propsEvent.value.event.date_end), until: new Date(propsEvent.value.event.date_end),
}); });
console.log(Object.keys(newValue.rule).length == 0, "00");
// let ruleObject = newRulse.toJSON();
propsEvent.value.event.period = propsEvent.value.event.period =
Object.keys(newValue.rule).length == 0 Object.keys(newValue.rule).length == 0
? null ? null
@@ -270,6 +268,7 @@ export default {
get: () => props.eventCalendar, get: () => props.eventCalendar,
set: (value) => emit("update:eventCalendar", value), set: (value) => emit("update:eventCalendar", value),
}); });
const feedalert = useAlertStore().alert; const feedalert = useAlertStore().alert;
const req = (val) => { const req = (val) => {
return !!val || "Поле обязательно"; return !!val || "Поле обязательно";
@@ -391,7 +390,6 @@ export default {
} else { } else {
titleCard.value = "Новое событие"; titleCard.value = "Новое событие";
newEvent.value = true; newEvent.value = true;
console.log(newEvent.value, " newEvent.value");
} }
}; };