Feat: Select poste on clicking

This commit is contained in:
2018-11-30 22:07:08 +01:00
parent e7d792e7ef
commit df4c1af893
4 changed files with 65 additions and 29 deletions

View File

@@ -13,10 +13,10 @@
</b-container>
<b-card-group deck class="mb-3">
<box postename="total" :rows="filter_rows"></box>
<box postename="cash" :rows="filter_rows"></box>
<box postename="CB" :rows="filter_rows"></box>
<box postename="other" :rows="filter_rows"></box>
<box @click.native="set_poste('total')" postename="total" :rows="date_rows"></box>
<box @click.native="set_poste('cash')" postename="cash" :rows="date_rows"></box>
<box @click.native="set_poste('CB')" postename="CB" :rows="date_rows"></box>
<box @click.native="set_poste('other')" postename="other" :rows="date_rows"></box>
</b-card-group>
<b-table striped hover :items="filter_rows" :fields='fields'></b-table>
@@ -54,6 +54,7 @@ export default {
}
],
spending: true,
poste: {},
start: monthAgo.toISOString().split('T')[0],
end: today.toISOString().split('T')[0]
}
@@ -68,20 +69,19 @@ export default {
'rows': 'datas/rows',
'postes': 'config/postes'
}),
filter_rows () {
date_rows () {
return this.filter_date(this.filter_spending(this.rows))
}
},
filter_rows () {
return this.filter_poste(this.date_rows)
},
},
methods: {
table_date_format (date) {
return date
},
filter_spending (rows) {
if (this.spending) {
return rows.filter(x => x.Montant < 0)
} else {
return rows
}
return rows.filter(x => x.Montant < 0)
},
filter_date (rows) {
var start = new Date(this.start)
@@ -89,6 +89,28 @@ export default {
return rows.filter(x => {
return (new Date(x.Date) >= start) & (new Date(x.Date) < end)
})
},
filter_poste (rows) {
if (this.poste.words) {
if (this.poste.invert) {
return rows.filter(x => {
return this.poste.words.every(v => {
return x.Libellé.indexOf(v) < 0
})
})
} else {
return rows.filter(x => {
return this.poste.words.some(v => {
return x.Libellé.indexOf(v) >= 0
})
})
}
} else {
return rows
}
},
set_poste (postename) {
this.poste = this.postes[postename]
}
}
}