例如:
1.接口ajaxList获取数据dataList
const dataList = [
{
code: 1001,
name: 'zs',
detailList: [
{ cId: 'c-10001', uid: 'GYS-00901', name: 'aaa' },
{ cId: 'c-10002', uid: 'GYS-00902', name: 'bbb' },
{ cId: 'c-10003', uid: 'GYS-00903', name: 'ccc' },
],
},
{
code: 1002,
name: 'lisi',
detailList: [
{ cId: 'c-10004', uid: 'GYS-00904', name: 'eee' },
{ cId: 'c-10005', uid: 'GYS-00905', name: 'ttt' },
{ cId: 'c-10006', uid: 'GYS-00906', name: 'qqq' },
],
},
{
code: 1003,
name: 'wangwu',
detailList: [
{ cId: 'c-10007', uid: 'GYS-00907', name: 'mm' },
{ cId: 'c-10008', uid: 'GYS-00908', name: 'nn' },
],
},
]
2.根据dataList里面的 detailList的每条数据 { cId: 'c-10001', uid: 'GYS-00901', name: 'aaa' }, 的参数params({ cId: 'c-10001', uid: 'GYS-00901'}) 去调用检查思否通过的接口 ajaxBatchValidate(params) 获得数据 ValidateData
const ValidateData = [
{ reasonList: '说明书正确', status: true },
{ reasonList: '缺少资质说明', status: false },
]
3.把2中获取的结果 插入到 dataList里detailList每条验证结果中
期望数据结构:
const dataList = [
{
code: 1001,
name: 'zs',
detailList: [
{
cId: 'c-10001',
uid: 'GYS-00901',
name: 'aaa',
ValidateLsit: [
{ reasonList: '说明书正确', status: true },
{ reasonList: '缺少资质说明', status: false },
],
},
{
cId: 'c-10002',
uid: 'GYS-00902',
name: 'bbb',
ValidateLsit: [
{ reasonList: 'xxxx', status: true },
{ reasonList: 'xxxx', status: false },
],
},
{
cId: 'c-10003',
uid: 'GYS-00903',
name: 'ccc',
ValidateLsit: [
{ reasonList: 'xxxx', status: true },
{ reasonList: 'xxxx', status: false },
],
},
],
},
{
code: 1002,
name: 'lisi',
detailList: [
{
cId: 'c-10004',
uid: 'GYS-00904',
name: 'eee',
ValidateLsit: [
{ reasonList: 'xxxx', status: true },
{ reasonList: 'xxxx', status: false },
],
},
{ cId: 'c-10005', uid: 'GYS-00905', name: 'ttt' },
{ cId: 'c-10006', uid: 'GYS-00906', name: 'qqq' },
],
},
{
code: 1003,
name: 'wangwu',
detailList: [
{ cId: 'c-10007', uid: 'GYS-00907', name: 'mm' },
{ cId: 'c-10008', uid: 'GYS-00908', name: 'nn' },
],
},
]
看你标签还选了vue,如果是vue里做渲染的话就不能直接赋值要用
this.$set
去赋值新的对象属性。ps: 其实我觉得这个应该后端连表查询后一起返回