fix [P-296]: фикс формы создания события

This commit is contained in:
Inna committed 2025-11-07 13:40:18 +03:00
1 parent e6b97d52b8
commit 953ba7fe0f
5 files changed
+131 -61

No files matched your search

@@ -155,13 +155,13 @@ export default {
initialView: props.forHomePage ? props.view : currentView.value, initialView: props.forHomePage ? props.view : currentView.value,
locales: [ruLocale], locales: [ruLocale],
locale: 'ru', locale: 'ru',
timeZone: 'locale', timeZone: 'Europe/Moscow',
firstDay: 1, firstDay: 1,
headerToolbar: false, headerToolbar: false,
height: '80vh', height: '80vh',
aspectRatio: 1.5, aspectRatio: 1.5,
weekNumbers: true, weekNumbers: true,
eventDisplay: 'block', eventDisplay: 'auto',
eventTimeFormat: { eventTimeFormat: {
hour: '2-digit', hour: '2-digit',
minute: '2-digit', minute: '2-digit',
@@ -277,7 +277,7 @@ export default {
title: instance.title, title: instance.title,
start: instance.start, start: instance.start,
end: instance.end, end: instance.end,
allDay: instance.allday || isMultiDay, allDay: instance.allDay,
textColor: '#ffffff', textColor: '#ffffff',
backgroundColor: eventColor, backgroundColor: eventColor,
borderColor: eventColor, borderColor: eventColor,
@@ -287,21 +287,12 @@ export default {
}, },
})); }));
} else { } else {
let end = event.date_end;
if (event.allday) {
// Для allDay: просто добавляем 1 день к конечной дате
const endDate = new Date(event.date_end);
endDate.setDate(endDate.getDate() + 1);
end = endDate.toISOString();
}
return [ return [
{ {
id: event.id, id: event.id,
title: event.name, title: event.name,
start: event.date_start, start: event.date_start,
end: end, end: event.date_end,
allDay: event.allday, allDay: event.allday,
textColor: '#ffffff', textColor: '#ffffff',
backgroundColor: eventColor, backgroundColor: eventColor,
@@ -13,31 +13,56 @@ import { computed } from 'vue';
export default { export default {
props: { props: {
dateEventStart: { dateEvent: {
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
}, },
setup(props, { emit }) { setup(props, { emit }) {
// const newDate = computed({
// get() {
// return propsDateEvent.value.allday;
// },
// set(newValue) {
// propsDateEvent.value.allday = newValue;
// if (newValue === true)
// (propsDateEvent.value.date_end = new Date(
// new Date(propsDateEvent.value.date_end).setHours(23, 59, 59),
// )) &&
// (propsDateEvent.value.date_start = new Date(
// new Date(propsDateEvent.value.date_start).setHours(0, 0, 0),
// ));
// },
// });
const newDate = computed({ const newDate = computed({
get() { get() {
return propsDateEvent.value.allday; return propsDateEvent.value.allday;
}, },
set(newValue) { set(newValue) {
propsDateEvent.value.allday = newValue; propsDateEvent.value.allday = newValue;
if (newValue === true)
(propsDateEvent.value.date_end = new Date( const startDate = new Date(propsDateEvent.value.date_start);
new Date(propsDateEvent.value.date_end).setHours(23, 59, 59), const endDate = new Date(propsDateEvent.value.date_end);
)) &&
(propsDateEvent.value.date_start = new Date( if (newValue === true) {
new Date(propsDateEvent.value.date_start).setHours(0, 0, 0), // Весь день: 00:00 - 23:59
)); startDate.setHours(0, 0, 0, 0);
endDate.setHours(23, 59, 59, 999);
} else {
// Рабочие часы: 09:00 - 17:00
startDate.setHours(9, 0, 0, 0);
endDate.setHours(17, 0, 0, 0);
}
propsDateEvent.value.date_start = startDate.toISOString();
propsDateEvent.value.date_end = endDate.toISOString();
}, },
}); });
const propsDateEvent = computed({ const propsDateEvent = computed({
get: () => props.dateEventStart, get: () => props.dateEvent,
set: (value) => emit('update:dateEventStart', value), set: (value) => emit('update:dateEvent', value),
}); });
return { return {
@@ -1,5 +1,5 @@
<template> <template>
<v-col lg="3" :class="`order-${order[0]}`"> <v-col :class="`order-${order[0]}`">
<v-menu <v-menu
v-model="menudate" v-model="menudate"
:nudge-right="40" :nudge-right="40"
@@ -19,6 +19,7 @@
v-bind="props" v-bind="props"
readonly readonly
hide-details hide-details
:disabled="isEndDateEnabled"
> >
<template v-slot:prepend-inner> <template v-slot:prepend-inner>
<v-icon v-bind="props" icon="mdi-calendar-today" color="cyan-darken-3" size="x-small" /> <v-icon v-bind="props" icon="mdi-calendar-today" color="cyan-darken-3" size="x-small" />
@@ -79,6 +80,7 @@
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { formatComa } from '@/utils/universal_functions'; import { formatComa } from '@/utils/universal_functions';
export default { export default {
inheritAttrs: false,
props: { props: {
dateEvent: { dateEvent: {
type: String, type: String,
@@ -106,16 +108,14 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
// Новый проп - ограничение по времени (для окончания повторений)
timeLimit: {
type: String,
default: '23:59',
},
// Новый проп - режим работы (обычный или для окончания повторений)
showTime: { showTime: {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
isEndDateEnabled: {
type: Boolean,
default: false,
},
}, },
emits: ['update:dateEvent', 'adjustEndDate'], emits: ['update:dateEvent', 'adjustEndDate'],
@@ -162,7 +162,7 @@ export default {
const startDate = new Date(props.limitation); const startDate = new Date(props.limitation);
if (newDate <= startDate) { if (newDate <= startDate) {
const correctedDate = new Date(startDate); const correctedDate = new Date(startDate);
correctedDate.setHours(startDate.getHours() + 1); correctedDate.setMinutes(startDate.getMinutes() + 30);
propsDateEvent.value = correctedDate; propsDateEvent.value = correctedDate;
} else { } else {
propsDateEvent.value = newDate; propsDateEvent.value = newDate;
@@ -172,7 +172,7 @@ export default {
const currentEnd = new Date(props.limitation); const currentEnd = new Date(props.limitation);
if (newDate > currentEnd) { if (newDate > currentEnd) {
const newEnd = new Date(newDate); const newEnd = new Date(newDate);
newEnd.setHours(newDate.getHours() + 1); newEnd.setMinutes(newDate.getMinutes() + 30);
emit('adjustEndDate', newEnd.toISOString()); emit('adjustEndDate', newEnd.toISOString());
} }
} }
@@ -193,7 +193,7 @@ export default {
const startDate = new Date(props.limitation); const startDate = new Date(props.limitation);
if (newDate <= startDate) { if (newDate <= startDate) {
const correctedDate = new Date(startDate); const correctedDate = new Date(startDate);
correctedDate.setHours(startDate.getHours() + 1); correctedDate.setMinutes(startDate.getMinutes() + 30);
propsDateEvent.value = correctedDate; propsDateEvent.value = correctedDate;
} else { } else {
propsDateEvent.value = newDate; propsDateEvent.value = newDate;
@@ -203,7 +203,7 @@ export default {
const currentEnd = new Date(props.limitation); const currentEnd = new Date(props.limitation);
if (newDate > currentEnd) { if (newDate > currentEnd) {
const newEnd = new Date(newDate); const newEnd = new Date(newDate);
newEnd.setHours(newDate.getHours() + 1); newEnd.setMinutes(newDate.getMinutes() + 30);
emit('adjustEndDate', newEnd.toISOString()); emit('adjustEndDate', newEnd.toISOString());
} }
} }
@@ -240,4 +240,19 @@ export default {
}; };
</script> </script>
<style></style> <style>
.wide-time-select :deep(.v-col.lg-3) {
flex: 1 !important;
max-width: none !important;
min-width: 200px !important;
}
.wide-time-select :deep(.v-textarea) {
width: 100% !important;
min-width: 200px !important;
}
.wide-time-select :deep(.v-menu) {
width: 100% !important;
}
</style>
@@ -8,9 +8,18 @@ export function useRecurrence() {
// Пробуем распарсить как RRULE-строку // Пробуем распарсить как RRULE-строку
if (periodString.includes('RRULE:')) { if (periodString.includes('RRULE:')) {
const rrule = RRule.fromString(periodString); const rrule = RRule.fromString(periodString);
const start = new Date(eventDateStart);
const localDtstart = new Date(
start.getFullYear(),
start.getMonth(),
start.getDate(),
start.getHours(),
start.getMinutes(),
start.getSeconds(),
);
return { return {
...rrule.origOptions, ...rrule.origOptions,
dtstart: new Date(eventDateStart), dtstart: localDtstart,
interval: rrule.origOptions.interval || 1, interval: rrule.origOptions.interval || 1,
}; };
} }
@@ -62,15 +71,14 @@ export function useRecurrence() {
if (!rrule) return [event]; if (!rrule) return [event];
const dates = rrule.all((date, i) => i < count); const dates = rrule.all((date, i) => i < count);
const start = new Date(event.date_start);
const end = new Date(event.date_end);
const duration = end - start;
return dates.map((date, index) => ({ const duration = new Date(event.date_end) - new Date(event.date_start);
return dates.map((date) => ({
id: event.id, id: event.id,
title: event.name, title: event.name,
start: date, start: date,
end: (date.getTime() + duration), end: date.getTime() + duration,
allDay: event.allday, allDay: event.allday,
extendedProps: { extendedProps: {
originalEventId: event.id, originalEventId: event.id,
@@ -104,10 +104,17 @@
</v-row> </v-row>
<v-row no-gutters> <v-row no-gutters>
<period-events <period-events
:dateEventStart="propsEvent.event" :dateEvent="propsEvent.event"
@update:dateEventStart="propsEvent.event = $event" @update:dateEvent="propsEvent.event = $event"
/> />
<v-col lg="7" class="pt-2 ml-5"> </v-row>
</v-col>
</v-row>
</v-col>
<v-row no-gutters class="align-top mt-3">
<v-col class="text-body-2 text-text_grey" lg="2"> Повтор события </v-col>
<v-col class="d-flex flex-column">
<!-- Выбор типа повторения -->
<v-autocomplete <v-autocomplete
v-model="selectedRule" v-model="selectedRule"
:items="repeatRules" :items="repeatRules"
@@ -117,32 +124,31 @@
item-title="type" item-title="type"
item-value="id" item-value="id"
@update:model-value="updatePeriodRule" @update:model-value="updatePeriodRule"
> hide-details
</v-autocomplete> />
</v-col>
</v-row> <!-- Окончание повторения -->
</v-col> <v-row class="align-center mt-2" style="height: 54px" no-gutters>
</v-row> <v-col cols="5">
</v-col>
<v-row no-gutters class="align-top" style="height: 50px">
<v-col class="text-body-2 text-text_grey" lg="2"> Окончание события </v-col>
<v-col class="d-flex flex-column">
<v-row class="gap" no-gutters>
<v-checkbox <v-checkbox
v-model="showRepeatEnd" v-model="showRepeatEnd"
:disabled="isRepeatEndDisabled" :disabled="isRepeatEndDisabled"
density="compact" density="compact"
hide-details hide-details
class="pr-3 pb-3" label="Окончание повторения"
/> />
</v-col>
<v-col cols="4">
<time-select <time-select
:showTime="false" :showTime="false"
v-if="showRepeatEnd"
:chek="false"
:order="[1, 2]" :order="[1, 2]"
:dateEvent="repeatEndDate ? String(repeatEndDate) : new Date()" :dateEvent="repeatEndDate ? String(repeatEndDate) : String(new Date())"
@update:dateEvent="updateRepeatEndDate" @update:dateEvent="updateRepeatEndDate"
class="wide-time-select"
:limitation="String(propsEvent.event.date_start)"
:isEndDateEnabled="!showRepeatEnd"
/> />
</v-col>
</v-row> </v-row>
</v-col> </v-col>
</v-row> </v-row>
@@ -591,6 +597,14 @@ export default {
let postEvent = new FormData(); let postEvent = new FormData();
// if (propsEvent.value.event.allday && propsEvent.value.event.period?.includes('DTSTART')) {
// // убираем суффикс Z (UTC), чтобы не было смещения на день
// propsEvent.value.event.period = propsEvent.value.event.period.replace(
// 'Z\nRRULE',
// '\nRRULE',
// );
// }
postEvent.append( postEvent.append(
'event', 'event',
JSON.stringify({ ...propsEvent.value.event, files: propsEvent.value.event.files }), JSON.stringify({ ...propsEvent.value.event, files: propsEvent.value.event.files }),
@@ -666,13 +680,30 @@ export default {
const dtstart = new Date(propsEvent.value.event.date_start); const dtstart = new Date(propsEvent.value.event.date_start);
const localDtstart = new Date(
dtstart.getFullYear(),
dtstart.getMonth(),
dtstart.getDate(),
dtstart.getHours(),
dtstart.getMinutes(),
dtstart.getSeconds(),
);
const ruleOptions = { const ruleOptions = {
...rule.rule, ...rule.rule,
dtstart: dtstart, dtstart: localDtstart,
}; };
if (showRepeatEnd.value && repeatEndDate.value) { if (showRepeatEnd.value && repeatEndDate.value) {
ruleOptions.until = new Date(repeatEndDate.value); const untilDate = new Date(repeatEndDate.value);
ruleOptions.until = new Date(
untilDate.getFullYear(),
untilDate.getMonth(),
untilDate.getDate(),
untilDate.getHours(),
untilDate.getMinutes(),
untilDate.getSeconds(),
);
} }
if (rule.rule.freq === RRule.WEEKLY) { if (rule.rule.freq === RRule.WEEKLY) {