let arguments =[{"shipmentNum":"ck1562016665272561666","pageNumber":"第1/1页","receivingAddress":"江苏盐城大丰区博汇纸业工厂","hab":"广东楷诚纸业有限公司","productCount":2,"operator":"彭叶强","allPage":1,"planNum":"0800103","total":220505.990,"allProductCount":2,"companyPhone":"0769-38841601","routeBz":null,"bz":"柜号/柜号:TEMU7327011/7340985<br/>共计:","allSquareNum":27178,"lines":6,"day":"2022-08-23","qq":null,"address":"广东省东莞市洪梅镇望沙路红梅段66号","printSum":1,"weightPrintVoList":[{"num":1,"product":"1*1127+1*1160+2*1137+1*1129+1*1145+1*1133+1*1150+1*1122+1*1136","name":"高强淋膜纸","unit2":"mm","width":1000.0000000},{"num":1,"product":"1*1336+2*1317+1*1265+1*1337+1*1325+2*1272+1*1352+1*1333+1*1309+1*1367","name":"高强淋膜纸","unit2":"mm","width":1200.0000000}],"signatoryPhone":"13111111303","list":[{"companyAlias":"1628","unit2":"kg","units":"kg","productCount":1,"specifications":null,"productName":"高强淋膜纸","number":"J1TY120TY120P18","sizeOther1":null,"bz":"柜号/柜号:TEMU7327011/7340985<br/>共计:","planId":"1562016665272561666","sizeLength":4334.0000000,"sizeWidth":1000.0000000,"weight":"1*1127+1*1160+2*1137+1*1129+1*1145+1*1133+1*1150+1*1122+1*1136+","productBz":"4500346815","sizeWeight":1127.0000000,"associatedPo":"","subtotal":"92298.04","squareUnitPrice":8.1134,"salesman":"谢国庆","squareNum":"11376"},{"companyAlias":"1628","unit2":"kg","units":"kg","productCount":1,"specifications":null,"productName":"高强淋膜纸","number":"J1TY120TY120P18","sizeOther1":null,"bz":"柜号/柜号:TEMU7327011/7340985<br/>共计:","planId":"1562016665272561666","sizeLength":4221.0000000,"sizeWidth":1200.0000000,"weight":"1*1336+2*1317+1*1265+1*1337+1*1325+2*1272+1*1352+1*1333+1*1309+1*1367+","productBz":"4500346815","sizeWeight":1336.0000000,"associatedPo":"","subtotal":"128207.95","squareUnitPrice":8.1134,"salesman":"谢国庆","squareNum":"15802"}],"companyContacts":"634","allTotal":220505.98,"contactsPhone":"13111111303","capitalChineseAllTotal":"贰拾贰万零伍佰零伍元玖角捌分","associatedPo":"","capitalChineseTotal":"贰拾贰万零伍佰零伍元玖角玖分","customerTo":"1628","shippingAddress":"江苏盐城大丰区博汇纸业工厂","salesman":"谢国庆","signatory":"634","currentPage":1,"totalSquareNum":27178.000,"customer":"江苏博汇纸业有限公司"}]
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 + "<span style='margin: 2px 0 4px 0;'>" + sizeWidth + frequency + "件:" + detailsBox.substr(0,detailsBox.length - 1)+ " </span><br/>";
}
}
// 备注的判断
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;
}
// 如果用户在发货单备注有“共计:”,则显示明细数据;如果没有,则清除明细数据里的数据
if(a.indexOf('共计:') == '-1'){
bzDetails = '';
}
// 明细数据传给新字段
data['bzDetails'] = bzDetails;
// 如果用户在发货单备注有“柜号/封号”,则分割开来,把它放到另外一个字段里面去
if(a.indexOf('柜号/封号') != '-1'){
let bzsplit = data["bz"].split("柜号/封号");
data["bz"] = bzsplit[0];
// 明细数据传给新字段
data['cabinet'] ="柜号/封号"+ bzsplit[1];
}
}
// 其他费用的特殊判断,后台修复后删除!
let detail = data["list"];
for(let i = 0;i < detail.length;i++){
let d = detail[i];
if(d['number'] == null && d['sizeWeight'] == 1){
data["list"][i]['productName'] = '其他费用';
}
}
// 定义弹框的内容
let detail1 = data["list"];
async function alertInput(text,acquiesce,name){
// let str = prompt(text, acquiesce);
let t;
if(str != null){
t = str;
}
// 把新字段塞到列表里面去
data[name + ""] = t;
// 把规格详细数据拿出来并组合
for(let i = 0;i < detail1.length;i++){
let d = detail1[i];
// 把新字段塞到明细里面去
if(d.productName){
data["list"][i]["" + name] = t;
}
}
}
// 1、为弹框的提醒文字; 2、为填写的默认文字 3、为返回字段的英文字符
alertInput("请输入税率", "13%","test");
// alertInput("请输入出货方式", "送货","CHFS");
// alertInput("请输入结算方式", "月结","JSFS");
// console.log(data);
// console.log(data['bz']);
// console.log(data['bzDetails']);
// console.log(data['cabinet']);
// console.log(data['bz']);
// return data; //返回处理完的数据
console