import moment from 'moment' export function getServerPrintData(printRow) { let { printFormat, //格式 //备注 } = printRow; let result = []; if (printFormat == 3) {//英文版 result = printEN(printRow) } else { result = printCN(printRow) } return result } function removeChineseCharacters(str) { return str.replace(/[\u4e00-\u9fa5]/g, ''); } function printEN(printRow) { let { id, //id qrCode, //序号 canisterNum, //筒数 grossWeight, //毛重 suttle, //净重 productSpecifications, //规格 productColor, //色泽 lotNum, //批次 boxNum, //箱号 } = printRow; let ENColor = removeChineseCharacters(productColor) || '' let res = [] res.push({ key1: 'GRADE:', key2: productSpecifications, }) res.push({ key1: 'LOT NO.:', key2: qrCode, }) res.push({ key1: 'COLOR NO.:', key2: ENColor + ' ' + lotNum, }) res.push({ key1: 'CONE NO.:', key2: canisterNum, }) res.push({ key1: 'NET WEIGHT:', key2: suttle, }) res.push({ key1: 'GROSS WEIGHT:', key2: grossWeight, }) res.push({ key1: 'CARTON NO:', key2: boxNum, }) return res } function printCN(printRow) { let { qrCode,//序号 machineTool,//机台 boxWeight,//箱重-车重 canisterweight,//筒重 canisterNum,//筒数 grossWeight,//毛重 suttle,//净重 workShifts,//班次 tubeColor,//管色 boxOrderNum, //生成的随机码 myNO,//箱号 productionDate, //日期 printFormat, //格式 productName, //产品名 productSpecifications, //规格 productColor, //色泽 lotNum, //批次 levels,//等级 directionOfTwist,//捻向 directionOfTwistLabel, qrCodeData, boxNum,//箱号 packaging } = printRow; let res = []; res.push({ key1: '品种', key2: productName, key3: '规格', key4: productSpecifications }) res.push({ key1: '批号', key2: lotNum, key3: '色号', key4: productColor }) res.push({ key1: '等级', key2: levels, key3: '箱号', key4: qrCode, key5: boxNum }) res.push({ key1: '筒数', key2: canisterNum + ' ' + tubeColor, key3: '捻向', key4: directionOfTwistLabel }) res.push({ key1: '班次', key2: workShifts + ' ' + machineTool, key3: '日期', key4: moment(new Date(productionDate)).format('YYYY-MM-DD') }) res.push({ key1: '毛重', key2: grossWeight, key3: '净重', key4: suttle }) return res }