This commit is contained in:
iriska-gri committed 2024-07-19 14:25:27 +03:00
1 parent 5c3830fd8c
commit f6b370ec9c
7 files changed
+143 -112

No files matched your search

+1
View File
@@ -81,6 +81,7 @@ class Event(models.Model):
date_end = models.DateTimeField(null=True, blank= True, verbose_name='Дата окончания события') date_end = models.DateTimeField(null=True, blank= True, verbose_name='Дата окончания события')
period = models.JSONField(verbose_name='Периодичность события', null=True, blank= True) period = models.JSONField(verbose_name='Периодичность события', null=True, blank= True)
description = RichTextUploadingField(null=True, blank= True, verbose_name='Описание события') description = RichTextUploadingField(null=True, blank= True, verbose_name='Описание события')
allday = models.BooleanField(default=False, verbose_name='Событие на целый день')
class Meta: class Meta:
verbose_name = "Событие календаря" verbose_name = "Событие календаря"
+2
View File
@@ -133,6 +133,8 @@ class MyEvents(APIView):
"calendar": 8, "calendar": 8,
'participant':[125,1], 'participant':[125,1],
'files':[объекты файлов, которые не будут удалены] 'files':[объекты файлов, которые не будут удалены]
'allday':boolean -добавлено 19072024
''' '''
# event = json.dumps( { # event = json.dumps( {
# "id": 1, # "id": 1,
@@ -73,16 +73,15 @@
</v-row> </v-row>
</v-card> </v-card>
</v-col> </v-col>
<v-col> <v-col class="d-flex flex-column">
<calendar-full <calendar-full
:allEvent="calendarForMy.filter((e) => e.events.length > 0)" :allEvent="calendarForMy.filter((e) => e.events.length > 0)"
@getEvent="createEvent" @getEvent="createEvent"
@update:allEvent="infoEvent($event)" @update:allEvent="infoEvent($event)"
/> />
<!-- @update:allEvent="calendarForMy = $event" -->
<!-- <v-btn @click="drawer_right = !drawer_right">
{{ drawer_right }}y
</v-btn> -->
</v-col> </v-col>
<!-- <v-navigation-drawer <!-- <v-navigation-drawer
@@ -7,9 +7,10 @@
:month="monthNow" :month="monthNow"
:year="YearNow" :year="YearNow"
:model-value="selectDay" :model-value="selectDay"
class="h-100"
> >
<template v-slot:header="{ title }"> <template v-slot:header>
<v-col class="d-flex flex-column p"> <v-col class="d-flex flex-column">
<v-row no-gutters class="gap"> <v-row no-gutters class="gap">
<v-col class="flex-grow-0" lg="2"> <v-col class="flex-grow-0" lg="2">
<v-btn <v-btn
@@ -29,7 +30,6 @@
</span> </span>
{{ YearNow }} г. {{ YearNow }} г.
<!-- <my-helper :pretext="returnPeriod" /> -->
</v-col> </v-col>
<v-col class="text-end align-self-center"> <v-col class="text-end align-self-center">
<v-btn <v-btn
@@ -77,7 +77,7 @@
<script> <script>
import { ref, computed } from "vue"; import { ref, computed } from "vue";
import { datetime, RRule, RRuleSet, rrulestr } from "rrule"; import { RRule } from "rrule";
export default { export default {
props: { props: {
@@ -111,43 +111,64 @@ export default {
let select = []; let select = [];
propsAllEvent.value.forEach((e) => { propsAllEvent.value.forEach((e) => {
// console.log(e, "e");
e.events.forEach((i) => { e.events.forEach((i) => {
if ( if (i.period == null && new Date(i.date_end) > dayNextMonth.value)
i.period == null && i.date_end = dayNextMonth.value;
new Date(i.date_end) > new Date(getLastDayOfMonth())
)
i.date_end = new Date(getLastDayOfMonth());
// console.log(i, "i");
let objRule = JSON.parse(i.period); let objRule = JSON.parse(i.period);
// console.log(objRule.origOptions, "распар правила");
console.log(i, "i");
//
if (objRule != null) { if (objRule != null) {
let startnew =
(objRule.origOptions.dtstart.split('T')[1].split(':')[0] != 21 && i.allday == false)
? new Date(objRule.origOptions.dtstart)
: new Date(objRule.origOptions.dtstart.split('T')[0])
console.log(objRule.origOptions.dtstart.split('T')[1].split(':')[0] != 21 || i.allday == false , '1')
console.log(startnew,' startnew')
let rule = new RRule({ let rule = new RRule({
...objRule.origOptions, ...objRule.origOptions,
// freq: objRule.origOptions.freq,
dtstart: new Date(objRule.origOptions.dtstart), dtstart: new Date(startnew),
until: until:
"until" in objRule.origOptions "until" in objRule.origOptions
? new Date(objRule.origOptions.until) ? new Date(objRule.origOptions.until)
: new Date("2024-08-01"), : dayNextMonth.value,
}); });
let actRule = rule.all(); let actRule = rule.all();
console.log(
actRule,
"actRule-------------------------------------"
);
let lastDateMonth = new Date(
new Date(dayNextMonth.value).setDate(
new Date(dayNextMonth.value).getDate() - 1
)
);
actRule actRule
.filter( .filter(
(date) => (date) =>
new Date(date).getMonth() === new Date(date).getMonth() ===
new Date(selectDay.value).getMonth() && new Date(lastDateMonth).getMonth() &&
new Date(date).getYear() === new Date(date).getYear() ===
new Date(selectDay.value).getYear() new Date(lastDateMonth).getYear()
) )
.forEach((r) => { .forEach((r) => {
let ev = { let ev = {
rule: objRule.origOptions,
title: i.name, title: i.name,
color: e.cl_color, color: e.cl_color,
start: new Date(r), start: new Date(r),
@@ -169,6 +190,7 @@ export default {
dates.forEach((d) => { dates.forEach((d) => {
let ev = { let ev = {
rule: "",
title: i.name, title: i.name,
color: e.cl_color, color: e.cl_color,
start: new Date(d), start: new Date(d),
@@ -200,13 +222,6 @@ export default {
return dates; return dates;
}; };
const getLastDayOfMonth = () => {
let currentMonth = new Date(selectDay.value).getMonth();
let currentYear = new Date(selectDay.value).getFullYear();
return new Date(currentYear, currentMonth + 1, 0);
};
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());
@@ -216,8 +231,6 @@ export default {
}, },
}); });
// const endWeek = ref();
const returnDate = () => { const returnDate = () => {
if (type.value == "month") { if (type.value == "month") {
if (monthNow.value != 0) { if (monthNow.value != 0) {
@@ -283,35 +296,78 @@ export default {
emit("getEvent", e.id); emit("getEvent", e.id);
}; };
const funRoundet = (ev, day) => { const zeroTime = (date) => {
if ( return new Date(date).setHours(0, 0, 0, 0);
new Date(day.date).setHours(0, 0, 0, 0) != };
new Date(ev.start_event).setHours(0, 0, 0, 0) &&
new Date(day.date).setHours(0, 0, 0, 0) !=
new Date(ev.end).setHours(0, 0, 0, 0)
) {
return "rounded-sm";
} else if (
new Date(day.date).setHours(0, 0, 0, 0) ==
new Date(ev.start_event).setHours(0, 0, 0, 0) &&
new Date(day.date).setHours(0, 0, 0, 0) ==
new Date(ev.end).setHours(0, 0, 0, 0)
) {
return ""; const funRoundet = (ev, day) => {
} else if ( // console.log(ev,'--------------------------------------------------------------')
new Date(day.date).setHours(0, 0, 0, 0) != if (ev.rule.freq == 3) {
new Date(ev.start_event).setHours(0, 0, 0, 0) if (
) { zeroTime(day.date) != zeroTime(ev.start_event) &&
return "rounded-s-lg"; zeroTime(day.date) != zeroTime(ev.end)
} else if ( ) {
new Date(day.date).setHours(0, 0, 0, 0) == return "rounded-sm";
new Date(ev.start_event).setHours(0, 0, 0, 0) } else if (
) { zeroTime(day.date) == zeroTime(ev.start_event) &&
return "rounded-e-lg"; zeroTime(day.date) == zeroTime(ev.end)
) {
return "";
} else if (zeroTime(day.date) != zeroTime(ev.start_event)) {
return "rounded-s-lg";
} else if (zeroTime(day.date) == zeroTime(ev.start_event)) {
return "rounded-e-lg";
}
}
if (ev.rule.freq == 2) {
let weeknumS =
ev.rule.byweekday[0].weekday == 6
? 0
: ev.rule.byweekday[0].weekday + 1;
let weeknumE =
ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6
? 0
: ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1;
if (day.date.getDay() == weeknumS && weeknumS != weeknumE) {
return "rounded-e-lg";
} else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) {
return "rounded-s-lg";
} else {
return "";
}
// if (
// zeroTime(day.date) != zeroTime(ev.start_event) &&
// zeroTime(day.date) != zeroTime(ev.end)
// ) {
// return "rounded-sm";
// } else if (
// zeroTime(day.date) == zeroTime(ev.start_event) &&
// zeroTime(day.date) == zeroTime(ev.end)
// ) {
// return "";
// } else if (zeroTime(day.date) != zeroTime(ev.start_event)) {
// return "rounded-s-lg";
// } else if (zeroTime(day.date) == zeroTime(ev.start_event)) {
// return "rounded-e-lg";
// }
} }
}; };
const dayNextMonth = computed({
get() {
const firstDayOfNextMonth = new Date(
YearNow.value,
monthNow.value + 1,
1
);
return firstDayOfNextMonth;
},
});
return { return {
type, type,
types, types,
@@ -328,9 +384,15 @@ export default {
selectDay, selectDay,
returnPeriod, returnPeriod,
funRoundet, funRoundet,
dayNextMonth,
}; };
}, },
}; };
</script> </script>
<style></style> <style>
.v-calendar__container {
overflow: auto;
height: 87vh;
}
</style>
@@ -1,6 +1,6 @@
<template> <template>
<v-col class="pb-2 pt-2 d-flex flex-column ml-n3 " lg=3> <v-col class="pb-2 pt-2 d-flex flex-column ml-n3" lg="3">
<v-row no-gutters class="gap "> <v-row no-gutters class="gap">
<v-col> <v-col>
<v-checkbox-btn <v-checkbox-btn
v-model="newDate" v-model="newDate"
@@ -8,7 +8,6 @@
label="Весь день" label="Весь день"
/> />
</v-col> </v-col>
</v-row> </v-row>
</v-col> </v-col>
</template> </template>
@@ -24,26 +23,20 @@ export default {
}, },
}, },
setup(props, { emit }) { setup(props, { emit }) {
const chek = ref(false);
const newDate = computed({ const newDate = computed({
get() { get() {
return chek.value; return propsDateEvent.value.allday;
}, },
set(newValue) { set(newValue) {
chek.value = newValue; propsDateEvent.value.allday = newValue;
if(newValue == true) if (newValue == true)
(propsDateEvent.value.date_end = new Date( (propsDateEvent.value.date_end = new Date(
new Date(propsDateEvent.value.date_end).setHours(23, 59, 0) new Date(propsDateEvent.value.date_end).setHours(23, 59, 0)
)) && )) &&
(propsDateEvent.value.date_start = new Date( (propsDateEvent.value.date_start = new Date(
new Date(propsDateEvent.value.date_start).setHours(0, 0, 0) new Date(propsDateEvent.value.date_start).setHours(0, 0, 0)
)) ));
// : (propsDateEvent.value.date_end = new Date())&&(propsDateEvent.value.date_start = new Date())
emit('chekUp', newValue)
}, },
}); });
const propsDateEvent = computed({ const propsDateEvent = computed({
@@ -32,7 +32,6 @@
</template> </template>
<v-locale-provider locale="ru"> <v-locale-provider locale="ru">
<v-date-picker <v-date-picker
v-model="modelDate" v-model="modelDate"
show-adjacent-months show-adjacent-months
@@ -128,14 +127,13 @@ export default {
}, },
set(newValue) { set(newValue) {
creatwdDate(modelDate.value, newValue); creatwdDate(modelDate.value, newValue);
}, },
}); });
const creatwdDate = (date, time) => { const creatwdDate = (date, time) => {
let tzero = time.split(':') let tzero = time.split(":");
time = tzero[0].padStart(2, "0") + ':' + tzero[1] time = tzero[0].padStart(2, "0") + ":" + tzero[1];
if (props.order[0] == 4) { if (props.order[0] == 4) {
if (time == "0:00") { if (time == "0:00") {
@@ -143,17 +141,13 @@ export default {
} else if ( } else if (
new Date(formatDash(date) + "T" + time) >= new Date(props.limitation) new Date(formatDash(date) + "T" + time) >= new Date(props.limitation)
) { ) {
propsDateEvent.value = new Date(formatDash(date) + "T" + time); propsDateEvent.value = new Date(formatDash(date) + "T" + time);
} else { } else {
propsDateEvent.value = new Date(props.limitation); propsDateEvent.value = new Date(props.limitation);
} }
} else { } else {
propsDateEvent.value = propsDateEvent.value =
time == "0:00" ? date : new Date(formatDash(date) + "T" + time); time == "0:00" ? date : new Date(formatDash(date) + "T" + time);
} }
}; };
@@ -90,8 +90,9 @@
</v-col> </v-col>
<v-col class="d-flex flex-column"> <v-col class="d-flex flex-column">
<v-row no-gutters class="gap"> <v-row no-gutters class="gap">
<time-select <time-select
:chek="allDay" :chek="propsEvent.event.allday"
:order="[2, 1]" :order="[2, 1]"
:dateEvent="String(propsEvent.event.date_start)" :dateEvent="String(propsEvent.event.date_start)"
:limitation="String(propsEvent.event.date_end)" :limitation="String(propsEvent.event.date_end)"
@@ -101,7 +102,7 @@
<v-icon icon="mdi-minus pt-4" color="grey-darken-1" /> <v-icon icon="mdi-minus pt-4" color="grey-darken-1" />
</v-col> </v-col>
<time-select <time-select
:chek="allDay" :chek="propsEvent.event.allday"
:order="[4, 5]" :order="[4, 5]"
:dateEvent="String(propsEvent.event.date_end)" :dateEvent="String(propsEvent.event.date_end)"
:limitation="String(propsEvent.event.date_start)" :limitation="String(propsEvent.event.date_start)"
@@ -110,7 +111,7 @@
</v-row> </v-row>
<v-row no-gutters> <v-row no-gutters>
<period-events <period-events
@chekUp="allDay = $event"
:dateEventStart="propsEvent.event" :dateEventStart="propsEvent.event"
@update:dateEventStart="propsEvent.event = $event" @update:dateEventStart="propsEvent.event = $event"
/> />
@@ -198,7 +199,7 @@ import UploadingFile from "@/components/UI/defaultportal/uploading-file.vue";
import ReminderEvent from "@/components/calendar_of_events/UI_calendar/reminderEvent.vue"; import ReminderEvent from "@/components/calendar_of_events/UI_calendar/reminderEvent.vue";
import PeriodEvents from "@/components/calendar_of_events/UI_calendar/periodEvents.vue"; import PeriodEvents from "@/components/calendar_of_events/UI_calendar/periodEvents.vue";
import { useAlertStore } from "@/store/useAlertStore"; import { useAlertStore } from "@/store/useAlertStore";
import { datetime, RRule, RRuleSet, rrulestr } from "rrule"; import { RRule } from "rrule";
export default { export default {
components: { components: {
@@ -237,7 +238,6 @@ export default {
if (propsEvent.value.event.period != null) { if (propsEvent.value.event.period != null) {
let objRule = JSON.parse(propsEvent.value.event.period); let objRule = JSON.parse(propsEvent.value.event.period);
if (objRule != null) { if (objRule != null) {
drawingRule(objRule.origOptions); drawingRule(objRule.origOptions);
repeatRules.findIndex( repeatRules.findIndex(
(e) => e.rule.freq == objRule.origOptions.freq (e) => e.rule.freq == objRule.origOptions.freq
@@ -253,14 +253,11 @@ export default {
select = repeatRules[0].type; select = repeatRules[0].type;
} }
calendarNewOrOld(); calendarNewOrOld();
return select; return select;
}, },
set(newValue) { set(newValue) {
drawingRule(newValue.rule); drawingRule(newValue.rule);
}, },
}); });
@@ -298,11 +295,10 @@ export default {
RRule.SA, RRule.SA,
]; ];
const allDay = ref(false);
const feedalert = useAlertStore().alert; const feedalert = useAlertStore().alert;
const req = (val) => { const req = (val) => {
console.log(val, 'val')
return !!val || "Поле обязательно"; return !!val || "Поле обязательно";
}; };
@@ -342,23 +338,9 @@ export default {
return propsEvent.value.mycalendars[indCal].participant.some( return propsEvent.value.mycalendars[indCal].participant.some(
(part) => part.id === n.id (part) => part.id === n.id
); );
// == n.id
}); });
if (emp.employees.length > 0) ns.push(emp); if (emp.employees.length > 0) ns.push(emp);
// if (propsEvent.value.event.participant.length > 0) {
// e.employees.forEach((empl) => {
// let ab = propsEvent.value.event.participant.find(
// (a) => a === empl.id
// );
// if (ab) {
// empl.selected = true;
// } else {
// empl.selected = false;
// }
// });
// }
}); });
return ns; return ns;
}, },
@@ -384,7 +366,6 @@ export default {
const calendar = computed({ const calendar = computed({
get() { get() {
// propsEvent.value.event.participant = [accountStore.user.is_idEmployee]
let selected = []; let selected = [];
if (propsEvent.value.event.calendar) { if (propsEvent.value.event.calendar) {
let ind = propsEvent.value.mycalendars.findIndex( let ind = propsEvent.value.mycalendars.findIndex(
@@ -394,17 +375,20 @@ export default {
cl_name: propsEvent.value.mycalendars[ind].cl_name, cl_name: propsEvent.value.mycalendars[ind].cl_name,
cl_color: propsEvent.value.mycalendars[ind].cl_color, cl_color: propsEvent.value.mycalendars[ind].cl_color,
id: propsEvent.value.mycalendars[ind].id, id: propsEvent.value.mycalendars[ind].id,
}); });
} else { } else {
selected.push({ selected.push({
cl_name: propsEvent.value.mycalendars[0].cl_name, cl_name: propsEvent.value.mycalendars[0].cl_name,
cl_color: propsEvent.value.mycalendars[0].cl_color, cl_color: propsEvent.value.mycalendars[0].cl_color,
id: propsEvent.value.mycalendars[0].id, id: propsEvent.value.mycalendars[0].id,
}); });
} }
if (propsEvent.value.event.calendar == null) if (propsEvent.value.event.calendar == null)
propsEvent.value.event.calendar = propsEvent.value.mycalendars[0].id; propsEvent.value.event.calendar = propsEvent.value.mycalendars[0].id;
return selected; return selected;
}, },
@@ -426,7 +410,7 @@ export default {
} }
}; };
const part = new Set();
const returnIdParticant = (idPart) => { const returnIdParticant = (idPart) => {
idPart.staff.forEach((e) => { idPart.staff.forEach((e) => {
@@ -477,7 +461,6 @@ export default {
const menudate = ref(false); const menudate = ref(false);
const postData = (validate) => { const postData = (validate) => {
console.log(validate, "validate");
if (validate) { if (validate) {
let postEvent = new FormData(); let postEvent = new FormData();
postEvent.append( postEvent.append(
@@ -514,7 +497,6 @@ export default {
} }
} }
if (start.getDay() != end.getDay() && start.getDay() > end.getDay()) { if (start.getDay() != end.getDay() && start.getDay() > end.getDay()) {
s = 0; s = 0;
for (let x = s; x <= end.getDay(); x++) { for (let x = s; x <= end.getDay(); x++) {
@@ -522,13 +504,11 @@ export default {
} }
} }
if (start.getDay() < end.getDay()) { if (start.getDay() < end.getDay()) {
for (let x = s; x <= end.getDay(); x++) { for (let x = s; x <= end.getDay(); x++) {
weekNumbers.push(x); weekNumbers.push(x);
} }
} }
if (start.getDay() == end.getDay()) { if (start.getDay() == end.getDay()) {
weekNumbers.push(start.getDay()); weekNumbers.push(start.getDay());
} }
let rulesWeek = []; let rulesWeek = [];
@@ -588,7 +568,7 @@ export default {
postData, postData,
rules, rules,
delEvent, delEvent,
allDay,
repeatRules, repeatRules,
returnPeriod, returnPeriod,
periodDisplayRule, periodDisplayRule,