reviewScan.vue 14 KB

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