scan.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. } from '@/api/business/processInspection.js'
  50. import {
  51. store
  52. } from '../../store';
  53. const carrierCode = ref('')
  54. const lot = ref({})
  55. const query = ref({})
  56. const selectProcessInspection = ref(null)
  57. // 页面生命周期函数
  58. onLoad(() => {})
  59. // 扫码
  60. const handleScanCode = () => {
  61. // 引入原生插件
  62. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  63. if (mpaasScanModule) {
  64. // 调用插件的 mpaasScan 方法
  65. mpaasScanModule.mpaasScan({
  66. // 扫码识别类型,参数可多选,qrCode、barCode,
  67. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  68. scanType: ["qrCode", "barCode"],
  69. // 是否隐藏相册,默认false不隐藏
  70. hideAlbum: false,
  71. },
  72. (ret) => {
  73. console.log(ret);
  74. const result = JSON.parse(ret.resp_result);
  75. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  76. uni.showToast({
  77. icon: "none",
  78. title: "请扫载具码",
  79. duration: 1000
  80. })
  81. return;
  82. }
  83. /************************ 查询是否一批多箱 ************************/
  84. getCarrierInfo(result).then(resqust => {
  85. if (resqust.code == 200) {
  86. //返回数据大于一条,跳转选择批次弹窗
  87. if (resqust.data.length > 1) {
  88. query.value = result;
  89. console.log("查询箱号信息", resqust)
  90. selectProcessInspection.value.open(resqust.data)
  91. } else {
  92. uni.showLoading({
  93. title: '加载中'
  94. });
  95. // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  96. // 需要定义一个请求方法, 从后端获取
  97. getLotInfo(result).then(res => {
  98. if (res.code == 200) {
  99. lot.value = res.data;
  100. lot.value.carrierCode = result.carrierCode
  101. carrierCode.value = result.carrierCode;
  102. console.log("res", res);
  103. uni.hideLoading();
  104. } else {
  105. uni.showToast({
  106. icon: 'none',
  107. title: res.msg,
  108. duration: 2000
  109. })
  110. }
  111. });
  112. }
  113. } else {
  114. uni.showToast({
  115. icon: 'none',
  116. title: res.msg,
  117. duration: 2000
  118. })
  119. }
  120. })
  121. }
  122. );
  123. }
  124. }
  125. //选择批号弹窗带回
  126. function handleSelectProcessInspection(data) {
  127. console.log("带回", data)
  128. query.value.lotCode = data
  129. uni.showLoading({
  130. title: '加载中'
  131. });
  132. getLotInfo(query.value).then(res => {
  133. if (res.code == 200) {
  134. lot.value = res.data;
  135. lot.value.carrierCode = query.value.carrierCode
  136. carrierCode.value = query.value.carrierCode;
  137. console.log("res", res);
  138. uni.hideLoading();
  139. } else {
  140. uni.showToast({
  141. icon: 'none',
  142. title: res.msg,
  143. duration: 2000
  144. })
  145. }
  146. });
  147. }
  148. // 确定后,将批次id,批次号,传递过去
  149. const handleConfirm = () => {
  150. if (lot.carrierCode || carrierCode.value !== "") {
  151. lot.value.carrierCode = carrierCode.value
  152. uni.showLoading({
  153. title: '加载中'
  154. });
  155. console.log("加载", lot.value);
  156. getLotInfo(lot.value).then(res => {
  157. if (res.code == 200) {
  158. lot.value = res.data;
  159. lot.value.carrierCode = carrierCode.value
  160. store.processInspection = null;
  161. uni.hideLoading();
  162. uni.navigateTo({
  163. url: "/pages/processInspection/form",
  164. success: (res) => {
  165. // 通过eventChannel向被打开页面传送数据
  166. res.eventChannel.emit("processInspectionFrom", {
  167. data: lot.value
  168. })
  169. }
  170. })
  171. } else {
  172. uni.showToast({
  173. icon: 'none',
  174. title: res.msg,
  175. duration: 2000
  176. })
  177. return;
  178. }
  179. })
  180. } else {
  181. uni.showToast({
  182. icon: 'none',
  183. title: "请输入箱号或扫描箱码",
  184. duration: 2000
  185. })
  186. return;
  187. }
  188. }
  189. </script>
  190. <style lang="scss">
  191. .page-container {
  192. height: 100%;
  193. background-color: #ececec;
  194. font-size: 28rpx;
  195. padding: 24rpx;
  196. box-sizing: border-box;
  197. }
  198. .consultation-container {
  199. background-color: #ffffff;
  200. padding: 24rpx;
  201. border-radius: 12rpx;
  202. .title {
  203. justify-content: center;
  204. font-size: 32rpx;
  205. font-weight: 700;
  206. }
  207. .info-row {
  208. margin-top: 24rpx;
  209. .label {
  210. width: 160rpx;
  211. }
  212. .value {
  213. flex: 1;
  214. textarea {
  215. flex: 1;
  216. border: 1px solid #888888;
  217. box-sizing: border-box;
  218. padding: 16rpx;
  219. }
  220. }
  221. }
  222. .btn {
  223. background-color: #1684fc;
  224. color: #ffffff;
  225. border-radius: 8rpx;
  226. margin: 4rpx 24rpx 24rpx 24rpx;
  227. height: 64rpx;
  228. justify-content: center;
  229. align-items: center;
  230. }
  231. input {
  232. margin: 48rpx 24rpx 0 24rpx;
  233. height: 64rpx;
  234. border: 1px solid #888888;
  235. text-align: center;
  236. }
  237. }
  238. </style>