遇到问题后端返回data{其中对应每一个item的checked和descrip}
{
"code": 200,
"msg": "请求成功",
"time": ,
"data": {
"id": "",
"measureFileDesc": null,
"measure": null,
"approveFile": null,
"approveFileDesc": null,
"startTime": null,
"endTime": null,
"fileMap": {
"approveFile": [
{
"createTime": "",
"updateTime": "",
"createBy": "",
"updateBy": "",
"id": "",
"fileName": "未命名文件.png",
"objectName": "/ng",
"bucketName": "fx2",
"fileSuffix": "png",
"correlationId": "",
"remark": "approveFile",
"modelName": "common",
"fileUrl": ""
}
],
"measureFile": [
{
"createTime": "",
"updateTime": "",
"createBy": "",
"updateBy": "",
"id": "",
"fileName": "未命名文件.png",
"objectName": "42.png",
"bucketName": "fx2",
"fileSuffix": "png",
"correlationId": "a",
"remark": "measureFile",
"modelName": "common",
"fileUrl": ""
}
],
}
},
"success": true
}
initInspectionItems(detail) {//detail是后端返回的数据
this.inspectionItems.forEach(item => {
item.items.forEach(child => {
if (detail[child.checked]) {
this.$set(child, 'showDescription', detail[child.checked]);//showDescription是需要赋值的字段,将从接口拿到的对应字段,比如approveFile的值赋值给showDescription。
}
if (detail[child.checked]) {
this.$set(child, 'description', detail[child.descrip]);
}
if (detail[child.checked]) {
this.$set(child, 'showFileList', detail.fileMap[child.checked]);
}
});
});
},
this.inspectionItems = [
{
title: '一、文件查验',
items: [
{
question: '是否已按要求取得文件',
checked: 'approveFile',
descrip: 'approveFileDesc',
description: '',
showFileList: [],
showDescription: '',
},
],
},
{
title: '二、测量文件',
items: [
{
question: '是否已按要求完成测量',
checked: 'measureFile',
descrip: 'measureFileDesc',
description: '',
showFileList: [],
showDescription: '',
},
],
},
]