scan.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. uni.scanCode({
  62. onlyFromCamera: true,
  63. success: function(res) {
  64. if (res.scanType !== 'QR_CODE') {
  65. uni.showToast({
  66. icon: 'none',
  67. title: '二维码未识别成功',
  68. duration: 2000
  69. })
  70. return
  71. }
  72. const result = JSON.parse(res.result)
  73. /************************ 查询是否一批多箱 ************************/
  74. getCarrierInfo(result).then(resqust => {
  75. if (resqust.code == 200) {
  76. //返回数据大于一条,跳转选择批次弹窗
  77. if (resqust.data.length > 1) {
  78. query.value = result;
  79. console.log("查询箱号信息", resqust)
  80. selectProcessInspection.value.open(resqust.data)
  81. } else {
  82. uni.showLoading({
  83. title: '加载中'
  84. });
  85. // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  86. // 需要定义一个请求方法, 从后端获取
  87. getLotInfo(result).then(res => {
  88. if (res.code == 200) {
  89. lot.value = res.data;
  90. lot.value.carrierCode = result.carrierCode
  91. carrierCode.value = result.carrierCode;
  92. console.log("res", res);
  93. uni.hideLoading();
  94. } else {
  95. uni.showToast({
  96. icon: 'none',
  97. title: res.msg,
  98. duration: 2000
  99. })
  100. }
  101. });
  102. }
  103. } else {
  104. uni.showToast({
  105. icon: 'none',
  106. title: res.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. console.log("加载", lot.value);
  145. getLotInfo(lot.value).then(res => {
  146. if (res.code == 200) {
  147. lot.value = res.data;
  148. lot.value.carrierCode = carrierCode.value
  149. store.processInspection = null;
  150. uni.hideLoading();
  151. uni.navigateTo({
  152. url: "/pages/processInspection/form",
  153. success: (res) => {
  154. // 通过eventChannel向被打开页面传送数据
  155. res.eventChannel.emit("processInspectionFrom", {
  156. data: lot.value
  157. })
  158. }
  159. })
  160. } else {
  161. uni.showToast({
  162. icon: 'none',
  163. title: res.msg,
  164. duration: 2000
  165. })
  166. return;
  167. }
  168. })
  169. } else {
  170. uni.showToast({
  171. icon: 'none',
  172. title: "请输入箱号或扫描箱码",
  173. duration: 2000
  174. })
  175. return;
  176. }
  177. }
  178. </script>
  179. <style lang="scss">
  180. .page-container {
  181. height: 100%;
  182. background-color: #ececec;
  183. font-size: 28rpx;
  184. padding: 24rpx;
  185. box-sizing: border-box;
  186. }
  187. .consultation-container {
  188. background-color: #ffffff;
  189. padding: 24rpx;
  190. border-radius: 12rpx;
  191. .title {
  192. justify-content: center;
  193. font-size: 32rpx;
  194. font-weight: 700;
  195. }
  196. .info-row {
  197. margin-top: 24rpx;
  198. .label {
  199. width: 160rpx;
  200. }
  201. .value {
  202. flex: 1;
  203. textarea {
  204. flex: 1;
  205. border: 1px solid #888888;
  206. box-sizing: border-box;
  207. padding: 16rpx;
  208. }
  209. }
  210. }
  211. .btn {
  212. background-color: #1684fc;
  213. color: #ffffff;
  214. border-radius: 8rpx;
  215. margin: 4rpx 24rpx 24rpx 24rpx;
  216. height: 64rpx;
  217. justify-content: center;
  218. align-items: center;
  219. }
  220. input {
  221. margin: 48rpx 24rpx 0 24rpx;
  222. height: 64rpx;
  223. border: 1px solid #888888;
  224. text-align: center;
  225. }
  226. }
  227. </style>