comptes/src/views/home.vue

156 lines
4.2 KiB
Vue
Raw Permalink Normal View History

2018-11-30 07:42:04 +00:00
<template>
<div class="import">
<h1>Analyse</h1>
<div class="analysis" v-if="datas_present">
<h2> Sur le temps </h2>
<graph-time></graph-time>
2018-11-30 14:15:23 +00:00
<h2> Par mois</h2>
<b-container fluid>
<b-row class="date-selector">
<b-button @click="prev_month" variant="link">
<font-awesome-icon icon="angle-left" class="fa" />
</b-button>
<span class="text-muted btn" disabled="true">
{{ month.format('MMMM YYYY') }}
</span>
<b-button @click="next_month" variant="link">
<font-awesome-icon icon="angle-right" class="fa" />
</b-button>
</b-row>
</b-container>
2018-11-30 17:36:30 +00:00
<b-card-group deck class="mb-3">
<div v-for="categorie in categories">
<card-categorie @click.native="set_categories_filter([categorie.name])" :categoriename="categorie.name"></card-categorie>
</div>
</b-card-group>
<tags-comparison></tags-comparison>
<b-table striped hover :items="filtered_rows" :fields='fields'>
<template slot="tags" slot-scope="data">
<div v-if="data.item.tags.length > 0">
<div v-for="tag in data.item.tags" :key="tag.name">
<font-awesome-icon :icon="tag.icon" class="fa"/>
</div>
</div>
<div v-else>
<b-btn v-b-modal="data.item.Libellé">
<font-awesome-icon icon="plus" class="fa"/>
</b-btn>
<!-- Modal Component -->
<b-modal :id="data.item.Libellé"
title="Tag pour le mot clé"
hide-footer
>
<associate-tag-keyword
:libelle="data.item.Libellé">
</associate-tag-keyword>
</b-modal>
</div>
</template>
</b-table>
2018-12-03 11:09:28 +00:00
</div>
<div v-else>
<div class="nodata">
<h1>
<font-awesome-icon icon="dizzy" class="fa"/>
Pas de données
<font-awesome-icon icon="dizzy" class="fa"/>
</h1>
<p>
Penser à en importer!
</p>
</div>
2018-12-03 11:09:28 +00:00
</div>
2018-11-30 07:42:04 +00:00
</div>
</template>
2018-11-30 10:53:50 +00:00
<script>
2018-12-01 13:49:02 +00:00
import { mapGetters, mapActions } from 'vuex'
import cardCategorie from '../components/card_categorie'
import tagsComparison from '../components/graph_tags_comparison'
import graphTime from '../components/graph_time'
import associateTagKeyword from '../components/associate_tag_keyword'
2019-01-21 11:33:24 +00:00
import moment from 'moment'
2018-11-30 10:53:50 +00:00
2019-01-24 10:50:27 +00:00
moment.locale('fr')
2018-11-30 10:53:50 +00:00
export default {
name: 'home',
2018-11-30 10:53:50 +00:00
components: {
cardCategorie: cardCategorie,
tagsComparison: tagsComparison,
graphTime: graphTime,
associateTagKeyword: associateTagKeyword
2018-11-30 10:53:50 +00:00
},
data () {
return {
2018-11-30 14:15:23 +00:00
fields: [
{
key: 'Date',
sortable: true,
2018-12-03 13:38:03 +00:00
formatter: d => d.format('DD/MM/YYYY')
2018-11-30 14:15:23 +00:00
},
{
key: 'Montant',
sortable: true
},
{
key: 'Libellé',
sortable: true
},
{
2018-12-03 11:09:28 +00:00
key: 'tags'
2018-11-30 14:15:23 +00:00
}
],
2018-12-03 11:00:41 +00:00
default_tag: {
2018-12-03 09:41:57 +00:00
name: 'Tout',
variant: 'info',
icon: 'file-invoice-dollar'
},
categories_filter: [],
keyword: ''
2018-11-30 10:53:50 +00:00
}
},
computed: {
...mapGetters({
'csvs': 'datas/csvs',
'categorie_filter_rows': 'datas/categorie_filter_rows',
'datas_present': 'datas/present',
2019-01-24 10:50:27 +00:00
'month': 'datas/month',
2021-06-10 19:56:51 +00:00
'months': 'datas/months',
'tags': 'config/tags',
'categories': 'config/categories'
2018-12-03 09:41:57 +00:00
}),
filtered_rows () {
return this.categorie_filter_rows(this.categories_filter)
}
2018-11-30 10:53:50 +00:00
},
methods: {
2018-12-01 13:49:02 +00:00
...mapActions('datas', [
2019-01-24 10:50:27 +00:00
'next_month',
'prev_month'
2018-12-01 13:49:02 +00:00
]),
set_categories_filter (categorienames) {
this.categories_filter = categorienames
},
showModal (name) {
console.log(name)
}
2018-11-30 10:53:50 +00:00
}
}
</script>
2018-11-30 14:15:23 +00:00
<style scoped>
.date-selector {
padding: 1rem;
}
.nodata{
text-align: center;
2018-11-30 14:15:23 +00:00
}
</style>