scan.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="consultation-container uni-column">
  4. <view class="title uni-row">箱号:{{ data.carrier_code }}</view>
  5. <view class="info-row uni-row">
  6. <view class="label">批次号</view>
  7. <view class="value">{{ data.lot_code }}</view>
  8. </view>
  9. <view class="info-row uni-row">
  10. <view class="label">产品描述</view>
  11. <view class="value">{{ data.product_description }}</view>
  12. </view>
  13. <view class="info-row uni-row">
  14. <view class="label">当前工序</view>
  15. <view class="value">{{ data.current_process }}</view>
  16. </view>
  17. <view class="info-row uni-row">
  18. <view class="label">投产数量</view>
  19. <view class="value">{{ data.production_quantity }}</view>
  20. </view>
  21. <input type="text" v-model="carrierCode" placeholder="请输入箱号" />
  22. <view class="btn uni-row" style="background-color: #ff5555;" @click.stop="handleScanCode">
  23. <uni-icons type="scan" size="16" style="color: #ffffff; margin-right: 8rpx;" />
  24. <text>扫描箱码</text>
  25. </view>
  26. <view class="btn uni-row" style="margin-top: 48rpx;" @click.stop="handleConfirm">确定</view>
  27. </view>
  28. </view>
  29. </template>
  30. <script setup>
  31. import { ref } from 'vue'
  32. import { onLoad, onReady, onUnload, onShow } from '@dcloudio/uni-app'
  33. const carrierCode = ref('')
  34. const data = ref({
  35. carrier_id: '',
  36. carrier_code: '',
  37. lot_id: 'D2423156000691',
  38. lot_code: 'D2423156000691',
  39. product_description: '',
  40. current_process: '热处理',
  41. production_quantity: 300
  42. })
  43. // 页面生命周期函数
  44. onLoad(() => {})
  45. // 扫码
  46. const handleScanCode = () => {
  47. uni.scanCode({
  48. onlyFromCamera: true,
  49. success: function (res) {
  50. if (res.scanType !== 'QR_CODE') {
  51. uni.showToast({
  52. icon: 'none',
  53. title: '二维码未识别成功',
  54. duration: 2000
  55. })
  56. return
  57. }
  58. const result = JSON.parse(res.result)
  59. console.log(result)
  60. // 此处根据拿到的箱子id,获取到相对应的【 lot_id 】,【 lot_code 】,以及该批次关联的其它箱号
  61. // 需要定义一个请求方法,从后端获取
  62. data.value.carrier_id = result.carrierId
  63. data.value.carrier_code = result.carrierCode
  64. }
  65. });
  66. }
  67. // 确定后,将批次id,批次号,传递过去
  68. const handleConfirm = () => {
  69. uni.navigateTo({
  70. url: '/pages/processInspection/form?lotId=' + data.value.lot_id + '&lotCode=' + data.value.lot_code
  71. })
  72. // if (type === 'ok') {
  73. // uni.navigateBack()
  74. // }
  75. }
  76. </script>
  77. <style lang="scss">
  78. .page-container {
  79. height: 100%;
  80. background-color: #ececec;
  81. font-size: 28rpx;
  82. padding: 24rpx;
  83. box-sizing: border-box;
  84. }
  85. .consultation-container {
  86. background-color: #ffffff;
  87. padding: 24rpx;
  88. border-radius: 12rpx;
  89. .title {
  90. justify-content: center;
  91. font-size: 32rpx;
  92. font-weight: 700;
  93. }
  94. .info-row {
  95. margin-top: 24rpx;
  96. .label {
  97. width: 160rpx;
  98. }
  99. .value {
  100. flex: 1;
  101. textarea {
  102. flex: 1;
  103. border: 1px solid #888888;
  104. box-sizing: border-box;
  105. padding: 16rpx;
  106. }
  107. }
  108. }
  109. .btn {
  110. background-color: #1684fc;
  111. color: #ffffff;
  112. border-radius: 8rpx;
  113. margin: 4rpx 24rpx 24rpx 24rpx;
  114. height: 64rpx;
  115. justify-content: center;
  116. align-items: center;
  117. }
  118. input {
  119. margin: 48rpx 24rpx 0 24rpx;
  120. height: 64rpx;
  121. border: 1px solid #888888;
  122. text-align: center;
  123. }
  124. }
  125. </style>