SOURCE

let arguments =[{"num":1,"list":[{"purpose":"工厂自用","orderId":null,"companyName":"工厂自用","unit2":"平方","type":1,"productCount":4,"unproductId":"1557290694420733954","receiverId":null,"sizeOther1":null,"price":null,"bz":null,"bagNum":null,"sizeLength":400.0000000,"sizeWidth":20.0000000,"productId":"1353287076667027458","sheetNum":null,"printing":0,"orderDetailId":null,"cutLength":null,"picture":"-1","unit":"卷","sizeWeight":null,"warehousefullName":"工厂自用","warehouseId":"1353275487322730497","name":"上光膜","fullname":"成品仓 / 光膜区"},{"purpose":"工厂自用","orderId":null,"companyName":"工厂自用","unit2":"平方","type":1,"productCount":1,"unproductId":"1557290694546563073","receiverId":null,"sizeOther1":null,"price":null,"bz":null,"bagNum":null,"sizeLength":400.0000000,"sizeWidth":27.0000000,"productId":"1371719829775261697","sheetNum":null,"printing":0,"orderDetailId":null,"cutLength":null,"picture":"-1","unit":"平方","sizeWeight":null,"warehousefullName":"工厂自用","warehouseId":"1353275487322730497","name":"上光膜","fullname":"成品仓 / 光膜区"}],"planId":"1557290690662637573","totalWidth":107.0000000,"key":"上光膜20.0000000-4|27.0000000-1|","planBatchNum":1,"planIdList":["1557290690662637573"]},{"num":1,"list":[{"purpose":"工厂自用","orderId":null,"companyName":"工厂自用","unit2":"平方","type":1,"productCount":6,"unproductId":"1557290690968821761","receiverId":null,"sizeOther1":null,"price":null,"bz":null,"bagNum":null,"sizeLength":400.0000000,"sizeWidth":15.0000000,"productId":"1353287091896545282","sheetNum":null,"printing":1,"orderDetailId":null,"cutLength":null,"picture":"-1","unit":"卷","sizeWeight":null,"warehousefullName":"工厂自用","warehouseId":"1353275487322730497","name":"上光膜","fullname":"成品仓 / 光膜区"},{"purpose":"工厂自用","orderId":null,"companyName":"工厂自用","unit2":"平方","type":1,"productCount":1,"unproductId":"1557290691287588865","receiverId":null,"sizeOther1":null,"price":null,"bz":null,"bagNum":null,"sizeLength":400.0000000,"sizeWidth":17.0000000,"productId":"1353287085458288642","sheetNum":null,"printing":0,"orderDetailId":null,"cutLength":null,"picture":"-1","unit":"卷","sizeWeight":null,"warehousefullName":"工厂自用","warehouseId":"1353275487322730497","name":"上光膜","fullname":"成品仓 / 光膜区"}],"planId":"1557290690662637573","totalWidth":107.0000000,"key":"上光膜15.0000000-6|17.0000000-1|","planBatchNum":3,"planIdList":["1557290690662637573"]},{"num":1,"list":[{"purpose":"工厂自用","orderId":null,"companyName":"工厂自用","unit2":"平方","type":1,"productCount":4,"unproductId":"1557290693397323778","receiverId":null,"sizeOther1":null,"price":null,"bz":null,"bagNum":null,"sizeLength":400.0000000,"sizeWidth":18.0000000,"productId":"1353287081108795394","sheetNum":null,"printing":0,"orderDetailId":null,"cutLength":null,"picture":"-1","unit":"卷","sizeWeight":null,"warehousefullName":"工厂自用","warehouseId":"1353275487322730497","name":"上光膜","fullname":"成品仓 / 光膜区"},{"purpose":"工厂自用","orderId":null,"companyName":"工厂自用","unit2":"平方","type":1,"productCount":1,"unproductId":"1557290693518958593","receiverId":null,"sizeOther1":null,"price":null,"bz":null,"bagNum":null,"sizeLength":400.0000000,"sizeWidth":35.0000000,"productId":"1420206987203514370","sheetNum":null,"printing":0,"orderDetailId":null,"cutLength":null,"picture":"-1","unit":"卷","sizeWeight":null,"warehousefullName":"工厂自用","warehouseId":"1353275487322730497","name":"上光膜","fullname":"成品仓 / 光膜区"}],"planId":"1557290690662637573","totalWidth":107.0000000,"key":"上光膜18.0000000-4|35.0000000-1|","planBatchNum":3,"planIdList":["1557290690662637573"]},{"num":1,"list":[{"purpose":"工厂自用","orderId":null,"companyName":"工厂自用","unit2":"平方","type":1,"productCount":1,"unproductId":"1557290692231307266","receiverId":null,"sizeOther1":null,"price":null,"bz":null,"bagNum":null,"sizeLength":400.0000000,"sizeWidth":13.0000000,"productId":"1353290167088934913","sheetNum":null,"printing":0,"orderDetailId":null,"cutLength":null,"picture":"-1","unit":"卷","sizeWeight":null,"warehousefullName":"工厂自用","warehouseId":"1353275487322730497","name":"上光膜","fullname":"成品仓 / 光膜区"},{"purpose":"工厂自用","orderId":null,"companyName":"工厂自用","unit2":"平方","type":1,"productCount":4,"unproductId":"1557290692009009153","receiverId":null,"sizeOther1":null,"price":null,"bz":null,"bagNum":null,"sizeLength":400.0000000,"sizeWidth":15.0000000,"productId":"1353287091896545282","sheetNum":null,"printing":0,"orderDetailId":null,"cutLength":null,"picture":"-1","unit":"卷","sizeWeight":null,"warehousefullName":"工厂自用","warehouseId":"1353275487322730497","name":"上光膜","fullname":"成品仓 / 光膜区"},{"purpose":"工厂自用","orderId":null,"companyName":"工厂自用","unit2":"平方","type":1,"productCount":2,"unproductId":"1557290692134838274","receiverId":null,"sizeOther1":null,"price":null,"bz":null,"bagNum":null,"sizeLength":400.0000000,"sizeWidth":17.0000000,"productId":"1353287085458288642","sheetNum":null,"printing":0,"orderDetailId":null,"cutLength":null,"picture":"-1","unit":"卷","sizeWeight":null,"warehousefullName":"工厂自用","warehouseId":"1353275487322730497","name":"上光膜","fullname":"成品仓 / 光膜区"}],"planId":"1557290690662637573","totalWidth":107.0000000,"key":"上光膜13.0000000-1|15.0000000-4|17.0000000-2|","planBatchNum":4,"planIdList":["1557290690662637573"]}]

