var list = [
{
"PassengerId": 1371039,
"PassengerName": "蒋悦有",
"MaterialBindingRiskType": 1,
"VisaShowInfos": [
{
"CountryName": "中国",
"VisaTypeName": "个人旅游签证",
"ListPersonType": [
{
"PersonTypeSort": 0,
"PersonTypeId": 0,
"PersonTypeName": "所有用户",
"ListMetarial": [
{
"Sort": 1,
"MaterialId": 1,
"MaterialName": "未成年补充材料",
"MaterialDesc": "未成年补充材料",
"MaterialType": 56,
"SamplePics": []
},
{
"Sort": 10,
"MaterialId": 10,
"MaterialName": "护照",
"MaterialDesc": "<p>★此项材料我司会对游客信息进行审核,视材料情况增收:</p><p>填好后直接将电子版发送,所有内容需如实、完整、清晰填写,儿童可由父母代签。</p><p> <a style=\"font-size:12px; color:#0066cc;\" href=\"Cruises/2018/3/29/4e53f5b3a98e4c45909399110d285a30.jpg\" title=\"梵蒂冈.jpg\">梵蒂冈.jpg</a> <a style=\"font-size:12px; color:#0066cc;\" href=\"http://resource.qa.17usoft.com/youlun/UploadFile/Cruises/2018/3/29/39026693982c46b78372cc23649251e0.docx\" title=\"护照.docx\">护照.docx</a><br/></p>",
"MaterialType": 22,
"SamplePics": []
},
{
"Sort": 11,
"MaterialId": 11,
"MaterialName": "身份证",
"MaterialDesc": "<p>身份证</p><p><a style=\"font-size:12px; color:#0066cc;\" href=\"Cruises/2018/3/29/4e53f5b3a98e4c45909399110d285a30.jpg\" title=\"梵蒂冈.jpg\">梵蒂冈.jpg</a></p><p><a style=\"font-size:12px; color:#0066cc;\" href=\"http://resource.qa.17usoft.com/youlun/UploadFile/Cruises/2018/3/29/39026693982c46b78372cc23649251e0.docx\" title=\"护照.docx\">护照.docx</a></p>",
"MaterialType": 21,
"SamplePics": []
}
]
}
]
}
]
},
{
"PassengerId": 1371039,
"PassengerName": "小王",
"MaterialBindingRiskType": 1,
"VisaShowInfos": [
{
"CountryName": "日本",
"VisaTypeName": "个人旅游签证",
"ListPersonType": [
{
"PersonTypeSort": 0,
"PersonTypeId": 0,
"PersonTypeName": "所有用户",
"ListMetarial": [
{
"Sort": 3,
"MaterialId": 3,
"MaterialName": "宋家麒测试材料类型",
"MaterialDesc": "vfdvfd <a style=\"font-size:12px; color:#0066cc;\" href=\"Cruises/2018/3/29/4e53f5b3a98e4c45909399110d285a30.jpg\" title=\"梵蒂冈.jpg\">梵蒂冈.jpg</a>",
"MaterialType": 22,
"SamplePics": [
"Cruises/2018/3/29/e62eb6824ede46ad9d2e445191b9cd22.jpg"
]
}
]
}
]
}
]
},
{
"PassengerId": 1371049,
"PassengerName": "王五在",
"MaterialBindingRiskType": 2,
"VisaShowInfos": [
{
"CountryName": "中国",
"VisaTypeName": "个人旅游签证",
"ListPersonType": [
{
"PersonTypeSort": 0,
"PersonTypeId": 0,
"PersonTypeName": "所有用户",
"ListMetarial": [
{
"Sort": 1,
"MaterialId": 1,
"MaterialName": "未成年补充材料",
"MaterialDesc": "未成年补充材料",
"MaterialType": 56,
"SamplePics": []
},
{
"Sort": 2,
"MaterialId": 2,
"MaterialName": "个人资源表",
"MaterialDesc": "个人资源表",
"MaterialType": 54,
"SamplePics": []
},
{
"Sort": 4,
"MaterialId": 4,
"MaterialName": "职业证明",
"MaterialDesc": "职业证明",
"MaterialType": 52,
"SamplePics": []
},
{
"Sort": 5,
"MaterialId": 5,
"MaterialName": "资产证明",
"MaterialDesc": "资产证明",
"MaterialType": 51,
"SamplePics": []
},
{
"Sort": 10,
"MaterialId": 10,
"MaterialName": "护照",
"MaterialDesc": "<p>★此项材料我司会对游客信息进行审核,视材料情况增收:</p><p>填好后直接将电子版发送,所有内容需如实、完整、清晰填写,儿童可由父母代签。</p><p> <a style=\"font-size:12px; color:#0066cc;\" href=\"Cruises/2018/3/29/4e53f5b3a98e4c45909399110d285a30.jpg\" title=\"梵蒂冈.jpg\">梵蒂冈.jpg</a> <a style=\"font-size:12px; color:#0066cc;\" href=\"http://resource.qa.17usoft.com/youlun/UploadFile/Cruises/2018/3/29/39026693982c46b78372cc23649251e0.docx\" title=\"护照.docx\">护照.docx</a><br/></p>",
"MaterialType": 22,
"SamplePics": []
},
{
"Sort": 11,
"MaterialId": 11,
"MaterialName": "身份证",
"MaterialDesc": "<p>身份证</p><p><a style=\"font-size:12px; color:#0066cc;\" href=\"Cruises/2018/3/29/4e53f5b3a98e4c45909399110d285a30.jpg\" title=\"梵蒂冈.jpg\">梵蒂冈.jpg</a></p><p><a style=\"font-size:12px; color:#0066cc;\" href=\"http://resource.qa.17usoft.com/youlun/UploadFile/Cruises/2018/3/29/39026693982c46b78372cc23649251e0.docx\" title=\"护照.docx\">护照.docx</a></p>",
"MaterialType": 21,
"SamplePics": []
}
]
}
]
}
]
},
{
"PassengerId": 1371049,
"PassengerName": "小丁",
"MaterialBindingRiskType": 2,
"VisaShowInfos": [
{
"CountryName": "日本",
"VisaTypeName": "个人旅游签证",
"ListPersonType": [
{
"PersonTypeSort": 0,
"PersonTypeId": 0,
"PersonTypeName": "所有用户",
"ListMetarial": [
{
"Sort": 3,
"MaterialId": 3,
"MaterialName": "宋家麒测试材料类型",
"MaterialDesc": "vfdvfd <a style=\"font-size:12px; color:#0066cc;\" href=\"Cruises/2018/3/29/4e53f5b3a98e4c45909399110d285a30.jpg\" title=\"梵蒂冈.jpg\">梵蒂冈.jpg</a>",
"MaterialType": 22,
"SamplePics": [
"Cruises/2018/3/29/e62eb6824ede46ad9d2e445191b9cd22.jpg"
]
}
]
}
]
}
]
},
{
"PassengerId": 1371049,
"PassengerName": "DDR",
"MaterialBindingRiskType": 1,
"VisaShowInfos": [
{
"CountryName": "日本",
"VisaTypeName": "个人旅游签证",
"ListPersonType": [
{
"PersonTypeSort": 0,
"PersonTypeId": 0,
"PersonTypeName": "所有用户",
"ListMetarial": [
{
"Sort": 3,
"MaterialId": 3,
"MaterialName": "宋家麒测试材料类型",
"MaterialDesc": "vfdvfd <a style=\"font-size:12px; color:#0066cc;\" href=\"Cruises/2018/3/29/4e53f5b3a98e4c45909399110d285a30.jpg\" title=\"梵蒂冈.jpg\">梵蒂冈.jpg</a>",
"MaterialType": 22,
"SamplePics": [
"Cruises/2018/3/29/e62eb6824ede46ad9d2e445191b9cd22.jpg"
]
}
]
}
]
}
]
}
];
var formatList = [];
var tempArr = []
list.forEach(function(item, index, arr){
if(tempArr.includes(item.MaterialBindingRiskType)){
formatList[tempArr.indexOf(item.MaterialBindingRiskType)].PassengerName+=","+item.PassengerName
}else{
tempArr.push(item.MaterialBindingRiskType);
formatList.push(item)
}
})
console.log(formatList)
console