// 点击按钮删除表格数据
let originalMemberInfo = [{name:'aaa', age:13}, {name:'bbb',age:14}];
let newMemberInfo = [ {name:'bbb',age:14}, {name:'ccc',age:15}];
let addMember = [];
let delMember = [];
let updateMember = [];
let originalMemberIndex = {};
for(let i=0; i<originalMemberInfo.length; i++){
originalMemberIndex[originalMemberInfo[i].name] = i;
}
let newMemberIndex = {};
for(let i=0; i<newMemberInfo.length; i++){
let memberName = newMemberInfo[i].name;
newMemberIndex[memberName] = i;
if(originalMemberIndex.hasOwnProperty(memberName)){
let originalMember = originalMemberInfo[originalMemberIndex[memberName]];
// if(originalMember.value!=newMemberInfo[i].value || originalMember.type!=newMemberInfo[i].type){
// updateMember.push(newMemberInfo[i]);
// }
}else{
addMember.push(newMemberInfo[i]);
}
}
for(let k in originalMemberIndex){
if(!newMemberIndex.hasOwnProperty(k)){
delMember.push(originalMemberInfo[originalMemberIndex[k]]);
}
}
console.log(addMember);
console.log(delMember);
console