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

No files matched your search

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