fix spaces
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
<!-- {{ tg_id }}-->
|
<!-- {{ tg_id }}-->
|
||||||
<Button label="Sub" :class="checkNotif ? 'flex' : '!hidden'" @click="checkSubscribe"/>
|
<Button label="Sub" :class="checkNotif ? 'flex' : '!hidden'" @click="checkSubscribe"/>
|
||||||
|
|
||||||
<!-- <router-view/>-->
|
<router-view/>
|
||||||
<div class="bg-gray-100 h-12 block lg:hidden"></div>
|
<div class="bg-gray-100 h-12 block lg:hidden"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import DatePicker from "primevue/datepicker";
|
|||||||
import {onMounted, ref} from "vue";
|
import {onMounted, ref} from "vue";
|
||||||
import {getMonthName} from "@/utils/utils";
|
import {getMonthName} from "@/utils/utils";
|
||||||
import {Budget} from "@/models/Budget";
|
import {Budget} from "@/models/Budget";
|
||||||
|
import {getCategories} from "@/services/categoryService";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
opened: {
|
opened: {
|
||||||
@@ -34,6 +35,10 @@ const create = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
const categories = ref([])
|
||||||
|
const fetchCategories = async () => {
|
||||||
|
await getCategories().then(res => categories.value = res.data)
|
||||||
|
}
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
emits("close-modal");
|
emits("close-modal");
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
getBudgetTransactions,
|
getBudgetTransactions,
|
||||||
updateBudgetCategoryRequest,
|
updateBudgetCategoryRequest,
|
||||||
getWarns,
|
getWarns,
|
||||||
hideWarnRequest
|
hideWarnRequest, getBudgetInfos
|
||||||
} from "@/services/budgetsService";
|
} from "@/services/budgetsService";
|
||||||
import {Budget, BudgetCategory, Warn} from "@/models/Budget";
|
import {Budget, BudgetCategory, Warn} from "@/models/Budget";
|
||||||
import {useRoute} from "vue-router";
|
import {useRoute} from "vue-router";
|
||||||
@@ -24,6 +24,7 @@ import Divider from "primevue/divider";
|
|||||||
import {useDrawerStore} from "@/stores/drawerStore";
|
import {useDrawerStore} from "@/stores/drawerStore";
|
||||||
import {EventBus} from '@/utils/EventBus.ts';
|
import {EventBus} from '@/utils/EventBus.ts';
|
||||||
import {useToast} from "primevue/usetoast";
|
import {useToast} from "primevue/usetoast";
|
||||||
|
import {useSpaceStore} from "@/stores/spaceStore";
|
||||||
|
|
||||||
// Зарегистрируем плагин
|
// Зарегистрируем плагин
|
||||||
ChartJS.register(ChartDataLabels);
|
ChartJS.register(ChartDataLabels);
|
||||||
@@ -719,17 +720,38 @@ watch([budget, plannedExpenses], () => {
|
|||||||
calendar.value = result;
|
calendar.value = result;
|
||||||
}, {immediate: true});
|
}, {immediate: true});
|
||||||
|
|
||||||
|
const spaceStore = useSpaceStore()
|
||||||
|
const selectedSpace = computed(() => spaceStore.space)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => selectedSpace.value,
|
||||||
|
async (newValue, oldValue) => {
|
||||||
|
|
||||||
|
if (newValue != oldValue || !oldValue) {
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
// Если выбранный space изменился, получаем новую информацию о бюджете
|
||||||
|
fetchBudgetInfo()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching budget infos:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
updateLoading.value = true;
|
updateLoading.value = true;
|
||||||
|
|
||||||
|
if (selectedSpace.value) {
|
||||||
fetchBudgetInfo()
|
fetchBudgetInfo()
|
||||||
fetchWarns()
|
fetchWarns()
|
||||||
|
}
|
||||||
EventBus.on('transactions-updated', fetchBudgetInfo, true);
|
EventBus.on('transactions-updated', fetchBudgetInfo, true);
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(async () => {
|
onUnmounted(async () => {
|
||||||
EventBus.off('transactions-updated', fetchBudgetInfo);
|
EventBus.off('transactions-updated', fetchBudgetInfo);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -185,10 +185,10 @@ const createTransaction = async (): Promise<void> => {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
|
||||||
// Фокусируем поле ввода суммы (при наличии)
|
// Фокусируем поле ввода суммы (при наличии)
|
||||||
const inputEl = amountInput.value.$el.querySelector('input') as HTMLInputElement | null;
|
// const inputEl = amountInput.value.$el.querySelector('input') as HTMLInputElement | null;
|
||||||
if (inputEl) {
|
// if (inputEl) {
|
||||||
inputEl.focus();
|
// inputEl.focus();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Вызываем событие создания транзакции и обновляем список транзакций
|
// Вызываем событие создания транзакции и обновляем список транзакций
|
||||||
emit('create-transaction', editedTransaction.value);
|
emit('create-transaction', editedTransaction.value);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import apiClient from '@/services/axiosSetup';
|
import apiClient from '@/services/axiosSetup';
|
||||||
import {Budget, BudgetCategory} from "@/models/Budget";
|
import {Budget, BudgetCategory} from "@/models/Budget";
|
||||||
import {format} from "date-fns";
|
import {format} from "date-fns";
|
||||||
|
import {useSpaceStore} from "@/stores/spaceStore";
|
||||||
// Импортируете настроенный экземпляр axios
|
// Импортируете настроенный экземпляр axios
|
||||||
|
|
||||||
export const getBudgetInfos = async () => {
|
export const getBudgetInfos = async () => {
|
||||||
@@ -62,8 +63,8 @@ export const getBudgetCategoriesSums = async (budgetId) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getBudgetInfo = async (budget_id: string) => {
|
export const getBudgetInfo = async (budget_id: string) => {
|
||||||
|
const spaceStore = useSpaceStore()
|
||||||
let budgetInfo = await apiClient.get('/budgets/' + budget_id);
|
let budgetInfo = await apiClient.get(`/spaces/${spaceStore.space?.id}/budgets/${budget_id}`);
|
||||||
budgetInfo = budgetInfo.data;
|
budgetInfo = budgetInfo.data;
|
||||||
|
|
||||||
budgetInfo.dateFrom = new Date(budgetInfo.dateFrom)
|
budgetInfo.dateFrom = new Date(budgetInfo.dateFrom)
|
||||||
@@ -87,7 +88,8 @@ export const hideWarnRequest = async (budgetId: string, warnId: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const updateBudgetCategoryRequest = async (budget_id, category: BudgetCategory) => {
|
export const updateBudgetCategoryRequest = async (budget_id, category: BudgetCategory) => {
|
||||||
return await apiClient.post('/budgets/' + budget_id + '/categories/' + category.category.id + "/limit", {"limit": category.currentLimit}).then(i => i.data);
|
const spaceStore = useSpaceStore()
|
||||||
|
return await apiClient.post(`/spaces/${spaceStore.space?.id}/budgets/${budget_id}/categories/${category.category.id}/limit`, {"limit": category.currentLimit}).then(i => i.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createBudget = async (budget: Budget, createRecurrent: Boolean) => {
|
export const createBudget = async (budget: Budget, createRecurrent: Boolean) => {
|
||||||
@@ -113,7 +115,8 @@ export const createBudget = async (budget: Budget, createRecurrent: Boolean) =>
|
|||||||
export const deleteBudgetRequest = async (budgetId: string) => {
|
export const deleteBudgetRequest = async (budgetId: string) => {
|
||||||
try {
|
try {
|
||||||
// throw Error("test")
|
// throw Error("test")
|
||||||
let response = await apiClient.delete(`/budgets/${budgetId}`);
|
const spaceStore = useSpaceStore()
|
||||||
|
let response = await apiClient.delete(`/spaces/${spaceStore.space?.id}/budgets/${budgetId}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user