var newList=[];var table={};var dataObj={};var finalList=[];var tableData=[{brName:'营业部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'20',tacheName:'奔驰'}]},{brName:'营业部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'30',tacheName:'宝马'}]},{brName:'营业部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'40',tacheName:'宝马'}]},{brName:'营业部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'50',tacheName:'帕萨特'}]},{brName:'营业部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'60',tacheName:'法拉利'}]},{brName:'营业部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'70',tacheName:'帕萨特'}]},{brName:'营业部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'80',tacheName:'法拉利'}]},{brName:'营业部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'90',tacheName:'奔驰'}]},{brName:'销售部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'10',tacheName:'奔驰'}]},{brName:'销售部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'50',tacheName:'奔驰'}]},{brName:'销售部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'70',tacheName:'帕萨特'}]},{brName:'销售部',dateStr:'2023-11-23',tacheArr:[{dealCnt:'20',tacheName:'帕萨特'}]},];for(let i in tableData){brName=tableData[i].brName;dateStr=tableData[i].dateStr;tacheArr=tableData[i].tacheArr;if(table[brName]==null){if(tacheArr[0].tacheName=='奔驰'){table[brName]={'name':brName,'dateStr':dateStr,'val1':Number(tacheArr[0].dealCnt),'val2':0,'val3':0,'val4':0,'val5':0,}}elseif(tacheArr[0].tacheName=='宝马'){table[brName]={'name':brName,'dateStr':dateStr,'val1':0,'val2':Number(tacheArr[0].dealCnt),'val3':0,'val4':0,'val5':0,}}elseif(tacheArr[0].tacheName=='法拉利'){table[brName]={'name':brName,'dateStr':dateStr,'val1':0,'val2':0,'val3':Number(tacheArr[0].dealCnt),'val4':0,'val5':0,}}elseif(tacheArr[0].tacheName=='布加迪'){table[brName]={'name':brName,'dateStr':dateStr,'val1':0,'val2':0,'val3':0,'val4':Number(tacheArr[0].dealCnt),'val5':0,}}elseif(tacheArr[0].tacheName=='帕萨特'){table[brName]={'name':brName,'dateStr':dateStr,'val1':0,'val2':0,'val3':0,'val4':0,'val5':Number(tacheArr[0].dealCnt),}}}else{if(tacheArr[0].tacheName=='奔驰'){table[brName].val1+=Number(tacheArr[0].dealCnt)}elseif(tacheArr[0].tacheName=='宝马'){table[brName].val2+=Number(tacheArr[0].dealCnt)}elseif(tacheArr[0].tacheName=='法拉利'){table[brName].val3+=Number(tacheArr[0].dealCnt)}elseif(tacheArr[0].tacheName=='布加迪'){table[brName].val4+=Number(tacheArr[0].dealCnt)}elseif(tacheArr[0].tacheName=='帕萨特'){table[brName].val5+=Number(tacheArr[0].dealCnt)}}}for(key in table){newList.push(table[key])}for(let k=0;k<newList.length;k++){dataObj={'brName':newList[k].name,'dateStr':newList[k].dateStr,'val1':newList[k].val1,'val2':newList[k].val2,'val3':newList[k].val3,'val4':newList[k].val4,'val5':newList[k].val5,}finalList.push(dataObj)}
console.log(finalList)