scan.vue 5.5 KB

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