scan.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <!-- 手动入库扫描添加 -->
  2. <template>
  3. <view class="container-wrap">
  4. <uni-nav-bar title="扫描添加" :status-bar="true" background-color="#3F92F9" color="#FFF">
  5. <view slot="left">
  6. <u-icon name="account-fill" color="#FFF" size="35"></u-icon>
  7. <span style="padding: 0 5rpx;color: #FFFFFF;">{{ userInfo.name }}</span>
  8. </view>
  9. <view slot="right" @tap="$utils.back()">
  10. <span style="color: #FFFFFF;">返回</span>
  11. </view>
  12. </uni-nav-bar>
  13. <view class="container">
  14. <!-- 扫描rfid -->
  15. <view class="reading">
  16. <view class="title">请扫描要入库的<br/>物料RFID标签</view>
  17. <u-image height="300rpx" mode="aspectFit" src="../../static/images/rfid.png"></u-image>
  18. <view class="title" v-if="isReading">扫描中...</view>
  19. <view class="title" v-if="!isReading">扫描结果</view>
  20. </view>
  21. <!-- 扫描到RFID标签时,打开质检结果 -->
  22. <view v-if="!isReading" class="info">
  23. <view class="title">物料信息</view>
  24. <view class="row flex-start">
  25. <view class="label">
  26. 物料标签:
  27. </view>
  28. <view class="value">
  29. {{ data.rfidCode }}
  30. </view>
  31. </view>
  32. <view class="row flex-start">
  33. <view class="label">
  34. 物料编码:
  35. </view>
  36. <view class="value">
  37. {{ data.materialCode }}
  38. </view>
  39. </view>
  40. <view class="row flex-start">
  41. <view class="label">
  42. 物料名称:
  43. </view>
  44. <view class="value">
  45. {{ data.materialName }}
  46. </view>
  47. </view>
  48. <view class="row flex-start">
  49. <view class="label">
  50. 物料规格:
  51. </view>
  52. <view class="value">
  53. {{ data.spec }}
  54. </view>
  55. </view>
  56. <view class="row flex-start">
  57. <view class="label">
  58. 物料数量:
  59. </view>
  60. <view class="value">
  61. {{ data.quantity }}
  62. </view>
  63. </view>
  64. </view>
  65. <view class="btn" v-if="!isReading">
  66. <view class="row">
  67. <u-button throttleTime="300" type="primary" style="width: 100%;" @click="cfm">确定</u-button>
  68. </view>
  69. <view class="row">
  70. <u-button throttleTime="300" type="error" style="width: 100%;" @click="$utils.back()">取消</u-button>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. // #ifdef APP-PLUS
  78. // #endif
  79. export default {
  80. data() {
  81. return {
  82. rfidCode: '',
  83. isReading: true,
  84. data: {},
  85. isActive: true,
  86. };
  87. },
  88. methods: {
  89. cfm() {
  90. const v = this
  91. uni.getStorage({
  92. key: 'reviewDtl',
  93. success: function (res) {
  94. res.data.checkDetailsInfoList[res.data.index].stockBackDetailsList[res.data.jindex].rfid = v.rfidCode
  95. uni.setStorage({
  96. key: 'reviewDtl',
  97. data: res.data,
  98. success: function () {
  99. v.$utils.open(`/pages/warehouse/reviewDtl`)
  100. v.$msg.showToast('扫描成功!')
  101. },fail() {
  102. v.$msg.showToast('扫描失败!')
  103. }
  104. });
  105. }
  106. });
  107. },
  108. getList() {
  109. this.$http.ScanRfidCodeStockTag({
  110. rfidCode: this.rfidCode,
  111. checkRfidType: 2,
  112. }).then(res => {
  113. console.log(res)
  114. if(res.code === 0) {
  115. this.isReading = false
  116. this.data = res.result
  117. } else {
  118. this.$msg.showToast(res.msg)
  119. if(this.isActive) {
  120. this.scanRfid()
  121. }
  122. }
  123. })
  124. },
  125. scanRfid() {
  126. this.$pda.uhfScan().then(res => {
  127. console.log(res)
  128. this.rfidCode = res[0].epc
  129. this.getList()
  130. console.log(this.rfidCode)
  131. }).catch(() => {
  132. this.$msg.showToast('未识别到有效RFID标签!')
  133. setTimeout(() => {
  134. this.$utils.back()
  135. }, 1000)
  136. })
  137. }
  138. },
  139. onLoad(option) {
  140. this.isActive = true
  141. this.scanRfid()
  142. },
  143. onUnload() {
  144. this.isActive = false
  145. this.$pda.uhfStop()
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .container-wrap {
  151. overflow: hidden;
  152. .container {
  153. padding: 0 60rpx;
  154. padding-bottom: 80rpx;
  155. height: calc(100vh - var(--status-bar-height) - 44px);
  156. overflow: auto;
  157. .title {
  158. padding: 20rpx 0;
  159. font-size: 36rpx;
  160. font-weight: bold;
  161. text-align: center;
  162. }
  163. .reading {
  164. padding: 40rpx 0;
  165. }
  166. .info {
  167. padding: 20rpx 60rpx;
  168. border-radius: 10rpx ;
  169. background-color: #FFFFFF;
  170. .row {
  171. align-items: flex-start;
  172. .label {
  173. font-size: 32rpx;
  174. width: 160rpx;
  175. }
  176. .value {
  177. font-size: 32rpx;
  178. flex: 1;
  179. overflow: hidden;
  180. word-wrap: break-word;
  181. }
  182. }
  183. }
  184. .btn {
  185. margin-top: 20rpx;
  186. .row {
  187. padding: 0;
  188. padding-bottom: 10rpx;
  189. width: 100%;
  190. &:last-child {
  191. padding-bottom: 0;
  192. }
  193. }
  194. }
  195. }
  196. }
  197. </style>