scan.vue 11 KB

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