SOURCE

let arguments =[{"address":"中国","purCompanyName":"中山金鹤胶粘制品有限公司","companyName":"深圳市高氏粘合剂制品有限公司","paymentBz":null,"openAccountBank":null,"taxRate":null,"companyId":"1534068241847672833","createBy":"朱丽平","planNum":"0900005","creditCode":null,"createTime":"2022-09-14 16:36:33","companyPhone":"19873376590","phone":"13702452498","subtotal":15120.0000000,"companyAddress":"中国","bz":"pm哑银,gg10*1090,","faxNumber":"0755-84084830","purAddress":"广东省中山市东升镇东锐工业开发区","deliveryDate":null,"squareNum":1080.0000000,"contacts":"高先生","bankCardCode":null,"DetailsList":[{"sizeLength":null,"sizeWidth":null,"productId":"1560178743493349378","companyName":"深圳市高氏粘合剂制品有限公司","unit2":"kg","productCount":6.0000000,"warehouseName":null,"number":null,"companyId":"1534068241847672833","unit":"桶","sizeWeight":180.0000000,"sizeOther1":null,"warehousefullName":null,"warehouseId":null,"totalNum":1.08E+3,"price":14.0000000,"subtotal":15120.0000000,"name":"8013","bz":"pm哑银,gg10*1090,","id":"1569968333104185345"}],"purchaseNumber":"1569968333066436610"}];

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

// 把规格详细数据拿出来并组合
let detail = data["DetailsList"];
// 定义分隔符
let pause = ',';

let a = data['bz'];

// 如果备注里包含修改则进行以下操作
if(a){
    // 品名的输入与转化的方法
    inputOut('pm','productName');
    // 规格的输入与转化的方法
    inputOut('gg','specification');
}

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["DetailsList"][i]['specification'] = specification;

    // 如果备注里有改名数据,则替换
    if(data['productName']){
        data["DetailsList"][i]['name'] = data['productName'];  
    }
    if(data['productName']){
        data["DetailsList"][i]['specification'] = data['specification']; 
    }
    
  
}
  // 输入与转化的方法 start
    // 输入与转化的方法 start
    // 输入与转化的方法 start
    function inputOut(key,name,qz,hz){
        // 定义可选参数,前缀和后缀,有填则取值,没有则为空
        this.qz = qz || '';
        this.hz = hz || '';
        // 在data里面定义一个值
        data[name] = "";
        if(a.indexOf(key)!= '-1'){
            data[name] = this.qz + getNum(a,key,pause) + this.hz;
            a = a.replace(key + getNum(a,key,pause) + pause ,'');
            data['bz'] = a;
        }
    } 
    // 输入与转化的方法 end
    // 输入与转化的方法 end
    // 输入与转化的方法 end
    
    // 截取中间的字符的方法
    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;
    }

console.log(data);
console 命令行工具 X clear

                    
>
console