需求1:将formData字段遍历插进外层,相同字段都以要插的表单字段为主,
需求2:将innerFormData字段遍历插进内层,相同字段都以要插的表单字段为主,
需求3:将原始orginObj对象下的deliveryNoteDetailVos改成stockRegisterDetailList,
需求4:将原始orginObj对象下stockRegisterDetailList里面的sourceCodeList提取出来,相同字段,以要提取出来的字段覆盖为主。
参考理想数据: resultObj,多谢大佬!!!
外层表单数据:
const formData = {
createTime: '2022-05-01',
createdepartmentCode: '22154',
status: 1
}
内层表单数据:
const innerFormData = {
createUer: '张铭清',
createdepartmentCode: '101210',
}
原始数据: orginObj
const orginObj = [
{
createTime: '',
createdepartmentCode: '101112',
id: '1001',
status: null,
deliveryNoteDetailVos: [
{
createUer: 'null',
createdepartmentCode: 'null',
id: 'yQvmraqdqrvmK2ml9B0',
productName: '医用胶带',
batch: '6784563',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
sourceCodeList: [
{
code: 'l9bX5S5GLsYo9ZZfh6u',
rejectionProcessType: 1,
rejectionDescription: '222222222222',
checkStatus: 2,
},
{
code: 'UhTH3ftpUA7jAAfau8U',
rejectionProcessType: null,
rejectionDescription: null,
checkStatus: 1,
}
],
},
{
createUer: 'null',
createdepartmentCode: 'null',
id: 'yQvmax2vmK2ml9B0',
productName: '剪刀',
batch: '6784563',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
sourceCodeList: [
{
code: 'xxadswe545112',
rejectionProcessType: 1,
rejectionDescription: '1111111',
checkStatus: 2,
},
{
code: '2a4414xqw',
rejectionProcessType: 1,
rejectionDescription: '12233333',
checkStatus: 2,
}
],
}
],
},
{
createTime: '',
createdepartmentCode: '101112',
id: '1002',
status: 1,
deliveryNoteDetailVos: [
{
id: 'yQvmraqdqrvmK2mx1',
productName: '化学仪器',
batch: '2441',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
sourceCodeList: [
{
code: 'x545451a1213',
rejectionProcessType: 1,
rejectionDescription: '333333333',
checkStatus: 1,
},
{
code: 'UhTH3ftpUAasdau8U',
rejectionProcessType: null,
rejectionDescription: null,
checkStatus: 1,
},
{
code: 'UhTH3ftpUAasd113',
rejectionProcessType: null,
rejectionDescription: null,
checkStatus: 2,
}
],
},
{
id: 'xxymraqdvm121ml9',
productName: '纱布',
batch: '1510455',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
sourceCodeList: [
{
id: 'x12dswe545112',
rejectionProcessType: 1,
rejectionDescription: '6666666666',
checkStatus: 2,
},
],
}
],
},
]
理想数据: resultObj
const resultObj = [
{
id: '1001',
createTime: '2022-05-01',
createdepartmentCode: '22154',
status: 1,
stockRegisterDetailList: [
{
createUer: '张铭清',
createdepartmentCode: '101210',
id: 'yQvmraqdqrvmK2ml9B0',
productName: '医用胶带',
batch: '6784563',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
code: 'l9bX5S5GLsYo9ZZfh6u',
rejectionProcessType: 1,
rejectionDescription: '222222222222',
checkStatus: 2,
},
{
createUer: '张铭清',
createdepartmentCode: '101210',
id: 'yQvmraqdqrvmK2ml9B0',
productName: '医用胶带',
batch: '6784563',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
code: 'UhTH3ftpUA7jAAfau8U',
rejectionProcessType: null,
rejectionDescription: null,
checkStatus: 1,
},
{
createUer: '张铭清',
createdepartmentCode: '101210',
id: 'yQvmax2vmK2ml9B0',
productName: '剪刀',
batch: '6784563',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
code: 'xxadswe545112',
rejectionProcessType: 1,
rejectionDescription: '1111111',
checkStatus: 2,
},
{
createUer: '张铭清',
createdepartmentCode: '101210',
id: 'yQvmax2vmK2ml9B0',
productName: '剪刀',
batch: '6784563',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
code: '2a4414xqw',
rejectionProcessType: 1,
rejectionDescription: '12233333',
checkStatus: 2,
}
],
},
{
createTime: '2022-05-01',
createdepartmentCode: '22154',
status: 1,
id: '1002',
stockRegisterDetailList: [
{
createUer: '张铭清',
createdepartmentCode: '101210',
id: 'yQvmraqdqrvmK2mx1',
productName: '化学仪器',
batch: '2441',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
code: 'x545451a1213',
rejectionProcessType: 1,
rejectionDescription: '333333333',
checkStatus: 1,
},
{
createUer: '张铭清',
createdepartmentCode: '101210',
id: 'yQvmraqdqrvmK2mx1',
productName: '化学仪器',
batch: '2441',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
code: 'UhTH3ftpUAasdau8U',
rejectionProcessType: null,
rejectionDescription: null,
checkStatus: 1,
},
{
createUer: '张铭清',
createdepartmentCode: '101210',
id: 'yQvmraqdqrvmK2mx1',
productName: '化学仪器',
batch: '2441',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
code: 'UhTH3ftpUAasd113',
rejectionProcessType: null,
rejectionDescription: null,
checkStatus: 2,
},
{
createUer: '张铭清',
createdepartmentCode: '101210',
id: 'xxymraqdvm121ml9',
productName: '纱布',
batch: '1510455',
rejectionProcessType: null,
rejectionProcessTypeName: null,
rejectionDescription: null,
num: 2,
code: 'x12dswe545112',
rejectionProcessType: 1,
rejectionDescription: '6666666666',
checkStatus: 2,
}
],
},
]
这里的实现是根据你的需求描述去实现的。但好像和你给出的示例结果不同。
比如
resultObj[0].stockRegisterDetailList[0].rejectionProcessType
是1
,但是你的示例结果是null
,但这个好像和你的需求4的描述不符。