let data = arguments;
// 定义一个数组,用来存储组合的所有的排刀数据
let dataList = [];
//你的代码,推荐在线编辑器https://jsrun.net/


// 获取所有批次的数据
for(let i = 0;i < data.length ;i++){
    // 定义基础数据节点方便后面调用
    let base = data[i];
    // 定义表头统计批次数
    let title = {
       "name":"<span style='font-weight:bold;font-size:18px;'>第" + (i+1) + "批次</span>",
       "sizeWidth":"<span style='font-weight:bold;font-size:18px;'>批次数量:" +base["planBatchNum"]+"</span>",
       "sizeLength":"",
       "productCount":"",
       
    };
    
    dataList.push(title);
    // console.log(title);
    // list数据拿出来,然后通过for循环取值
    let list = base["list"];
    for(let listIndex = 0;listIndex < list.length;listIndex++){
        let listBase = list[listIndex];
        // 取出品名、宽度、长度、数量
        let name = listBase["name"];
        let sizeWidth = listBase["sizeWidth"];
        let sizeLength = listBase["sizeLength"];
        let productCount = listBase["productCount"];
        let listArray = {
            "name":name,
            "sizeWidth":sizeWidth,
            "sizeLength":sizeLength,
            "productCount":productCount,
            };
        dataList.push(listArray);
    }
    // 定义表尾区分批次
    let end = {
       "name":"",
       "sizeWidth":"",
       "sizeLength":"",
       "productCount":"",
       
    };

    dataList.push(end);
}
data["dataList"] = dataList;
console.log(data["dataList"]);
// return data; //返回处理完的数据
console 命令行工具 X clear

                    
>
console