dispatch-check-scan.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <!-- 每日盘点扫描 -->
  2. <template>
  3. <view class="container-wrap">
  4. <uni-nav-bar :title="isReading ? '扫描中' : '扫描结果'" :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 v-if="!isReading" class="info">
  16. <view class="row flex-start">
  17. <view class="col">
  18. <view class="label">
  19. 物料类型:
  20. </view>
  21. <view class="value">
  22. {{ data.materialType }}
  23. </view>
  24. </view>
  25. <view class="col">
  26. <view class="label">
  27. 标签编码:
  28. </view>
  29. <view class="value">
  30. {{ data.materialCode }}
  31. </view>
  32. </view>
  33. </view>
  34. <view class="row flex-start">
  35. <view class="col">
  36. <view class="label">
  37. 物料名称:
  38. </view>
  39. <view class="value">
  40. {{ data.materialName }}
  41. </view>
  42. </view>
  43. </view>
  44. <view class="row flex-start">
  45. <view class="col">
  46. <view class="label">
  47. 所在仓库:
  48. </view>
  49. <view class="value">
  50. {{ data.saveHouse }}
  51. </view>
  52. </view>
  53. <view class="col">
  54. <view class="label">
  55. 放置区域:
  56. </view>
  57. <view class="value">
  58. {{ data.stockArea }}
  59. </view>
  60. </view>
  61. </view>
  62. <view class="row flex-start">
  63. <view class="col">
  64. <view class="label">
  65. 库存件数:
  66. </view>
  67. <view class="value">
  68. {{ data.tagNum }}
  69. </view>
  70. </view>
  71. <view class="col">
  72. <view class="label">
  73. 库存数量:
  74. </view>
  75. <view class="value">
  76. {{ data.quantity }}
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <!-- 扫描rfid -->
  82. <view class="reading">
  83. <u-image height="200rpx" mode="aspectFit" src="../../../static/images/rfid.png"></u-image>
  84. <view class="title" v-if="isReading">扫描中...</view>
  85. <view class="title" v-if="!isReading">批量扫描中...</view>
  86. </view>
  87. <!-- 扫描列表 -->
  88. <view class="info bottom-list" style="background-color: #FFFFFF;">
  89. <view class="row"
  90. v-for="(item, index) in list"
  91. :key="index"
  92. :style="{color: item.statusColor || '#b0b0b0'}"
  93. >
  94. <view class="col" style="flex: 3;overflow: hidden;color: inherit;">
  95. <view class="label" style="width: 120rpx;">标签值:</view>
  96. <view class="value">{{ item.rfidCode }}</view>
  97. </view>
  98. <view class="col" style="flex: 1;color: inherit;">
  99. <view class="label">物料数量:</view>
  100. <view class="value">{{ item.quantity }}</view>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="info">
  105. <view class="row">
  106. <view class="col">
  107. <view class="label">库存件数:</view>
  108. <view class="value">{{ list.length }}</view>
  109. </view>
  110. <view class="col">
  111. <view class="label">扫描件数:</view>
  112. <view class="value">{{ list.filter(item => (item.statusColor == 'red' || item.statusColor == 'black')).length }}</view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <view class="btn">
  118. <my-fixed-button :customClick="true" @click="over" text="结束盘点"></my-fixed-button>
  119. </view>
  120. </view>
  121. </template>
  122. <script>
  123. const uhf = uni.requireNativePlugin('js-uhf');
  124. export default {
  125. data() {
  126. return {
  127. scanResult: {},
  128. timer: null,
  129. rfidCodeList: [],
  130. quantity: 0,
  131. isReading: false,
  132. data: {},
  133. list: [],
  134. rfidCode: ''
  135. };
  136. },
  137. methods: {
  138. over() {
  139. this.$pda.uhfStop()
  140. let list = this.list.filter(item => item.statusColor !== 'black')
  141. if (list.length > 0) {
  142. this.$utils.open(`/pages/store-manage/dispatch-check/dispatch-check-result?data=${JSON.stringify(this.data)}&list=${JSON.stringify(list)}&rfidItems=${JSON.stringify(this.rfidCodeList)}`)
  143. } else {
  144. this.$http.CompleteBatchCheck({
  145. materialCode: this.data.materialCode,
  146. stockHouseId: this.data.stockHouseId,
  147. rfidItems: this.rfidCodeList
  148. }).then(res => {
  149. console.log(res)
  150. if(res.code === 0) {
  151. this.$utils.back()
  152. uni.$emit('getlist')
  153. }
  154. })
  155. }
  156. },
  157. back() {
  158. this.$utils.back()
  159. },
  160. getList() {
  161. this.$http.GetStockDetailRfid({
  162. materialCode: this.data.materialCode,
  163. stockHouseId: this.data.stockHouseId
  164. }).then(res => {
  165. console.log(res)
  166. if(res.code === 0) {
  167. this.list = res.result
  168. }
  169. })
  170. },
  171. handleList (list) {
  172. list.forEach(item => {
  173. if (this.rfidCodeList.indexOf(item.epc) == -1) {
  174. this.rfidCodeList.push(item.epc)
  175. }
  176. })
  177. },
  178. scanRfid () {
  179. uhf.starts({}, res => {
  180. // console.log(res)
  181. if(res.data[0]) {
  182. if(this.rfidCodeList.length === 0) {
  183. this.rfidCodeList.push(res.data[0].epc)
  184. } else {
  185. this.handleList(res.data)
  186. }
  187. }
  188. })
  189. this.timer = setInterval(() => {
  190. this.$http.GetEveryDayCheckRfid({
  191. materialCode: this.data.materialCode,
  192. stockHouseId: this.data.stockHouseId,
  193. rfidItems: this.rfidCodeList,
  194. isUnShowLoading: true
  195. }).then(res => {
  196. if(res.code === 0) {
  197. this.scanResult = res.result
  198. /* 数据比对 匹配到的修改为黑色 未匹配到的改为灰色 列表中不存在的则添加并改为红色 */
  199. this.scanResult.rfidItems.forEach(outItem => {
  200. let flag = true
  201. this.list.forEach(inItem => {
  202. if (outItem.rfidCode === inItem.rfidCode) {
  203. if(inItem.statusColor === 'red') {
  204. flag = false
  205. } else {
  206. this.$set(inItem, 'statusColor', 'black')
  207. flag = false
  208. }
  209. }
  210. })
  211. if (flag) {
  212. this.list.push({ ...outItem, statusColor: 'red'})
  213. }
  214. })
  215. }
  216. })
  217. }, 1000)
  218. }
  219. },
  220. onLoad(option) {
  221. this.data = JSON.parse(option.data)
  222. this.getList()
  223. this.scanRfid()
  224. // this.list = [
  225. // { rfidCode: 'a', quantity: 1, statusColor: 'black' },
  226. // { rfidCode: 'b', quantity: 2 },
  227. // { rfidCode: 'c', quantity: 3 },
  228. // { rfidCode: 'd', quantity: 4, statusColor: 'red' },
  229. // { rfidCode: 'e', quantity: 5, statusColor: 'red' },
  230. // { rfidCode: 'f', quantity: 6, statusColor: 'red' }
  231. // ]
  232. },
  233. onUnload() {
  234. this.$pda.uhfStops()
  235. clearInterval(this.timer)
  236. }
  237. }
  238. </script>
  239. <style lang="scss" scoped>
  240. .container-wrap {
  241. overflow: hidden;
  242. .container {
  243. padding: 0 10rpx;
  244. height: calc(100vh - var(--status-bar-height) - 44px);
  245. overflow: hidden;
  246. display: flex;
  247. flex-direction: column;
  248. padding-bottom: 80rpx;
  249. .title {
  250. font-size: 36rpx;
  251. font-weight: bold;
  252. text-align: center;
  253. }
  254. .reading {
  255. padding: 40rpx 0;
  256. }
  257. .info {
  258. padding: 20rpx 60rpx;
  259. border-radius: 10rpx ;
  260. .row {
  261. align-items: flex-start;
  262. .label {
  263. color: inherit;
  264. font-size: 28rpx;
  265. width: 140rpx;
  266. }
  267. .value {
  268. color: inherit;
  269. font-size: 28rpx;
  270. flex: 1;
  271. overflow: hidden;
  272. word-wrap: break-word;
  273. }
  274. }
  275. }
  276. .bottom-list {
  277. flex: 1;
  278. overflow: auto;
  279. }
  280. .btn {
  281. height: 180rpx;
  282. .row {
  283. padding: 0;
  284. padding-bottom: 10rpx;
  285. width: 100%;
  286. &:last-child {
  287. padding-bottom: 0;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. </style>