style [P-302]: корректная подсветка выходных и праздников в светлой и тёмной темах
This commit is contained in:
1 parent
45768f1921
commit
d9defd0528
6 files changed
+211
-293
No files matched your search
@@ -35,7 +35,6 @@
|
||||
|
||||
<script>
|
||||
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';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
@@ -48,7 +47,6 @@ import EventCalendarShow from '@/components/calendar_of_events/event-calendar-sh
|
||||
export default {
|
||||
components: { EventCreate, MiniCalendar, CustomCalendar, EventCalendarShow },
|
||||
setup() {
|
||||
const week = useWeekendsStore();
|
||||
const selectdate = ref(new Date());
|
||||
const MyYear = ref(selectdate.value.getFullYear());
|
||||
const MyMonth = ref(selectdate.value.getMonth() + 1);
|
||||
@@ -127,7 +125,7 @@ export default {
|
||||
|
||||
onMounted(() => {
|
||||
getEvent();
|
||||
week.getWeekend(MyYear.value);
|
||||
calendarStore.fetchHolidays(MyYear.value);
|
||||
getDictEmployee();
|
||||
getCalendar();
|
||||
getEmployees();
|
||||
@@ -143,15 +141,7 @@ export default {
|
||||
}, 200);
|
||||
};
|
||||
|
||||
const CheckingStore = () => {
|
||||
if (MyYear.value in week.week) {
|
||||
weekendsData();
|
||||
} else {
|
||||
week.getWeekend(MyYear.value);
|
||||
}
|
||||
};
|
||||
|
||||
const openCalendarCreate = () => {
|
||||
const openCalendarCreate = () => {
|
||||
miniCalendarRef.value?.openCalendarCreate();
|
||||
};
|
||||
|
||||
@@ -212,8 +202,6 @@ export default {
|
||||
selectedDate,
|
||||
getMonth,
|
||||
getYear,
|
||||
week,
|
||||
CheckingStore,
|
||||
showEventDialog,
|
||||
calendarForMy,
|
||||
getCalendar,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<v-row no-gutters class="mb-2 align-end" style="height: 60px" justify="space-between">
|
||||
<v-col md="5" class="flex-grow-0 d-flex align-center">
|
||||
<template v-if="currentView !== 'listAllEvents'">
|
||||
<div class="pb-3 d-flex align-center">
|
||||
<div class="pb-1 d-flex align-center">
|
||||
<v-btn
|
||||
variant="outlined"
|
||||
class="text-subtitle-2 mr-2"
|
||||
@@ -38,7 +38,7 @@
|
||||
<v-icon size="large">mdi-chevron-right</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<span class="text-h5 text-no-wrap ml-2">
|
||||
<span class="text-h6 text-no-wrap ml-2">
|
||||
{{ currentTitle }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -62,12 +62,12 @@
|
||||
variant="plain"
|
||||
density="comfortable"
|
||||
>
|
||||
<v-btn value="timeGridDay">День</v-btn>
|
||||
<v-btn value="timeGridWeek">Неделя</v-btn>
|
||||
<v-btn value="dayGridMonth">Месяц</v-btn>
|
||||
<v-btn value="multiMonthYear">Год</v-btn>
|
||||
<v-btn value="listWeek">Расписание</v-btn>
|
||||
<v-btn value="listAllEvents">Все события</v-btn>
|
||||
<v-btn value="timeGridDay" class="px-2">День</v-btn>
|
||||
<v-btn value="timeGridWeek" class="px-2">Неделя</v-btn>
|
||||
<v-btn value="dayGridMonth" class="px-2">Месяц</v-btn>
|
||||
<v-btn value="multiMonthYear" class="px-2">Год</v-btn>
|
||||
<v-btn value="listWeek" class="px-2">Расписание</v-btn>
|
||||
<v-btn value="listAllEvents" class="px-2">Все события</v-btn>
|
||||
</v-btn-toggle>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -113,6 +113,12 @@ export default {
|
||||
EventsListView,
|
||||
EventListFilters,
|
||||
},
|
||||
|
||||
props: {
|
||||
forHomePage: { type: Boolean, default: false },
|
||||
view: { type: String, default: 'dayGridMonth' },
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
const currentView = ref('dayGridMonth');
|
||||
const currentTitle = ref('Календарь');
|
||||
@@ -175,19 +181,21 @@ export default {
|
||||
selectable: true,
|
||||
unselectAuto: false,
|
||||
selectMirror: false,
|
||||
|
||||
dayCellDidMount: (arg) => {
|
||||
const date = arg.date;
|
||||
const dayInfo = calendarStore.isNonWorkingDay(date);
|
||||
|
||||
if (dayInfo.isHoliday === true) {
|
||||
arg.el.classList.add('non-working-day');
|
||||
}
|
||||
|
||||
if (dayInfo.isWeekendForStyling === true) {
|
||||
arg.el.classList.add('grey-background');
|
||||
}
|
||||
dayCellClassNames: (arg) => {
|
||||
const dayInfo = calendarStore.isNonWorkingDay(arg.date);
|
||||
const classes = [];
|
||||
if (dayInfo.isHoliday) classes.push('non-working-day');
|
||||
if (dayInfo.isWeekendForStyling) classes.push('grey-background');
|
||||
return classes;
|
||||
},
|
||||
dayHeaderClassNames: (arg) => {
|
||||
const dayInfo = calendarStore.isNonWorkingDay(arg.date);
|
||||
const classes = [];
|
||||
if (dayInfo.isHoliday) classes.push('non-working-day');
|
||||
if (dayInfo.isWeekendForStyling) classes.push('grey-background');
|
||||
return classes;
|
||||
},
|
||||
|
||||
views: {
|
||||
timeGridDay: {
|
||||
type: 'timeGrid',
|
||||
@@ -312,7 +320,6 @@ export default {
|
||||
|
||||
successCallback(events);
|
||||
},
|
||||
selectable: true,
|
||||
eventClick: handleEventClick,
|
||||
|
||||
dateClick: (info) => {
|
||||
@@ -324,18 +331,8 @@ export default {
|
||||
|
||||
datesSet: (info) => {
|
||||
if (info.view.type === 'listWeek' && selectedDate.value) {
|
||||
const date = new Date(selectedDate.value);
|
||||
|
||||
const options = {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
};
|
||||
|
||||
const formattedDate = date.toLocaleDateString('ru-RU', options);
|
||||
currentTitle.value = `Расписание на ${formattedDate}`;
|
||||
} else {
|
||||
currentTitle.value = formatScheduleTitle(selectedDate.value);
|
||||
} else if (info.view.type !== 'listWeek') {
|
||||
currentTitle.value = info.view.title;
|
||||
}
|
||||
|
||||
@@ -395,39 +392,82 @@ export default {
|
||||
selectedDate.value = dateStr;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
const weekdayMap = {
|
||||
воскресенье: 'воскресенье',
|
||||
понедельник: 'понедельник',
|
||||
вторник: 'вторник',
|
||||
среда: 'среду',
|
||||
четверг: 'четверг',
|
||||
пятница: 'пятницу',
|
||||
суббота: 'субботу',
|
||||
};
|
||||
|
||||
const formatScheduleTitle = (dateValue) => {
|
||||
const date = new Date(dateValue);
|
||||
const weekdayRaw = date.toLocaleDateString('ru-RU', { weekday: 'long' });
|
||||
const weekday = weekdayMap[weekdayRaw] || weekdayRaw;
|
||||
const rest = date.toLocaleDateString('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
return `Расписание на ${weekday}, ${rest}`;
|
||||
};
|
||||
|
||||
const applyView = async (newView) => {
|
||||
if (newView === 'listAllEvents') {
|
||||
currentTitle.value = 'Все события';
|
||||
return;
|
||||
}
|
||||
if (newView === 'listWeek' && selectedDate.value) {
|
||||
currentTitle.value = formatScheduleTitle(selectedDate.value);
|
||||
}
|
||||
|
||||
await nextTick();
|
||||
if (!calendarApi.value) return;
|
||||
|
||||
calendarApi.value.changeView(newView);
|
||||
|
||||
if (newView !== 'listWeek') {
|
||||
currentTitle.value = calendarApi.value.view.title;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
const currentYear = new Date().getFullYear();
|
||||
calendarStore.fetchHolidays(currentYear);
|
||||
// Ждем следующего тика для гарантии, что календарь инициализирован
|
||||
await nextTick();
|
||||
|
||||
// Принудительно обновляем события после загрузки праздников
|
||||
if (calendarApi.value) {
|
||||
if (calendarApi.value && currentView.value !== 'listAllEvents') {
|
||||
calendarApi.value.refetchEvents();
|
||||
}
|
||||
|
||||
if (selectedDate.value) {
|
||||
if (selectedDate.value && currentView.value !== 'listAllEvents') {
|
||||
handleDateSelection(selectedDate.value);
|
||||
}
|
||||
});
|
||||
|
||||
watch(currentView, (newView) => {
|
||||
applyView(newView);
|
||||
});
|
||||
|
||||
watch(
|
||||
allEvents,
|
||||
() => {
|
||||
// При изменении событий перезагружаем календарь
|
||||
if (calendarApi.value) {
|
||||
calendarApi.value.refetchEvents();
|
||||
}
|
||||
if (currentView.value === 'listAllEvents') return;
|
||||
calendarApi.value?.refetchEvents();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
calendarColorMap,
|
||||
(newColorMap, oldColorMap) => {
|
||||
if (calendarRef.value && JSON.stringify(newColorMap) !== JSON.stringify(oldColorMap)) {
|
||||
renderEvents();
|
||||
}
|
||||
() => {
|
||||
if (currentView.value === 'listAllEvents') return;
|
||||
calendarApi.value?.refetchEvents();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
@@ -441,15 +481,6 @@ export default {
|
||||
}
|
||||
});
|
||||
|
||||
watch(currentView, (newView) => {
|
||||
if (newView === 'listAllEvents') {
|
||||
currentTitle.value = 'Все события';
|
||||
} else if (calendarApi.value) {
|
||||
calendarApi.value.changeView(newView);
|
||||
currentTitle.value = calendarApi.value.view.title;
|
||||
}
|
||||
});
|
||||
|
||||
const handleFiltersUpdate = (newFilters) => {
|
||||
Object.keys(newFilters).forEach((key) => {
|
||||
if (filters[key] !== undefined) {
|
||||
@@ -504,7 +535,7 @@ export default {
|
||||
:deep(.fc-day-today .fc-daygrid-day-number) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: #00897b;
|
||||
color: rgb(var(--v-theme-btn_text));
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
@@ -514,7 +545,7 @@ export default {
|
||||
transform: translate(-50%, -50%);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px solid #00897b;
|
||||
border: 1px solid rgb(var(--v-theme-btn_text));
|
||||
border-radius: 50%;
|
||||
z-index: -1;
|
||||
}
|
||||
@@ -529,7 +560,7 @@ export default {
|
||||
:deep(.fc-day-selected-custom .fc-daygrid-day-number) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: white !important;
|
||||
color: rgb(var(--v-theme-bg_white)) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day-selected-custom .fc-daygrid-day-number::before) {
|
||||
@@ -540,7 +571,7 @@ export default {
|
||||
transform: translate(-50%, -50%);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background-color: #00897b;
|
||||
background-color: rgb(var(--v-theme-btn_text));
|
||||
border-radius: 50%;
|
||||
z-index: -1;
|
||||
}
|
||||
@@ -555,11 +586,16 @@ export default {
|
||||
|
||||
:deep(.v-btn--active) {
|
||||
background-color: transparent !important;
|
||||
color: #00897b !important;
|
||||
color: rgb(var(--v-theme-btn_text)) !important;
|
||||
}
|
||||
|
||||
:deep(.fc .fc-timegrid-col.fc-day-today) {
|
||||
background-color: #e0f2f1 !important;
|
||||
background-color: rgba(var(--v-theme-btn_text), 0.1) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-timegrid-col.non-working-day),
|
||||
:deep(.fc-day.non-working-day:not(.fc-daygrid-day)) {
|
||||
background-color: rgba(var(--v-theme-holiday_text), 0.05) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-highlight) {
|
||||
@@ -571,27 +607,31 @@ export default {
|
||||
}
|
||||
|
||||
:deep(.fc-popover) {
|
||||
background-color: rgb(248, 244, 244) !important;
|
||||
background-color: rgb(var(--v-theme-cards)) !important;
|
||||
}
|
||||
|
||||
.non-working-day {
|
||||
color: red !important;
|
||||
:deep(.fc-day.non-working-day .fc-daygrid-day-number),
|
||||
:deep(.fc-day.non-working-day .fc-daygrid-day-top) {
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
}
|
||||
|
||||
:global(.fc-daygrid-day.non-working-day .fc-daygrid-day-number) {
|
||||
color: #d32f2f !important;
|
||||
}
|
||||
|
||||
:global(.fc-daygrid-day.grey-background.fc-daygrid-day-number) {
|
||||
background-color: rgb(196, 187, 187) !important;
|
||||
}
|
||||
|
||||
.grey-background {
|
||||
background-color: rgb(240, 229, 229) !important;
|
||||
:deep(.fc-col-header-cell.non-working-day),
|
||||
:deep(.fc-col-header-cell.non-working-day .fc-col-header-cell-cushion) {
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
}
|
||||
|
||||
:deep(.grey-background),
|
||||
:deep(.fc-day.grey-background) {
|
||||
background-color: #f5f5f5 !important;
|
||||
background-color: rgb(var(--v-theme-weekend_bg)) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day.grey-background .fc-daygrid-day-number) {
|
||||
color: rgb(var(--v-theme-weekend_text)) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-col-header-cell.grey-background),
|
||||
:deep(.fc-col-header-cell.grey-background .fc-col-header-cell-cushion) {
|
||||
color: rgb(var(--v-theme-weekend_text)) !important;
|
||||
}
|
||||
|
||||
.custom-calendar {
|
||||
|
||||
@@ -69,7 +69,6 @@
|
||||
:key="event.id"
|
||||
class="schedule-item"
|
||||
:class="{ 'current-event': isCurrentEvent(event) }"
|
||||
@click="handleEventClick(event)"
|
||||
>
|
||||
<template #prepend>
|
||||
<div
|
||||
@@ -349,10 +348,6 @@ export default {
|
||||
return dayInfo.isHoliday || dayInfo.isWeekendForStyling;
|
||||
};
|
||||
|
||||
const handleEventClick = (event) => {
|
||||
calendarStore.handleEventClick({ event: { id: event.id } });
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
selectedDate.value = formatToLocalDate(new Date());
|
||||
await calendarStore.fetchHolidays(currentYear);
|
||||
@@ -386,7 +381,6 @@ export default {
|
||||
allEvents,
|
||||
expandMultiDayInstance,
|
||||
formatForWidget,
|
||||
handleEventClick,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -461,6 +455,19 @@ export default {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.day-cell.today {
|
||||
background-color: rgba(var(--v-theme-primary), 0.15);
|
||||
}
|
||||
|
||||
.day-cell.selected {
|
||||
background-color: rgb(var(--v-theme-btn_text));
|
||||
color: rgb(var(--v-theme-bg_white));
|
||||
}
|
||||
|
||||
.day-cell.selected .day-number {
|
||||
color: rgb(var(--v-theme-bg_white));
|
||||
}
|
||||
|
||||
.day-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -540,6 +547,7 @@ export default {
|
||||
.event-time {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #302f2f;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
@@ -565,17 +573,17 @@ export default {
|
||||
}
|
||||
|
||||
.day-schedule::-webkit-scrollbar-track {
|
||||
background: rgba(var(--v-theme-on-surface), 0.05);
|
||||
background: #f1f1f1;
|
||||
border-radius: 0 8px 8px 0;
|
||||
}
|
||||
|
||||
.day-schedule::-webkit-scrollbar-thumb {
|
||||
background: rgba(var(--v-theme-on-surface), 0.25);
|
||||
background: #c1c1c1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.day-schedule::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(var(--v-theme-on-surface), 0.4);
|
||||
background: #a8a8a8;
|
||||
}
|
||||
|
||||
.non-working-day {
|
||||
@@ -590,15 +598,4 @@ export default {
|
||||
.day-cell:not(.current-month).non-working-day {
|
||||
color: inherit !important;
|
||||
}
|
||||
|
||||
.day-cell.selected,
|
||||
.day-cell.selected.grey-background,
|
||||
.day-cell.selected.non-working-day {
|
||||
background-color: rgb(var(--v-theme-btn_text)) !important;
|
||||
color: rgb(var(--v-theme-bg_white)) !important;
|
||||
}
|
||||
|
||||
.day-cell.selected .day-number {
|
||||
color: rgb(var(--v-theme-bg_white)) !important;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<v-card class="h-100 rounded-0 d-flex flex-colmn">
|
||||
<v-card class="h-100 rounded-0 d-flex flex-column">
|
||||
<v-row no-gutters class="flex-column">
|
||||
<v-col class="flex-grow-0 px-2 pt-1">
|
||||
<SearchEvents />
|
||||
@@ -56,7 +56,7 @@ import { useCalendarStore } from '@/store/calendarStore';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
|
||||
import SearchEvents from '@/components/calendar_of_events/UI_calendar/SearchEvents.vue';
|
||||
import { onMounted, watch, nextTick, ref } from 'vue';
|
||||
import { onMounted, watch, nextTick, ref, onBeforeUnmount } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
export default {
|
||||
@@ -67,14 +67,10 @@ export default {
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
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);
|
||||
let observer = null;
|
||||
|
||||
const handleDateClick = (date) => {
|
||||
calendarStore.setSelectedDateFromPicker(date);
|
||||
@@ -89,12 +85,6 @@ export default {
|
||||
calendarStore.loadCalendars();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadCalendars();
|
||||
|
||||
updateCalendarDays();
|
||||
});
|
||||
|
||||
// Реакция на изменения пользователя
|
||||
watch(user, (newUser) => {
|
||||
if (newUser) {
|
||||
@@ -192,25 +182,24 @@ export default {
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
// При смене месяца через кнопки навигации
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === 'childList') {
|
||||
updateCalendarDays();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
loadCalendars();
|
||||
updateCalendarDays();
|
||||
// Наблюдаем за изменениями в DOM date-picker
|
||||
const datePicker = document.querySelector('.minCal');
|
||||
if (datePicker) {
|
||||
observer = new MutationObserver(() => updateCalendarDays());
|
||||
observer.observe(datePicker, { childList: true, subtree: true });
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
observer?.disconnect();
|
||||
});
|
||||
|
||||
return {
|
||||
accountStore,
|
||||
calendarStore,
|
||||
user,
|
||||
myCalendars,
|
||||
subscribedCalendars,
|
||||
@@ -225,16 +214,7 @@ export default {
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
/* .minCal:deep(.v-date-picker-month__days) {
|
||||
display: grid !important;
|
||||
grid-template-columns: repeat(7, 40px) !important;
|
||||
gap: 3px !important;
|
||||
width: 250px !important;
|
||||
justify-content: center !important;
|
||||
margin: 0 auto !important;
|
||||
} */
|
||||
|
||||
.minCal .v-date-picker-monWth__day {
|
||||
.minCal .v-date-picker-month__day {
|
||||
height: 31px;
|
||||
width: 31px;
|
||||
}
|
||||
@@ -255,23 +235,24 @@ export default {
|
||||
/* СТИЛИ ДЛЯ ВЫХОДНЫХ И ПРАЗДНИКОВ */
|
||||
|
||||
.minCal:deep(.weekend-day .v-btn__content) {
|
||||
color: #666 !important;
|
||||
color: rgb(var(--v-theme-weekend_text)) !important;
|
||||
}
|
||||
|
||||
.minCal:deep(.holiday-day .v-btn__content) {
|
||||
color: #ff4444 !important;
|
||||
font-weight: bold !important;
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
.minCal:deep(.weekend-day.holiday-day) {
|
||||
background-color: #ffe0e0 !important;
|
||||
.minCal:deep(.weekend-day.holiday-day) .v-btn {
|
||||
background-color: rgba(var(--v-theme-holiday_text), 0.12) !important;
|
||||
}
|
||||
|
||||
.minCal:deep(.weekend-day.holiday-day .v-btn__content) {
|
||||
color: #cc0000 !important;
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
search-dropdown {
|
||||
.search-dropdown {
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
Executable → Regular
+19
-16
@@ -1,19 +1,16 @@
|
||||
import '@mdi/font/css/materialdesignicons.css'
|
||||
import 'vuetify/styles'
|
||||
// import { VCalendar } from 'vuetify/labs/VCalendar'
|
||||
|
||||
import { createVuetify } from 'vuetify'
|
||||
import { ru } from 'vuetify/locale'
|
||||
import '@mdi/font/css/materialdesignicons.css';
|
||||
import 'vuetify/styles';
|
||||
import { VCalendar } from 'vuetify/components';
|
||||
|
||||
import { createVuetify } from 'vuetify';
|
||||
import { ru } from 'vuetify/locale';
|
||||
|
||||
export default createVuetify({
|
||||
|
||||
locale: {
|
||||
messages: { ru, },
|
||||
messages: { ru },
|
||||
},
|
||||
components: {
|
||||
// VCalendar,
|
||||
|
||||
VCalendar,
|
||||
},
|
||||
theme: {
|
||||
defaultTheme: 'light',
|
||||
@@ -23,7 +20,7 @@ export default createVuetify({
|
||||
lampa: '#FFFFFF',
|
||||
primary: '#1867C0',
|
||||
secondary: '#5CBBF6',
|
||||
main_theme: "#f7f7f7",
|
||||
main_theme: '#f7f7f7',
|
||||
scrollbar: '#367F8A',
|
||||
cards: '#F5F5F5',
|
||||
text_grey: '#7A7A7A', //Цвет серого текста
|
||||
@@ -43,7 +40,10 @@ export default createVuetify({
|
||||
insert_table: '#FAFAFA',
|
||||
btn_text: '#00897B', // фигма, текст кнопки с иконкой
|
||||
select_list: '#E0EAE8',
|
||||
btn_gray: '#E0E0E0'
|
||||
btn_gray: '#E0E0E0',
|
||||
weekend_text: '#D32F2F', // красный для сб/вс
|
||||
holiday_text: '#B71C1C', // насыщеннее для праздников
|
||||
weekend_bg: '#FAFAFA', // лёгкий серый фон для выходных
|
||||
},
|
||||
},
|
||||
dark: {
|
||||
@@ -51,7 +51,7 @@ export default createVuetify({
|
||||
lampa: '#121212',
|
||||
primary: '#1E88E5',
|
||||
secondary: '#64B5F6',
|
||||
main_theme: "#121212",
|
||||
main_theme: '#121212',
|
||||
scrollbar: '#4DB6AC',
|
||||
cards: '#1E1E1E',
|
||||
text_grey: '#B0BEC5',
|
||||
@@ -76,12 +76,15 @@ export default createVuetify({
|
||||
background: '#121212',
|
||||
'on-background': '#FFFFFF',
|
||||
'on-surface': '#FFFFFF',
|
||||
'card-background': '#1E1E1E'
|
||||
'card-background': '#1E1E1E',
|
||||
weekend_text: '#EF5350',
|
||||
holiday_text: '#FF5252',
|
||||
weekend_bg: '#2A2A2A',
|
||||
},
|
||||
},
|
||||
options: {
|
||||
customProperties: true
|
||||
customProperties: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
});
|
||||
@@ -9,6 +9,8 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
// State
|
||||
const selectedDate = ref(new Date());
|
||||
const events = ref([]);
|
||||
const selectedEvent = ref(null);
|
||||
const showEventDialog = ref(false);
|
||||
const currentView = ref('dayGridMonth'); // Текущий вид календаря
|
||||
const calendars = ref([]); // Список календарей пользователя
|
||||
const lastUpdatedBy = ref(null);
|
||||
@@ -18,11 +20,6 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
const dictEmployeesLoaded = ref(false);
|
||||
const employees = ref([]);
|
||||
|
||||
const selectedEvent = ref(null);
|
||||
const showEventDialog = ref(false);
|
||||
const selectedEventForView = ref(null);
|
||||
const showViewDialog = ref(false);
|
||||
|
||||
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
||||
const hiddenCalendarIds = ref([]);
|
||||
|
||||
@@ -178,141 +175,60 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
return editableEvents.value.some((e) => e.id === id);
|
||||
};
|
||||
|
||||
const fetchHolidays = async (year) => {
|
||||
if (holidays.value[year] || loadingYears.value.has(year)) {
|
||||
return holidays.value[year];
|
||||
}
|
||||
loadingYears.value.add(year);
|
||||
try {
|
||||
const { data } = await axiosApiInstance.get(
|
||||
`api/calendar_of_events/exclusion_dates/?year=${year}`,
|
||||
);
|
||||
holidays.value = { ...holidays.value, ...data };
|
||||
return holidays.value[year];
|
||||
} catch (err) {
|
||||
console.error('Ошибка загрузки праздников:', err);
|
||||
throw err;
|
||||
} finally {
|
||||
loadingYears.value.delete(year);
|
||||
}
|
||||
};
|
||||
const fetchHolidays = async (year) => {
|
||||
if (holidays.value[year] || loadingYears.value.has(year)) {
|
||||
return holidays.value[year];
|
||||
}
|
||||
loadingYears.value.add(year);
|
||||
try {
|
||||
const { data } = await axiosApiInstance.get(
|
||||
`api/calendar_of_events/exclusion_dates/?year=${year}`,
|
||||
);
|
||||
holidays.value = { ...holidays.value, ...data };
|
||||
return holidays.value[year];
|
||||
} catch (err) {
|
||||
console.error('Ошибка загрузки праздников:', err);
|
||||
throw err;
|
||||
} finally {
|
||||
loadingYears.value.delete(year);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Метод для проверки, является ли день выходным или праздничным
|
||||
const isNonWorkingDay = (dateInput) => {
|
||||
const date = dateInput instanceof Date ? dateInput : new Date(dateInput);
|
||||
if (isNaN(date.getTime())) {
|
||||
return { isNonWorking: false, isWeekendForStyling: false, isHoliday: false };
|
||||
}
|
||||
const isNonWorkingDay = (dateInput) => {
|
||||
const date = dateInput instanceof Date ? dateInput : new Date(dateInput);
|
||||
if (isNaN(date.getTime())) {
|
||||
return { isNonWorking: false, isWeekendForStyling: false, isHoliday: false };
|
||||
}
|
||||
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;
|
||||
const iso = `${year}-${String(month).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;
|
||||
const iso = `${year}-${String(month).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
|
||||
const day = date.getDay();
|
||||
const isWeekend = day === 0 || day === 6;
|
||||
const isHoliday = (holidays.value[year]?.[month] ?? []).includes(iso);
|
||||
const day = date.getDay();
|
||||
const isWeekend = day === 0 || day === 6;
|
||||
const isHoliday = (holidays.value[year]?.[month] ?? []).includes(iso);
|
||||
|
||||
return {
|
||||
isNonWorking: isWeekend || isHoliday,
|
||||
isWeekendForStyling: isWeekend,
|
||||
isHoliday,
|
||||
};
|
||||
};
|
||||
|
||||
const setSelectedEvent = (event) => {
|
||||
selectedEvent.value = event;
|
||||
};
|
||||
|
||||
// Шаблон пустого события (создание)
|
||||
const getEmptyEventWrapper = () => {
|
||||
const now = new Date();
|
||||
const inHour = new Date(now.getTime() + 60 * 60 * 1000);
|
||||
return {
|
||||
event: {
|
||||
name: '',
|
||||
description: '',
|
||||
date_start: now.toISOString(),
|
||||
date_end: inHour.toISOString(),
|
||||
allday: false,
|
||||
period: null,
|
||||
participant: [accountStore.user.is_idEmployee],
|
||||
calendar: null,
|
||||
files: [],
|
||||
},
|
||||
mycalendars: calendars.value,
|
||||
};
|
||||
};
|
||||
|
||||
// Шаблон обёртки для редактирования
|
||||
const buildEventWrapper = (fullEvent) => {
|
||||
return {
|
||||
event: {
|
||||
...fullEvent,
|
||||
participant: Array.isArray(fullEvent.participant)
|
||||
? fullEvent.participant.map((p) => (typeof p === 'object' ? p.id : p))
|
||||
: [],
|
||||
},
|
||||
mycalendars: calendars.value,
|
||||
};
|
||||
return {
|
||||
isNonWorking: isWeekend || isHoliday,
|
||||
isWeekendForStyling: isWeekend,
|
||||
isHoliday,
|
||||
};
|
||||
};
|
||||
|
||||
// Открыть диалог создания/редактирования
|
||||
const openEventDialog = async (eventOrInfo = null) => {
|
||||
if (eventOrInfo === null) {
|
||||
selectedEvent.value = getEmptyEventWrapper();
|
||||
showEventDialog.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const id = eventOrInfo?.event?.id ?? eventOrInfo?.id;
|
||||
if (!id) {
|
||||
selectedEvent.value = getEmptyEventWrapper();
|
||||
showEventDialog.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const { data } = await axiosApiInstance.get(`api/calendar_of_events/my_events/?id=${id}`);
|
||||
selectedEvent.value = data;
|
||||
showEventDialog.value = true;
|
||||
} catch (error) {
|
||||
console.error('Ошибка загрузки события:', error);
|
||||
}
|
||||
const openEventDialog = (event = null) => {
|
||||
selectedEvent.value = event;
|
||||
showEventDialog.value = true;
|
||||
};
|
||||
|
||||
// Закрыть диалог
|
||||
const closeEventDialog = () => {
|
||||
showEventDialog.value = false;
|
||||
selectedEvent.value = null;
|
||||
};
|
||||
|
||||
const openEventView = async (eventId) => {
|
||||
if (!eventId) return;
|
||||
|
||||
try {
|
||||
const { data } = await axiosApiInstance.get(
|
||||
`api/calendar_of_events/my_events/?id=${eventId}`,
|
||||
);
|
||||
selectedEventForView.value = data;
|
||||
showViewDialog.value = true;
|
||||
} catch (error) {
|
||||
console.error('Ошибка загрузки события:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const closeEventView = () => {
|
||||
showViewDialog.value = false;
|
||||
selectedEventForView.value = null;
|
||||
};
|
||||
|
||||
const handleEventClick = (info) => {
|
||||
const id = info.event?.id ?? info.id;
|
||||
if (canEditEvent(id)) {
|
||||
openEventDialog(info);
|
||||
} else {
|
||||
openEventView(id);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
// State
|
||||
selectedDate,
|
||||
@@ -346,9 +262,6 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
loadCalendars,
|
||||
openEventDialog,
|
||||
closeEventDialog,
|
||||
openEventView,
|
||||
closeEventView,
|
||||
handleEventClick,
|
||||
setSelectedDateFromCalendar,
|
||||
setSelectedDateFromPicker,
|
||||
toggleCalendarVisibility,
|
||||
@@ -356,9 +269,5 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
isNonWorkingDay,
|
||||
loadDictEmployees,
|
||||
loadEmployees,
|
||||
setSelectedEvent,
|
||||
|
||||
getEmptyEventWrapper,
|
||||
buildEventWrapper,
|
||||
};
|
||||
});
|
||||
Reference in new issue
Block a user