reviewScan.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="consultation-container uni-column">
  4. <view class="info-row uni-row">
  5. <view class="label">批次号</view>
  6. <view class="value">{{ lot.lotCode }}</view>
  7. </view>
  8. <view class="info-row uni-row">
  9. <view class="label">图号</view>
  10. <view class="value">{{ lot.drawingNumber }}</view>
  11. </view>
  12. <view class="info-row uni-row">
  13. <view class="label">工艺版本</view>
  14. <view class="value">{{ lot.technologyVersion }}</view>
  15. </view>
  16. <view class="info-row uni-row">
  17. <view class="label">产品描述</view>
  18. <view class="value">{{ lot.productDescription }}</view>
  19. </view>
  20. <view class="info-row uni-row">
  21. <view class="label">当前工序</view>
  22. <view class="value">{{ lot.processAlias }}</view>
  23. </view>
  24. <view class="info-row uni-row">
  25. <view class="label">当前工段</view>
  26. <view class="value">{{ lot.deptName }}</view>
  27. </view>
  28. <view class="info-row uni-row" style="margin-top: 40rpx;">
  29. <view class="label">操作者</view>
  30. <view class="value">
  31. <uni-data-select v-model="userId" :localdata="userList" :clear="false"
  32. @change="handleGetEquipmentList"
  33. style="outline: 2rpx solid #999999;border-radius: 10rpx;"></uni-data-select>
  34. </view>
  35. </view>
  36. <view class="info-row uni-row" style="margin-top: 40rpx;">
  37. <view class="label">加工设备</view>
  38. <view class="value">
  39. <uni-data-select v-model="equipment" :localdata="equipmentList" :clear="false"
  40. style="outline: 2rpx solid #999999;border-radius: 10rpx;"></uni-data-select>
  41. </view>
  42. </view>
  43. <view class="info-row uni-row">
  44. <view class="label">所有箱号</view>
  45. <view class="value">{{ lot.allCarrierName }}</view>
  46. </view>
  47. <view class="info-row uni-row">
  48. <view class="label">巡检箱号</view>
  49. <view class="value">{{ lot.inspectionCarrierCode }}</view>
  50. </view>
  51. <!-- <input type="text" v-model="carrierCode" placeholder="请输入箱号" /> -->
  52. <view class="btn uni-row" style="background-color: #ff5555;" @click.stop="handleScanCode">
  53. <uni-icons type="scan" size="16" style="color: #ffffff; margin-right: 8rpx;" />
  54. <text>扫描箱码及检测箱码</text>
  55. </view>
  56. <view class="btn uni-row" style="margin-top: 48rpx;" @click.stop="handleConfirm">确定</view>
  57. </view>
  58. <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
  59. <dialog-processInspection ref='selectProcessInspection'
  60. @handleSelectProcessInspection='handleSelectProcessInspection'></dialog-processInspection>
  61. </view>
  62. </template>
  63. <script setup>
  64. import {
  65. ref
  66. } from 'vue'
  67. import {
  68. onLoad,
  69. onReady,
  70. onUnload,
  71. onShow
  72. } from '@dcloudio/uni-app'
  73. import QrScanner from '../vueQrCode/index.vue'
  74. import {
  75. getLotInfoByFirstInspection,
  76. getCarrierInfoProcess,
  77. getCarrierInfo,
  78. getFirstInspectionLotInfo,
  79. } from '@/api/business/processInspection.js'
  80. import {
  81. debounce
  82. } from '../../utils/common';
  83. import {
  84. store
  85. } from '../../store';
  86. import {
  87. getDayWorkItemHistory
  88. } from '../../api/business/dayWorkItem';
  89. const carrierCode = ref('')
  90. const equipmentList = ref([])
  91. const inspectionChamber = ref(null)
  92. const selectProcessInspection = ref(null)
  93. const userList = ref([])
  94. const userId = ref(null)
  95. const equipment = ref(null)
  96. const lot = ref({})
  97. const query = ref({})
  98. const showQrCodeReader = ref(false);
  99. function onDecodeHandler(data) {
  100. showQrCodeReader.value = false;
  101. const result = {
  102. carrierCode: data,
  103. processCode: '',
  104. deptId: store.curDeptDetails.deptId
  105. }
  106. if (!result.carrierCode || result.carrierCode == "") {
  107. uni.showToast({
  108. icon: "none",
  109. title: "请扫载具码",
  110. duration: 1000
  111. })
  112. return
  113. }
  114. //判断该箱是否绑定批次
  115. result.processCode = store.outsourcedCode;
  116. // console.log(result.processCode)
  117. /************************ 根据扫码查询到的数据和需要检查的工序查询信息 ************************/
  118. getCarrierInfo(result).then(response => {
  119. if (response.code == 200) {
  120. // 判断是哪种返回值 假设是想信息则给lot附检查箱信息
  121. // 假设是dayworkCarriers 则 判断是几个批次,假设为多批,则弹出选择框。
  122. if (response.data.dayworkCarriers != null) {
  123. if (response.data.dayworkCarriers.length > 1) {
  124. query.value = result;
  125. selectProcessInspection.value.open(response.data.dayworkCarriers)
  126. } else {
  127. // console.log(response)
  128. uni.showLoading({
  129. title: '加载中'
  130. });
  131. // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  132. // 需要定义一个请求方法, 从后端获取
  133. result.deptId = store.curDeptDetails.deptId
  134. getFirstInspectionLotInfo(result).then(res => {
  135. if (res.code == 200) {
  136. console.log(res)
  137. getUser(res.data.dayworkItemList)
  138. getEquipment(res.data.dayworkItemList)
  139. lot.value = {
  140. ...lot.value,
  141. ...res.data
  142. };
  143. lot.value.carrierCode = result.carrierCode
  144. carrierCode.value = result.carrierCode;
  145. // console.log("res", res);
  146. uni.hideLoading();
  147. // 判断是否批次号和检查箱码都扫完
  148. checkSave()
  149. } else {
  150. uni.showToast({
  151. icon: 'none',
  152. title: res.msg,
  153. duration: 2000
  154. })
  155. }
  156. }).catch(err => {
  157. uni.showToast({
  158. icon: 'none',
  159. title: err.message,
  160. duration: 2000
  161. })
  162. })
  163. }
  164. } else if (response.data.inspectionCarrier != null) {
  165. console.log(response)
  166. lot.value.inspectionCarrierCode = response.data.inspectionCarrier.code
  167. lot.value.inspectionCarrierId = response.data.inspectionCarrier.id
  168. // 判断是否批次号和检查箱码都扫完
  169. checkSave()
  170. }
  171. } else {
  172. uni.showToast({
  173. icon: 'none',
  174. title: response.msg,
  175. duration: 2000
  176. })
  177. }
  178. }).catch(err => {
  179. uni.showToast({
  180. icon: 'none',
  181. title: err.message,
  182. duration: 2000
  183. })
  184. })
  185. }
  186. //H5扫码器关闭
  187. function qrReaderClose() {
  188. showQrCodeReader.value = false;
  189. }
  190. // 页面生命周期函数
  191. const handleScanCode = () => {
  192. showQrCodeReader.value = true;
  193. // 引入原生插件
  194. // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  195. // if (mpaasScanModule) {
  196. // // 调用插件的 mpaasScan 方法
  197. // mpaasScanModule.mpaasScan({
  198. // // 扫码识别类型,参数可多选,qrCode、barCode,
  199. // // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  200. // scanType: ["qrCode", "barCode"],
  201. // // 是否隐藏相册,默认false不隐藏
  202. // hideAlbum: false,
  203. // },
  204. // (ret) => {
  205. // console.log(ret)
  206. // const result = {
  207. // carrierCode: ret.resp_result,
  208. // processCode: '',
  209. // deptId: store.curDeptDetails.deptId
  210. // }
  211. // if (!result.carrierCode || result.carrierCode == "") {
  212. // uni.showToast({
  213. // icon: "none",
  214. // title: "请扫载具码",
  215. // duration: 1000
  216. // })
  217. // return
  218. // }
  219. // //判断该箱是否绑定批次
  220. // result.processCode = store.outsourcedCode;
  221. // // console.log(result.processCode)
  222. // /************************ 根据扫码查询到的数据和需要检查的工序查询信息 ************************/
  223. // getCarrierInfo(result).then(response => {
  224. // if (response.code == 200) {
  225. // // 判断是哪种返回值 假设是想信息则给lot附检查箱信息
  226. // // 假设是dayworkCarriers 则 判断是几个批次,假设为多批,则弹出选择框。
  227. // if (response.data.dayworkCarriers != null) {
  228. // if (response.data.dayworkCarriers.length > 1) {
  229. // query.value = result;
  230. // selectProcessInspection.value.open(response.data.dayworkCarriers)
  231. // } else {
  232. // // console.log(response)
  233. // uni.showLoading({
  234. // title: '加载中'
  235. // });
  236. // // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  237. // // 需要定义一个请求方法, 从后端获取
  238. // result.deptId = store.curDeptDetails.deptId
  239. // getFirstInspectionLotInfo(result).then(res => {
  240. // if (res.code == 200) {
  241. // console.log(res)
  242. // getUser(res.data.dayworkItemList)
  243. // getEquipment(res.data.dayworkItemList)
  244. // lot.value = {
  245. // ...lot.value,
  246. // ...res.data
  247. // };
  248. // lot.value.carrierCode = result.carrierCode
  249. // carrierCode.value = result.carrierCode;
  250. // // console.log("res", res);
  251. // uni.hideLoading();
  252. // // 判断是否批次号和检查箱码都扫完
  253. // checkSave()
  254. // } else {
  255. // uni.showToast({
  256. // icon: 'none',
  257. // title: res.msg,
  258. // duration: 2000
  259. // })
  260. // }
  261. // }).catch(err => {
  262. // uni.showToast({
  263. // icon: 'none',
  264. // title: err.message,
  265. // duration: 2000
  266. // })
  267. // })
  268. // }
  269. // } else if (response.data.inspectionCarrier != null) {
  270. // console.log(response)
  271. // lot.value.inspectionCarrierCode = response.data.inspectionCarrier.code
  272. // lot.value.inspectionCarrierId = response.data.inspectionCarrier.id
  273. // // 判断是否批次号和检查箱码都扫完
  274. // checkSave()
  275. // }
  276. // } else {
  277. // uni.showToast({
  278. // icon: 'none',
  279. // title: response.msg,
  280. // duration: 2000
  281. // })
  282. // }
  283. // }).catch(err => {
  284. // uni.showToast({
  285. // icon: 'none',
  286. // title: err.message,
  287. // duration: 2000
  288. // })
  289. // })
  290. // }
  291. // )
  292. // } else {
  293. // const result = {
  294. // carrierCode: '300027',
  295. // deptId: store.curDeptDetails.deptId
  296. // }
  297. // getCarrierInfo(result).then(response => {
  298. // if (response.code == 200) {
  299. // // 判断是哪种返回值 假设是想信息则给lot附检查箱信息
  300. // // 假设是dayworkCarriers 则 判断是几个批次,假设为多批,则弹出选择框。
  301. // if (response.data.dayworkCarriers != null) {
  302. // if (response.data.dayworkCarriers.length > 1) {
  303. // query.value = result;
  304. // query.value.deptId = store.curDeptDetails.deptId
  305. // selectProcessInspection.value.open(response.data.dayworkCarriers)
  306. // } else {
  307. // // console.log(response)
  308. // uni.showLoading({
  309. // title: '加载中'
  310. // });
  311. // // 此处根据拿到的箱子id, 获取到相对应的【 lot_id】,【 lot_code】, 以及该批次关联的其它箱号
  312. // // 需要定义一个请求方法, 从后端获取
  313. // getFirstInspectionLotInfo(result).then(res => {
  314. // if (res.code == 200) {
  315. // console.log(res)
  316. // console.log("888")
  317. // getUser(res.data.dayworkItemList)
  318. // getEquipment(res.data.dayworkItemList)
  319. // lot.value = {
  320. // ...lot.value,
  321. // ...res.data
  322. // };
  323. // lot.value.carrierCode = result.carrierCode
  324. // carrierCode.value = result.carrierCode;
  325. // lot.value.inspectionCarrierId = '1803605009533812742'
  326. // lot.value.inspectionCarrierCode = "300025"
  327. // // console.log("res", res);
  328. // uni.hideLoading();
  329. // // 判断是否批次号和检查箱码都扫完
  330. // checkSave()
  331. // } else {
  332. // uni.showToast({
  333. // icon: 'none',
  334. // title: res.msg,
  335. // duration: 2000
  336. // })
  337. // }
  338. // }).catch(err => {
  339. // uni.showToast({
  340. // icon: 'none',
  341. // title: err.message,
  342. // duration: 2000
  343. // })
  344. // })
  345. // }
  346. // } else if (response.data.inspectionCarrier != null) {
  347. // console.log(response)
  348. // lot.value.inspectionCarrierCode = response.data.inspectionCarrier.code
  349. // lot.value.inspectionCarrierId = response.data.inspectionCarrier.id
  350. // // 判断是否批次号和检查箱码都扫完
  351. // checkSave()
  352. // }
  353. // } else {
  354. // uni.showToast({
  355. // icon: 'none',
  356. // title: response.msg,
  357. // duration: 2000
  358. // })
  359. // }
  360. // }).catch(err => {
  361. // uni.showToast({
  362. // icon: 'none',
  363. // title: err.message,
  364. // duration: 2000
  365. // })
  366. // })
  367. // }
  368. }
  369. function getUser(data) {
  370. const uniqueUserMap = new Map();
  371. console.log(data)
  372. data.forEach(item => {
  373. // 检查 Map 中是否已经有这个 equimentDetailId
  374. if (!uniqueUserMap.has(item.userId)) {
  375. // 如果没有,添加到 Map 中
  376. uniqueUserMap.set(item.userId, {
  377. value: item.userId,
  378. text: item.nickName
  379. });
  380. }
  381. });
  382. console.log(uniqueUserMap)
  383. // 将 Map 的值转换为数组
  384. userList.value = Array.from(uniqueUserMap.values());
  385. console.log(userList.value)
  386. userId.value = userList.value[0].value
  387. }
  388. function checkSave() {
  389. if (lot.value.lotCode == '' || lot.value.lotCode == null) {
  390. debounce(handleScanCode, 700)
  391. }
  392. if (lot.value.inspectionCarrierId == null || lot.value.inspectionCarrierId == '') {
  393. debounce(handleScanCode, 700)
  394. }
  395. }
  396. function handleGetEquipmentList() {
  397. getEquipment(lot.value.dayworkItemList)
  398. }
  399. //选择批号弹窗带回
  400. function handleSelectProcessInspection(data) {
  401. console.log("带回", data)
  402. query.value.lotCode = data
  403. uni.showLoading({
  404. title: '加载中'
  405. });
  406. getFirstInspectionLotInfo(query.value).then(res => {
  407. if (res.code == 200) {
  408. console.log(res)
  409. if (res.data.dayworkItemList.length == 0) {
  410. uni.showToast({
  411. icon: 'none',
  412. title: "该批次当天没有报工",
  413. duration: 2000
  414. })
  415. } else {
  416. console.log("888")
  417. getUser(res.data.dayworkItemList)
  418. getEquipment(res.data.dayworkItemList)
  419. lot.value = {
  420. ...lot.value,
  421. ...res.data
  422. };
  423. lot.value.carrierCode = query.value.carrierCode
  424. carrierCode.value = query.value.carrierCode;
  425. // console.log("res", res);
  426. uni.hideLoading();
  427. // 判断是否批次号和检查箱码都扫完
  428. checkSave()
  429. }
  430. } else {
  431. uni.showToast({
  432. icon: 'none',
  433. title: res.msg,
  434. duration: 2000
  435. })
  436. }
  437. }).catch(err => {
  438. uni.showToast({
  439. icon: 'none',
  440. title: err.message,
  441. duration: 2000
  442. })
  443. })
  444. }
  445. function getEquipment(data) {
  446. const uniqueEquipmentMap = new Map();
  447. console.log(userId.value)
  448. let filterList = data.filter(info => info.userId == userId.value)
  449. console.log(filterList)
  450. filterList.forEach(item => {
  451. // 检查 Map 中是否已经有这个 equimentDetailId
  452. if (!uniqueEquipmentMap.has(item.equipmentDetailId)) {
  453. // 如果没有,添加到 Map 中
  454. uniqueEquipmentMap.set(item.equipmentDetailId, {
  455. value: item.equipmentDetailId,
  456. text: item.equipmentDetailCode
  457. });
  458. }
  459. });
  460. // 将 Map 的值转换为数组
  461. equipmentList.value = Array.from(uniqueEquipmentMap.values());
  462. equipment.value = equipmentList.value[0].value
  463. }
  464. //确定后,将批次id,批次号,传递过去
  465. const handleConfirm = () => {
  466. console.log(lot.value)
  467. if (lot.value.inspectionCarrierId != undefined) {
  468. if (equipment.value == null) {
  469. uni.showToast({
  470. icon: 'none',
  471. title: "请选择加工设备",
  472. duration: 2000
  473. })
  474. } else {
  475. lot.value.equipmentDetailId = equipment.value
  476. lot.value.equipmentDetailCode = equipmentList.value[equipmentList.value.findIndex(item => item.value ==
  477. equipment.value)].text
  478. lot.value.userId = userId.value
  479. lot.value.nickName = userList.value[userList.value.findIndex(item => item.value == userId.value)].text
  480. store.processInspection = null
  481. //判断选择了那种检测类型
  482. //选择首检
  483. uni.navigateTo({
  484. url: "/pages/firstInspection/form",
  485. success: (res) => {
  486. // 通过eventChannel向被打开页面传送数据
  487. res.eventChannel.emit("firstInspectionFrom", {
  488. data: lot.value
  489. })
  490. }
  491. })
  492. }
  493. } else {
  494. if (lot.value.inspectionCarrierId == undefined) {
  495. uni.showToast({
  496. icon: 'none',
  497. title: "请扫描检测载具",
  498. duration: 2000
  499. })
  500. }
  501. return;
  502. }
  503. }
  504. </script>
  505. <style lang="scss">
  506. .page-container {
  507. height: 100%;
  508. background-color: #ececec;
  509. font-size: 28rpx;
  510. padding: 24rpx;
  511. box-sizing: border-box;
  512. }
  513. .consultation-container {
  514. background-color: #ffffff;
  515. padding: 24rpx;
  516. border-radius: 12rpx;
  517. .title {
  518. justify-content: center;
  519. font-size: 32rpx;
  520. font-weight: 700;
  521. }
  522. .info-row {
  523. margin-top: 24rpx;
  524. .label {
  525. width: 160rpx;
  526. }
  527. .value {
  528. flex: 1;
  529. textarea {
  530. flex: 1;
  531. border: 1px solid #888888;
  532. box-sizing: border-box;
  533. padding: 16rpx;
  534. }
  535. }
  536. }
  537. .btn {
  538. background-color: #1684fc;
  539. color: #ffffff;
  540. border-radius: 8rpx;
  541. margin: 4rpx 24rpx 24rpx 24rpx;
  542. height: 64rpx;
  543. justify-content: center;
  544. align-items: center;
  545. }
  546. input {
  547. margin: 48rpx 24rpx 0 24rpx;
  548. height: 64rpx;
  549. border: 1px solid #888888;
  550. text-align: center;
  551. }
  552. }
  553. </style>