ver 2
This commit is contained in:
@@ -6,9 +6,10 @@ import {computed, onMounted, PropType, ref} from "vue";
|
||||
import {Transaction} from "@/models/Transaction";
|
||||
import {Category, CategoryType} from "@/models/Category";
|
||||
import {getCategories, getCategoryTypes} from "@/services/categoryService";
|
||||
import {setTransactionDoneRequest} from "@/services/transactionService";
|
||||
import { updateTransactionRequest} from "@/services/transactionService";
|
||||
import {formatAmount, formatDate} from "@/utils/utils";
|
||||
import TransactionForm from "@/components/transactions/TransactionForm.vue";
|
||||
import {useToast} from "primevue/usetoast";
|
||||
|
||||
|
||||
const props = defineProps(
|
||||
@@ -30,31 +31,44 @@ const props = defineProps(
|
||||
const emits = defineEmits(['open-drawer', 'transaction-checked', 'transaction-updated', 'delete-transaction'])
|
||||
|
||||
|
||||
|
||||
const setIsDoneTrue = async () => {
|
||||
setTimeout(async () => {
|
||||
await setTransactionDoneRequest(props.transaction)
|
||||
emits('transaction-checked')
|
||||
}, 10);
|
||||
console.log("here")
|
||||
await updateTransactionRequest(props.transaction)
|
||||
emits('transaction-updated')
|
||||
}, 20);
|
||||
// showedTransaction.value.isDone = !showedTransaction.value.isDone;
|
||||
|
||||
|
||||
}
|
||||
|
||||
const toast = useToast();
|
||||
const drawerOpened = ref(false)
|
||||
const toggleDrawer = () => {
|
||||
if (drawerOpened.value) {
|
||||
drawerOpened.value = false;
|
||||
if (props.transaction?.parentId) {
|
||||
toast.add({
|
||||
severity: 'warn',
|
||||
summary: 'Транзакцию нельзя изменить!',
|
||||
detail: 'Транзакции созданные из плана не могут быть изменены.',
|
||||
life: 3000
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
if (drawerOpened.value) {
|
||||
drawerOpened.value = false;
|
||||
}
|
||||
drawerOpened.value = !drawerOpened.value
|
||||
emits('open-drawer', props.transaction)
|
||||
}
|
||||
drawerOpened.value = !drawerOpened.value
|
||||
emits('open-drawer', props.transaction)
|
||||
}
|
||||
|
||||
const transactionUpdate = () => {
|
||||
console.log("transaction updated")
|
||||
emits('transaction-updated')
|
||||
}
|
||||
|
||||
const isPlanned = computed(() => {
|
||||
return props.transaction?.transactionType.code === "PLANNED"
|
||||
return props.transaction?.type.code === "PLANNED"
|
||||
})
|
||||
|
||||
|
||||
@@ -94,6 +108,8 @@ const closeDrawer = () => {
|
||||
onMounted(async () => {
|
||||
// await fetchCategories();
|
||||
// await fetchCategoryTypes()
|
||||
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
@@ -104,12 +120,15 @@ onMounted(async () => {
|
||||
"
|
||||
class="flex bg-white min-w-fit max-h-fit flex-row items-center gap-4 w-full ">
|
||||
<div>
|
||||
<p v-if="transaction.transactionType.code=='INSTANT' || props.isList"
|
||||
<p v-if="transaction.type.code=='INSTANT' || props.isList"
|
||||
class="text-6xl font-bold text-gray-700 dark:text-gray-400">
|
||||
{{ transaction.category.icon }}</p>
|
||||
<Checkbox v-model="transaction.isDone" v-else-if="transaction.transactionType.code=='PLANNED' && !props.isList"
|
||||
{{ transaction.category.icon }}
|
||||
</p>
|
||||
|
||||
<Checkbox v-model="transaction.isDone" v-else-if="transaction.type.code=='PLANNED' && !props.isList"
|
||||
:binary="true"
|
||||
@click="setIsDoneTrue"/>
|
||||
|
||||
</div>
|
||||
<button class="flex flex-row items-center p-x-4 justify-between w-full " @click="toggleDrawer">
|
||||
|
||||
@@ -138,7 +157,7 @@ onMounted(async () => {
|
||||
|
||||
|
||||
<TransactionForm v-if="drawerOpened" :visible="drawerOpened" :transaction="transaction"
|
||||
@close-drawer="closeDrawer" @transaction-updated="transactionUpdate"
|
||||
@close-drawer="closeDrawer" @transaction-updated="transactionUpdate"
|
||||
@delete-transaction="transactionUpdate"
|
||||
@create-transaction="transactionUpdate"/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user