printView.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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?nowData.shelfInfo.shelfName: nowData.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 style="margin-top:10px;" v-if="!(nowData&&nowData.shelfInfo)">
  37. <span style="margin-left:16px;">打印数量:</span>
  38. <a-input-number
  39. size="small"
  40. id="replenishmentManagement-printNum"
  41. v-model="printQtyNum"
  42. :min="1"
  43. :max="999999"
  44. :precision="0"
  45. style="width:63%;"/>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="btn-cont">
  50. <a-button type="primary" id="replenishmentManagement-printSticker-modal-save" @click="handleSave">确定打印</a-button>
  51. <a-button id="replenishmentManagement-printSticker-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  52. </div>
  53. </a-modal>
  54. </template>
  55. <script>
  56. import { commonMixin } from '@/utils/mixin'
  57. import moment from 'moment'
  58. import vueQr from 'vue-qr'
  59. import { JGPrintTag } from '@/libs/JGPrint'
  60. import { STable, VSelect } from '@/components'
  61. export default {
  62. name: 'PrintStickerModal',
  63. components: { STable, VSelect, vueQr },
  64. mixins: [commonMixin],
  65. props: {
  66. openModal: { // 弹框显示状态
  67. type: Boolean,
  68. default: false
  69. }
  70. },
  71. data () {
  72. return {
  73. isShow: false,
  74. nowData: null, // 当前数据
  75. list: [], // 打印明细列表
  76. printQtyNum: 1// 默认打印数量
  77. }
  78. },
  79. methods: {
  80. moment: moment,
  81. // 开始打印
  82. handleSave () {
  83. for (let i = 0; i < this.list.length; i++) {
  84. const item = this.list[i]
  85. item.dealerName = this.nowData.dealerName
  86. item.qrCodeContent = `${item.shelfSn}&${item.productCode}&${item.productSn}&${item.shelfPlaceSn}`
  87. item.shelfName = this.nowData.shelfInfo ? this.nowData.shelfInfo.shelfName : this.nowData.shelfName
  88. item.printTime = moment().format('YYYY-MM-DD HH:mm')
  89. if (!(this.nowData && this.nowData.shelfInfo)) {
  90. item.printQty = this.printQtyNum
  91. }
  92. JGPrintTag('60mm', '40mm', item)
  93. }
  94. },
  95. // 设置值
  96. setData (nowData, list) {
  97. const dearInfo = this.$store.state.user.info
  98. this.nowData = nowData
  99. this.list = list
  100. this.nowData.dealerName = dearInfo.orgName
  101. this.nowData.dealerSn = dearInfo.orgSn
  102. this.nowData.parintUser = dearInfo.userNameCN
  103. }
  104. },
  105. watch: {
  106. // 父页面传过来的弹框状态
  107. openModal (newValue, oldValue) {
  108. this.isShow = newValue
  109. },
  110. // 重定义的弹框状态
  111. isShow (newValue, oldValue) {
  112. if (!newValue) {
  113. this.nowData = null
  114. this.list = []
  115. this.$emit('close')
  116. }
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="less">
  122. .replenishmentManagement-printSticker-modal {
  123. .btn-cont {
  124. text-align: center;
  125. margin: 35px 0 10px;
  126. }
  127. .print-pages{
  128. border-bottom: 1px solid #eee;
  129. }
  130. }
  131. </style>