Good morning, gentlemen, I have the following array of objects:
[{
key:"-Kw05MQXBFh8uUxDml-v",
datainicio:"2017-10-09",
dataprevisao:"2017-10-13",
descricao:"teste",
etapa:"A testar",
numero:"56789",
qteDias: 4
},
{
key:"-Kw05iv443JpB9EstNxs",
datainicio:"2017-10-04",
dataprevisao:"2017-10-11",
descricao:"teste",
etapa:"Em desenvolvimento",
numero:"56874",
qteDias: 7
}]
I would like to add another position in the two objects, and it would be porcentagem
calculating the forecast date for today, example I have 4 days to deliver a project and already two days passed then the percentage would be 50% ..
Here's how I'd like to base it with today's date 10/9/2017:
[{
key:"-Kw05MQXBFh8uUxDml-v",
datainicio:"2017-10-09",
dataprevisao:"2017-10-13",
descricao:"teste",
etapa:"A testar",
numero:"56789",
qteDias: 4,
porcentagem: 0.00
},
{
key:"-Kw05iv443JpB9EstNxs",
datainicio:"2017-10-04",
dataprevisao:"2017-10-11",
descricao:"teste",
etapa:"Em desenvolvimento",
numero:"56874",
qteDias: 7,
porcentagem: 71.00
}]
So basically I want to calculate the percentage of days running based on the fields in the calendar and the forecast date and add a new field in the object.
Note: I'm using vues and I'm trying to put this list in computed, the percentage calculation I've done and it works, but my problem is not knowing what to use to add the porcentagem
field to all objects, like I can use or better to do this, I tried with a for
(kkkk) and it did not work.
lista () {
for(i = 0; i < this.cards.length; i++) {
this.cards[i].porcentagem = 2
}
return this.cards;
}
(error during evaluation)