数组对象去除重复对象

方法一

适用在子组件中改动数组对象数据

let arr = [...this.rightListSel];
this.rightListSel.length = 0;
var obj = {};
for(var i =0; i<arr.length; i++){
    if(!obj[arr[i].sysCode]){
        this.rightListSel.push(arr[i]);
        obj[arr[i].sysCode] = true;
    }
}

方法二

var hash = {};
this.rightListSel = this.rightListSel.reduce(function(item, next) {
    hash[next.sysCode] ? '' : hash[next.sysCode] = true && item.push(next);
    return item
}, [])

数组对象按数组移除项

方法一

适用在子组件中改动数组对象数据

for(let i = this.rightListSel.length - 1; i >= 0; i--){
    for(let j = 0; j < this.multipleSelectionRight.length;j++){
        if(this.rightListSel[i].sysCode == this.multipleSelectionRight[j].sysCode){
            this.rightListSel.splice(i,1);
        }
    }
}

方法二

this.rightListSel = [...this.rightListSel].filter(x => [...this.multipleSelectionRight].every(y => y['sysCode'] !== x['sysCode']));