console
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<body>
<script type="text/javascript">
function groupArr(list,field){
var fieldList = [],att=[];
list.map((e)=>{
fieldList.push(e[field])
})
fieldList = fieldList.filter((e,i,self)=>{
return self.indexOf(e)==i
})
for(var j=0;j<fieldList.length;j++){
var arr = list.filter((e)=>{
return e[field]==fieldList[j];
})
att.push({
[field]:arr[0][field],
list:arr
})
}
return att;
}
$(function() {
$.ajax({
type : "GET",
contentType: "application/json;charset=UTF-8",
url : "http://huaweidev.24e.co/api/query_history_data?FRAM_ID=HWYQ_B11_2F¤tPage=0&pageTotal=1000000&start_time=&end_time=&type=洁净度",
dataType: "json",
success : function(result) {
result = JSON.parse(result);
let formatData = [];
result.tableData.map((item, index ) => {
let tempObj = $.extend(true,{}, item);
tempObj.index = index;
let tempGroupName = "";
item.map( (val, keyIndex ) => {
if(keyIndex === 2) {
tempGroupName += val.value;
}else {
tempGroupName += val;
}
})
tempObj.groupName = tempGroupName;
formatData.push(tempObj);
})
let dealResult = groupArr(formatData, "groupName");
let repetitionArr = [];
dealResult.map((item, index) => {
if(item.list.length > 1) {
repetitionArr.push(item);
}
})
if(repetitionArr.length > 0) {
alert("调用华为接口返回的数据存在 重复!!!,详情请看控制台")
console.log(repetitionArr);
}else {
alert("调用华为接口返回的数据 没有重复")
}
},
error : function(e){
console.log(e.status);
console.log(e.responseText);
}
});
});
</script>
</body>
</html>