let arguments = [{ "shipmentNum": "ck1600772080385146882", "pageNumber": "第1/1页", "receivingAddress": "广州市增城区荔湾新十二路96号长风国际31栋2121房", "hab": "广州市盈信纸业有限公司", "productCount": 1, "operator": "administrator", "allPage": 1, "planNum": "1200006", "total": 563.500, "allProductCount": 1, "companyPhone": "02084305189", "routeBz": null, "bz": "", "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": "", "pdBz": "zs3000,", "planId": "1600772080385146882", "brand": null, "sizeLength": 1000.0000000, "sizeWidth": 24.5000000, "productBz": null, "sizeWeight": null, "associatedPo": "", "subtotal": "563.5", "squareUnitPrice": 2.3000000, "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": "/" }, { "sizeWeight": "/", "subtotal": "/", "productBz": "/", "units": "/", "productCount": "/", "specifications": "/", "productName": "/", "squareNum": "/" }], "companyContacts": null, "allTotal": 563.5, "contactsPhone": null, "capitalChineseAllTotal": "伍佰陆拾叁元伍角", "associatedPo": "", "capitalChineseTotal": "伍佰陆拾叁元伍角", "customerTo": "广州市晖远新材料有限公司", "shippingAddress": "广州市增城区荔湾新十二路96号长风国际31栋2121房", "signatory": "吴成锋", "currentPage": 1, "totalSquareNum": 245.000, "customer": "广州市晖远新材料有限公司" }]
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.pdBz;
if (a) {
let pause = ',';
// 改名的输入与转化
inputOut('zs', 'otherSize');
// 输入与转化的方法 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]['pdBz'] = a;
}
}
// 输入与转化的方法 end
// 输入与转化的方法 end
// 输入与转化的方法 end
if (data['list'][index]['otherSize']) {
let spc = data['list'][index]['specifications']
let arr = spc.split('*')
arr.splice(2, 0, data['list'][index]['otherSize'] + "张")
arr.join( "*")
console.log(arr);
}
}
}
// console.log(data['list']);
// return data; //返回处理完的数据
console