reviewScan.vue 16 KB

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