fix [P-293]: создание календаря при создании события
This commit is contained in:
1 parent
aaacee5abc
commit
ed5b94b13d
5 files changed
+253
-245
No files matched your search
@@ -34,7 +34,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, watch, computed } from 'vue';
|
||||
import { ref, onMounted, watch, computed, provide } from 'vue';
|
||||
import { useWeekendsStore } from '@/store/WeekendsStore';
|
||||
import EventCreate from '@/components/calendar_of_events/event-create.vue';
|
||||
import CustomCalendar from '@/components/calendar_of_events/UI_calendar/CustomCalendar.vue';
|
||||
@@ -56,6 +56,7 @@ export default {
|
||||
const eventFromCalendar = ref({});
|
||||
const eventKey = ref(0);
|
||||
const calendarKey = ref(0);
|
||||
const miniCalendarRef = ref(null);
|
||||
|
||||
const calendarStore = useCalendarStore();
|
||||
const accountStore = useAccountStore();
|
||||
@@ -150,6 +151,12 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
const openCalendarCreate = () => {
|
||||
miniCalendarRef.value?.openCalendarCreate();
|
||||
};
|
||||
|
||||
provide('openCalendarCreate', openCalendarCreate);
|
||||
|
||||
watch(
|
||||
() => calendarStore.showEventDialog,
|
||||
(newValue, oldValue) => {
|
||||
@@ -226,6 +233,7 @@ export default {
|
||||
allCalendars,
|
||||
eventKey,
|
||||
calendarKey,
|
||||
openCalendarCreate,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
block
|
||||
elevation="1"
|
||||
@click="openEventDialog"
|
||||
:disabled="!myCalendars || myCalendars.length === 0"
|
||||
>Создать событие</v-btn
|
||||
>
|
||||
<!-- :disabled="!myCalendars || myCalendars.length === 0" -->
|
||||
</v-col>
|
||||
<v-col lg="3">
|
||||
<v-locale-provider locale="ru">
|
||||
@@ -33,7 +33,7 @@
|
||||
</v-col>
|
||||
|
||||
<v-col class="flex-column d-flex">
|
||||
<v-row no-gutters class=" overflow-hidden flex-column flex-nowrap">
|
||||
<v-row no-gutters class="overflow-hidden flex-column flex-nowrap">
|
||||
<v-col>
|
||||
<calendar-my
|
||||
:calendars="myCalendars"
|
||||
@@ -68,6 +68,10 @@ export default {
|
||||
|
||||
const { selectedDate, myCalendars, subscribedCalendars } = storeToRefs(calendarStore);
|
||||
|
||||
// const selectedDate = computed(() => calendarStore.selectedDate);
|
||||
// const myCalendars = computed(() => calendarStore.myCalendars);
|
||||
// const subscribedCalendars = computed(() => calendarStore.subscribedCalendars);
|
||||
|
||||
const { user } = storeToRefs(accountStore);
|
||||
|
||||
const currentDisplay = ref(null);
|
||||
@@ -181,7 +185,7 @@ export default {
|
||||
);
|
||||
|
||||
watch(
|
||||
[myCalendars, subscribedCalendars],
|
||||
() => [calendarStore.myCalendars, calendarStore.subscribedCalendars],
|
||||
() => {
|
||||
updateCalendarDays();
|
||||
},
|
||||
|
||||
@@ -161,7 +161,7 @@ export default {
|
||||
cl_descr: [(val) => req(val)],
|
||||
};
|
||||
|
||||
const isNewCalendar = computed(() => !propsCalendar.value.id);
|
||||
const isNewCalendar = computed(() => !propsCalendar.value?.id);
|
||||
const isAuthor = computed(() => propsCalendar.value.author === accountStore.user.is_idEmployee);
|
||||
|
||||
const titleCard = computed(() =>
|
||||
@@ -217,41 +217,41 @@ export default {
|
||||
},
|
||||
});
|
||||
|
||||
// const color = [
|
||||
// '#0ea5e9', // Яркий голубой
|
||||
// '#3b82f6', // Королевский синий
|
||||
// '#10b981', // Изумрудно-зеленый
|
||||
// '#f59e0b', // Теплый янтарный
|
||||
// '#ef4444', // Акцентный красный
|
||||
// '#8b5cf6', // Фиолетовый
|
||||
// '#4f46e5', // Индиго (профессиональный синий)
|
||||
// '#06b6d4', // Бирюзовый
|
||||
// '#84cc16', // Лаймовый
|
||||
// '#f97316', // Оранжевый
|
||||
// '#ec4899', // Розовый
|
||||
// '#6366f1', // Фиолетово-синий
|
||||
// '#14b8a6', // Бирюзово-зеленый
|
||||
// '#eab308', // Золотисто-желтый
|
||||
// '#22c55e', // Зеленый
|
||||
// ];
|
||||
|
||||
const color = [
|
||||
'#3b82f6', // Синий
|
||||
'#10b981', // Зеленый
|
||||
'#dc2626', // Красный
|
||||
'#d97706', // Оранжевый
|
||||
'#7c3aed', // Фиолетовый
|
||||
'#0ea5e9', // Голубой
|
||||
'#84cc16', // Лаймовый
|
||||
'#f59e0b', // Янтарный
|
||||
'#8b5cf6', // Пурпурный
|
||||
const color = [
|
||||
'#0ea5e9', // Яркий голубой
|
||||
'#3b82f6', // Королевский синий
|
||||
'#10b981', // Изумрудно-зеленый
|
||||
'#f59e0b', // Теплый янтарный
|
||||
'#ef4444', // Акцентный красный
|
||||
'#8b5cf6', // Фиолетовый
|
||||
'#4f46e5', // Индиго (профессиональный синий)
|
||||
'#06b6d4', // Бирюзовый
|
||||
'#f97316', // Теплый оранжевый
|
||||
'#6366f1', // Фиолетово-синий
|
||||
'#14b8a6', // Морской волны
|
||||
'#84cc16', // Лаймовый
|
||||
'#f97316', // Оранжевый
|
||||
'#ec4899', // Розовый
|
||||
'#64748b', // Серо-синий
|
||||
];
|
||||
'#6366f1', // Фиолетово-синий
|
||||
'#14b8a6', // Бирюзово-зеленый
|
||||
'#eab308', // Золотисто-желтый
|
||||
'#22c55e', // Зеленый
|
||||
];
|
||||
|
||||
// const color = [
|
||||
// '#3b82f6', // Синий
|
||||
// '#10b981', // Зеленый
|
||||
// '#dc2626', // Красный
|
||||
// '#d97706', // Оранжевый
|
||||
// '#7c3aed', // Фиолетовый
|
||||
// '#0ea5e9', // Голубой
|
||||
// '#84cc16', // Лаймовый
|
||||
// '#f59e0b', // Янтарный
|
||||
// '#8b5cf6', // Пурпурный
|
||||
// '#06b6d4', // Бирюзовый
|
||||
// '#f97316', // Теплый оранжевый
|
||||
// '#6366f1', // Фиолетово-синий
|
||||
// '#14b8a6', // Морской волны
|
||||
// '#ec4899', // Розовый
|
||||
// '#64748b', // Серо-синий
|
||||
// ];
|
||||
const colorPik = (col) => {
|
||||
if (propsCalendar.value.cl_color === col) {
|
||||
propsCalendar.value.cl_color = null;
|
||||
|
||||
@@ -73,41 +73,32 @@
|
||||
</v-expansion-panels>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, watch } from 'vue';
|
||||
<script setup>
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
|
||||
export default {
|
||||
components: { calendarCreate },
|
||||
const props = defineProps({
|
||||
calendars: Array,
|
||||
title: String,
|
||||
});
|
||||
|
||||
props: {
|
||||
calendars: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
const emit = defineEmits(['getCalendar']);
|
||||
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
const showDialog = ref(false);
|
||||
const accountStore = useAccountStore();
|
||||
const { user } = storeToRefs(accountStore);
|
||||
const calendarStore = useCalendarStore();
|
||||
const { toggleCalendarVisibility, hiddenCalendarIds } = calendarStore;
|
||||
|
||||
setup(props) {
|
||||
const showDialog = ref(false);
|
||||
const accountStore = useAccountStore();
|
||||
const { user } = storeToRefs(accountStore);
|
||||
const calendarStore = useCalendarStore();
|
||||
const { toggleCalendarVisibility, hiddenCalendarIds } = calendarStore;
|
||||
const calendar = ref(null);
|
||||
const openGroup = ref([0]);
|
||||
// const trans = ref(false);
|
||||
const hover = ref(0);
|
||||
|
||||
const calendar = ref(null);
|
||||
const openGroup = ref([0]);
|
||||
const trans = ref(false);
|
||||
const hover = ref(0);
|
||||
|
||||
const editCreatedCalendar = (cal) => {
|
||||
const editCreatedCalendar = (cal) => {
|
||||
if (cal === undefined) {
|
||||
calendar.value = {
|
||||
cl_name: '',
|
||||
@@ -119,43 +110,41 @@ export default {
|
||||
calendar.value = { ...cal };
|
||||
}
|
||||
showDialog.value = true;
|
||||
};
|
||||
};
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
onMounted(() => {
|
||||
window.$createCalendar = () => {
|
||||
editCreatedCalendar();
|
||||
};
|
||||
});
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
if (calendar.value.cl_name.length > 1) {
|
||||
const calendarData = JSON.parse(JSON.stringify(calendar.value));
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('calendarCreated', {
|
||||
detail: calendarData,
|
||||
}),
|
||||
);
|
||||
}
|
||||
showDialog.value = false;
|
||||
};
|
||||
};
|
||||
|
||||
const resetCalendar = () => {
|
||||
const resetCalendar = () => {
|
||||
calendar.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
const toggleVisiblityEvents = (cal) => {
|
||||
const toggleVisiblityEvents = (cal) => {
|
||||
toggleCalendarVisibility(cal.id);
|
||||
};
|
||||
};
|
||||
|
||||
watch(hiddenCalendarIds, (newHiddenIds) => {}, { deep: true });
|
||||
watch(hiddenCalendarIds, (newHiddenIds) => {}, { deep: true });
|
||||
|
||||
watch(
|
||||
watch(
|
||||
() => props.calendars,
|
||||
(newCalendars) => {},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
return {
|
||||
accountStore,
|
||||
user,
|
||||
calendar,
|
||||
showDialog,
|
||||
editCreatedCalendar,
|
||||
toggleVisiblityEvents,
|
||||
openGroup,
|
||||
trans,
|
||||
hover,
|
||||
handleCloseDialog,
|
||||
resetCalendar,
|
||||
};
|
||||
},
|
||||
};
|
||||
);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -165,14 +154,14 @@ export default {
|
||||
height: 22px !important;
|
||||
border-radius: 3px !important;
|
||||
margin-left: 0.5rem;
|
||||
background-color: #00897B !important;
|
||||
background-color: #00897b !important;
|
||||
color: white;
|
||||
margin-bottom: 2px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.simple-hover:hover {
|
||||
background-color: #004D40 !important;
|
||||
background-color: #004d40 !important;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.fade-enter-active,
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
hide-details
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
class="py-3"
|
||||
class="py-3 my-select"
|
||||
return-object
|
||||
:rules="rules.calendar"
|
||||
:disabled="'id' in propsEvent.event"
|
||||
@@ -65,7 +65,8 @@
|
||||
:value="item"
|
||||
color="primary"
|
||||
v-bind="props"
|
||||
@click.stop="myCalendar = item.raw"
|
||||
@click.stop="handleCalendarSelect(item.raw)"
|
||||
:data-calendar-id="item.raw.id"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
|
||||
@@ -183,8 +184,8 @@
|
||||
</dialog-create>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
<script setup>
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import DialogCreate from '@/components/calendar_of_events/UI_calendar/dialogCreate.vue';
|
||||
@@ -198,47 +199,29 @@ import { RRule } from 'rrule';
|
||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||
import { useCalendarStore } from '../../store/calendarStore';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
calendarCreateSelect,
|
||||
DialogCreate,
|
||||
TimeSelect,
|
||||
UploadingFile,
|
||||
ReminderEvent,
|
||||
PeriodEvents,
|
||||
},
|
||||
const props = defineProps({
|
||||
eventCalendar: Object,
|
||||
allCalendars: Array,
|
||||
selectedRule: Object,
|
||||
});
|
||||
|
||||
props: {
|
||||
eventCalendar: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
allCalendars: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
selectedRule: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
const emit = defineEmits(['update:eventCalendar', 'getCalendar', 'closeDialog']);
|
||||
|
||||
setup(props, { emit }) {
|
||||
const accountStore = useAccountStore();
|
||||
const calendarStore = useCalendarStore();
|
||||
const createDialog = ref(null);
|
||||
const accountStore = useAccountStore();
|
||||
const calendarStore = useCalendarStore();
|
||||
const createDialog = ref(null);
|
||||
|
||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||
|
||||
const propsEvent = computed({
|
||||
const propsEvent = computed({
|
||||
get: () => {
|
||||
return props.eventCalendar;
|
||||
},
|
||||
|
||||
set: (value) => emit('update:eventCalendar', value),
|
||||
});
|
||||
});
|
||||
|
||||
const currentCalendarAuthorId = computed(() => {
|
||||
const currentCalendarAuthorId = computed(() => {
|
||||
if (isNewEvent.value) {
|
||||
// Для нового события - автор текущего выбранного календаря
|
||||
return myCalendar.value?.author;
|
||||
@@ -250,9 +233,9 @@ export default {
|
||||
);
|
||||
return currentCalendar?.author;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const newStaff = computed({
|
||||
const newStaff = computed({
|
||||
get() {
|
||||
let filteredStaff = [];
|
||||
|
||||
@@ -317,19 +300,19 @@ export default {
|
||||
|
||||
return filteredStaff;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// ВАЛИДАЦИЯ
|
||||
const rules = {
|
||||
// ВАЛИДАЦИЯ
|
||||
const rules = {
|
||||
name: [
|
||||
(val) => !!val || 'Поле обязательно для заполнения',
|
||||
(val) => (val && val.length >= 3) || 'Минимум 3 символа',
|
||||
(val) => (val && val.length <= 100) || 'Максимум 100 символов',
|
||||
],
|
||||
calendar: [(val) => !!val || 'Выберите календарь'],
|
||||
};
|
||||
};
|
||||
|
||||
const repeatRules = [
|
||||
const repeatRules = [
|
||||
{ type: 'Не повторять', rule: null, id: 1 },
|
||||
{
|
||||
type: 'Каждый день',
|
||||
@@ -387,14 +370,14 @@ export default {
|
||||
},
|
||||
id: 5,
|
||||
},
|
||||
];
|
||||
];
|
||||
|
||||
const selectedRule = ref(repeatRules[0]);
|
||||
const showRepeatEnd = ref(false);
|
||||
const repeatEndDate = ref(new Date());
|
||||
const selectedRule = ref(repeatRules[0]);
|
||||
const showRepeatEnd = ref(false);
|
||||
const repeatEndDate = ref(new Date());
|
||||
|
||||
// Инициализация повторов при редактировании
|
||||
const initializeRule = () => {
|
||||
// Инициализация повторов при редактировании
|
||||
const initializeRule = () => {
|
||||
if (!propsEvent.value.event.period) {
|
||||
selectedRule.value = repeatRules[0]; // "Не повторять"
|
||||
repeatEndDate.value = propsEvent.value.event.date_end
|
||||
@@ -453,56 +436,67 @@ export default {
|
||||
? new Date(propsEvent.value.event.date_end)
|
||||
: new Date();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const isRepeatEndDisabled = computed(() => {
|
||||
const isRepeatEndDisabled = computed(() => {
|
||||
return !selectedRule.value.rule; // disabled если правило null (не повторять)
|
||||
});
|
||||
});
|
||||
|
||||
const feedalert = useAlertStore().alert;
|
||||
const feedalert = useAlertStore().alert;
|
||||
|
||||
const titleCard = computed(() => {
|
||||
const titleCard = computed(() => {
|
||||
if (propsEvent.value.event.hasOwnProperty('id')) {
|
||||
return 'Редактирование события';
|
||||
} else {
|
||||
return 'Новое событие';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const isNewEvent = computed(() => !propsEvent.value.event.hasOwnProperty('id'));
|
||||
const isNewEvent = computed(() => !propsEvent.value.event.hasOwnProperty('id'));
|
||||
|
||||
const myCalendar = ref(null);
|
||||
// const isNewEvent = computed(() => !propsEvent.value.event.id);
|
||||
const myCalendar = ref(null);
|
||||
|
||||
// Computed property с защитой от undefined
|
||||
// const safeCalendars = computed(() => props.allCalendars || []);
|
||||
|
||||
const safeCalendars = computed(() => {
|
||||
const safeCalendars = computed(() => {
|
||||
const userId = accountStore.user.is_idEmployee;
|
||||
|
||||
return (props.allCalendars || []).filter((calendar) => {
|
||||
// Пользователь - автор календаря (полные права)
|
||||
if (calendar.author === userId) {
|
||||
return true;
|
||||
}
|
||||
// return (props.allCalendars || []).filter((calendar) => {
|
||||
// // Пользователь - автор календаря (полные права)
|
||||
// if (calendar.author === userId) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// Пользователь - участник с правами редактора
|
||||
// // Пользователь - участник с правами редактора
|
||||
// const participant = calendar.participant?.find((p) => p.participant_calendar === userId);
|
||||
|
||||
// return participant?.editor === true;
|
||||
// });
|
||||
|
||||
let filtered = (props.allCalendars || []).filter((calendar) => {
|
||||
if (calendar.author === userId) return true;
|
||||
const participant = calendar.participant?.find((p) => p.participant_calendar === userId);
|
||||
|
||||
return participant?.editor === true;
|
||||
});
|
||||
|
||||
// Добавляем пункт "Создать календарь"
|
||||
filtered.push({
|
||||
id: 'create_new',
|
||||
cl_name: '➕ Создать календарь',
|
||||
isFake: true,
|
||||
});
|
||||
|
||||
const isCalendarsReady = computed(() => safeCalendars.value.length > 0);
|
||||
return filtered;
|
||||
});
|
||||
|
||||
// Computed для календаря события
|
||||
const eventCalendar = computed(() => {
|
||||
const isCalendarsReady = computed(() => safeCalendars.value.length > 0);
|
||||
|
||||
// Computed для календаря события
|
||||
const eventCalendar = computed(() => {
|
||||
if (!propsEvent.value?.event?.calendar || !safeCalendars.value.length) return null;
|
||||
return safeCalendars.value.find((cal) => cal.id === propsEvent.value.event.calendar);
|
||||
});
|
||||
});
|
||||
|
||||
// Единоразовая инициализация при монтировании/получении данных
|
||||
const initializeCalendar = () => {
|
||||
// Единоразовая инициализация при монтировании/получении данных
|
||||
const initializeCalendar = () => {
|
||||
if (myCalendar.value) return; // Уже инициализирован
|
||||
|
||||
// Приоритет 1: календарь из события (редактирование)
|
||||
@@ -513,27 +507,31 @@ export default {
|
||||
|
||||
// Приоритет 2: первый доступный календарь (создание)
|
||||
if (safeCalendars.value.length > 0) {
|
||||
myCalendar.value = safeCalendars.value[0];
|
||||
// myCalendar.value = safeCalendars.value[0];
|
||||
const firstRealCalendar = safeCalendars.value.find((cal) => cal.id !== 'create_new');
|
||||
if (firstRealCalendar) {
|
||||
myCalendar.value = firstRealCalendar;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// Инициализируем когда все готово
|
||||
watch(
|
||||
// Инициализируем когда все готово
|
||||
watch(
|
||||
[() => safeCalendars.value.length, () => propsEvent.value],
|
||||
() => {
|
||||
(newCalendar) => {
|
||||
initializeCalendar();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
||||
// Дополнительная защита - вотчер только на смену самого календаря
|
||||
watch(eventCalendar, (newCalendar) => {
|
||||
// Дополнительная защита - вотчер только на смену самого календаря
|
||||
watch(eventCalendar, (newCalendar) => {
|
||||
if (newCalendar && newCalendar.id !== myCalendar.value?.id) {
|
||||
myCalendar.value = newCalendar;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const delEvent = (idev) => {
|
||||
const delEvent = (idev) => {
|
||||
axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`).then((result) => {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
@@ -542,11 +540,11 @@ export default {
|
||||
emit('getCalendar');
|
||||
});
|
||||
emit('closeDialog');
|
||||
};
|
||||
};
|
||||
|
||||
const newFiles = ref([]);
|
||||
const newFiles = ref([]);
|
||||
|
||||
const handleFilesUpdate = (updatedExistingFiles) => {
|
||||
const handleFilesUpdate = (updatedExistingFiles) => {
|
||||
// Сохраняем новые файлы во временную переменную
|
||||
const currentNewFiles = [...newFiles.value];
|
||||
|
||||
@@ -555,13 +553,13 @@ export default {
|
||||
|
||||
// Восстанавливаем новые файлы
|
||||
newFiles.value = currentNewFiles;
|
||||
};
|
||||
};
|
||||
|
||||
const postFiles = (updatedFiles) => {
|
||||
const postFiles = (updatedFiles) => {
|
||||
newFiles.value = updatedFiles;
|
||||
};
|
||||
};
|
||||
|
||||
const returnIdParticant = (idPart) => {
|
||||
const returnIdParticant = (idPart) => {
|
||||
idPart.staff.forEach((e) => {
|
||||
if (e.selected == true && !propsEvent.value.event.participant.includes(e.id)) {
|
||||
propsEvent.value.event.participant.push(e.id);
|
||||
@@ -573,9 +571,9 @@ export default {
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const cbSelect = (item, arr) => {
|
||||
const cbSelect = (item, arr) => {
|
||||
item.forEach((e) => {
|
||||
if (!('employees' in e)) {
|
||||
if (!propsEvent.value.event.participant.includes(e.id)) {
|
||||
@@ -586,25 +584,17 @@ export default {
|
||||
cbSelect(e.employees);
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const menudate = ref(false);
|
||||
|
||||
const postData = (validate) => {
|
||||
const postData = async (validate) => {
|
||||
if (validate) {
|
||||
await nextTick();
|
||||
|
||||
updatePeriodRule(selectedRule.value);
|
||||
propsEvent.value.event.calendar = myCalendar.value.id;
|
||||
|
||||
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(
|
||||
'event',
|
||||
JSON.stringify({ ...propsEvent.value.event, files: propsEvent.value.event.files }),
|
||||
@@ -626,25 +616,25 @@ export default {
|
||||
emit('closeDialog');
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const handleAutoAdjustEnd = (newEndDate) => {
|
||||
const handleAutoAdjustEnd = (newEndDate) => {
|
||||
propsEvent.value.event.date_end = newEndDate;
|
||||
};
|
||||
};
|
||||
|
||||
const updateRepeatEndDate = (date) => {
|
||||
const updateRepeatEndDate = (date) => {
|
||||
repeatEndDate.value = date;
|
||||
updatePeriodRule(selectedRule.value); // Пересоздаем правило с новой датой
|
||||
};
|
||||
};
|
||||
|
||||
watch(selectedRule, (newRule) => {
|
||||
watch(selectedRule, (newRule) => {
|
||||
if (!newRule.rule) {
|
||||
showRepeatEnd.value = false;
|
||||
repeatEndDate.value = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const updateDateStart = (newDate) => {
|
||||
const updateDateStart = (newDate) => {
|
||||
// Нормализуем к ISO строке
|
||||
const normalizedDate = new Date(newDate).toISOString();
|
||||
propsEvent.value.event.date_start = normalizedDate;
|
||||
@@ -662,15 +652,15 @@ export default {
|
||||
if (selectedRule.value.rule) {
|
||||
updatePeriodRule(selectedRule.value);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const updateDateEnd = (newDate) => {
|
||||
const updateDateEnd = (newDate) => {
|
||||
// Нормализуем к ISO строке
|
||||
propsEvent.value.event.date_end = new Date(newDate).toISOString();
|
||||
};
|
||||
};
|
||||
|
||||
// функция обновления периода
|
||||
const updatePeriodRule = (rule) => {
|
||||
// функция обновления периода
|
||||
const updatePeriodRule = (rule) => {
|
||||
selectedRule.value = rule;
|
||||
|
||||
if (!rule.rule) {
|
||||
@@ -723,9 +713,9 @@ export default {
|
||||
const rrule = new RRule(ruleOptions);
|
||||
|
||||
propsEvent.value.event.period = rrule.toString();
|
||||
};
|
||||
};
|
||||
|
||||
watch(
|
||||
watch(
|
||||
() => propsEvent.value.event?.period,
|
||||
(newPeriod) => {
|
||||
if (newPeriod) {
|
||||
@@ -733,43 +723,60 @@ export default {
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch([safeCalendars, myCalendar], (newCalendar) => {}, { deep: true, immediate: true });
|
||||
|
||||
// function handleCalendarSelect(calendar) {
|
||||
// if (calendar.id === 'create_new') {
|
||||
// if (window.$createCalendar) {
|
||||
// // Создаем слушатель события
|
||||
// const handleCalendarCreated = (event) => {
|
||||
// // myCalendar.value = JSON.parse(JSON.stringify(event.detail));
|
||||
// propsEvent.value.event.calendar = event.detail.id;
|
||||
// myCalendar.value = event.detail;
|
||||
// window.removeEventListener('calendarCreated', handleCalendarCreated);
|
||||
// };
|
||||
|
||||
// window.addEventListener('calendarCreated', handleCalendarCreated);
|
||||
// window.$createCalendar();
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// myCalendar.value = calendar;
|
||||
// }
|
||||
|
||||
function handleCalendarSelect(calendar) {
|
||||
if (calendar.id === 'create_new') {
|
||||
if (window.$createCalendar) {
|
||||
// Запоминаем максимальный ID до создания
|
||||
const maxIdBefore = Math.max(
|
||||
...safeCalendars.value.filter((cal) => cal.id !== 'create_new').map((cal) => cal.id),
|
||||
);
|
||||
|
||||
return {
|
||||
menudate,
|
||||
titleCard,
|
||||
propsEvent,
|
||||
newStaff,
|
||||
returnIdParticant,
|
||||
postFiles,
|
||||
postData,
|
||||
rules,
|
||||
delEvent,
|
||||
myCalendar,
|
||||
window.$createCalendar();
|
||||
|
||||
// Следим за появлением календаря с ID больше максимального
|
||||
const unwatch = watch(
|
||||
safeCalendars,
|
||||
isCalendarsReady,
|
||||
isNewEvent,
|
||||
currentCalendarAuthorId,
|
||||
isRepeatEndDisabled,
|
||||
(newCalendars) => {
|
||||
const realCalendars = newCalendars.filter((cal) => cal.id !== 'create_new');
|
||||
const newCalendar = realCalendars.find((cal) => cal.id > maxIdBefore);
|
||||
|
||||
repeatRules,
|
||||
updatePeriodRule,
|
||||
selectedRule,
|
||||
updateDateEnd,
|
||||
updateDateStart,
|
||||
initializeRule,
|
||||
|
||||
createDialog,
|
||||
handleAutoAdjustEnd,
|
||||
newFiles,
|
||||
handleFilesUpdate,
|
||||
initializeCalendar,
|
||||
updateRepeatEndDate,
|
||||
showRepeatEnd,
|
||||
repeatEndDate,
|
||||
};
|
||||
if (newCalendar) {
|
||||
myCalendar.value = newCalendar;
|
||||
unwatch();
|
||||
}
|
||||
},
|
||||
};
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
setTimeout(() => unwatch(), 5000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
myCalendar.value = calendar;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in new issue
Block a user