1
Good morning gentlemen, I have the following object array:
[{
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
}]
and would like to add one more position in the two objects, and would be the porcentagem
calculating the forecast date for today, example I have 4 days to deliver a project and already passed two days then the percentage would be 50%..
here how I would like basing with today’s date 09/10/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 running days based on whether the start and date fields and add a new field to the object.
Note: I am using vuejs and I want 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 field porcentagem
in all objects, like what I can use or best way to perform this operation, I tried with a for
(kkkk) and did not work.
lista () {
for(i = 0; i < this.cards.length; i++) {
this.cards[i].porcentagem = 2
}
return this.cards;
}
(error during evaluation)
Hi Sergio thanks for the reply, your reply really helps me in calculating the percentage, but I forgot to mention that I want to add the value in the list for the purpose of sorting objects with the lodash, or would have another way?
– Lennon S. Bueno
@So you want to have the list sorted and with that calculated percentage that’s it?
– Sergio
That’s right @Sergio
– Lennon S. Bueno
@Lennons.Bueno what is the field that orders?
– Sergio
I haven’t set the filter yet, but it would be for the percentage that I don’t have on the list because each day the percentage needs to be calculated again, date start, date and number, but today it comes without any ordering @Sergio
– Lennon S. Bueno
@Lennons.Bueno take a look again.
– Sergio
solved thank you, now I need to study more about map that got a little confusing rsrs (I’m having trouble marking you)
– Lennon S. Bueno