scan.vue 11 KB

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