tag-change.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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">请扫描待更换的物料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="row flex-start">
  24. <view class="label">
  25. 物料编码:
  26. </view>
  27. <view class="value">
  28. {{ data.materialCode }}
  29. </view>
  30. </view>
  31. <view class="row flex-start">
  32. <view class="label">
  33. 物料名称:
  34. </view>
  35. <view class="value">
  36. {{ data.materialName }}
  37. </view>
  38. </view>
  39. <view class="row flex-start">
  40. <view class="label">
  41. 物料规格:
  42. </view>
  43. <view class="value">
  44. {{ data.spec }}
  45. </view>
  46. </view>
  47. <view class="row flex-start">
  48. <view class="label">
  49. 物料单位:
  50. </view>
  51. <view class="value">
  52. {{ data.unitName }}
  53. </view>
  54. </view>
  55. <view class="row flex-start">
  56. <view class="label">
  57. 物料长度:
  58. </view>
  59. <view class="value">
  60. {{ data.quantity }}
  61. <span style="padding: 0 10rpx;">米</span>
  62. </view>
  63. </view>
  64. <view class="row" style="align-items: center;justify-content: flex-start;">
  65. <view class="col" style="align-items: center;">
  66. <view class="label">
  67. 修正长度:
  68. </view>
  69. <view class="value">
  70. <u-input v-model="quantity" type="number" :border="true"/>
  71. </view>
  72. <span style="margin-left: 10rpx;">米</span>
  73. </view>
  74. </view>
  75. <view class="btn flex-column-center" v-if="!isReading">
  76. <view class="row">
  77. <u-button throttleTime="300" type="primary" style="width: 100%;border-radius: 0;" @click="bind">继续</u-button>
  78. </view>
  79. <view class="row" style="justify-content: flex-end;">
  80. <a href="#" @tap="toNewTag">标签损坏?</a>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. // #ifdef APP-PLUS
  89. // #endif
  90. export default {
  91. data() {
  92. return {
  93. quantity: '',
  94. isReading: true,
  95. data: {},
  96. rfidCode: 'rfid-3',
  97. isActive: true,
  98. };
  99. },
  100. methods: {
  101. toNewTag() {
  102. this.$utils.open('/pages/tag/tag')
  103. },
  104. bind() {
  105. if(!this.quantity) {
  106. return this.$msg.showToast('请输入物料长度!')
  107. }
  108. let data = {
  109. stockTagId: this.data.stockTagId,
  110. quantity: this.quantity
  111. }
  112. this.$utils.open(`/pages/tag/tag-change-scan?data=${this.$utils.object2Code(data)}`)
  113. },
  114. /* rfid获取绑定物料信息 */
  115. getList() {
  116. this.$http.ScanRfidCodeStockTag({
  117. rfidCode: this.rfidCode
  118. }).then(res => {
  119. console.log(res)
  120. if(res.code === 0) {
  121. this.isReading = false
  122. this.data = res.result
  123. } else {
  124. this.$msg.showToast(res.msg)
  125. if(this.isActive) {
  126. this.scanRfid()
  127. }
  128. }
  129. })
  130. },
  131. scanRfid() {
  132. this.$pda.uhfScan().then(res => {
  133. console.log(res)
  134. this.rfidCode = res[0].epc
  135. this.getList()
  136. console.log(this.rfidCode)
  137. }).catch(() => {
  138. this.$msg.showToast('未识别到有效RFID标签!')
  139. setTimeout(() => {
  140. this.$utils.back()
  141. }, 1000)
  142. })
  143. }
  144. },
  145. onLoad() {
  146. this.isActive = true
  147. this.scanRfid()
  148. uni.$on('clear', res => {
  149. this.quantity = ''
  150. })
  151. },
  152. onUnload() {
  153. this.isActive = false
  154. uni.$off('clear')
  155. this.$pda.uhfStop()
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .container-wrap {
  161. overflow: hidden;
  162. .container {
  163. padding: 0 10rpx;
  164. height: calc(100vh - var(--status-bar-height) - 44px);
  165. overflow: auto;
  166. .title {
  167. padding: 20rpx 0;
  168. font-size: 36rpx;
  169. font-weight: bold;
  170. text-align: center;
  171. }
  172. .reading {
  173. padding: 40rpx 0;
  174. }
  175. .info {
  176. padding: 20rpx 60rpx;
  177. border-radius: 10rpx ;
  178. .row {
  179. align-items: flex-start;
  180. .label {
  181. font-size: 32rpx;
  182. width: 160rpx;
  183. }
  184. .value {
  185. font-size: 32rpx;
  186. flex: 1;
  187. overflow: hidden;
  188. word-wrap: break-word;
  189. }
  190. }
  191. }
  192. .btn {
  193. height: 180rpx;
  194. .row {
  195. padding: 0;
  196. padding-bottom: 10rpx;
  197. width: 100%;
  198. &:last-child {
  199. padding-bottom: 0;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. </style>