sendOutGoods.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="sendOutGoods-wrap">
  3. <view class="barCode" id="barcode"></view>
  4. <view class="info-body">
  5. <view class="info partList">
  6. <!-- 补货产品 -->
  7. <partList :list="partList" title="补货产品" model="view" fromPage="sendOutGoods" ref="partList" noDataText="暂无产品"></partList>
  8. </view>
  9. </view>
  10. <!-- 确认弹框 -->
  11. <common-modal v-if="confirmModal" :openModal="confirmModal" title="扫码失败" content="确认对该数字货架进行补货吗?" confirmText="好的" :isCancel="false" @confirm="modalConfirm" @close="confirmModal=false" />
  12. </view>
  13. </template>
  14. <script>
  15. import partList from '@/pages/common/partList.vue'
  16. import commonModal from '@/pages/common/commonModal.vue'
  17. import { shelfReplenishDetailList, shelfReplenishQrCode } from '@/api/shelfReplenish'
  18. export default {
  19. components: { partList, commonModal },
  20. data() {
  21. return {
  22. barcode:null,
  23. replenishBillSn: null,
  24. partList: [],
  25. confirmModal: false
  26. }
  27. },
  28. onReady() {
  29. // 初始化摄像头
  30. // this.init()
  31. },
  32. onLoad(options) {
  33. this.replenishBillSn = options.replenishBillSn
  34. this.getPartList()
  35. },
  36. methods: {
  37. // 查询列表
  38. getPartList(){
  39. const _this = this
  40. shelfReplenishDetailList({ replenishBillSn: this.replenishBillSn }).then(res => {
  41. if(res.status == 200 && res.data){
  42. res.data.map(item =>{
  43. item.confirmQty = item.confirmQty ? Number(item.confirmQty) : 0
  44. })
  45. this.partList = res.data || []
  46. }else{
  47. this.partList = []
  48. }
  49. })
  50. },
  51. // 扫码结果
  52. scanResult(qrCode){
  53. const _this = this
  54. shelfReplenishQrCode({
  55. qrCode: qrCode,
  56. replenishBillSn: this.replenishBillSn
  57. }).then(res => {
  58. if(res.status == 200){
  59. _this.toashMsg("扫码成功!")
  60. uni.navigateTo({ url: "/pages/common/printTag/printTag?sn="+item.replenishBillSn })
  61. }else{
  62. this.confirmModal = true
  63. // clzConfirm({
  64. // title: '扫码失败',
  65. // content: res.message,
  66. // showCancel: false,
  67. // success: (ret) => {
  68. // _this.barcode.start()
  69. // }
  70. // })
  71. }
  72. })
  73. },
  74. modalConfirm(){
  75. this.confirmModal = false
  76. this.barcode.start()
  77. },
  78. init(){
  79. const _this = this
  80. // 初始化
  81. this.barcode = plus.barcode.create('barcode', [], {
  82. top:'0px',
  83. left:'0px',
  84. width: '100%',
  85. height: '28%',
  86. position: 'static',
  87. frameColor: '#00aaff',
  88. scanbarColor: '#00aaff'
  89. })
  90. // 设置高度
  91. const query = uni.createSelectorQuery().in(this);
  92. query.select('#barcode').boundingClientRect(data => {
  93. this.barcode.setStyle({
  94. height: data.height + 'px' // 调整扫码控件的位置
  95. })
  96. }).exec()
  97. // 扫码成功后
  98. this.barcode.onmarked = function(type, result) {
  99. _this.scanResult(result)
  100. }
  101. // 扫码识别出错
  102. this.barcode.onerror = function(error){
  103. console.log(error)
  104. _this.toashMsg("条形码错误!")
  105. _this.barcode.start()
  106. }
  107. const currentWebview = this.$mp.page.$getAppWebview()
  108. currentWebview.append(this.barcode)
  109. this.barcode.start()
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="less">
  115. page{
  116. height: 100vh;
  117. }
  118. .sendOutGoods-wrap{
  119. width: 100%;
  120. height: 100%;
  121. .barCode{
  122. height: 28%;
  123. }
  124. .info-body{
  125. flex-flow: 1;
  126. overflow: auto;
  127. height: 72%;
  128. }
  129. .info{
  130. background-color: #FFFFFF;
  131. padding: 10rpx 30upx;
  132. font-size: 32rpx;
  133. margin-top: 20rpx;
  134. }
  135. }
  136. </style>