SOURCE

let arguments = [
    {
        "shipmentNum": "ck1584381424344993794", 
        "pageNumber": "第1/1页", 
        "hab": "福建蓝竹不干胶材料有限公司", 
        "productCount": 21, 
        "operator": "admin", 
        "allPage": 1, 
        "planNum": null, 
        "allProductCount": 21, 
        "updateBy": null, 
        "companyPhone": "18959228823", 
        "routeBz": null, 
        "newWarehouse": "成品仓 / 成品小料区", 
        "bz": null, 
        "allSquareNum": 9195.38, 
        "lines": 6, 
        "day": "2022-10-24", 
        "qq": null, 
        "address": "福建省漳州市龙文区台商投资区角美镇龙池工业园锦湖路15号3#厂房一楼", 
        "weightPrintVoList": [
            {
                "num": 3, 
                "product": "1*1990+1*1985+1*2000", 
                "name": "70gD三防热敏纸/热熔/58g白格", 
                "unit2": "mm", 
                "width": 173
            }, 
            {
                "num": 3, 
                "product": "1*2020+1*1985+1*1990", 
                "name": "70gD三防热敏纸/热熔/58g白格", 
                "unit2": "mm", 
                "width": 178
            }, 
            {
                "num": 15, 
                "product": "5*1985+5*1990+2*2000+3*2020", 
                "name": "70gD三防热敏纸/热熔/58g白格", 
                "unit2": "mm", 
                "width": 237
            }
        ], 
        "updateTime": "", 
        "list": [
            {
                "sizeLength": 1990, 
                "sizeWidth": 173, 
                "purpose": null, 
                "weight": "1*1990+1*1985+1*2000+", 
                "productBz": null, 
                "updateTime": null, 
                "unit2": "平方", 
                "units": "m²", 
                "productCount": 3, 
                "specifications": null, 
                "productName": "70gD三防热敏纸/热熔/58g白格", 
                "oldWarehouse": "生产车间仓 / 分切2号机旁", 
                "number": "", 
                "createBy": "admin", 
                "sizeWeight": null, 
                "sizeOther1": null, 
                "updateBy": null, 
                "createTime": "2022-10-24", 
                "bz": null, 
                "planId": "1584381424344993794", 
                "squareNum": "1033.675"
            }, 
            {
                "sizeLength": 2020, 
                "sizeWidth": 178, 
                "purpose": null, 
                "weight": "1*2020+1*1985+1*1990+", 
                "productBz": null, 
                "updateTime": null, 
                "unit2": "平方", 
                "units": "m²", 
                "productCount": 3, 
                "specifications": null, 
                "productName": "70gD三防热敏纸/热熔/58g白格", 
                "oldWarehouse": "生产车间仓 / 分切2号机旁", 
                "number": "", 
                "createBy": "admin", 
                "sizeWeight": null, 
                "sizeOther1": null, 
                "updateBy": null, 
                "createTime": "2022-10-24", 
                "bz": null, 
                "planId": "1584381424344993794", 
                "squareNum": "1067.11"
            }, 
            {
                "sizeLength": 1985, 
                "sizeWidth": 237, 
                "purpose": null, 
                "weight": "5*1985+5*1990+2*2000+3*2020+", 
                "productBz": null, 
                "updateTime": null, 
                "unit2": "平方", 
                "units": "m²", 
                "productCount": 15, 
                "specifications": null, 
                "productName": "70gD三防热敏纸/热熔/58g白格", 
                "oldWarehouse": "生产车间仓 / 分切2号机旁", 
                "number": "", 
                "createBy": "admin", 
                "sizeWeight": null, 
                "sizeOther1": null, 
                "updateBy": null, 
                "createTime": "2022-10-24", 
                "bz": null, 
                "planId": "1584381424344993794", 
                "squareNum": "7094.595"
            }
        ], 
        "createBy": "admin", 
        "createTime": "2022-10-24 11:09:02", 
        "customerTo": null, 
        "salesman": null, 
        "currentPage": 1, 
        "totalSquareNum": 9195.38, 
        "customer": null
    }
]


let data = arguments[0]; //获取传入的原始数据
//你的代码,推荐在线编辑器https://jsrun.net/



