tags and new analytics new in budget
This commit is contained in:
@@ -30,7 +30,7 @@ const budget = ref(new Budget())
|
|||||||
const create = async () => {
|
const create = async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await createBudget(budget.value)
|
await createBudget(budget.value, createRecurrentPayments.value)
|
||||||
.then((res) => budget.value = res)
|
.then((res) => budget.value = res)
|
||||||
.catch((err) => console.log(err));
|
.catch((err) => console.log(err));
|
||||||
emits("budget-created", budget.value, createRecurrentPayments.value);
|
emits("budget-created", budget.value, createRecurrentPayments.value);
|
||||||
@@ -115,10 +115,10 @@ onMounted(() => {
|
|||||||
<DatePicker v-model="budget.dateTo" id="dateTo" dateFormat="dd.mm.yy"/>
|
<DatePicker v-model="budget.dateTo" id="dateTo" dateFormat="dd.mm.yy"/>
|
||||||
</FloatLabel>
|
</FloatLabel>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="flex flex-row items-center min-w-fit gap-4">-->
|
<div class="flex flex-row items-center min-w-fit gap-4">
|
||||||
<!-- <Checkbox v-model="createRecurrentPayments" binary/>-->
|
<Checkbox v-model="createRecurrentPayments" binary/>
|
||||||
<!-- Создать ежемесячные платежи?-->
|
Создать ежемесячные платежи?
|
||||||
<!-- </div>-->
|
</div>
|
||||||
<div v-if="categories.length ==0" class="text-red-500 font-bold">Сперва лучше создать категории</div>
|
<div v-if="categories.length ==0" class="text-red-500 font-bold">Сперва лучше создать категории</div>
|
||||||
<div class="flex flex-row gap-2 justify-end items-center">
|
<div class="flex flex-row gap-2 justify-end items-center">
|
||||||
<Button label="Создать" severity="success" icon="pi pi-save" @click="create"/>
|
<Button label="Создать" severity="success" icon="pi pi-save" @click="create"/>
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ import {Transaction} from "@/models/Transaction";
|
|||||||
import ProgressSpinner from "primevue/progressspinner";
|
import ProgressSpinner from "primevue/progressspinner";
|
||||||
import {getUsers} from "@/services/userService";
|
import {getUsers} from "@/services/userService";
|
||||||
import Button from "primevue/button";
|
import Button from "primevue/button";
|
||||||
import { EventBus } from '@/utils/EventBus.ts';
|
import {EventBus} from '@/utils/EventBus.ts';
|
||||||
import {useSpaceStore} from "@/stores/spaceStore";
|
import {useSpaceStore} from "@/stores/spaceStore";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
|
import {useDrawerStore} from "@/stores/drawerStore";
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const searchText = ref("");
|
const searchText = ref("");
|
||||||
@@ -21,6 +22,8 @@ const limit = 20; // Количество транзакций на одну з
|
|||||||
const offset = ref(0); // Начальное смещение
|
const offset = ref(0); // Начальное смещение
|
||||||
const allLoaded = ref(false); // Флаг для отслеживания окончания данных
|
const allLoaded = ref(false); // Флаг для отслеживания окончания данных
|
||||||
|
|
||||||
|
const drawerStore = useDrawerStore()
|
||||||
|
|
||||||
// Функция для получения транзакций с параметрами limit и offset
|
// Функция для получения транзакций с параметрами limit и offset
|
||||||
const fetchTransactions = async (reload) => {
|
const fetchTransactions = async (reload) => {
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ const fetchTransactions = async (reload) => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await getTransactions( 'INSTANT', null, null, selectedUserId.value ? selectedUserId.value : null, null, reload ? offset.value : limit, reload ? 0 : offset.value);
|
const response = await getTransactions('INSTANT', null, null, selectedUserId.value ? selectedUserId.value : null, null, reload ? offset.value : limit, reload ? 0 : offset.value);
|
||||||
const newTransactions = response.data;
|
const newTransactions = response.data;
|
||||||
|
|
||||||
// Проверка на конец данных
|
// Проверка на конец данных
|
||||||
@@ -39,7 +42,7 @@ const fetchTransactions = async (reload) => {
|
|||||||
// Добавляем новые транзакции к текущему списку
|
// Добавляем новые транзакции к текущему списку
|
||||||
|
|
||||||
reload ? transactions.value = newTransactions : transactions.value.push(...newTransactions)
|
reload ? transactions.value = newTransactions : transactions.value.push(...newTransactions)
|
||||||
!reload ? offset.value += limit : offset.value
|
!reload ? offset.value += limit : offset.value
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching transactions:", error);
|
console.error("Error fetching transactions:", error);
|
||||||
}
|
}
|
||||||
@@ -62,7 +65,6 @@ const switchUserFilter = async (user) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const tgname = computed(() => {
|
const tgname = computed(() => {
|
||||||
if (window.Telegram.WebApp) {
|
if (window.Telegram.WebApp) {
|
||||||
const tg = window.Telegram.WebApp;
|
const tg = window.Telegram.WebApp;
|
||||||
@@ -109,38 +111,47 @@ const fetchUsers = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const selectedTransactionType = ref(null)
|
const selectedTransactionType = ref(null)
|
||||||
const spaceStore = useSpaceStore()
|
const spaceStore = useSpaceStore()
|
||||||
const selectedSpace = computed(() => spaceStore.space)
|
const selectedSpace = computed(() => spaceStore.space)
|
||||||
|
|
||||||
watch( selectedSpace, async (newValue, oldValue) => {
|
watch(selectedSpace, async (newValue, oldValue) => {
|
||||||
if (newValue != oldValue) {
|
if (newValue != oldValue) {
|
||||||
await fetchTransactions(false)
|
await fetchTransactions(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const types = ref([])
|
const types = ref([])
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
EventBus.on('transactions-updated', fetchTransactions,true);
|
EventBus.on('transactions-updated', fetchTransactions, true);
|
||||||
if (selectedSpace.value){
|
if (selectedSpace.value) {
|
||||||
await fetchTransactions(false); // Первоначальная загрузка данных
|
await fetchTransactions(false); // Первоначальная загрузка данных
|
||||||
|
|
||||||
}
|
}
|
||||||
// await fetchUsers();
|
// await fetchUsers();
|
||||||
await getTransactionTypes().then( it => types.value = it.data);
|
await getTransactionTypes().then(it => types.value = it.data);
|
||||||
// window.addEventListener("scroll", handleScroll); // Добавляем обработчик прокрутки
|
// window.addEventListener("scroll", handleScroll); // Добавляем обработчик прокрутки
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted( async () => {
|
onUnmounted(async () => {
|
||||||
EventBus.off('transactions-updated', fetchTransactions);
|
EventBus.off('transactions-updated', fetchTransactions);
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="px-4 bg-gray-100 h-full">
|
<div class="flex flex-col gap-4 p-4 bg-gray-100 h-full ">
|
||||||
<h2 class="text-4xl mb-6 font-bold">Список транзакций </h2>
|
<div class="flex flex-row gap-4 items-center">
|
||||||
|
<h2 class="text-4xl font-bold">Список транзакций </h2>
|
||||||
|
<Button label="+ Создать" @click="{
|
||||||
|
drawerStore.setCategoryType('EXPENSE');
|
||||||
|
drawerStore.setTransactionType('INSTANT');
|
||||||
|
drawerStore.visible = true
|
||||||
|
}" size="small"/>
|
||||||
|
</div>
|
||||||
<div v-if="!selectedSpace" class="flex w-full h-full items-center justify-center">
|
<div v-if="!selectedSpace" class="flex w-full h-full items-center justify-center">
|
||||||
<p>Сперва нужно выбрать Пространство.
|
<p>Сперва нужно выбрать Пространство.
|
||||||
<button class="text-blue-500 hover:underline" @click="router.push('/spaces').then((res) => router.go(0))">Перейти</button>
|
<button class="text-blue-500 hover:underline" @click="router.push('/spaces').then((res) => router.go(0))">
|
||||||
|
Перейти
|
||||||
|
</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="flex flex-col gap-2">
|
<div v-else class="flex flex-col gap-2">
|
||||||
@@ -158,9 +169,9 @@ onUnmounted( async () => {
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
||||||
<!-- <button v-for="type in types" class="rounded-xl border p-1 bg-white border-gray-300 mb-2 min-w-fit px-2">-->
|
<!-- <button v-for="type in types" class="rounded-xl border p-1 bg-white border-gray-300 mb-2 min-w-fit px-2">-->
|
||||||
<!-- <p><span class="text-sm font-bold">{{ type.name }}</span></p>-->
|
<!-- <p><span class="text-sm font-bold">{{ type.name }}</span></p>-->
|
||||||
<!-- </button>-->
|
<!-- </button>-->
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user