scan.vue 11 KB

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