scan-box.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="content flex">
  3. <view class="title">
  4. 扫描箱号条形码
  5. </view>
  6. <u-toast ref="uToast"></u-toast>
  7. <view class="box-scan">
  8. <uni-easyinput ref="inputScan" prefixIcon="search" v-model="info.EnchaseId" @click="search" @clear="cleanItem"
  9. :focus="isFocus" @blur="isFocus = false" placeholder="请扫描">
  10. </uni-easyinput>
  11. <!-- <view style="margin: 10px;
  12. margin-left: 0;">{{info.FEntity}}</view>
  13. <view style="margin: 10px;
  14. margin-left: 0;">{{info.BillType}}</view>
  15. <view style="margin: 10px;
  16. margin-left: 0;">{{info.EnchaseId}}</view> -->
  17. </view>
  18. <view class="form-btn flex">
  19. <button @click="back" class="cu-btn bg-gray lg shadow" style="font-size: 40rpx;">上一步</button>
  20. <button @click="cleanItem" class="cu-btn bg-gray lg shadow" style="font-size: 40rpx;">清空</button>
  21. <button @click="next" class="cu-btn bg-blue lg shadow" style="font-size: 40rpx;">下一步</button>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. GetClothesEnchaseByQRCode } from "../../api/enchase";
  28. export default {
  29. data() {
  30. return {
  31. isFocus: true,
  32. info: {
  33. PrdOrgId: '',
  34. BillType: '',
  35. EnchaseId: '',
  36. WorkShopId: '',
  37. OrderNo: '',
  38. BoxNo: '',
  39. MatchNo: '',
  40. boxInvNo: '',
  41. EnchaseTypeId: '',
  42. EnchaseType: '',
  43. Note: '',
  44. FEntity: [],
  45. },
  46. };
  47. },
  48. onLoad() {
  49. this.info.BillType = uni.getStorageSync('box_invType');
  50. this.info.PrdOrgId = uni.getStorageSync('box_org');
  51. this.info.WorkShopId = uni.getStorageSync('box_workshopCode');
  52. this.info.EnchaseType = uni.getStorageSync('box_packType');
  53. this.info.EnchaseTypeId = uni.getStorageSync('box_packTypeId');
  54. },
  55. onReady() {
  56. //自动聚焦
  57. },
  58. methods: {
  59. //自动聚焦
  60. focusPoint() {
  61. console.log("执行了聚焦")
  62. this.info.EnchaseId = ""
  63. this.isFocus = false;
  64. this.$nextTick(() => {
  65. this.info.EnchaseId = ""
  66. this.isFocus = true;
  67. });
  68. },
  69. cleanItem() {
  70. this.info.EnchaseId = '',
  71. this.focusPoint()
  72. this.$modal.msgSuccess('已清空!');
  73. },
  74. back() {
  75. uni.reLaunch({
  76. url: "/pages/index/index"
  77. })
  78. },
  79. async next() {
  80. //统一校验
  81. if (!this.info.EnchaseId) {
  82. this.$modal.msgError("箱号不能为空!");
  83. this.focusPoint()
  84. return
  85. }
  86. //按计划装箱
  87. if ("AJHZX" == this.info.BillType) {
  88. console.log("按计划装箱校验----")
  89. //调用接口获得装箱单据编号
  90. let boxInfo = '';
  91. try{
  92. const res = await GetClothesEnchaseByQRCode(this.info.EnchaseId)
  93. boxInfo = res
  94. }catch(e){
  95. console.error('GetClothesEnchaseByQRCode', error);
  96. }
  97. console.log(boxInfo)
  98. if (!boxInfo ||JSON.stringify(boxInfo) === '{}') {
  99. this.$refs.uToast.show({
  100. message: '不存在的计划单!',
  101. type: 'error',
  102. icon: true
  103. });
  104. this.focusPoint()
  105. return
  106. }
  107. if (boxInfo.FEnchaseBillNo.trim()) {
  108. this.$refs.uToast.show({
  109. message: '已经装箱,请重新扫描其它箱号条形码!',
  110. type: 'error',
  111. icon: true
  112. });
  113. this.focusPoint()
  114. return
  115. }
  116. this.info.EnchaseId = boxInfo.FEnchaseId
  117. this.info.BoxNo = boxInfo.FBoxNum
  118. this.info.PrdOrgId = boxInfo.FOrgId
  119. this.info.WorkShopId = boxInfo.FWorkShopNum
  120. this.info.OrderNo = boxInfo.FOrderNo
  121. this.info.FCustId = boxInfo.FCustId
  122. this.info.FPlanQty = boxInfo.FPlanQty
  123. this.info.MatchNo = boxInfo.FMatchNo
  124. this.info.EnchaseTypeId = boxInfo.FEnchaseTypeId
  125. this.info.EnchaseType = boxInfo.FEnchaseTypeName
  126. this.info.Note = boxInfo.FNote
  127. this.info.FEntity = boxInfo.subDetail
  128. console.log("按计划装箱校验----" + JSON.stringify(this
  129. .info))
  130. }
  131. // 校验成功进入服装扫描页面
  132. this.$tab.navigateTo('/pages/index/scan-clothing?Info=' + encodeURIComponent(JSON.stringify(this
  133. .info)))
  134. },
  135. search() {
  136. // this.info.EnchaseId = '240423135230-00001'
  137. // console.log(this.info.EnchaseId)
  138. let that = this
  139. if(this.info.EnchaseId === ''){
  140. uni.showToast({
  141. title: '请扫描条码',
  142. icon: 'none',
  143. duration: 3000
  144. })
  145. }
  146. //扫描箱号
  147. // uni.scanCode({
  148. // onlyFromCamera: true,
  149. // success: function(res) {
  150. // that.info.EnchaseId = res.result
  151. // console.log('条码类型:' + res.scanType);
  152. // console.log('条码内容:' + res.result);
  153. // }
  154. // });
  155. },
  156. },
  157. }
  158. </script>
  159. <style lang="scss">
  160. .content {
  161. flex-direction: column;
  162. .title {
  163. text-align: center;
  164. padding-top: 20%;
  165. font-size: 85rpx;
  166. color: #8a8a8a;
  167. }
  168. // .form {
  169. // height: 60rpx;
  170. // margin: 0 10%;
  171. // border-bottom: 5rpx solid #245cd5;
  172. // }
  173. .box-scan {
  174. height: 60rpx;
  175. margin: 15% 10%;
  176. border-bottom: 5rpx solid #245cd5;
  177. }
  178. .form-btn {
  179. margin: 50rpx;
  180. justify-content: space-around;
  181. }
  182. }
  183. </style>