SOURCE

let arguments =[
        {
            "address": "镜湖大道", 
            "purCompanyName": "广州市盈信纸业有限公司", 
            "companyName": "采购供应商", 
            "paymentBz": "付款备注", 
            "openAccountBank": null, 
            "taxRate": "5.2", 
            "companyId": "1531546372954136577", 
            "createBy": "administrator", 
            "planNum": "0700011", 
            "creditCode": "123123", 
            "createTime": "2022-07-15 16:54:55", 
            "companyPhone": "13202045555", 
            "phone": "02084305189", 
            "subtotal": 8506, 
            "companyAddress": "镜湖大道", 
            "bz": "sj2022年07月16日13:42:06,这是其他备注", 
            "faxNumber": "0763555", 
            "purAddress": "广东省广州市白云区钟落潭镇马新路140号301", 
            "deliveryDate": null, 
            "squareNum": 840, 
            "contacts": "小杨", 
            "bankCardCode": null, 
            "DetailsList": [
                {
                    "sizeLength": null, 
                    "sizeWidth": null, 
                    "productId": "1547855237446443009", 
                    "companyName": "采购供应商", 
                    "unit2": "kg", 
                    "productCount": 1, 
                    "warehouseName": null, 
                    "number": "www", 
                    "companyId": "1531546372954136577", 
                    "unit": "池", 
                    "sizeWeight": 100, 
                    "sizeOther1": null, 
                    "warehousefullName": null, 
                    "warehouseId": null, 
                    "totalNum": 100, 
                    "price": 30, 
                    "subtotal": 3000, 
                    "name": "木卡板-规格1250*1250mm", 
                    "bz": null, 
                    "id": "1547867291033083905"
                }, 
                {
                    "sizeLength": null, 
                    "sizeWidth": null, 
                    "productId": "1547866319690997761", 
                    "companyName": "采购供应商", 
                    "unit2": "kg", 
                    "productCount": 1, 
                    "warehouseName": null, 
                    "number": "www", 
                    "companyId": "1531546372954136577", 
                    "unit": "池", 
                    "sizeWeight": 300, 
                    "sizeOther1": null, 
                    "warehousefullName": null, 
                    "warehouseId": null, 
                    "totalNum": 300, 
                    "price": 4.2, 
                    "subtotal": 1260, 
                    "name": "双面胶-品名:海绵胶-宽幅:20mm-码数:4y", 
                    "bz": null, 
                    "id": "1547867291033083906"
                }, 
                {
                    "sizeLength": null, 
                    "sizeWidth": null, 
                    "productId": "1547866343455924225", 
                    "companyName": "采购供应商", 
                    "unit2": "kg", 
                    "productCount": 1, 
                    "warehouseName": null, 
                    "number": "www", 
                    "companyId": "1531546372954136577", 
                    "unit": "池", 
                    "sizeWeight": 80, 
                    "sizeOther1": null, 
                    "warehousefullName": null, 
                    "warehouseId": null, 
                    "totalNum": 80, 
                    "price": 12, 
                    "subtotal": 960, 
                    "name": "双面胶-品名:油胶80u-宽幅:50mm-码数:50y", 
                    "bz": null, 
                    "id": "1547867291033083907"
                }, 
                {
                    "sizeLength": null, 
                    "sizeWidth": null, 
                    "productId": "1547866654060912641", 
                    "companyName": "采购供应商", 
                    "unit2": "kg", 
                    "productCount": 1, 
                    "warehouseName": null, 
                    "number": "www", 
                    "companyId": "1531546372954136577", 
                    "unit": "池", 
                    "sizeWeight": 160, 
                    "sizeOther1": null, 
                    "warehousefullName": null, 
                    "warehouseId": null, 
                    "totalNum": 160, 
                    "price": 1.05, 
                    "subtotal": 168, 
                    "name": "透明封箱胶-宽幅:50mm-码数:100y-粘度:40u", 
                    "bz": null, 
                    "id": "1547867291033083908"
                }, 
                {
                    "sizeLength": null, 
                    "sizeWidth": null, 
                    "productId": "1547867221634129922", 
                    "companyName": "采购供应商", 
                    "unit2": "kg", 
                    "productCount": 1, 
                    "warehouseName": null, 
                    "number": "www", 
                    "companyId": "1531546372954136577", 
                    "unit": "池", 
                    "sizeWeight": 200, 
                    "sizeOther1": null, 
                    "warehousefullName": null, 
                    "warehouseId": null, 
                    "totalNum": 200, 
                    "price": 15.59, 
                    "subtotal": 3118, 
                    "name": "纸管-规格:6-长度:1190mm-厚度:15mm", 
                    "bz": null, 
                    "id": "1547867291033083909"
                }
            ], 
            "purchaseNumber": "1547867290953392129"
        }
    ]


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



