scan.vue 13 KB

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