printView.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <a-modal
  3. centered
  4. class="replenishmentManagement-printSticker-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="打印预览"
  8. v-model="isShow"
  9. @cancel="isShow = false"
  10. :width="400">
  11. <!-- 列表 -->
  12. <div id="print">
  13. <div
  14. v-for="(item,index) in list"
  15. :key="index"
  16. class="print-pages"
  17. style="font-size: 12px;padding:10pt 15pt;width:300px;margin:0 auto;">
  18. <div class="storeName" style="text-align: center;margin: 5pt 0 0;">
  19. {{ nowData.dealerName }}
  20. </div>
  21. <div class="storeName" style="text-align: center;margin: 0pt 0 10pt;">
  22. {{ nowData.shelfInfo.shelfName }}
  23. </div>
  24. <div style="overflow: hidden;">
  25. <div style="float: left;">
  26. <div class="qrcode" ref="qrCodeUrl" style="text-align: center;">
  27. <vue-qr :text="`${item.shelfSn}&${item.productCode}&${item.productSn}&${item.shelfPlaceSn}`" :margin="0" :size="70"></vue-qr>
  28. </div>
  29. </div>
  30. <div style="float: left;padding-left:10pt;width: 60%;">
  31. <div class="productSno" style="font-size: 30pt;height:30pt;line-height:30pt;">{{ item.shelfPlaceCode }}</div>
  32. <div class="productCode" style="margin-top: 2pt;font-size:12pt;">{{ item.productCode }}</div>
  33. <div style="margin: 2pt 0;">{{ moment().format('YYYY-MM-DD HH:mm') }}</div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="btn-cont">
  39. <a-button type="primary" id="replenishmentManagement-printSticker-modal-save" @click="handleSave">确定打印</a-button>
  40. <a-button id="replenishmentManagement-printSticker-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  41. </div>
  42. </a-modal>
  43. </template>
  44. <script>
  45. import { commonMixin } from '@/utils/mixin'
  46. import moment from 'moment'
  47. import vueQr from 'vue-qr'
  48. import { JGPrintTag } from '@/libs/JGPrint'
  49. import { STable, VSelect } from '@/components'
  50. export default {
  51. name: 'PrintStickerModal',
  52. components: { STable, VSelect, vueQr },
  53. mixins: [commonMixin],
  54. props: {
  55. openModal: { // 弹框显示状态
  56. type: Boolean,
  57. default: false
  58. }
  59. },
  60. data () {
  61. return {
  62. isShow: false,
  63. nowData: null,
  64. list: []
  65. }
  66. },
  67. methods: {
  68. moment: moment,
  69. // 开始打印
  70. handleSave () {
  71. for (let i = 0; i < this.list.length; i++) {
  72. const item = this.list[i]
  73. item.dealerName = this.nowData.dealerName
  74. item.qrCodeContent = `${item.shelfSn}&${item.productCode}&${item.productSn}&${item.shelfPlaceSn}`
  75. item.shelfName = this.nowData.shelfInfo.shelfName
  76. item.printTime = moment().format('YYYY-MM-DD HH:mm')
  77. JGPrintTag('60mm', '40mm', item)
  78. }
  79. },
  80. setData (nowData, list) {
  81. const dearInfo = this.$store.state.user.info
  82. this.nowData = nowData
  83. this.list = list
  84. this.nowData.dealerName = dearInfo.orgName
  85. this.nowData.dealerSn = dearInfo.orgSn
  86. this.nowData.parintUser = dearInfo.userNameCN
  87. console.log(this.list)
  88. }
  89. },
  90. watch: {
  91. // 父页面传过来的弹框状态
  92. openModal (newValue, oldValue) {
  93. this.isShow = newValue
  94. },
  95. // 重定义的弹框状态
  96. isShow (newValue, oldValue) {
  97. if (!newValue) {
  98. this.nowData = null
  99. this.list = []
  100. this.$emit('close')
  101. }
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="less">
  107. .replenishmentManagement-printSticker-modal {
  108. .btn-cont {
  109. text-align: center;
  110. margin: 35px 0 10px;
  111. }
  112. .print-pages{
  113. border-bottom: 1px solid #eee;
  114. }
  115. }
  116. </style>