// 合计数据处理模块
// 拿到外面的汇总数据
let outside = data;
// 定义一个新的叫做大写数字的字段
let totalNumChinese = Arabia_to_Chinese(outside.subtotal)
// 转化数字变成大写数字后插入到汇总数据中
data['totalNumChinese'] = totalNumChinese;

// 拿到备注并判断是否有时间
// 判断备注中是否有时间的休止符
let pauseTime = ',';
// 备注的提取
let bz = data['bz'];
// 交货时间的输入与转化
var deliveryTimeFirstStr='sj';
// 先定义交货时间的字段
let deliveryTime= '';
data['deliveryTime'] = deliveryTime;
// 确定备注里面有没有时间
let sj = parseInt(bz.indexOf(deliveryTimeFirstStr))
if(sj!= -1){
    data['deliveryTime'] = getNum(bz,deliveryTimeFirstStr,pauseTime);
    bz = bz.replace(deliveryTimeFirstStr + getNum(bz,deliveryTimeFirstStr,pauseTime) + pauseTime ,'');
    data['bz'] = bz;
}


// 转化为大写数字的方法
function Arabia_to_Chinese(str)
    {
        var num = parseFloat(str);
        var strOutput = "",
        strUnit = '仟佰拾亿仟佰拾万仟佰拾元角分';
        num += "00";
        var intPos = num.indexOf('.'); 
        if (intPos >= 0){
            num = num.substring(0, intPos) + num.substr(intPos + 1, 2);
        }
        strUnit = strUnit.substr(strUnit.length - num.length);
        for (var i=0; i < num.length; i++){
            strOutput += '零壹贰叁肆伍陆柒捌玖'.substr(num.substr(i,1),1) + strUnit.substr(i,1);
        }
        return strOutput.replace(/零角零分$/, '整').replace(/零[仟佰拾]/g, '零').replace(/零{2,}/g, '零').replace(/零([亿|万])/g, '$1').replace(/零+元/, '元').replace(/亿零{0,3}万/, '亿').replace(/^元/, "零元")
    } 

// 截取中间的字符的方法
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 detail = data.DetailsList;
// 定义分隔符
let pause = '-';

for (index = 0;index < detail.length;index++){
    // 品名的判断
    let a = detail[index]['name'];
    if(a.indexOf(pause)!= '-1'){
        // 根据分隔符分开字段,并把数组存到m中
        m = a.split(pause);
        // 把名称里第一部分作为产品名
        detail[index]['name'] = m[0];
        // 名称里的其余部分塞到规格数组里面去
        for (var i=1;i<m.length;i++)
        {
            detail[index]['format'+i] = m[i];
        }

        // 单位根据品名判断单位是什么
      

        switch(m[0])
        {
            case (m[0].indexOf('支')!= '-1'):
                break;
            case 2:
                break;
            default:
                detail[index]['unit2'] = "个";

        }
    }
}
console.log(data);
// return data; //返回处理完的数据
console 命令行工具 X clear

                    
>
console