i want to create a line with total from each group of items in a list like this:
So i did this to group by Car:
if (val == 2) {
this.dadosResumo.sort((a, b) => (a.carro > b.carro ? 1 : -1))
and i'm using v-data-table
to render the itens from dadosResumo.
but idk how to create a line in each group with the totals.
the list:
[
carro: '11016', number: '1', quantity: '4', total: '2'},
carro: '11016', number: '2', quantity: '3', total: '4'},
carro: '1122', number: '2', quantity: '4', total: '5'},
carro: '1122', number: '1', quantity: '1', total: '4'},
carro: '1133', number: '1', quantity: '2', total: '3'},
]
i tried to create an map to add line with if but not worked.
EDITED
i was thinking and the best way that i saw is to put the Subtotal inside the list, like this, because i use the list to create an pdf, anyway to create an map to add the subtotal inside? the list should be:
[
{carro: '11016', number: '1', quantity: '4', total: '2'},
{carro: '11016', number: '2', quantity: '3', total: '4'},
**{carro: 'Subtotal', number: '', quantity: '7', total: '6'},**
{carro: '1122', number: '2', quantity: '4', total: '5'},
{carro: '1122', number: '1', quantity: '1', total: '4'},
**{carro: 'Subtotal', number: '', quantity: '5', total: '9'},**
{carro: '1133', number: '1', quantity: '2', total: '3'},
**{carro: 'Subtotal', number: '', quantity: '2', total: '3},**
]