tags and new analytics new in budget

This commit is contained in:
xds
2025-02-23 23:44:00 +03:00
parent 85b6d0a796
commit 512e720d19
5 changed files with 59 additions and 76 deletions

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import Dialog from "primevue/dialog";
import Checkbox from "primevue/checkbox";
import Button from "primevue/button";
import InputText from "primevue/inputtext";
@@ -10,7 +10,7 @@ import {getMonthName} from "@/utils/utils";
import {Budget} from "@/models/Budget";
import {getCategories} from "@/services/categoryService";
import {useSpaceStore} from "@/stores/spaceStore";
import {createBudget, getBudgetInfos} from "@/services/budgetsService";
import {createBudget} from "@/services/budgetsService";
const props = defineProps({
opened: {
@@ -19,7 +19,7 @@ const props = defineProps({
}
})
const emits = defineEmits(['budget-created', 'close-modal'])
const createRecurrentPayments = ref<Boolean>(false)
const createRecurrentPayments = ref<Boolean>(true)
const name = ref('')
const dateFrom = ref(new Date())
@@ -30,10 +30,9 @@ const budget = ref(new Budget())
const create = async () => {
try {
await createBudget(budget.value, createRecurrentPayments)
.then((res) => {
budget.value = res
})
await createBudget(budget.value)
.then((res) => budget.value = res)
.catch((err) => console.log(err));
emits("budget-created", budget.value, createRecurrentPayments.value);
} catch (e) {
console.error(e)
@@ -41,22 +40,6 @@ const create = async () => {
}
}
const creationSuccessShow = async (budget, createRecurrentPayments) => {
try {
await createBudget(budget, createRecurrentPayments)
budgetInfos.value = await getBudgetInfos()
toast.add({severity: 'success', summary: 'Успешно!', detail: 'Бюджет создан!', life: 3000});
creationOpened.value = false
} catch (error) {
console.log(error.response.data["message"])
toast.add({severity: "error", summary: "Бюджет не создан", detail: error.response.data["message"], life: 3000});
}
// creationSuccessModal.value = true
// setTimeout(() => {
// creationSuccessModal.value = false
// }
// , 1000)
}
const categories = ref([])
const fetchCategories = async () => {
await getCategories().then(res => categories.value = res.data)
@@ -111,34 +94,39 @@ onMounted(() => {
fetchCategories()
}
})
</script>
<template>
<div class="flex flex-col gap-4 mt-1">
<FloatLabel variant="on" class="w-full">
<label for="name">Название</label>
<InputText v-model="budget.name" id="name" class="w-full"/>
</FloatLabel>
<div class="flex flex-row gap-4">
<FloatLabel variant="on">
<label for="dateFrom">Дата начала</label>
<DatePicker v-model="budget.dateFrom" id="dateFrom" dateFormat="dd.mm.yy"/>
</FloatLabel>
<FloatLabel variant="on">
<label for="dateTo">Дата завершения</label>
<DatePicker v-model="budget.dateTo" id="dateTo" dateFormat="dd.mm.yy"/>
<Dialog :visible="opened" modal header="Создать новый бюджет" :style="{ width: '25rem' }" @hide="cancel"
@update:visible="cancel">
<div class="flex flex-col gap-4 mt-1">
<FloatLabel variant="on" class="w-full">
<label for="name">Название</label>
<InputText v-model="budget.name" id="name" class="w-full"/>
</FloatLabel>
<div class="flex flex-row gap-4">
<FloatLabel variant="on">
<label for="dateFrom">Дата начала</label>
<DatePicker v-model="budget.dateFrom" id="dateFrom" dateFormat="dd.mm.yy"/>
</FloatLabel>
<FloatLabel variant="on">
<label for="dateTo">Дата завершения</label>
<DatePicker v-model="budget.dateTo" id="dateTo" dateFormat="dd.mm.yy"/>
</FloatLabel>
</div>
<!-- <div class="flex flex-row items-center min-w-fit gap-4">-->
<!-- <Checkbox v-model="createRecurrentPayments" binary/>-->
<!-- Создать ежемесячные платежи?-->
<!-- </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">
<Button label="Создать" severity="success" icon="pi pi-save" @click="create"/>
<Button label="Отмена" severity="secondary" icon="pi pi-times-circle" @click="cancel"/>
</div>
</div>
<!-- <div class="flex flex-row items-center min-w-fit gap-4">-->
<!-- <Checkbox v-model="createRecurrentPayments" binary/>-->
<!-- Создать ежемесячные платежи?-->
<!-- </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">
<Button label="Создать" severity="success" icon="pi pi-save" @click="create"/>
<Button label="Отмена" severity="secondary" icon="pi pi-times-circle" @click="cancel"/>
</div>
</div>
</Dialog>
</template>
<style scoped>