scan.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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 (!result.carrierId || result.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. }).catch(err => {
  112. uni.showToast({
  113. icon: 'none',
  114. title: error.msg,
  115. duration: 2000
  116. })
  117. })
  118. }
  119. } else {
  120. uni.showToast({
  121. icon: 'none',
  122. title: res.msg,
  123. duration: 2000
  124. })
  125. }
  126. })
  127. }
  128. );
  129. }
  130. }
  131. //选择批号弹窗带回
  132. function handleSelectProcessInspection(data) {
  133. console.log("带回", data)
  134. query.value.lotCode = data
  135. uni.showLoading({
  136. title: '加载中'
  137. });
  138. getLotInfo(query.value).then(res => {
  139. if (res.code == 200) {
  140. lot.value = res.data;
  141. lot.value.carrierCode = query.value.carrierCode
  142. carrierCode.value = query.value.carrierCode;
  143. console.log("res", res);
  144. uni.hideLoading();
  145. } else {
  146. uni.showToast({
  147. icon: 'none',
  148. title: res.msg,
  149. duration: 2000
  150. })
  151. }
  152. });
  153. }
  154. // 确定后,将批次id,批次号,传递过去
  155. const handleConfirm = () => {
  156. if (lot.carrierCode || carrierCode.value !== "") {
  157. lot.value.carrierCode = carrierCode.value
  158. uni.showLoading({
  159. title: '加载中'
  160. });
  161. console.log("加载", lot.value);
  162. getLotInfo(lot.value).then(res => {
  163. if (res.code == 200) {
  164. lot.value = res.data;
  165. lot.value.carrierCode = carrierCode.value
  166. store.processInspection = null;
  167. uni.hideLoading();
  168. uni.navigateTo({
  169. url: "/pages/processInspection/form",
  170. success: (res) => {
  171. // 通过eventChannel向被打开页面传送数据
  172. res.eventChannel.emit("processInspectionFrom", {
  173. data: lot.value
  174. })
  175. }
  176. })
  177. } else {
  178. uni.showToast({
  179. icon: 'none',
  180. title: res.msg,
  181. duration: 2000
  182. })
  183. return;
  184. }
  185. })
  186. } else {
  187. uni.showToast({
  188. icon: 'none',
  189. title: "请输入箱号或扫描箱码",
  190. duration: 2000
  191. })
  192. return;
  193. }
  194. }
  195. </script>
  196. <style lang="scss">
  197. .page-container {
  198. height: 100%;
  199. background-color: #ececec;
  200. font-size: 28rpx;
  201. padding: 24rpx;
  202. box-sizing: border-box;
  203. }
  204. .consultation-container {
  205. background-color: #ffffff;
  206. padding: 24rpx;
  207. border-radius: 12rpx;
  208. .title {
  209. justify-content: center;
  210. font-size: 32rpx;
  211. font-weight: 700;
  212. }
  213. .info-row {
  214. margin-top: 24rpx;
  215. .label {
  216. width: 160rpx;
  217. }
  218. .value {
  219. flex: 1;
  220. textarea {
  221. flex: 1;
  222. border: 1px solid #888888;
  223. box-sizing: border-box;
  224. padding: 16rpx;
  225. }
  226. }
  227. }
  228. .btn {
  229. background-color: #1684fc;
  230. color: #ffffff;
  231. border-radius: 8rpx;
  232. margin: 4rpx 24rpx 24rpx 24rpx;
  233. height: 64rpx;
  234. justify-content: center;
  235. align-items: center;
  236. }
  237. input {
  238. margin: 48rpx 24rpx 0 24rpx;
  239. height: 64rpx;
  240. border: 1px solid #888888;
  241. text-align: center;
  242. }
  243. }
  244. </style>