scan.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. result.processCode = store.outsourcedCode;
  85. /************************ 根据扫码查询到的数据和需要检查的工序查询信息 ************************/
  86. getLotOutsourcedInfo(result).then(resqust => {
  87. if (resqust.code == 200) {
  88. lot.value = resqust.data;
  89. lot.value.carrierCode = result.carrierCode
  90. carrierCode.value = result.carrierCode;
  91. // store.processInspection = null;
  92. console.log("resqust", resqust);
  93. uni.hideLoading();
  94. } else {
  95. // uni.hideLoading();
  96. uni.showToast({
  97. icon: 'none',
  98. title: resqust.msg,
  99. duration: 2000
  100. })
  101. }
  102. })
  103. }
  104. )
  105. }
  106. }
  107. //选择批号弹窗带回
  108. function handleSelectProcessInspection(data) {
  109. console.log("带回", data)
  110. query.value.lotCode = data
  111. uni.showLoading({
  112. title: '加载中'
  113. });
  114. getLotInfo(query.value).then(res => {
  115. if (res.code == 200) {
  116. lot.value = res.data;
  117. lot.value.carrierCode = query.value.carrierCode
  118. carrierCode.value = query.value.carrierCode;
  119. console.log("res", res);
  120. uni.hideLoading();
  121. } else {
  122. uni.showToast({
  123. icon: 'none',
  124. title: res.msg,
  125. duration: 2000
  126. })
  127. }
  128. });
  129. }
  130. // 确定后,将批次id,批次号,传递过去
  131. const handleConfirm = () => {
  132. if (lot.carrierCode || carrierCode.value !== "") {
  133. lot.value.carrierCode = carrierCode.value
  134. uni.showLoading({
  135. title: '加载中'
  136. });
  137. lot.value.processCode = store.outsourcedCode;
  138. /************************ 根据扫码查询到的数据和需要检查的工序查询信息 ************************/
  139. getLotOutsourcedInfo(lot.value).then(resqust => {
  140. if (resqust.code == 200) {
  141. lot.value = resqust.data;
  142. lot.value.carrierCode = carrierCode.value
  143. store.processInspection = null;
  144. console.log("resqust", resqust);
  145. uni.hideLoading();
  146. uni.navigateTo({
  147. url: "/pages/outsourcedInspection/form",
  148. success: (resqust) => {
  149. // 通过eventChannel向被打开页面传送数据
  150. resqust.eventChannel.emit("outsourcedInspectionFrom", {
  151. data: lot.value
  152. })
  153. }
  154. })
  155. } else {
  156. // uni.hideLoading();
  157. uni.showToast({
  158. icon: 'none',
  159. title: resqust.msg,
  160. duration: 2000
  161. })
  162. }
  163. })
  164. } else {
  165. uni.showToast({
  166. icon: 'none',
  167. title: "请输入箱号或扫描箱码",
  168. duration: 2000
  169. })
  170. return;
  171. }
  172. }
  173. </script>
  174. <style lang="scss">
  175. .page-container {
  176. height: 100%;
  177. background-color: #ececec;
  178. font-size: 28rpx;
  179. padding: 24rpx;
  180. box-sizing: border-box;
  181. }
  182. .consultation-container {
  183. background-color: #ffffff;
  184. padding: 24rpx;
  185. border-radius: 12rpx;
  186. .title {
  187. justify-content: center;
  188. font-size: 32rpx;
  189. font-weight: 700;
  190. }
  191. .info-row {
  192. margin-top: 24rpx;
  193. .label {
  194. width: 160rpx;
  195. }
  196. .value {
  197. flex: 1;
  198. textarea {
  199. flex: 1;
  200. border: 1px solid #888888;
  201. box-sizing: border-box;
  202. padding: 16rpx;
  203. }
  204. }
  205. }
  206. .btn {
  207. background-color: #1684fc;
  208. color: #ffffff;
  209. border-radius: 8rpx;
  210. margin: 4rpx 24rpx 24rpx 24rpx;
  211. height: 64rpx;
  212. justify-content: center;
  213. align-items: center;
  214. }
  215. input {
  216. margin: 48rpx 24rpx 0 24rpx;
  217. height: 64rpx;
  218. border: 1px solid #888888;
  219. text-align: center;
  220. }
  221. }
  222. </style>