style [P-302]: корректная подсветка выходных и праздников в светлой и тёмной темах
This commit is contained in:
1 parent
8caff79cdb
commit
f268b7bad4
8 files changed
+225
-255
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(
|
||||
[() => calendarStore.calendars, () => calendarStore.hiddenCalendarIds],
|
||||
() => {
|
||||
// При изменении событий перезагружаем календарь
|
||||
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 {
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
'current-month': day.isCurrentMonth,
|
||||
today: isToday(day.date),
|
||||
selected: isSelected(day.date),
|
||||
'non-working-day': calendarStore.isNonWorkingDay(day.date).isHoliday,
|
||||
'grey-background': calendarStore.isNonWorkingDay(day.date).isWeekendForStyling,
|
||||
'non-working-day': day.isHoliday,
|
||||
'grey-background': day.isWeekend,
|
||||
}"
|
||||
@click="onDateClick(day.date)"
|
||||
>
|
||||
@@ -228,9 +228,7 @@ export default {
|
||||
const calendarWeeks = computed(() => {
|
||||
const year = currentDate.value.getFullYear();
|
||||
const month = currentDate.value.getMonth();
|
||||
|
||||
const firstDay = new Date(year, month, 1);
|
||||
const lastDay = new Date(year, month + 1, 0);
|
||||
|
||||
const weeks = [];
|
||||
let week = [];
|
||||
@@ -244,10 +242,14 @@ export default {
|
||||
const currentDay = new Date(startDay);
|
||||
currentDay.setDate(startDay.getDate() + i);
|
||||
|
||||
const dayInfo = calendarStore.isNonWorkingDay(currentDay);
|
||||
|
||||
week.push({
|
||||
day: currentDay.getDate(),
|
||||
date: formatToLocalDate(currentDay),
|
||||
isCurrentMonth: currentDay.getMonth() === month,
|
||||
isHoliday: dayInfo.isHoliday,
|
||||
isWeekend: dayInfo.isWeekendForStyling,
|
||||
});
|
||||
|
||||
if (week.length === 7) {
|
||||
@@ -348,17 +350,9 @@ export default {
|
||||
|
||||
onMounted(async () => {
|
||||
selectedDate.value = formatToLocalDate(new Date());
|
||||
calendarStore.fetchHolidays(currentYear);
|
||||
await calendarStore.fetchHolidays(currentYear);
|
||||
});
|
||||
|
||||
watch(
|
||||
calendarColorMap,
|
||||
(newMap) => {
|
||||
newMap.value;
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
return {
|
||||
// Реактивные данные
|
||||
currentDate,
|
||||
@@ -395,7 +389,6 @@ export default {
|
||||
<style scoped>
|
||||
.home-calendar-widget {
|
||||
width: 100%;
|
||||
/* width: 700px; */
|
||||
height: 100%;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
@@ -416,7 +409,7 @@ export default {
|
||||
.month-title {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
@@ -433,10 +426,10 @@ export default {
|
||||
.weekday-header {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
padding: 8px 4px;
|
||||
border-bottom: 1px solid #afadad;
|
||||
color: rgb(var(--v-theme-text_grey));
|
||||
border-bottom: 1px solid rgb(var(--v-theme-btn_gray));
|
||||
}
|
||||
|
||||
.day-cell {
|
||||
@@ -450,28 +443,29 @@ export default {
|
||||
}
|
||||
|
||||
.day-cell:hover {
|
||||
background-color: #f5f5f5;
|
||||
background-color: rgba(var(--v-theme-on-surface), 0.04);
|
||||
}
|
||||
|
||||
.day-cell.current-month {
|
||||
color: #333;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
}
|
||||
|
||||
.day-cell:not(.current-month) {
|
||||
color: #ccc;
|
||||
color: rgb(var(--v-theme-text_grey));
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.day-cell.today {
|
||||
background-color: #e3f2fd;
|
||||
background-color: rgba(var(--v-theme-primary), 0.15);
|
||||
}
|
||||
|
||||
.day-cell.selected {
|
||||
background-color: #00897b;
|
||||
color: white;
|
||||
background-color: rgb(var(--v-theme-btn_text));
|
||||
color: rgb(var(--v-theme-bg_white));
|
||||
}
|
||||
|
||||
.day-cell.selected .day-number {
|
||||
color: white;
|
||||
color: rgb(var(--v-theme-bg_white));
|
||||
}
|
||||
|
||||
.day-content {
|
||||
@@ -524,13 +518,13 @@ export default {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
color: #333;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
}
|
||||
|
||||
.day-schedule {
|
||||
height: 90%;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #e0e0e0;
|
||||
border: 1px solid rgb(var(--v-theme-btn_gray));
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
@@ -538,7 +532,7 @@ export default {
|
||||
min-height: 48px;
|
||||
padding: 8px 12px;
|
||||
border-left: 4px solid transparent;
|
||||
border-bottom: 1px solid #d3cecede;
|
||||
border-bottom: 1px solid rgb(var(--v-theme-btn_gray));
|
||||
}
|
||||
|
||||
.schedule-item:last-child {
|
||||
@@ -546,14 +540,15 @@ export default {
|
||||
}
|
||||
|
||||
.schedule-item.current-event {
|
||||
border-left-color: #2196f3;
|
||||
background-color: #f8f9fa;
|
||||
border-left-color: rgb(var(--v-theme-primary));
|
||||
background-color: rgba(var(--v-theme-primary), 0.05);
|
||||
}
|
||||
|
||||
.event-time {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #302f2f;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
@@ -562,7 +557,7 @@ export default {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #1b1b1b;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
}
|
||||
|
||||
.no-events {
|
||||
@@ -592,14 +587,15 @@ export default {
|
||||
}
|
||||
|
||||
.non-working-day {
|
||||
color: red !important;
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
}
|
||||
|
||||
.grey-background {
|
||||
background-color: rgb(243, 243, 243) !important;
|
||||
background-color: rgb(var(--v-theme-weekend_bg)) !important;
|
||||
color: rgb(var(--v-theme-weekend_text)) !important;
|
||||
}
|
||||
|
||||
.day-cell:not(.current-month).non-working-day {
|
||||
/* color: inherit !important; */
|
||||
color: inherit !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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
|
||||
|
||||
<div>
|
||||
<v-btn @click="f_feedbackdata"> ical</v-btn>
|
||||
|
||||
@@ -23,13 +23,11 @@ import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { ref, onMounted } from "vue";
|
||||
|
||||
import ical from "ical.js";
|
||||
import { useWeekendsStore } from '@/store/WeekendsStore'
|
||||
|
||||
// const burl = baseURL.slice(0, -1);
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const week= useWeekendsStore()
|
||||
const drawer_right = ref(false);
|
||||
const cal = ref(null)
|
||||
const participant = ref("");
|
||||
@@ -42,15 +40,15 @@ export default {
|
||||
|
||||
|
||||
onMounted(()=>{
|
||||
|
||||
|
||||
cal.value.$el.querySelectorAll(".v-date-picker-month__day").forEach((e)=>{
|
||||
if (hol.includes(e.getAttribute("data-v-date"))) {
|
||||
e.querySelectorAll("span").forEach(n=>{n.classList.add("text-red")})
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
function f_feedbackdata() {
|
||||
@@ -59,7 +57,7 @@ export default {
|
||||
participants: participant.value,
|
||||
calendar: calendar.value,
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
const handleFilesUpload = (event) => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
},
|
||||
theme: {
|
||||
defaultTheme: 'light',
|
||||
@@ -23,13 +20,13 @@ export default createVuetify({
|
||||
lampa: '#FFFFFF',
|
||||
primary: '#1867C0',
|
||||
secondary: '#5CBBF6',
|
||||
main_theme: "#f7f7f7",
|
||||
main_theme: '#f7f7f7',
|
||||
scrollbar: '#367F8A',
|
||||
cards: '#F5F5F5',
|
||||
text_grey: '#7A7A7A', //Цвет серого текста
|
||||
text_carous: '#242424',
|
||||
navigation: '#004D40', // Цвет текста и иконок в левом навигационном меню
|
||||
black_grey: '#3C3C3C', // Цвет для карусели с цифрами в работе
|
||||
black_grey: '#3C3C3C', // Цвет для карусели с цифрами в работе
|
||||
modal_btn: '#1E88E5', // Цвет для кнопок в модальных окнах
|
||||
grey: '#7A7A7A', // Цвет иконки для отображения количества посещений
|
||||
yellow: '#F9A825', // Цвет для звездочек в обратной связи
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
export const useWeekendsStore = defineStore("weekends", () => {
|
||||
|
||||
const week = ref({});
|
||||
|
||||
function getWeekend(year) {
|
||||
axiosApiInstance
|
||||
.get(`api/calendar_of_events/exclusion_dates/?year=${year}`, {})
|
||||
.then((data) => {
|
||||
week.value = data.data;
|
||||
});
|
||||
}
|
||||
return { week, getWeekend };
|
||||
});
|
||||
@@ -14,7 +14,8 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
const currentView = ref('dayGridMonth'); // Текущий вид календаря
|
||||
const calendars = ref([]); // Список календарей пользователя
|
||||
const lastUpdatedBy = ref(null);
|
||||
const holidays = ref([]);
|
||||
const holidays = ref({});
|
||||
const loadingYears = ref(new Set());
|
||||
const dictEmployees = ref([]);
|
||||
const dictEmployeesLoaded = ref(false);
|
||||
const employees = ref([]);
|
||||
@@ -43,7 +44,6 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
const subscribedCalendars = computed(() => {
|
||||
const userId = accountStore.user.is_idEmployee;
|
||||
|
||||
@@ -175,66 +175,47 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
return editableEvents.value.some((e) => e.id === id);
|
||||
};
|
||||
|
||||
const fetchHolidays = async (year) => {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(
|
||||
`api/calendar_of_events/exclusion_dates/?year=${year}`,
|
||||
);
|
||||
holidays.value = response.data;
|
||||
return holidays.value;
|
||||
} catch (err) {
|
||||
console.error('Ошибка загрузки праздников:', err);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
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) => {
|
||||
let date;
|
||||
const isNonWorkingDay = (dateInput) => {
|
||||
const date = dateInput instanceof Date ? dateInput : new Date(dateInput);
|
||||
if (isNaN(date.getTime())) {
|
||||
return { isNonWorking: false, isWeekendForStyling: false, isHoliday: false };
|
||||
}
|
||||
|
||||
// Если входные данные — это строка в формате 'YYYY-MM-DD'
|
||||
if (typeof dateInput === 'string') {
|
||||
date = new Date(dateInput);
|
||||
}
|
||||
// Если входные данные — это объект Date
|
||||
else if (dateInput instanceof Date) {
|
||||
date = new Date(dateInput);
|
||||
}
|
||||
// Если входные данные некорректны
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;
|
||||
const iso = `${year}-${String(month).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
|
||||
// Проверяем, что дата корректна
|
||||
if (isNaN(date.getTime())) {
|
||||
return false;
|
||||
}
|
||||
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 year = date.getFullYear();
|
||||
const month = date.getMonth() + 1; // Месяцы в JS начинаются с 0
|
||||
const dayOfMonth = date.getDate();
|
||||
|
||||
const normalizedCurrentDate = `${year}-${String(month).padStart(2, '0')}-${String(dayOfMonth).padStart(2, '0')}`;
|
||||
// Проверяем, что данные о праздничных днях существуют для текущего года и месяца
|
||||
const holidaysForYear = holidays.value[year] || {};
|
||||
const holidaysForMonth = holidaysForYear[month] || [];
|
||||
|
||||
// Проверка на исключение (рабочая суббота или праздничный будний день)
|
||||
const isExceptionDay = holidaysForMonth.includes(normalizedCurrentDate);
|
||||
|
||||
const result = {
|
||||
isNonWorking: (isWeekend && !isExceptionDay) || (!isWeekend && isExceptionDay),
|
||||
isWeekendForStyling: isWeekend && !isExceptionDay,
|
||||
isHoliday: !isWeekend && isExceptionDay,
|
||||
};
|
||||
return result;
|
||||
return {
|
||||
isNonWorking: isWeekend || isHoliday,
|
||||
isWeekendForStyling: isWeekend,
|
||||
isHoliday,
|
||||
};
|
||||
};
|
||||
|
||||
// Открыть диалог создания/редактирования
|
||||
const openEventDialog = (event = null) => {
|
||||
|
||||
Reference in new issue
Block a user