comptes/src/components/box.vue

86 lines
1.5 KiB
Vue
Raw Normal View History

2018-11-30 17:36:30 +00:00
<template>
2018-11-30 21:07:08 +00:00
<b-card v-if="poste"
:bg-variant="poste.variant"
2018-11-30 17:36:30 +00:00
text-variant="white"
class="text-center">
2018-11-30 21:07:08 +00:00
<div class="card-text">
<div class="icon">
<font-awesome-icon :icon="poste.icon" class="fa-3x"/>
</div>
<div class="amount">
<h3>{{ total() }}</h3>
{{ poste.name }}
</div>
</div>
2018-11-30 17:36:30 +00:00
</b-card>
</template>
<script>
import { mapGetters } from 'vuex'
2018-12-03 10:53:01 +00:00
import { total } from '../libs/data_processing'
2018-11-30 17:36:30 +00:00
export default {
name: 'box',
props: [
'postename',
'rows'
],
data () {
return {
2018-12-03 09:41:57 +00:00
default_poste: {
name: 'Tout',
variant: 'info',
icon: 'file-invoice-dollar'
}
2018-11-30 17:36:30 +00:00
}
},
computed: {
...mapGetters('config', [
'postes'
]),
2018-12-01 13:49:02 +00:00
...mapGetters('datas', [
2018-12-03 09:41:57 +00:00
'tag_filter_rows'
2018-12-01 13:49:02 +00:00
]),
2018-11-30 17:36:30 +00:00
poste () {
2018-12-03 09:41:57 +00:00
if (this.postename) {
return this.postes[this.postename]
} else {
return this.default_poste
}
2018-11-30 17:36:30 +00:00
}
},
methods: {
filter_rows () {
2018-12-03 09:41:57 +00:00
if (this.poste === this.default_poste) {
return this.tag_filter_rows([])
} else {
return this.tag_filter_rows([this.poste.name])
}
2018-11-30 17:36:30 +00:00
},
total () {
2018-12-03 10:53:01 +00:00
return total(this.filter_rows())
2018-11-30 17:36:30 +00:00
},
count () {
}
2018-12-01 14:03:38 +00:00
}
2018-11-30 17:36:30 +00:00
}
</script>
<style scoped>
2018-11-30 21:07:08 +00:00
.card-body {
padding: 10px;
}
.card-text {
display: flex;
}
.icon {
flex: 40%;
2018-12-01 13:49:02 +00:00
align-self: center;
2018-11-30 21:07:08 +00:00
}
.amount {
flex: 50%;
text-align: right;
margin-left: 10px;
}
2018-11-30 17:36:30 +00:00
</style>