feat(expense): import expense

This commit is contained in:
2021-11-30 01:46:30 +01:00
parent b0aa4ad301
commit 566e75f99a
5 changed files with 4041 additions and 47 deletions

View File

@@ -6,7 +6,7 @@
<div>
<div class="expense-button-div float-left">
<b-button variant="success">Ajouter une dépense</b-button>
<b-button variant="info">Importer des dépenses</b-button>
<b-button variant="info" v-on:click="showImportExpenses">Importer des dépenses</b-button>
</div>
<div class="float-right">
<b-button variant="light">Partager le compte</b-button></div>
@@ -15,12 +15,35 @@
</b-tab>
</b-tabs>
</b-card>
<b-modal ref="import-expense" size="lg" centered title="">
<template #modal-header="{ }">
</template>
<template #default="{ }">
<!-- Styled -->
<b-form-file
v-model="file"
:state="Boolean(file1)"
placeholder="Choose a file or drop it here..."
drop-placeholder="Drop file here..."
></b-form-file>
</template>
<template #modal-footer="{ ok, cancel }">
<b-button size="sm" variant="success" @click="validateFormImportExpenses()">
Importer
</b-button>
<b-button size="sm" variant="danger" @click="cancel()">
Fermer
</b-button>
</template>
</b-modal>
</div>
</template>
<script>
import {BCard, BTabs , BTab, BTable} from "bootstrap-vue";
import {getAnAccount, getExpenses} from "@/config/noscomptes";
import {BCard, BTabs , BTab, BTable, BFormFile} from "bootstrap-vue";
import {getAnAccount, getExpenses, sendCSVImportExpenses} from "@/config/noscomptes";
export default {
name: 'account',
data: function () {
@@ -43,6 +66,7 @@ export default {
},
],
file: undefined,
account: {},
expenses : [{
expenseDate: "Today",
@@ -57,9 +81,7 @@ export default {
this.account = data
})
getExpenses(loggedUser.oauth_token, loggedUser.nosComptesId, this.$route.params.accountId).then(data => {
if (data.lenght > 0) {
this.expenses = data
}
})
},
mounted () {
@@ -71,6 +93,13 @@ export default {
this.account = data
})
},
showImportExpenses() {
this.$refs['import-expense'].show()
},
validateFormImportExpenses() {
let loggedUser = this.$store.state.loggedUser
sendCSVImportExpenses(loggedUser.oauth_token, loggedUser.nosComptesId, this.$route.params.accountId, this.file)
}
},
@@ -78,7 +107,8 @@ export default {
BCard,
BTabs,
BTab,
BTable
BTable,
BFormFile
}
}
</script>