scan.vue 11 KB

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