/后台返回的数据格式 (一周7天的状态)
let data = [
{"TYPE": "01", "REMARK": "休假",value:2},
{"TYPE": "03", "REMARK": "在班",value:2},
{"TYPE": "03", "REMARK": "在班",value:2},
{"TYPE": "02", "REMARK": "上海出差",value:2},
{"TYPE": "02", "REMARK": "北京出差",value:2},
{"TYPE": "04", "REMARK": "休息",value:2},
{"TYPE": "04", "REMARK": "休息",value:2}
]
let newArr = []
data.forEach(el=> {
const res = newArr.findIndex(ol=> {
return el.TYPE === ol.TYPE&&el.REMARK === ol.REMARK;
});
if (res !== -1) {
newArr[res].value = newArr[res].value + el.value
} else {
newArr.push(el);
}
})
console.log(newArr)
11-12
4515
08-09
797
07-20
437