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

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