calendar fixs

This commit is contained in:
xds
2025-02-13 17:36:55 +03:00
parent 1534fedfb4
commit a530d657d3
2 changed files with 24 additions and 7 deletions

View File

@@ -28,6 +28,7 @@ import TransactionForm from "@/components/transactions/TransactionForm.vue";
import Checkbox from "primevue/checkbox"; import Checkbox from "primevue/checkbox";
import {useDrawerStore} from "@/stores/drawerStore"; import {useDrawerStore} from "@/stores/drawerStore";
import {EventBus} from '@/utils/EventBus.ts'; import {EventBus} from '@/utils/EventBus.ts';
import {useUserStore} from "@/stores/userStore";
// Зарегистрируем плагин // Зарегистрируем плагин
ChartJS.register(ChartDataLabels); ChartJS.register(ChartDataLabels);
@@ -624,7 +625,21 @@ const expandCats = (value: boolean) => {
} }
} }
}; };
const calendarExpanded = ref(false);
const calendarOpened = ref(localStorage.getItem('budgetCalendarOpened') === "1");
// Используем computed для получения значения
const calendarExpanded = computed(() => calendarOpened.value);
// Функция для переключения состояния
const toggleCalendar = () => {
// Переключаем состояние
calendarOpened.value = !calendarOpened.value;
// Сохраняем в localStorage
localStorage.setItem('budgetCalendarOpened', calendarOpened.value ? "1" : "0");
};
const calendar = ref<{ date: Date, dateStr: string, expenses: any[], expensesSum: number }[]>([]); const calendar = ref<{ date: Date, dateStr: string, expenses: any[], expensesSum: number }[]>([]);
watch([budget, plannedExpenses], () => { watch([budget, plannedExpenses], () => {
@@ -1016,12 +1031,14 @@ onUnmounted(async () => {
</div> </div>
<div class="flex flex-col gap-4 pb-4"> <div class="flex flex-col gap-4 pb-4">
<div class="flex flex-row gap-2"><span class="text-lg font-bold items-center">Календарь</span> <div class="flex flex-row gap-2"><span class="text-lg font-bold items-center">Календарь</span>
<button class="font-light text-sm" @click="calendarExpanded = !calendarExpanded"> <button class="font-light text-sm" @click="toggleCalendar">
{{ calendarExpanded ? 'Скрыть' : 'Раскрыть' }} {{ calendarExpanded ? 'Скрыть' : 'Раскрыть' }}
</button> </button>
</div> </div>
<div v-for="day, dayOne in calendar" class="flex flex-col justify-between p-4 shadow-lg rounded-lg " v-if="calendarExpanded" <div v-for="day, dayOne in calendar" class="flex flex-col justify-between p-4 shadow-lg rounded-lg "
v-if="calendarExpanded == '1'"
:class="day.date.toISOString().split('T')[0] == new Date().toISOString().split('T')[0]? 'bg-emerald-200' : 'bg-white '"> :class="day.date.toISOString().split('T')[0] == new Date().toISOString().split('T')[0]? 'bg-emerald-200' : 'bg-white '">
<div class="flex flex-row gap-2 items-center "> <div class="flex flex-row gap-2 items-center ">
<span class="font-bold text-xl">{{ day.dateStr }} </span> <span class="font-bold text-xl">{{ day.dateStr }} </span>

View File

@@ -8,7 +8,7 @@ export const useUserStore = defineStore('user', () => {
const loadingUser = ref(true); const loadingUser = ref(true);
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const settings = ref({"budgetViewVersion": "2"}) const settings = ref({"budgetViewVersion": "2", "budgetCalendarOpened": false})
async function fetchUserProfile() { async function fetchUserProfile() {
// Убираем проверку на `loadingUser`, чтобы не блокировать запрос // Убираем проверку на `loadingUser`, чтобы не блокировать запрос