scan.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="consultation-container uni-column">
  4. <view class="title uni-row">箱号:{{ lot.carrierCode }}</view>
  5. <view class="info-row uni-row">
  6. <view class="label">批次号</view>
  7. <view class="value">{{ lot.lotCode }}</view>
  8. </view>
  9. <view class="info-row uni-row">
  10. <view class="label">产品描述</view>
  11. <view class="value">{{ lot.productDescription }}</view>
  12. </view>
  13. <view class="info-row uni-row">
  14. <view class="label">当前工序</view>
  15. <view class="value">{{ lot.processAlias }}</view>
  16. </view>
  17. <view class="info-row uni-row">
  18. <view class="label">投产数量</view>
  19. <view class="value">{{ lot.pudName }}</view>
  20. </view>
  21. <view class="info-row uni-row">
  22. <view class="label">所有箱号</view>
  23. <view class="value">{{ lot.allCarrierName }}</view>
  24. </view>
  25. <input type="text" v-model="carrierCode" placeholder="请输入箱号" />
  26. <view class="btn uni-row" style="background-color: #ff5555;" @click.stop="handleScanCode">
  27. <uni-icons type="scan" size="16" style="color: #ffffff; margin-right: 8rpx;" />
  28. <text>扫描箱码</text>
  29. </view>
  30. <view class="btn uni-row" style="margin-top: 48rpx;" @click.stop="handleConfirm">确定</view>
  31. </view>
  32. <dialog-processInspection ref='selectProcessInspection'
  33. @handleSelectProcessInspection='handleSelectProcessInspection'></dialog-processInspection>
  34. </view>
  35. </template>
  36. <script setup>
  37. import {
  38. ref
  39. } from 'vue'
  40. import {
  41. onLoad,
  42. onReady,
  43. onUnload,
  44. onShow
  45. } from '@dcloudio/uni-app'
  46. import {
  47. getLotInfo,
  48. getCarrierInfo,
  49. getLotOutsourcedInfo
  50. } from '@/api/business/processInspection.js'
  51. import {
  52. store
  53. } from '../../store';
  54. const carrierCode = ref('')
  55. const lot = ref({})
  56. const query = ref({})
  57. const selectProcessInspection = ref(null)
  58. // 页面生命周期函数
  59. onLoad(() => {})
  60. // 扫码
  61. const handleScanCode = () => {
  62. // 引入原生插件
  63. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  64. if (mpaasScanModule) {
  65. // 调用插件的 mpaasScan 方法
  66. mpaasScanModule.mpaasScan({
  67. // 扫码识别类型,参数可多选,qrCode、barCode,
  68. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  69. scanType: ["qrCode", "barCode"],
  70. // 是否隐藏相册,默认false不隐藏
  71. hideAlbum: false,
  72. },
  73. (ret) => {
  74. console.log(ret);
  75. const result = JSON.parse(ret.resp_result);
  76. if (!result.carrierId || result.carrierId == "") {
  77. uni.showToast({
  78. icon: "none",
  79. title: "请扫载具码",
  80. duration: 1000
  81. })
  82. return;
  83. }
  84. //判断该箱是否绑定批次
  85. result.processCode = store.outsourcedCode;
  86. /************************ 根据扫码查询到的数据和需要检查的工序查询信息 ************************/
  87. getLotOutsourcedInfo(result).then(resqust => {
  88. if (resqust.code == 200) {
  89. lot.value = resqust.data;
  90. lot.value.carrierCode = result.carrierCode
  91. carrierCode.value = result.carrierCode;
  92. // store.processInspection = null;
  93. console.log("resqust", resqust);
  94. uni.hideLoading();
  95. } else {
  96. // uni.hideLoading();
  97. uni.showToast({
  98. icon: 'none',
  99. title: resqust.msg,
  100. duration: 2000
  101. })
  102. }
  103. }).catch(err => {
  104. uni.showToast({
  105. icon: 'none',
  106. title: error.msg,
  107. duration: 2000
  108. })
  109. })
  110. }
  111. )
  112. }
  113. }
  114. //选择批号弹窗带回
  115. function handleSelectProcessInspection(data) {
  116. console.log("带回", data)
  117. query.value.lotCode = data
  118. uni.showLoading({
  119. title: '加载中'
  120. });
  121. getLotInfo(query.value).then(res => {
  122. if (res.code == 200) {
  123. lot.value = res.data;
  124. lot.value.carrierCode = query.value.carrierCode
  125. carrierCode.value = query.value.carrierCode;
  126. console.log("res", res);
  127. uni.hideLoading();
  128. } else {
  129. uni.showToast({
  130. icon: 'none',
  131. title: res.msg,
  132. duration: 2000
  133. })
  134. }
  135. });
  136. }
  137. // 确定后,将批次id,批次号,传递过去
  138. const handleConfirm = () => {
  139. if (lot.carrierCode || carrierCode.value !== "") {
  140. lot.value.carrierCode = carrierCode.value
  141. uni.showLoading({
  142. title: '加载中'
  143. });
  144. lot.value.processCode = store.outsourcedCode;
  145. /************************ 根据扫码查询到的数据和需要检查的工序查询信息 ************************/
  146. getLotOutsourcedInfo(lot.value).then(resqust => {
  147. if (resqust.code == 200) {
  148. lot.value = resqust.data;
  149. lot.value.carrierCode = carrierCode.value
  150. store.processInspection = null;
  151. console.log("resqust", resqust);
  152. uni.hideLoading();
  153. uni.navigateTo({
  154. url: "/pages/outsourcedInspection/form",
  155. success: (resqust) => {
  156. // 通过eventChannel向被打开页面传送数据
  157. resqust.eventChannel.emit("outsourcedInspectionFrom", {
  158. data: lot.value
  159. })
  160. }
  161. })
  162. } else {
  163. // uni.hideLoading();
  164. uni.showToast({
  165. icon: 'none',
  166. title: resqust.msg,
  167. duration: 2000
  168. })
  169. }
  170. })
  171. } else {
  172. uni.showToast({
  173. icon: 'none',
  174. title: "请输入箱号或扫描箱码",
  175. duration: 2000
  176. })
  177. return;
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. .page-container {
  183. height: 100%;
  184. background-color: #ececec;
  185. font-size: 28rpx;
  186. padding: 24rpx;
  187. box-sizing: border-box;
  188. }
  189. .consultation-container {
  190. background-color: #ffffff;
  191. padding: 24rpx;
  192. border-radius: 12rpx;
  193. .title {
  194. justify-content: center;
  195. font-size: 32rpx;
  196. font-weight: 700;
  197. }
  198. .info-row {
  199. margin-top: 24rpx;
  200. .label {
  201. width: 160rpx;
  202. }
  203. .value {
  204. flex: 1;
  205. textarea {
  206. flex: 1;
  207. border: 1px solid #888888;
  208. box-sizing: border-box;
  209. padding: 16rpx;
  210. }
  211. }
  212. }
  213. .btn {
  214. background-color: #1684fc;
  215. color: #ffffff;
  216. border-radius: 8rpx;
  217. margin: 4rpx 24rpx 24rpx 24rpx;
  218. height: 64rpx;
  219. justify-content: center;
  220. align-items: center;
  221. }
  222. input {
  223. margin: 48rpx 24rpx 0 24rpx;
  224. height: 64rpx;
  225. border: 1px solid #888888;
  226. text-align: center;
  227. }
  228. }
  229. </style>