index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <!-- 扫码贴标RFID扫描 -->
  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. <view class="title">物料信息</view>
  15. <view class="info">
  16. <view class="row flex-start">
  17. <view class="label">
  18. 序号:
  19. </view>
  20. <view class="value">
  21. {{ data.number }}
  22. </view>
  23. </view>
  24. <view class="row flex-start">
  25. <view class="label">
  26. 合同编码:
  27. </view>
  28. <view class="value">
  29. {{ data.applyBillNo }}
  30. </view>
  31. </view>
  32. <view class="row flex-start">
  33. <view class="label">
  34. 入库单号:
  35. </view>
  36. <view class="value">
  37. {{ data.stockInOutBillNo }}
  38. </view>
  39. </view>
  40. <view class="row flex-start">
  41. <view class="label">
  42. 物料编码:
  43. </view>
  44. <view class="value">
  45. {{ data.materialCode }}
  46. </view>
  47. </view>
  48. <view class="row flex-start">
  49. <view class="label">
  50. 物料名称:
  51. </view>
  52. <view class="value">
  53. {{ data.materialName }}
  54. </view>
  55. </view>
  56. <view class="row flex-start">
  57. <view class="label">
  58. 物料规格:
  59. </view>
  60. <view class="value">
  61. {{ data.spec }}
  62. </view>
  63. </view>
  64. <view class="row flex-start">
  65. <view class="label">
  66. 物料数量:
  67. </view>
  68. <view class="value">
  69. {{ data.quantity }}
  70. </view>
  71. </view>
  72. <view class="row flex-start">
  73. <view class="label">
  74. 物料单位:
  75. </view>
  76. <view class="value">
  77. {{ data.unitName }}
  78. </view>
  79. </view>
  80. </view>
  81. <view v-if="!scanCode">
  82. <my-fixed-button :customClick="true" @click="scan" text="重新扫描二维码"></my-fixed-button>
  83. </view>
  84. <view v-else>
  85. <view class="title">请扫描RFID标签</view>
  86. <u-image height="300rpx" mode="aspectFit" src="../../../static/images/rfid.png"></u-image>
  87. <view class="title" v-if="isReading">扫描中...</view>
  88. <view class="title" v-if="!isReading">扫描成功</view>
  89. <view class="btn" v-if="!isReading">
  90. <u-button throttleTime="300" type="primary" style="width: 100%;margin-bottom: 20rpx;" @click="bind">绑定并继续</u-button>
  91. <u-button throttleTime="300" type="primary" style="width: 100%;" @click="$utils.back()">结束贴标</u-button>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. const pda = uni.requireNativePlugin('js-pda');
  99. export default {
  100. data() {
  101. return {
  102. timer: null,
  103. data: {},
  104. isReading: true,
  105. rfidCode: '',
  106. scanCode: ''
  107. };
  108. },
  109. methods: {
  110. scan() {
  111. clearTimeout(this.timer)
  112. this.$msg.showLoading('扫描中...')
  113. pda.scanCode({}, res => {
  114. this.$msg.hideLoading()
  115. this.scanCode = res.replace('\n', '')
  116. this.getlist(res)
  117. clearTimeout(this.timer)
  118. })
  119. this.timer = setTimeout(() => {
  120. this.$msg.hideLoading()
  121. }, 3000)
  122. },
  123. bind() {
  124. this.$http.BandingStockInRfidCode({
  125. stockTagId: this.data.stockTagId,
  126. rfidCode: this.rfidCode
  127. }).then(res => {
  128. console.log(res)
  129. console.log(this.data.stockTagId)
  130. console.log(this.rfidCode)
  131. if(res.code === 0) {
  132. this.$msg.showToast(res.msg || '绑定成功!')
  133. setTimeout(() => {
  134. this.$utils.back()
  135. uni.$emit('scan')
  136. // this.$utils.uniScanCode().then(res => {
  137. // this.$utils.open(`/pages/store-in-manage/scan-paste/index?data=${res.result}`)
  138. // })
  139. }, 2000)
  140. } else {
  141. this.isReading = true
  142. this.$pda.uhfScan().then(res => {
  143. console.log(res)
  144. this.isReading = false
  145. this.rfidCode = res[0].epc
  146. console.log(this.rfidCode)
  147. }).catch(() => {
  148. this.$msg.showToast('未识别到有效RFID标签!')
  149. setTimeout(() => {
  150. this.$utils.back()
  151. }, 1000)
  152. })
  153. }
  154. })
  155. },
  156. getlist() {
  157. this.$http.ScanStockInQRCode({
  158. scanCode: this.scanCode
  159. }).then(res => {
  160. console.log({
  161. scanCode: this.scanCode
  162. })
  163. console.log(res)
  164. if(res.code === 0) {
  165. this.data = res.result
  166. this.$pda.uhfScan().then(res => {
  167. console.log(res)
  168. this.isReading = false
  169. this.rfidCode = res[0].epc
  170. console.log(this.rfidCode)
  171. }).catch(() => {
  172. this.$msg.showToast('未识别到有效RFID标签!')
  173. setTimeout(() => {
  174. this.$utils.back()
  175. }, 1000)
  176. })
  177. } else {
  178. this.scanCode = ''
  179. }
  180. })
  181. }
  182. },
  183. onLoad(option) {
  184. this.scan()
  185. },
  186. onUnload() {
  187. // #ifdef APP-PLUS
  188. // #endif
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .container-wrap {
  194. background-color: #FFFFFF;
  195. overflow: hidden;
  196. .container {
  197. padding: 0 40rpx;
  198. padding-bottom: 40px;
  199. height: calc(100vh - var(--status-bar-height) - 44px);
  200. overflow: auto;
  201. .title {
  202. padding: 20rpx 0;
  203. font-size: 36rpx;
  204. font-weight: bold;
  205. text-align: center;
  206. }
  207. .info {
  208. .row {
  209. .label {
  210. font-size: 32rpx;
  211. width: 160rpx;
  212. }
  213. .value {
  214. font-size: 32rpx;
  215. flex: 1;
  216. overflow: hidden;
  217. word-wrap: break-word;
  218. }
  219. }
  220. }
  221. }
  222. }
  223. </style>