// 截取中间的字符的方法
function getNum(str,firstStr,secondStr){
   if(str == "" || str == null || str == undefined){ // "",null,undefined
       return "";
   }
   if(str.indexOf(firstStr)<0){
        return "";
   }
   var subFirstStr=str.substring(str.indexOf(firstStr)+firstStr.length,str.length);
   var subSecondStr=subFirstStr.substring(0,subFirstStr.indexOf(secondStr));
   return subSecondStr;
}

// 定义规格明细的盒子
let bzDetails = '';
// 从明细里面把数据拿出来
let dataList = data['list'];
// 如果有明细才进行判断和排序
if(dataList[0].weight){
    for (let i = 0;i < dataList.length;i++)
    {  
        //拿到每一个合并材料明细的数据
       let dealBox = dataList[i].weight;
        //根据+号分割明细数据
       let array = dealBox.split("+");
        //计算有多少卷
       let frequency = 0;
        //定义一个盒子装材料明细的内容
       let detailsBox = '';
       
        //用循环把数量和规格拆分    
       for (let i=0;i < array.length;i++){
        //    定义明细的盒子
           let bzArray = [];
        //    通过 * 分割字符以达到符合每卷材料分开展示(满足客户展示习惯的效果)
           bzArray = array[i].split("*");
        //    根据重复次数循环,1卷就记录一次,2卷就记录2次,以此类推
            for (let i=0;i < parseInt(bzArray[0]);i++){
                // 每一卷明细记录到
                detailsBox = detailsBox + bzArray[1] + "+";
                // 计数加一
                frequency++;
            }
       }
    //    定义规格,如果有就显示出来
       let sizeWidth = '';
       if(dataList[i].sizeWidth){
           sizeWidth = dataList[i].sizeWidth + "mm/";
       }
    //    把所有明细数据组合起来
       bzDetails =  bzDetails + "<p style='margin: 2px 0 4px 0;'>" + sizeWidth + frequency + "件:" + detailsBox.substr(0,detailsBox.length - 1)+ " </p>";

    }

    data['bzDetails'] = bzDetails;

}
// 备注的判断
let a = data['bz'];
if(a){
    let pause = ',';

    // 车牌号的输入与转化
    var cpFirstStr='车牌号:';

    data['cp'] = "";
    let cp = parseInt(a.indexOf(cpFirstStr))
    if(cp!= -1){
        data['cp'] = getNum(a,cpFirstStr,pause);
        a = a.replace(cpFirstStr + getNum(a,cpFirstStr,pause) + pause ,'');
        data['bz'] = a;
    }
    
    // 司机的输入与转化
    var driverFirstStr='司机:';

    data['driver'] = "";
    let driver = parseInt(a.indexOf(driverFirstStr))
    if(driver!= -1){
        data['driver'] = getNum(a,driverFirstStr,pause);
        a = a.replace(driverFirstStr + getNum(a,driverFirstStr,pause) + pause ,'');
        data['bz'] = a;
    }
    
}


// 其他费用的特殊判断,后台修复后删除!
let detail = data["list"];

for(let i = 0;i < detail.length;i++){
    let d = detail[i];
    
    // 规格的输出
    let specification = '';
    // 根据宽度、长度、重量组合成规格
    // 宽度
    if(d['sizeWidth']){
        specification = d['sizeWidth'] + 'mm';
    };
    // 长度
    if(d['sizeLength']){
        specification = specification + ' * ' + d['sizeLength'] + 'm';
    };
    // 重量
    if(d['sizeWeight']){
        if(specification){
            specification = specification + ' * ' +  d['sizeWeight'] + 'kg';
        }else{
            specification = d['sizeWeight'] + 'kg/桶';
        }
    };

    data["list"][i]['specification'] = specification;

    // 其他费用的替换
    if(d['number'] == null && d['sizeWeight'] == 1){
        data["list"][i]['productName'] = '其他费用';
    }
}

// console.log(data);
// console.log(data['cp']);
// console.log(data['driver']);
// console.log(data['bzDetails']);
// console.log(data['bz']);
// return data; //返回处理完的数据
console 命令行工具 X clear

                    
>
console