这个方法太绝啦
let list = this.checkRecordList.map(item => {
return item.CheckRecordsDtos
})
var arr = new Array();
console.log(list)
// [Array(1), Array(2)]: [
// [{
// CheckDetailedListItemId: "7b61fce2-1d18-4e52-a830-2f0b7099b4bd"
// Text: "从业人员"
// CheckResult: 2
// imgList:[]
// InfoFileJson: "[]"
// }],
// [{
// CheckDetailedListItemId: "b1dea39b-2153-4b77-9e28-9378ca325c4a"
// Text: "许可证"
// CheckResult: 2
// imgList:[]
// InfoFileJson: "[]"
// }, {
// CheckDetailedListItemId: "fe4e5d7f-40e1-4834-910b-df409081b7fc"
// Text: "经营类别一致"
// CheckResult: 1
// imgList:[]
// InfoFileJson: "[]"
// }]
// ]
for (var j in list) {
for (var i in list[j]) {
arr.push(list[j][i]);
}
}
console.log(arr)
// [{
// CheckDetailedListItemId: "7b61fce2-1d18-4e52-a830-2f0b7099b4bd"
// Text: "从业人员"
// CheckResult: 2
// imgList:[]
// InfoFileJson: "[]"
// },
// {
// CheckDetailedListItemId: "b1dea39b-2153-4b77-9e28-9378ca325c4a"
// Text: "许可证"
// CheckResult: 2
// imgList:[]
// InfoFileJson: "[]"
// },
// {
// CheckDetailedListItemId: "fe4e5d7f-40e1-4834-910b-df409081b7fc"
// Text: "经营类别一致"
// CheckResult: 1
// imgList:[]
// InfoFileJson: "[]"
// }
// ]
arr = arr.map(item => {
item.InfoFileJson = JSON.stringify(item.imgList)
return item
})
let checkRecordJson = JSON.stringify(arr)
console.log(checkRecordJson)
//[{"CheckDetailedListItemId":"7b61fce2-1d18-4e52-a830-2f0b7099b4bd","Text":"从业人员","CheckResult":2,"imgList":[],"InfoFileJson":"[]"},{"CheckDetailedListItemId":"b1dea39b-2153-4b77-9e28-9378ca325c4a","Text":"许可证","CheckResult":2,"imgList":[],"InfoFileJson":"[]"},{"CheckDetailedListItemId":"fe4e5d7f-40e1-4834-910b-df409081b7fc","Text":"经营类别一致","CheckResult":1,"imgList":[],"InfoFileJson":"[]"}]