bonus-material-app/src/pages/repair/testedInBound/codeScan.vue

346 lines
10 KiB
Vue
Raw Normal View History

2024-12-19 09:06:26 +08:00
<template>
2024-12-31 15:37:54 +08:00
<view class="accept page-common">
2025-01-24 18:00:07 +08:00
<view class="card" style="margin-top: 10px;">
2024-12-19 09:06:26 +08:00
<uni-row :gutter="24">
2024-12-31 15:37:54 +08:00
<uni-col :span="6">入库方式</uni-col>
2024-12-19 09:06:26 +08:00
<uni-col :span="6">
2025-01-24 18:00:07 +08:00
<view class="coding-btn" @click="ocrScan">编码识别</view>
2024-12-19 09:06:26 +08:00
</uni-col>
<uni-col :span="6">
2024-12-31 15:37:54 +08:00
<view class="coding-btn" @click="codeScan">二维码识别</view>
2024-12-19 09:06:26 +08:00
</uni-col>
<!-- <uni-col :span="6">
2025-01-03 18:19:03 +08:00
<view class="coding-btn" @click="boxScan">标准箱识别</view>
</uni-col> -->
2024-12-19 09:06:26 +08:00
</uni-row>
2025-01-24 18:00:07 +08:00
</view>
<view class="card" style="margin-top: 10px;">
<view style="font-size: 32rpx;font-weight: 600;margin-bottom: 20rpx;">设备信息</view>
2024-12-31 15:37:54 +08:00
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
<uni-col :span="8">退料单位</uni-col>
<uni-col :span="16">
{{ maInfo.backUnit }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
<uni-col :span="8">退料工程</uni-col>
<uni-col :span="16">
{{ maInfo.backPro }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
<uni-col :span="8">二维码编号</uni-col>
<uni-col :span="16">
{{ maInfo.qrCode }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
<uni-col :span="8">设备编码</uni-col>
<uni-col :span="16">
{{ maInfo.maCode }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
<uni-col :span="8">物资类型</uni-col>
<uni-col :span="16">
{{ maInfo.typeName }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
<uni-col :span="8">规格型号</uni-col>
<uni-col :span="16">
{{ maInfo.typeModelName }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
<uni-col :span="8">维修单号</uni-col>
<uni-col :span="16">
{{ maInfo.repairCode }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
<uni-col :span="8">入库单号</uni-col>
<uni-col :span="16">
{{ maInfo.inputCode }}
</uni-col>
</uni-row>
2024-12-19 09:06:26 +08:00
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
2024-12-31 15:37:54 +08:00
<uni-col :span="8">设备状态</uni-col>
2024-12-19 09:06:26 +08:00
<uni-col :span="16">
2024-12-31 15:37:54 +08:00
{{ maInfo.statusName }}
2024-12-19 09:06:26 +08:00
</uni-col>
2024-12-31 15:37:54 +08:00
</uni-row>
2025-01-24 18:00:07 +08:00
</view>
2024-12-19 09:06:26 +08:00
2025-01-24 18:00:07 +08:00
<view class="btn">
2024-12-31 15:37:54 +08:00
<button class="btn-cont" @click="cinfirmCodeInBound">入库</button>
2024-12-19 09:06:26 +08:00
<button class="btn-cont" @click="cancelPage">取消</button>
2025-01-24 18:00:07 +08:00
</view>
2024-12-19 09:06:26 +08:00
</view>
</template>
<script setup>
import { ref, reactive } from 'vue'
2024-12-31 15:37:54 +08:00
import { onLoad } from '@dcloudio/uni-app'
2025-06-15 10:08:08 +08:00
import { getCodeListApi,repairInputWarehouseApi,rejectWarehouseApi,getInfoByQrcodeApi,repairInputWarehouseApiTwo } from '@/services/repair/testedInBound.js'
2025-01-24 18:00:07 +08:00
import { getBoxCodeListApi } from '@/services/standard.js'
2024-12-19 09:06:26 +08:00
const taskInfo = ref({})
const maId = ref("") //编码
const maCode = ref("") //编码
const typeName = ref("")//物资类型
const materialName = ref("") //规格型号
const typeId = ref("") //类型id
2024-12-31 15:37:54 +08:00
const maStatusName = ref("") //状态
const qrCode = ref("") //二维码
const maInfo = ref({}) //二维码
2025-01-03 18:19:03 +08:00
const boxCode = ref("") //标准箱
const boxInfo = ref([])
2024-12-19 09:06:26 +08:00
2025-01-24 18:00:07 +08:00
//编码识别
const ocrScan = () => {
}
2024-12-31 15:37:54 +08:00
// 二维码扫码
const codeScan = async () => {
qrCode.value=""
2025-06-15 10:08:08 +08:00
// var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
uni.scanCode({
success: function (res) {
// qrCode.value = res.resp_result.split("qrcode=")[1];
console.log('条码内容:' + res.result);
qrCode.value = res.result
2024-12-31 15:37:54 +08:00
codeInBound()
}
2025-06-15 10:08:08 +08:00
});
// mpaasScanModule.mpaasScan({
// // 扫码识别类型参数可多选qrCode、barCode不设置默认识别所有
// 'scanType': ['qrCode','barCode'],
// // 是否隐藏相册默认false不隐藏
// 'hideAlbum': false,
// //ios需要设置这个参数只支持中英文 zh-Hans、en默认中文
// 'language' : 'en',
// //相册选择照片识别错误提示(ios)
// 'failedMsg': '未识别到二维码,请重试',
// //Android支持全屏需要设置此参数
// 'screenType': 'full'
// },(ret) => {
// console.log(ret)
// if(ret.resp_code==10){
// uni.showToast({ title: '用户取消', icon: 'none' })
// maInfo.value = {}
// }
// if(ret.resp_code==11){
// uni.showToast({ title: '扫码失败', icon: 'none' })
// }
// if(ret.resp_code==1000){
// // uni.showToast({ title: '扫码成功', icon: 'none' })
// qrCode.value = ret.resp_result.split("qrcode=")[1];
// codeInBound()
// }
// // uni.showModal({
// // title: "弹窗标题",
// // // 返回值中resp_code 表示返回结果值10用户取消11其他错误1000成功
// // // 返回值中resp_message 表示返回结果信息
// // // 返回值中resp_result 表示扫码结果,只有成功才会有返回
// // content: JSON.stringify(ret),
// // showCancel: false,
// // confirmText: "确定"
// // })
// })
2024-12-19 09:06:26 +08:00
}
2024-12-31 15:37:54 +08:00
// 二维码入库
const codeInBound = async () => {
if(qrCode.value==""){
uni.showToast({ title: '扫码识别失败', icon: 'none'})
}else{
let param = {
qrCode: qrCode.value,
}
//通过二维码获取相绑定的设备编码
const res = await getInfoByQrcodeApi(param)
console.log(res)
2025-01-24 18:00:07 +08:00
if(res.code==200){
2024-12-31 15:37:54 +08:00
maInfo.value = res.data[0]
2025-06-15 10:08:08 +08:00
if(maInfo.value.maId!=undefined&&maInfo.value.maId!=""){
2024-12-31 15:37:54 +08:00
}else{
uni.showToast({ title: '扫码二维码未绑定设备编码!', icon: 'none'})
}
}else{
uni.showToast({ title: res.data.msg, icon: 'none'})
}
}
2024-12-19 09:06:26 +08:00
}
2024-12-31 15:37:54 +08:00
// 二维码入库确认
const cinfirmCodeInBound = async () => {
if(maInfo.value.taskId==''&&maInfo.value.typeId==''){
uni.showToast({
title: '请先扫码!',
icon: 'none',
})
}else{
2025-06-15 10:08:08 +08:00
// let arr=[{"maId":maInfo.value.maId}]
// let param = {
// taskId: maInfo.value.taskId,
// typeId: maInfo.value.typeId,
// agreementId: maInfo.value.agreementId,
// maCodeList: arr,
// }
let param = {qrCode:qrCode.value}
console.log("bbbbbbbbbbbbbbbbb")
const res = await repairInputWarehouseApiTwo(param)
console.log("yyyyyyyyy",res)
2024-12-31 15:37:54 +08:00
if (res.code === 200) {
uni.showToast({
title: '入库成功!',
icon: 'none',
})
setTimeout(() => {
codeScan()
}, 800)
2024-12-19 09:06:26 +08:00
}
2024-12-31 15:37:54 +08:00
}
2024-12-19 09:06:26 +08:00
}
2025-01-03 18:19:03 +08:00
// 标准箱识别
const boxScan = async () => {
boxCode.value=""
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({
// 扫码识别类型参数可多选qrCode、barCode不设置默认识别所有
'scanType': ['qrCode','barCode'],
// 是否隐藏相册默认false不隐藏
'hideAlbum': false,
//ios需要设置这个参数只支持中英文 zh-Hans、en默认中文
'language' : 'en',
//相册选择照片识别错误提示(ios)
'failedMsg': '未识别到二维码,请重试',
//Android支持全屏需要设置此参数
'screenType': 'full'
},(ret) => {
console.log(ret)
if(ret.resp_code==10){
uni.showToast({ title: '用户取消', icon: 'none' })
}
if(ret.resp_code==11){
uni.showToast({ title: '扫码失败', icon: 'none' })
}
if(ret.resp_code==1000){
boxCode.value = ret.resp_result;
boxInBound()
}
})
}
// 标准箱入库
const boxInBound = async () => {
if(boxCode.value==""){
uni.showToast({ title: '扫码识别失败', icon: 'none'})
}else{
let param = {
boxCode: boxCode.value,
maTypeId:queryParams.value.typeId
}
const res = await getBoxCodeListApi(param)
console.log(res)
if(res.code==200){
if(res.data.length>0){
let successMaTotal = res.data.length
boxInfo.value = res.data
uni.showModal({
title: '提示',
content: `监测到${boxCode.value}标准箱中符合入库条件设备${boxInfo.value.successMaTotal}台,是否确定入库?`,
confirmText: '确定',
cancelText: '取消',
success: async (res) => {
if (res.confirm) {
if(boxInfo.value.successMaTotal>0){
confirmBoxInBound()
}
}
}
})
}
//
}else{
uni.showToast({ title: '扫码识别失败', icon: 'none'})
}
}
}
// 标准箱入库确认
const confirmBoxInBound = async () => {
}
2024-12-31 15:37:54 +08:00
2024-12-19 09:06:26 +08:00
const cancelPage = () => {
uni.navigateBack({
delta: 1 // 返回到已存在的页面
});
}
onLoad((options)=>{
console.log(options)
2024-12-31 15:37:54 +08:00
// taskInfo.value = JSON.parse(options.taskInfo)
2024-12-19 09:06:26 +08:00
})
</script>
<style lang="scss">
.accept {
padding: 10px;
height: 100%;
word-break: break-all;
}
.card {
padding: 10px;
background-color: #fff;
border-radius: 6px;
box-shadow: 0 2upx 4upx 0 rgba(0, 0, 0, 0.1);
}
.coding-btn {
padding: 5rpx 0;
background-color: #409eff;
border-radius: 6rpx;
text-align: center;
color: #fff;
font-size: 14px;
}
.upload {
width: 80px;
height: 80px;
background-color: #f5f5f5;
border-radius: 6px;
display: flex;
justify-content: center;
align-items: center;
font-size: 20px;
color: #ccc;
margin-top: 10px;
}
.btn {
display: flex;
justify-content: space-around;
margin-top: 30px;
.btn-cont {
width: 40%;
height: 40px;
line-height: 40px;
text-align: center;
background-color: #3784fb;
color: #fff;
2024-12-31 15:37:54 +08:00
border-radius: 10rpx;
2024-12-19 09:06:26 +08:00
// 取消按钮淡蓝色
2024-12-31 15:37:54 +08:00
&:last-child {
2024-12-19 09:06:26 +08:00
background-color: #aacefb;
}
}
}
</style>