breakage-apply-scan.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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.supplierName }}
  62. </view>
  63. </view>
  64. <view class="row flex-start">
  65. <view class="label">
  66. 合同批次:
  67. </view>
  68. <view class="value">
  69. {{ data.batchNo }}
  70. </view>
  71. </view>
  72. <view class="row flex-start">
  73. <view class="label">
  74. 数量:
  75. </view>
  76. <view class="value">
  77. {{ data.quantity }}
  78. </view>
  79. </view>
  80. <view class="row flex-start">
  81. <view class="label">
  82. 金额:
  83. </view>
  84. <view class="value">
  85. {{ data.amount }}
  86. </view>
  87. </view>
  88. <view class="row flex-start">
  89. <view class="label">
  90. 申请原因:
  91. </view>
  92. <view class="value">
  93. {{ data.applyReason }}
  94. </view>
  95. </view>
  96. <view class="row flex-start">
  97. <view class="value">
  98. <u-input v-model="applyReason" type="textarea" :border="true" height="150"/>
  99. </view>
  100. </view>
  101. </view>
  102. <view v-if="!isReading" class="row" style="justify-content: flex-start;">
  103. <u-upload
  104. ref="uUpload"
  105. :size-type="['compressed']"
  106. @on-remove="onRemove"
  107. :before-upload="beforeUpload">
  108. </u-upload>
  109. </view>
  110. <view class="btn" v-if="!isReading">
  111. <view class="row">
  112. <u-button throttleTime="300" type="primary" style="width: 100%;" @click="cfm">确定</u-button>
  113. </view>
  114. <view class="row">
  115. <u-button throttleTime="300" type="error" style="width: 100%;" @click="$utils.back()">取消</u-button>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. // #ifdef APP-PLUS
  123. // #endif
  124. export default {
  125. data() {
  126. return {
  127. rfidCode: '',
  128. isReading: true,
  129. data: {},
  130. isActive: true,
  131. applyReason: '',
  132. uploadList: []
  133. };
  134. },
  135. methods: {
  136. beforeUpload(index, list) {
  137. console.log('upload list -------------')
  138. console.log(list)
  139. console.log(index)
  140. uni.compressImage({
  141. src: list[index].url,
  142. quality: 50,
  143. width: '60%',
  144. height: '60%',
  145. success: res => {
  146. plus.io.resolveLocalFileSystemURL(res.tempFilePath,
  147. (entry) => {
  148. entry.file(file => {
  149. let reader = new plus.io.FileReader();
  150. reader.onloadend = ( e ) => {
  151. this.$http.UploadBase64({
  152. fileBase64: e.target.result,
  153. fileName: file.name,
  154. floder: 'ytjImg',
  155. }).then(res => {
  156. console.log(res)
  157. if(res.code === 0) {
  158. // this.form.imageUrl = res.result
  159. this.uploadList.push(res.result)
  160. } else {
  161. this.uploadList.push(null)
  162. }
  163. }).catch(() => {
  164. this.uploadList.push(null)
  165. })
  166. };
  167. reader.readAsDataURL( file );
  168. })
  169. },
  170. (e) => {
  171. console.log(e)
  172. })
  173. }
  174. })
  175. return false
  176. },
  177. onRemove(index) {
  178. // this.form.imageUrl = ''
  179. this.uploadList.splice(index, 1)
  180. },
  181. cfm() {
  182. if(this.uploadList.find(item => item === null) === null) {
  183. this.$msg.showToast('存在上传失败图片 正在重新上传')
  184. this.$refs['uUpload'].reUpload()
  185. this.uploadList = []
  186. return
  187. }
  188. if(!this.applyReason) {
  189. return this.$msg.showToast('请输入申请原因')
  190. }
  191. uni.$emit('scan-list', {
  192. ...this.data,
  193. takeQty: this.data.quantity,
  194. rfidCode: this.rfidCode,
  195. imageUrls: this.uploadList.join(','),
  196. applyReason: this.applyReason
  197. })
  198. this.$utils.back()
  199. },
  200. getList() {
  201. this.$http.ScanRfidCodeStockTag({
  202. rfidCode: this.rfidCode,
  203. checkRfidType: 1,
  204. }).then(res => {
  205. console.log(res)
  206. if(res.code === 0) {
  207. this.isReading = false
  208. this.data = res.result
  209. } else {
  210. this.$msg.showToast(res.msg)
  211. if(this.isActive) {
  212. this.scanRfid()
  213. }
  214. }
  215. })
  216. },
  217. scanRfid() {
  218. this.$pda.uhfScan().then(res => {
  219. console.log(res)
  220. this.rfidCode = res[0].epc
  221. this.getList()
  222. console.log(this.rfidCode)
  223. }).catch(() => {
  224. this.$msg.showToast('未识别到有效RFID标签!')
  225. setTimeout(() => {
  226. this.$utils.back()
  227. }, 1000)
  228. })
  229. }
  230. },
  231. onLoad(option) {
  232. this.isActive = true
  233. this.scanRfid()
  234. },
  235. onUnload() {
  236. this.isActive = false
  237. this.$pda.uhfStop()
  238. }
  239. }
  240. </script>
  241. <style lang="scss" scoped>
  242. .container-wrap {
  243. overflow: hidden;
  244. .container {
  245. padding: 0 60rpx;
  246. padding-bottom: 200rpx;
  247. height: calc(100vh - var(--status-bar-height) - 44px);
  248. overflow: auto;
  249. .title {
  250. padding: 20rpx 0;
  251. font-size: 36rpx;
  252. font-weight: bold;
  253. text-align: center;
  254. }
  255. .reading {
  256. padding: 40rpx 0;
  257. }
  258. .info {
  259. padding: 20rpx 60rpx;
  260. border-radius: 10rpx ;
  261. background-color: #FFFFFF;
  262. .row {
  263. align-items: flex-start;
  264. .label {
  265. font-size: 32rpx;
  266. width: 160rpx;
  267. }
  268. .value {
  269. font-size: 32rpx;
  270. flex: 1;
  271. overflow: hidden;
  272. word-wrap: break-word;
  273. }
  274. }
  275. }
  276. .btn {
  277. padding: 0 60rpx;
  278. position: fixed;
  279. bottom: 20rpx;
  280. left: 0;
  281. width: 100%;
  282. z-index: 9999;
  283. .row {
  284. padding: 0;
  285. width: 100%;
  286. &:last-child {
  287. padding-bottom: 0;
  288. }
  289. }
  290. }
  291. }
  292. /deep/ .u-add-wrap {
  293. background-color: #FFFFFF;
  294. }
  295. }
  296. </style>