printUtils.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import moment from 'moment'
  2. export function getServerPrintData(printRow) {
  3. let {
  4. printFormat, //格式 //备注
  5. } = printRow;
  6. let result = [];
  7. if (printFormat == 3) {//英文版
  8. result = printEN(printRow)
  9. } else {
  10. result = printCN(printRow)
  11. }
  12. return result
  13. }
  14. function removeChineseCharacters(str) {
  15. return str.replace(/[\u4e00-\u9fa5]/g, '');
  16. }
  17. function printEN(printRow) {
  18. let {
  19. id, //id
  20. qrCode, //序号
  21. canisterNum, //筒数
  22. grossWeight, //毛重
  23. suttle, //净重
  24. productSpecifications, //规格
  25. productColor, //色泽
  26. lotNum, //批次
  27. boxNum, //箱号
  28. } = printRow;
  29. let ENColor = removeChineseCharacters(productColor) || ''
  30. let res = []
  31. res.push({
  32. key1: 'GRADE:',
  33. key2: productSpecifications,
  34. })
  35. res.push({
  36. key1: 'LOT NO.:',
  37. key2: qrCode,
  38. })
  39. res.push({
  40. key1: 'COLOR NO.:',
  41. key2: ENColor + ' ' + lotNum,
  42. })
  43. res.push({
  44. key1: 'CONE NO.:',
  45. key2: canisterNum,
  46. })
  47. res.push({
  48. key1: 'NET WEIGHT:',
  49. key2: suttle,
  50. })
  51. res.push({
  52. key1: 'GROSS WEIGHT:',
  53. key2: grossWeight,
  54. })
  55. res.push({
  56. key1: 'CARTON NO:',
  57. key2: boxNum,
  58. })
  59. return res
  60. }
  61. function printCN(printRow) {
  62. let {
  63. qrCode,//序号
  64. machineTool,//机台
  65. boxWeight,//箱重-车重
  66. canisterweight,//筒重
  67. canisterNum,//筒数
  68. grossWeight,//毛重
  69. suttle,//净重
  70. workShifts,//班次
  71. tubeColor,//管色
  72. boxOrderNum, //生成的随机码
  73. myNO,//箱号
  74. productionDate, //日期
  75. printFormat, //格式
  76. productName, //产品名
  77. productSpecifications, //规格
  78. productColor, //色泽
  79. lotNum, //批次
  80. levels,//等级
  81. directionOfTwist,//捻向
  82. directionOfTwistLabel,
  83. qrCodeData,
  84. boxNum,//箱号
  85. packaging
  86. } = printRow;
  87. let res = [];
  88. res.push({
  89. key1: '品种',
  90. key2: productName,
  91. key3: '规格',
  92. key4: productSpecifications
  93. })
  94. res.push({
  95. key1: '批号',
  96. key2: lotNum,
  97. key3: '色号',
  98. key4: productColor
  99. })
  100. res.push({
  101. key1: '等级',
  102. key2: levels,
  103. key3: '箱号',
  104. key4: qrCode,
  105. key5: boxNum
  106. })
  107. res.push({
  108. key1: '筒数',
  109. key2: canisterNum + ' ' + tubeColor,
  110. key3: '捻向',
  111. key4: directionOfTwistLabel
  112. })
  113. res.push({
  114. key1: '班次',
  115. key2: workShifts + ' ' + machineTool,
  116. key3: '日期',
  117. key4: moment(new Date(productionDate)).format('YYYY-MM-DD')
  118. })
  119. res.push({
  120. key1: '毛重',
  121. key2: grossWeight,
  122. key3: '净重',
  123. key4: suttle
  124. })
  125. return res
  126. }