reviewScan.vue 12 KB

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