print-test.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div id>
  3. <remote-css cdn="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css"></remote-css>
  4. <!-- <button type="button" @click="doPrint()">打印</button>-->
  5. <!--startprint-->
  6. <div class="page" id="printMe" style="margin-left: 20mm;">
  7. <div class="top-title">
  8. <p class="ref-title">重庆壳牌能源有限公司中央仓收货单</p>
  9. </div>
  10. <div class="order-info px-4 mb-2">
  11. <div>
  12. <span>收货日期:</span><span>${_receiptModel.workDate}</span>
  13. <span>订单编号:</span><span>${_receiptModel.sheetId}</span>
  14. <span>相关单号:</span><span>${_receiptModel.refSheetId}</span>
  15. </div>
  16. <div>
  17. <span>供应商:</span><span>${_receiptModel.vender}</span>
  18. </div>
  19. </div>
  20. <div>
  21. <table class="table">
  22. <thead>
  23. <tr>
  24. <th nowrap class="font-weight-normal">商品条码</th>
  25. <th nowrap class="font-weight-normal px-0">商品名称</th>
  26. <th nowrap class="text-center font-weight-normal">箱装数</th>
  27. <th nowrap class="text-center font-weight-normal">预定箱数</th>
  28. <th nowrap class="text-center font-weight-normal">预定总数</th>
  29. <th nowrap class="text-center font-weight-normal">保质期</th>
  30. <th nowrap class="text-center font-weight-normal">推荐库位</th>
  31. <th nowrap class="text-center font-weight-normal">生产日期</th>
  32. </tr>
  33. </thead>
  34. <tbody>
  35. <tr><td>商品条码1</td><td>商品名称</td><td>箱装数</td><td>预定箱数</td><td>预定总数</td><td>保质期</td><td>推荐库位</td><td>生产日期</td></tr><tr><td>商品条码2</td><td>商品名称</td><td>箱装数</td><td>预定箱数</td><td>预定总数</td><td>保质期</td><td>推荐库位</td><td>生产日期</td></tr>
  36. <tr><td>商品条码3</td><td>商品名称</td><td>箱装数</td><td>预定箱数</td><td>预定总数</td><td>保质期</td><td>推荐库位</td><td>生产日期</td></tr>
  37. <tr><td>商品条码4</td><td>商品名称</td><td>箱装数</td><td>预定箱数</td><td>预定总数</td><td>保质期</td><td>推荐库位</td><td>生产日期</td></tr>
  38. <tr><td>商品条码5</td><td>商品名称</td><td>箱装数</td><td>预定箱数</td><td>预定总数</td><td>保质期</td><td>推荐库位</td><td>生产日期</td></tr>
  39. <tr><td>商品条码6</td><td>商品名称</td><td>箱装数</td><td>预定箱数</td><td>预定总数</td><td>保质期</td><td>推荐库位</td><td>生产日期</td></tr>
  40. <tr><td>商品条码7</td><td>商品名称</td><td>箱装数</td><td>预定箱数</td><td>预定总数</td><td>保质期</td><td>推荐库位</td><td>生产日期</td></tr>
  41. <tr><td>商品条码8</td><td>商品名称</td><td>箱装数</td><td>预定箱数</td><td>预定总数</td><td>保质期</td><td>推荐库位</td><td>生产日期</td></tr>
  42. </tbody>
  43. </table>
  44. </div>
  45. </div>
  46. <el-button v-print="printObj" type="primary" icon="el-icon-printer">打 印</el-button>
  47. <!--endprint-->
  48. </div>
  49. </template>
  50. <script>
  51. import print from 'vue-print-nb';
  52. export default {
  53. name: 'PrintTest',
  54. components: {
  55. 'remote-css': {
  56. render(h) {
  57. return (
  58. <link rel='stylesheet' type='text/css' href={this.cdn} />
  59. )
  60. },
  61. props: {
  62. cdn: {
  63. type: String,
  64. required: true
  65. }
  66. }
  67. }
  68. },
  69. directives: {
  70. print
  71. },
  72. data() {
  73. return {
  74. printObj: {
  75. id: 'printMe'
  76. },
  77. }
  78. },
  79. methods: {
  80. doPrint() {
  81. // let bdhtml=window.document.body.innerHTML;
  82. // let sprnstr="<!--startprint-->"; //开始打印标识字符串有17个字符
  83. // let eprnstr="<!--endprint-->"; //结束打印标识字符串
  84. // let prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); //从开始打印标识之后的内容
  85. // prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); //截取开始标识和结束标识之间的内容
  86. // window.document.body.innerHTML=prnhtml; //把需要打印的指定内容赋给body.innerHTML
  87. window.print();
  88. // window.document.body.innerHTML=bdhtml;
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped>
  94. /*.page {width: 220mm; height: 140mm; position: relative; margin: 0 auto; overflow: hidden;}*/
  95. /*.top-title {position: relative;}*/
  96. .ref-title {font-size: 36px; text-align: center; font-weight: 600;}
  97. .order-info {font-size: 18px;}
  98. th,td {font-size: 18px;}
  99. #printMe {
  100. font-family: "Microsoft YaHei","Arial","黑体",sans-serif;
  101. }
  102. /*.table tbody tr td{overflow: hidden;font-size:5mm; padding-bottom: 5mm;}*/
  103. /*button {position: fixed; right: 10; font-size: 24px;}*/
  104. </style>