scan.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. /*
  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. 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: err.message,
  115. duration: 2000
  116. })
  117. })
  118. }
  119. } else {
  120. uni.showToast({
  121. icon: 'none',
  122. title: resqust.msg,
  123. duration: 2000
  124. })
  125. }
  126. }).catch(err => {
  127. uni.showToast({
  128. icon: 'none',
  129. title: err.message,
  130. duration: 2000
  131. })
  132. })
  133. }
  134. );
  135. }
  136. // else{
  137. // const result = {carrierCode: '000191'}
  138. // getCarrierInfo({carrierCode: '000191'}).then(resqust => {
  139. // if (resqust.code == 200) {
  140. // //返回数据大于一条,跳转选择批次弹窗
  141. // if (resqust.data.length > 1) {
  142. // query.value = result;
  143. // console.log("查询箱号信息", resqust)
  144. // selectProcessInspection.value.open(resqust.data)
  145. // } else {
  146. // uni.showLoading({
  147. // title: '加载中'
  148. // });
  149. // // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  150. // // 需要定义一个请求方法, 从后端获取
  151. // getLotInfo(result).then(res => {
  152. // if (res.code == 200) {
  153. // lot.value = res.data;
  154. // lot.value.carrierCode = result.carrierCode
  155. // carrierCode.value = result.carrierCode;
  156. // console.log("res", res);
  157. // uni.hideLoading();
  158. // } else {
  159. // uni.showToast({
  160. // icon: 'none',
  161. // title: res.msg,
  162. // duration: 2000
  163. // })
  164. // }
  165. // }).catch(err => {
  166. // uni.showToast({
  167. // icon: 'none',
  168. // title: err.message,
  169. // duration: 2000
  170. // })
  171. // })
  172. // }
  173. // } else {
  174. // uni.showToast({
  175. // icon: 'none',
  176. // title: resqust.msg,
  177. // duration: 2000
  178. // })
  179. // }
  180. // }).catch(err => {
  181. // uni.showToast({
  182. // icon: 'none',
  183. // title: err.message,
  184. // duration: 2000
  185. // })
  186. // })
  187. // }
  188. }
  189. */
  190. const handleScanCode = () => {
  191. // 引入原生插件
  192. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  193. if (mpaasScanModule) {
  194. // 调用插件的 mpaasScan 方法
  195. mpaasScanModule.mpaasScan({
  196. // 扫码识别类型,参数可多选,qrCode、barCode,
  197. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  198. scanType: ["qrCode", "barCode"],
  199. // 是否隐藏相册,默认false不隐藏
  200. hideAlbum: false,
  201. },
  202. (ret) => {
  203. console.log(ret);
  204. const result = {carrierCode: ret.resp_result};
  205. if (!result.carrierCode || result.carrierCode == "") {
  206. uni.showToast({
  207. icon: "none",
  208. title: "请扫载具码",
  209. duration: 1000
  210. })
  211. return;
  212. }
  213. getCarrierInfo(result).then(resqust => {
  214. if (resqust.code == 200) {
  215. //返回数据大于一条,跳转选择批次弹窗
  216. if (resqust.data.length > 1) {
  217. query.value = result;
  218. console.log("查询箱号信息", resqust)
  219. selectProcessInspection.value.open(resqust.data)
  220. } else {
  221. uni.showLoading({
  222. title: '加载中'
  223. });
  224. // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  225. // 需要定义一个请求方法, 从后端获取
  226. getLotInfo(result).then(res => {
  227. if (res.code == 200) {
  228. lot.value = res.data;
  229. lot.value.carrierCode = result.carrierCode
  230. carrierCode.value = result.carrierCode;
  231. console.log("res", res);
  232. uni.hideLoading();
  233. } else {
  234. uni.showToast({
  235. icon: 'none',
  236. title: res.msg,
  237. duration: 2000
  238. })
  239. }
  240. }).catch(err => {
  241. uni.showToast({
  242. icon: 'none',
  243. title: err.message,
  244. duration: 2000
  245. })
  246. })
  247. }
  248. } else {
  249. uni.showToast({
  250. icon: 'none',
  251. title: resqust.msg,
  252. duration: 2000
  253. })
  254. }
  255. }).catch(err => {
  256. uni.showToast({
  257. icon: 'none',
  258. title: err.message,
  259. duration: 2000
  260. })
  261. })
  262. }
  263. );
  264. }
  265. }
  266. //选择批号弹窗带回
  267. function handleSelectProcessInspection(data) {
  268. console.log("带回", data)
  269. query.value.lotCode = data
  270. uni.showLoading({
  271. title: '加载中'
  272. });
  273. getLotInfo(query.value).then(res => {
  274. if (res.code == 200) {
  275. lot.value = res.data;
  276. lot.value.carrierCode = query.value.carrierCode
  277. carrierCode.value = query.value.carrierCode;
  278. console.log("res", res);
  279. uni.hideLoading();
  280. } else {
  281. uni.showToast({
  282. icon: 'none',
  283. title: res.msg,
  284. duration: 2000
  285. })
  286. }
  287. });
  288. }
  289. // 确定后,将批次id,批次号,传递过去
  290. const handleConfirm = () => {
  291. if (lot.carrierCode || carrierCode.value !== "") {
  292. lot.value.carrierCode = carrierCode.value
  293. uni.showLoading({
  294. title: '加载中'
  295. });
  296. console.log("加载", lot.value);
  297. getLotInfo(lot.value).then(res => {
  298. if (res.code == 200) {
  299. lot.value = res.data;
  300. lot.value.carrierCode = carrierCode.value
  301. store.processInspection = null;
  302. uni.hideLoading();
  303. uni.navigateTo({
  304. url: "/pages/processInspection/form",
  305. success: (res) => {
  306. // 通过eventChannel向被打开页面传送数据
  307. res.eventChannel.emit("processInspectionFrom", {
  308. data: lot.value
  309. })
  310. }
  311. })
  312. } else {
  313. uni.showToast({
  314. icon: 'none',
  315. title: res.msg,
  316. duration: 2000
  317. })
  318. return;
  319. }
  320. })
  321. } else {
  322. uni.showToast({
  323. icon: 'none',
  324. title: "请输入箱号或扫描箱码",
  325. duration: 2000
  326. })
  327. return;
  328. }
  329. }
  330. </script>
  331. <style lang="scss">
  332. .page-container {
  333. height: 100%;
  334. background-color: #ececec;
  335. font-size: 28rpx;
  336. padding: 24rpx;
  337. box-sizing: border-box;
  338. }
  339. .consultation-container {
  340. background-color: #ffffff;
  341. padding: 24rpx;
  342. border-radius: 12rpx;
  343. .title {
  344. justify-content: center;
  345. font-size: 32rpx;
  346. font-weight: 700;
  347. }
  348. .info-row {
  349. margin-top: 24rpx;
  350. .label {
  351. width: 160rpx;
  352. }
  353. .value {
  354. flex: 1;
  355. textarea {
  356. flex: 1;
  357. border: 1px solid #888888;
  358. box-sizing: border-box;
  359. padding: 16rpx;
  360. }
  361. }
  362. }
  363. .btn {
  364. background-color: #1684fc;
  365. color: #ffffff;
  366. border-radius: 8rpx;
  367. margin: 4rpx 24rpx 24rpx 24rpx;
  368. height: 64rpx;
  369. justify-content: center;
  370. align-items: center;
  371. }
  372. input {
  373. margin: 48rpx 24rpx 0 24rpx;
  374. height: 64rpx;
  375. border: 1px solid #888888;
  376. text-align: center;
  377. }
  378. }
  379. </style>