diff --git a/src/front/src/components/UI/defaultportal/uploading-file.vue b/src/front/src/components/UI/defaultportal/uploading-file.vue
index 16cb4124b..56d4c8154 100644
--- a/src/front/src/components/UI/defaultportal/uploading-file.vue
+++ b/src/front/src/components/UI/defaultportal/uploading-file.vue
@@ -4,15 +4,14 @@
label="Добавить файл (размер файла не должен превышать 2Мб)"
chips
multiple
- v-model="newFiles"
+ v-model="localNewFiles"
density="compact"
variant="outlined"
- @update:modelValue="handleFilesChange"
:error-messages="errorMessages"
+ @update:model-value="handleFilesChange"
>
-
-
+
@@ -71,11 +70,16 @@ export default {
emits: ['update:files', 'postFiles'],
setup(props, { emit }) {
- const newFiles = ref([]);
+ const localNewFiles = ref([]);
const errorMessages = ref([]);
const MAX_FILE_SIZE = 2 * 1024 * 1024; // 2 МБ
const MAX_NEW_FILES = 5;
+ // const newFiles = computed({
+ // get: () => props.newFiles,
+ // set: (value) => emit('update:newFiles', value),
+ // });
+
const formatFileSize = (bytes) => {
if (bytes === 0) return '0 Б';
const k = 1024;
@@ -87,8 +91,9 @@ export default {
const validateFiles = (files) => {
errorMessages.value = [];
+ const totalFiles = localNewFiles.value.length + files.length;
// Проверка количества
- if (files.length > MAX_NEW_FILES) {
+ if (totalFiles > MAX_NEW_FILES) {
errorMessages.value.push(`Можно добавить не более ${MAX_NEW_FILES} файлов`);
return false;
}
@@ -104,10 +109,15 @@ export default {
return true;
};
-
// Существующие файлы из event.files
const existingFiles = computed(() => (Array.isArray(props.files) ? props.files : []));
+ const getFileKey = (file, index) => {
+ return file instanceof File
+ ? `${file.name}-${file.size}-${file.lastModified}`
+ : file.id || index;
+ };
+
// Получаем имя файла из объекта файла
const getFileName = (fileData) => {
if (fileData instanceof File) {
@@ -165,18 +175,22 @@ export default {
// Обработка изменения новых файлов
const handleFilesChange = (files) => {
if (!files) {
- newFiles.value = [];
+ // localNewFiles.value = [];
emit('postFiles', []);
return;
}
- // Валидация
- if (!validateFiles(files)) {
+ const validFiles = files.filter((file) => file instanceof File);
+
+ if (validFiles.length === 0) {
return;
}
- errorMessages.value = [];
- // newFiles.value = [...files];
- emit('postFiles', files);
+ // Валидация
+ if (!validateFiles(validFiles)) {
+ return;
+ }
+
+ emit('postFiles', validFiles);
};
// Удаление существующего файла
@@ -185,7 +199,7 @@ export default {
// Создаем копию event и удаляем файл
const updatedFiles = props.files.filter((file) => file.id !== fileId);
// props.files = updatedFiles;
- emit('update:files', [...updatedFiles]);
+ emit('update:files', updatedFiles);
} catch (error) {
console.error('Ошибка при удалении файла:', error);
}
@@ -193,14 +207,12 @@ export default {
// Удаление нового файла (еще не загруженного)
const removeNewFile = (index) => {
- const updatedFiles = [...newFiles.value];
- updatedFiles.splice(index, 1);
- newFiles.value = updatedFiles;
- emit('postFiles', updatedFiles);
+ localNewFiles.value.splice(index, 1);
+ emit('postFiles', localNewFiles.value);
};
return {
- newFiles,
+ localNewFiles,
existingFiles,
handleFilesChange,
removeExistingFile,
@@ -210,6 +222,7 @@ export default {
formatFileSize,
errorMessages,
validateFiles,
+ getFileKey,
};
},
};
diff --git a/src/front/src/components/calendar_of_events/BigCalendar.vue b/src/front/src/components/calendar_of_events/BigCalendar.vue
index ce089347f..293097b39 100644
--- a/src/front/src/components/calendar_of_events/BigCalendar.vue
+++ b/src/front/src/components/calendar_of_events/BigCalendar.vue
@@ -6,15 +6,7 @@
-
+
-
@@ -48,6 +41,7 @@ export default {
const MyMonth = ref(selectdate.value.getMonth() + 1);
const calendarForMy = ref([]);
const eventFromCalendar = ref({});
+ const eventKey = ref(0);
const calendarStore = useCalendarStore();
const accountStore = useAccountStore();
@@ -112,6 +106,7 @@ export default {
const openEventDialog = (selectedEvent) => {
getEvent(selectedEvent.event.id);
+
calendarStore.openEventDialog();
};
@@ -122,6 +117,7 @@ export default {
const closeEventDialog = () => {
calendarStore.closeEventDialog();
+
eventFromCalendar.value = createEmptyEvent(); // Очищаем событие
};
@@ -133,6 +129,16 @@ export default {
}
};
+ watch(
+ () => calendarStore.showEventDialog,
+ (newValue) => {
+ if (!newValue) {
+ // Когда диалог закрывается (любым способом), очищаем данные
+ eventFromCalendar.value = createEmptyEvent();
+ }
+ },
+ );
+
return {
selectedDate,
getMonth,
@@ -149,6 +155,7 @@ export default {
closeEventDialog,
openEventDialog,
createEmptyEvent,
+ eventKey,
};
},
};
diff --git a/src/front/src/components/calendar_of_events/event-create.vue b/src/front/src/components/calendar_of_events/event-create.vue
index 1b903d4e5..f856285f7 100644
--- a/src/front/src/components/calendar_of_events/event-create.vue
+++ b/src/front/src/components/calendar_of_events/event-create.vue
@@ -145,12 +145,18 @@
-
+
Файлы
@@ -337,18 +343,9 @@ export default {
(newEvent) => {
if (!newEvent || !safeCalendars.value.length) return;
- const isNewEvent = !newEvent.event.id;
-
- if (isNewEvent) {
- // НОВОЕ СОБЫТИЕ - первый календарь из списка или календарь по умолчанию
- myCalendar.value = safeCalendars.value[0];
- } else {
- // РЕДАКТИРОВАНИЕ - календарь из события
- const eventCalendar = safeCalendars.value.find(
- (cal) => cal.id === newEvent.event.calendar,
- );
- myCalendar.value = eventCalendar || safeCalendars.value[0];
- }
+ // РЕДАКТИРОВАНИЕ - календарь из события
+ const eventCalendar = safeCalendars.value.find((cal) => cal.id === newEvent.event.calendar);
+ myCalendar.value = eventCalendar || safeCalendars.value[0];
},
{ immediate: true, deep: true },
);
@@ -446,13 +443,10 @@ export default {
emit('closeDialog');
};
- const files = ref([]);
+ const newFiles = ref([]);
- const postFiles = (newFiles) => {
- files.value = newFiles;
-
- const updatedFiles = [...propsEvent.value.event.files, ...newFiles];
- propsEvent.value.event.files = updatedFiles;
+ const postFiles = (updatedFiles) => {
+ newFiles.value = updatedFiles;
};
const returnIdParticant = (idPart) => {
@@ -491,11 +485,16 @@ export default {
let postEvent = new FormData();
postEvent.append('event', JSON.stringify({ ...propsEvent.value.event, files: [] }));
- if (propsEvent.value.event.files !== null) {
- files.value.forEach((e) => postEvent.append('files', e));
+ // if (propsEvent.value.event.files !== null) {
+ // files.value.forEach((e) => postEvent.append('files', e));
+ // }
+ if (newFiles.value.length > 0) {
+ newFiles.value.forEach((file) => {
+ postEvent.append('files', file);
+ });
}
- console.log(postEvent);
+ console.log('Отправляемые файлы:', newFiles.value);
axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent).then((result) => {
feedalert.alert = true;
diff --git a/src/front/src/store/calendarStore.js b/src/front/src/store/calendarStore.js
index 014919c49..8d8997a73 100644
--- a/src/front/src/store/calendarStore.js
+++ b/src/front/src/store/calendarStore.js
@@ -21,15 +21,6 @@ export const useCalendarStore = defineStore('calendarStore', () => {
// Getters
const formattedSelectedDate = computed(() => selectedDate.value.toISOString().split('T')[0]);
- // const myCalendars = computed(() =>
- // calendars.value
- // .filter((e) => e.author === accountStore.user.is_idEmployee)
- // .map((calendar) => ({
- // ...calendar,
- // // Видимый, если его нет в массиве скрытых
- // visible: !hiddenCalendarIds.value.includes(calendar.id),
- // })),
- // );
const myCalendars = computed(() => {
const userId = accountStore.user.is_idEmployee;