comptes/src/views/home.vue

128 lines
3.0 KiB
Vue
Raw 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">
<b-container fluid>
<b-row class="date-selector">
2019-01-24 10:50:27 +00:00
<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 14:15:23 +00:00
<b-card-group deck class="mb-3">
<box @click.native="set_tags_filter([])"></box>
<box @click.native="set_tags_filter(['cash'])" tagname="cash"></box>
<box @click.native="set_tags_filter(['cb'])" tagname="cb"></box>
<box @click.native="set_tags_filter(['virements'])" tagname="virements"></box>
</b-card-group>
2018-11-30 17:36:30 +00:00
<tags-comparison></tags-comparison>
<b-table striped hover :items="filtered_rows" :fields='fields'>
<template slot="tags" slot-scope="data">
<div v-for="tag in data.item.tags" :key="tag.name">
<div v-if="tag.name !== 'Tout'">
<font-awesome-icon :icon="tag.icon" class="fa"/>
</div>
</div>
</template>
</b-table>
2018-12-03 11:09:28 +00:00
</div>
<div v-else>
<div class="nodata">
<h1>
2018-12-03 11:09:28 +00:00
<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'
2018-11-30 17:36:30 +00:00
import box from '../components/box'
2018-12-03 11:00:41 +00:00
import tagsComparison from '../components/tags_comparison'
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: {
box: box,
2018-12-03 11:00:41 +00:00
tagsComparison: tagsComparison
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'
},
2018-12-03 11:00:41 +00:00
tags_filter: []
2018-11-30 10:53:50 +00:00
}
},
computed: {
...mapGetters({
'csvs': 'datas/csvs',
2018-12-03 09:41:57 +00:00
'tag_filter_rows': 'datas/tag_filter_rows',
'datas_present': 'datas/present',
2019-01-24 10:50:27 +00:00
'month': 'datas/month',
2018-12-03 11:00:41 +00:00
'tags': 'config/tags'
2018-12-03 09:41:57 +00:00
}),
filtered_rows () {
2018-12-03 11:00:41 +00:00
return this.tag_filter_rows(this.tags_filter)
2019-01-24 10:50:27 +00:00
},
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
]),
2018-12-03 11:00:41 +00:00
set_tags_filter (tagnames) {
this.tags_filter = tagnames
2019-01-21 11:33:24 +00:00
},
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>