SOURCE

let arguments = [
    {
        "allSquareNum": 245, 
        "lines": 6, 
        "day": "2022-12-08", 
        "qq": "196113390", 
        "address": "广东省广州市白云区钟落潭镇马新路140号301", 
        "printSum": 0, 
        "signatoryPhone": "13537593750", 
        "list": [
            {
                "companyAlias": "广州市晖远新材料有限公司", 
                "unit2": "平方", 
                "units": "m²", 
                "productCount": 1, 
                "specifications": "24.5cm * 1000m * 1R", 
                "productName": "80铜板/油胶/60白格底", 
                "number": null, 
                "sizeOther1": null, 
                "bz": "sx2,", 
                "productBz": "zs3000,sx2,", 
                "planId": "1600772080385146882", 
                "brand": null, 
                "sizeLength": 1000, 
                "sizeWidth": 24.5, 
                "pdBz": null, 
                "sizeWeight": null, 
                "associatedPo": "", 
                "subtotal": "563.5", 
                "squareUnitPrice": 2.3, 
                "salesman": "公司客户", 
                "squareNum": "245", 
                "additionalAttributes": null
            }, 
            {
                "companyAlias": "广州市晖远新材料有限公司", 
                "unit2": "平方", 
                "units": "m²", 
                "productCount": 1, 
                "specifications": "24.5cm * 1000m * 1R", 
                "productName": "80铜板/油胶/60白格底", 
                "number": null, 
                "sizeOther1": null, 
                "bz": "sx1,", 
                "productBz": "zs3000,sx1,", 
                "planId": "1600772080385146882", 
                "brand": null, 
                "sizeLength": 1000, 
                "sizeWidth": 24.5, 
                "pdBz": null, 
                "sizeWeight": null, 
                "associatedPo": "", 
                "subtotal": "563.5", 
                "squareUnitPrice": 2.3, 
                "salesman": "公司客户", 
                "squareNum": "245", 
                "additionalAttributes": null
            }, 
            {
                "sizeWeight": "/", 
                "subtotal": "/", 
                "productBz": "/", 
                "units": "/", 
                "productCount": "/", 
                "specifications": "/", 
                "productName": "/", 
                "squareNum": "/"
            }, 
            {
                "sizeWeight": "/", 
                "subtotal": "/", 
                "productBz": "/", 
                "units": "/", 
                "productCount": "/", 
                "specifications": "/", 
                "productName": "/", 
                "squareNum": "/"
            }, 
            {
                "sizeWeight": "/", 
                "subtotal": "/", 
                "productBz": "/", 
                "units": "/", 
                "productCount": "/", 
                "specifications": "/", 
                "productName": "/", 
                "squareNum": "/"
            }, 
            {
                "sizeWeight": "/", 
                "subtotal": "/", 
                "productBz": "/", 
                "units": "/", 
                "productCount": "/", 
                "specifications": "/", 
                "productName": "/", 
                "squareNum": "/"
            }
        ]
    }
]
let data = arguments[0]; //获取传入的原始数据
//你的代码,推荐在线编辑器https://jsrun.net/

// console.log(data)
// 从明细里面把数据拿出来
let dataList = data['list'];


// 截取中间的字符的方法
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 list = data['list']
for (let index = 0; index < list.length; index++) {
    const element = list[index];


}

for (let index = 0; index < dataList.length; index++) {
    const element = dataList[index];

    let a = element.productBz;
    if (a) {
        let pause = ',';



        // 改名的输入与转化
        // inputOut('zs', 'otherSize');
        // 顺序的输入与转化
        inputOut('sx', 'seq');

        

        // 输入与转化的方法 start
        // 输入与转化的方法 start
        // 输入与转化的方法 start
        function inputOut(key, name, qz, hz) {
            // 定义可选参数,前缀和后缀,有填则取值,没有则为空
            this.qz = qz || '';
            this.hz = hz || '';
            // 在data里面定义一个值
            data['list'][index][name] = "";
            if (a.indexOf(key) != '-1') {
                data['list'][index][name] = this.qz + getNum(a, key, pause) + this.hz;
                a = a.replace(key + getNum(a, key, pause) + pause, '');
                data['list'][index]['productBz'] = a;
                
            }
        }
    }
}
// 重新排序的方法
function compare(a, b) {
    if (a.seq === "" && b.seq !== "") {
        return 1;
    } else if (a.seq !== "" && b.seq === "") {
        return -1;
    } else if (a.seq === "" && b.seq === "") {
        return 0;
    } else {
        return parseInt(a.seq) - parseInt(b.seq);
    }
}


data['list'].sort(compare);

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

                    
>
console