scan.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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. getCarrierInfoProcess
  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 = {
  205. carrierCode: ret.resp_result
  206. };
  207. if (!result.carrierCode || result.carrierCode == "") {
  208. uni.showToast({
  209. icon: "none",
  210. title: "请扫载具码",
  211. duration: 1000
  212. })
  213. return;
  214. }
  215. getCarrierInfoProcess(result).then(resqust => {
  216. if (resqust.code == 200) {
  217. //返回数据大于一条,跳转选择批次弹窗
  218. if (resqust.data.length > 1) {
  219. query.value = result;
  220. console.log("查询箱号信息", resqust)
  221. selectProcessInspection.value.open(resqust.data)
  222. } else {
  223. uni.showLoading({
  224. title: '加载中'
  225. });
  226. // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  227. // 需要定义一个请求方法, 从后端获取
  228. getLotInfo(result).then(res => {
  229. if (res.code == 200) {
  230. lot.value = res.data;
  231. lot.value.carrierCode = result.carrierCode
  232. carrierCode.value = result.carrierCode;
  233. console.log("res", res);
  234. uni.hideLoading();
  235. } else {
  236. uni.showToast({
  237. icon: 'none',
  238. title: res.msg,
  239. duration: 2000
  240. })
  241. }
  242. }).catch(err => {
  243. uni.showToast({
  244. icon: 'none',
  245. title: err.message,
  246. duration: 2000
  247. })
  248. })
  249. }
  250. } else {
  251. uni.showToast({
  252. icon: 'none',
  253. title: resqust.msg,
  254. duration: 2000
  255. })
  256. }
  257. }).catch(err => {
  258. uni.showToast({
  259. icon: 'none',
  260. title: err.message,
  261. duration: 2000
  262. })
  263. })
  264. }
  265. );
  266. }
  267. }
  268. //选择批号弹窗带回
  269. function handleSelectProcessInspection(data) {
  270. console.log("带回", data)
  271. query.value.lotCode = data
  272. uni.showLoading({
  273. title: '加载中'
  274. });
  275. getLotInfo(query.value).then(res => {
  276. if (res.code == 200) {
  277. lot.value = res.data;
  278. lot.value.carrierCode = query.value.carrierCode
  279. carrierCode.value = query.value.carrierCode;
  280. console.log("res", res);
  281. uni.hideLoading();
  282. } else {
  283. uni.showToast({
  284. icon: 'none',
  285. title: res.msg,
  286. duration: 2000
  287. })
  288. }
  289. });
  290. }
  291. // 确定后,将批次id,批次号,传递过去
  292. const handleConfirm = () => {
  293. if (lot.carrierCode || carrierCode.value !== "") {
  294. lot.value.carrierCode = carrierCode.value
  295. const result = {
  296. ...lot.value
  297. }
  298. if (lot.value.lotCode == "" || lot.value.lotCode == null || lot.value.carrierCode != carrierCode.value) {
  299. getCarrierInfoProcess(result).then(resqust => {
  300. if (resqust.code == 200) {
  301. //返回数据大于一条,跳转选择批次弹窗
  302. if (resqust.data.length > 1) {
  303. query.value = result;
  304. console.log("查询箱号信息", resqust)
  305. selectProcessInspection.value.open(resqust.data)
  306. } else {
  307. uni.showLoading({
  308. title: '加载中'
  309. });
  310. // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  311. // 需要定义一个请求方法, 从后端获取
  312. getLotInfo(result).then(res => {
  313. if (res.code == 200) {
  314. lot.value = res.data;
  315. lot.value.carrierCode = result.carrierCode
  316. carrierCode.value = result.carrierCode;
  317. console.log("res", res);
  318. uni.hideLoading();
  319. } else {
  320. uni.showToast({
  321. icon: 'none',
  322. title: res.msg,
  323. duration: 2000
  324. })
  325. }
  326. }).catch(err => {
  327. uni.showToast({
  328. icon: 'none',
  329. title: err.message,
  330. duration: 2000
  331. })
  332. })
  333. }
  334. } else {
  335. uni.showToast({
  336. icon: 'none',
  337. title: resqust.msg,
  338. duration: 2000
  339. })
  340. }
  341. }).catch(err => {
  342. uni.showToast({
  343. icon: 'none',
  344. title: err.message,
  345. duration: 2000
  346. })
  347. })
  348. return
  349. }
  350. uni.showLoading({
  351. title: '加载中'
  352. });
  353. console.log("加载", lot.value);
  354. getLotInfo(lot.value).then(res => {
  355. if (res.code == 200) {
  356. lot.value = res.data;
  357. lot.value.carrierCode = carrierCode.value
  358. store.processInspection = null;
  359. uni.hideLoading();
  360. uni.navigateTo({
  361. url: "/pages/processInspection/form",
  362. success: (res) => {
  363. // 通过eventChannel向被打开页面传送数据
  364. res.eventChannel.emit("processInspectionFrom", {
  365. data: lot.value
  366. })
  367. }
  368. })
  369. } else {
  370. uni.showToast({
  371. icon: 'none',
  372. title: res.msg,
  373. duration: 2000
  374. })
  375. return;
  376. }
  377. })
  378. // console.log(result)
  379. // getCarrierInfo(result).then(resqust => {
  380. // if (resqust.code == 200) {
  381. // //返回数据大于一条,跳转选择批次弹窗
  382. // if (resqust.data.length > 1) {
  383. // query.value = result;
  384. // console.log("查询箱号信息", resqust)
  385. // selectProcessInspection.value.open(resqust.data)
  386. // } else {
  387. // uni.showLoading({
  388. // title: '加载中'
  389. // });
  390. // // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  391. // // 需要定义一个请求方法, 从后端获取
  392. // getLotInfo(result).then(res => {
  393. // if (res.code == 200) {
  394. // lot.value = res.data;
  395. // lot.value.carrierCode = result.carrierCode
  396. // carrierCode.value = result.carrierCode;
  397. // console.log("res", res);
  398. // uni.hideLoading();
  399. // } else {
  400. // uni.showToast({
  401. // icon: 'none',
  402. // title: res.msg,
  403. // duration: 2000
  404. // })
  405. // }
  406. // }).catch(err => {
  407. // uni.showToast({
  408. // icon: 'none',
  409. // title: err.message,
  410. // duration: 2000
  411. // })
  412. // })
  413. // }
  414. // } else {
  415. // uni.showToast({
  416. // icon: 'none',
  417. // title: resqust.msg,
  418. // duration: 2000
  419. // })
  420. // }
  421. // }).catch(err => {
  422. // uni.showToast({
  423. // icon: 'none',
  424. // title: err.message,
  425. // duration: 2000
  426. // })
  427. // })
  428. } else {
  429. uni.showToast({
  430. icon: 'none',
  431. title: "请输入箱号或扫描箱码",
  432. duration: 2000
  433. })
  434. return;
  435. }
  436. }
  437. </script>
  438. <style lang="scss">
  439. .page-container {
  440. height: 100%;
  441. background-color: #ececec;
  442. font-size: 28rpx;
  443. padding: 24rpx;
  444. box-sizing: border-box;
  445. }
  446. .consultation-container {
  447. background-color: #ffffff;
  448. padding: 24rpx;
  449. border-radius: 12rpx;
  450. .title {
  451. justify-content: center;
  452. font-size: 32rpx;
  453. font-weight: 700;
  454. }
  455. .info-row {
  456. margin-top: 24rpx;
  457. .label {
  458. width: 160rpx;
  459. }
  460. .value {
  461. flex: 1;
  462. textarea {
  463. flex: 1;
  464. border: 1px solid #888888;
  465. box-sizing: border-box;
  466. padding: 16rpx;
  467. }
  468. }
  469. }
  470. .btn {
  471. background-color: #1684fc;
  472. color: #ffffff;
  473. border-radius: 8rpx;
  474. margin: 4rpx 24rpx 24rpx 24rpx;
  475. height: 64rpx;
  476. justify-content: center;
  477. align-items: center;
  478. }
  479. input {
  480. margin: 48rpx 24rpx 0 24rpx;
  481. height: 64rpx;
  482. border: 1px solid #888888;
  483. text-align: center;
  484. }
  485. }
  486. </style>