Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 8x 2x 8x 2x 2x 2x 2x 10x 10x 2x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x | /* eslint-disable for-direction */ import moment from 'moment-timezone'; import labelInformation from '../information'; import stringToStringLiteral from '../../../helpers/conversion/stringToStringLiteral'; function grossWeightFormat(value) { let valueGross = value; Iif (typeof valueGross !== 'number') { valueGross = parseFloat(value); } const valueFormat = String(valueGross.toFixed(3)).replace('.', ','); return valueFormat; } export default async function serialLabel( serial, typeLabel, zplSimulation, languageCode = 'ZPL' ) { const productName = serial.product.name; const sizeName = productName.length; const maxLine = 30; let Desc1 = ''; let Desc2 = ''; let Desc3 = ''; let EAN = ''; let grossWeight = ''; let QuantityPackage = 1; let posEnd1 = 0; let posEnd2 = 0; let posEnd3 = 0; let ZPL = ''; if (sizeName <= maxLine) { posEnd1 = sizeName; } else { for (let nPos = maxLine; nPos < sizeName; nPos -= 1) { if (productName[nPos] === ' ') { posEnd1 = nPos; break; } } if (sizeName <= posEnd1 + maxLine) { posEnd2 = sizeName; } else E{ for ( let nPos2 = posEnd1 + maxLine; nPos2 < productName.length; nPos2 -= 1 ) { if (productName[nPos2] === ' ') { posEnd2 = nPos2; break; } } if (!posEnd2) posEnd2 = posEnd1 + maxLine; if (sizeName <= posEnd2 + maxLine) { posEnd3 = sizeName; } else { for ( let nPos3 = posEnd2 + maxLine; nPos3 < productName.length; nPos3 -= 1 ) { if (productName[nPos3] === ' ') { posEnd3 = nPos3; break; } } if (!posEnd3) posEnd3 = posEnd2 + maxLine; } } } Desc1 = productName.substring(0, posEnd1); if (posEnd2) { Desc2 = productName.substring(posEnd1 + 1, posEnd2); } Iif (posEnd3) { Desc3 = productName.substring(posEnd2 + 1, posEnd3); } if (serial.product.productEans.length > 0) { QuantityPackage = serial.product.productEans[0].factor || 1; EAN = serial.product.productEans[0].ean; } else E{ EAN = serial.productCode; } grossWeight = grossWeightFormat( (serial.product.grossWeight / 1000) * QuantityPackage ); ZPL = ''; const modelLabel = await labelInformation.getLabel( { trigger: `serial${typeLabel}`, active: true, }, { attributes: [`label${languageCode}`], raw: true, nest: true } ); Eif (zplSimulation || modelLabel) { ZPL += stringToStringLiteral( zplSimulation || modelLabel[`label${languageCode}`], { serial, Desc1, Desc2, Desc3, QuantityPackage, grossWeight, EAN, moment, } ); } return ZPL; } |