编码识别问题完善

This commit is contained in:
BianLzhaoMin 2025-05-16 17:59:17 +08:00
parent a0cde7db6b
commit 0694c4c573
4 changed files with 585 additions and 427 deletions

View File

@ -66,7 +66,8 @@
<view>
<uni-easyinput
v-model="queryBindForm.codeSuffixStart"
type="number" maxlength="6"
type="number"
maxlength="6"
placeholder="开始值"
/>
</view>
@ -75,7 +76,8 @@
<view>
<uni-easyinput
v-model="queryBindForm.codeSuffixEnd"
type="number" maxlength="6"
type="number"
maxlength="6"
placeholder="结束值"
/>
</view>
@ -262,16 +264,18 @@ const onHandlerFill = () => {
console.log(passCodeNUm)
//
for (let i = 0; i < passCodeNUm; i++) {
let digitNum = -4;
if(codeSuffixEnd.length>4){
digitNum = 0-codeSuffixEnd.length;
let digitNum = -4
if (codeSuffixEnd.length > 4) {
digitNum = 0 - codeSuffixEnd.length
}
const codeItem = {
typeName,
maTypeName,
outFacCode: '',
// productDate: "",
maCode: `${codePrefix}${('000000'+Number(Number(codeSuffixStart) + i)).slice(digitNum)}`,
maCode: `${codePrefix}${('000000' + Number(Number(codeSuffixStart) + i)).slice(
digitNum,
)}`,
}
codeBindingList.value.push(codeItem)
}
@ -285,9 +289,7 @@ const onHandelDelete = (index) => {
//
const onCodeIdentify = () => {
uni.navigateTo({
url: `/pages/new-purchase/bind/ocr-bind?queryParams=${JSON.stringify(
queryParams.value,
)}`,
url: `/pages/new-purchase/bind/ocr-bind?queryParams=${JSON.stringify(queryParams.value)}`,
})
}

View File

@ -27,15 +27,28 @@
<uni-easyinput v-model="formData.qrCode" :disabled="true" />
</uni-forms-item>
<uni-forms-item label="设备编码:" name="maCode">
<uni-easyinput v-model="formData.maCode" :maxlength="50" placeholder="请输入设备编码"/>
<uni-easyinput
v-model="formData.maCode"
:maxlength="50"
placeholder="请输入设备编码"
/>
</uni-forms-item>
<uni-forms-item label="出厂编码:" name="outFacCode">
<uni-easyinput v-model="formData.outFacCode" :maxlength="50" placeholder="请输入出厂编码" />
<uni-easyinput
v-model="formData.outFacCode"
:maxlength="50"
placeholder="请输入出厂编码"
/>
</uni-forms-item>
<!-- <uni-forms-item label="出厂日期:" name="warnDocuments">
</uni-forms-item> -->
</uni-forms>
</div>
<ScanQrCode
ref="scanQrCodeRef"
@scanSuccess="handleScanSuccess"
@scanError="handleScanError"
/>
<div class="btn">
<button class="btn-cont" @click="backPage">取消</button>
<button class="btn-cont" @click="onHandleBinding">确认</button>
@ -45,9 +58,10 @@
<script setup>
import { ref, computed } from 'vue'
import { setBindCodingAPI,getTypeByQrcode } from '@/services/new-purchase/bind.js'
import { setBindCodingAPI, getTypeByQrcode } from '@/services/new-purchase/bind.js'
import { debounce } from 'lodash-es'
import { onShow, onLoad } from '@dcloudio/uni-app'
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
// const query = defineProps() //
// const queryParams = JSON.parse(query.queryParams)
const queryParams = ref({})
@ -63,6 +77,7 @@ const codeNun = ref(0)
const waitBindNum = computed(() => {
return queryParams.value.checkNum - queryParams.value.bindNum - codeNun.value
})
const scanQrCodeRef = ref(null)
onLoad((options) => {
queryParams.value = JSON.parse(options.queryParams)
@ -70,88 +85,106 @@ onLoad((options) => {
//
const scanStart = () => {
if(queryParams.value.checkNum - queryParams.value.bindNum - codeNun.value==0){
if (queryParams.value.checkNum - queryParams.value.bindNum - codeNun.value == 0) {
uni.showToast({ title: '待绑定数量为空!', icon: 'none' })
}else{
console.log('编码识别--')
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({
// qrCodebarCode
'scanType': ['qrCode','barCode'],
// false
'hideAlbum': false,
//ios zh-Hansen
'language' : 'en',
//(ios)
'failedMsg': '未识别到二维码,请重试',
//Android
'screenType': 'full'
},(ret) => {
console.log(ret)
if(ret.resp_code==10){
uni.showToast({ title: '用户取消', icon: 'none' })
} else {
if (scanQrCodeRef.value) {
scanQrCodeRef.value.scanQrCode()
}
if(ret.resp_code==11){
uni.showToast({ title: '扫码失败', icon: 'none' })
// console.log('--')
// var mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
// mpaasScanModule.mpaasScan(
// {
// // qrCodebarCode
// scanType: ['qrCode', 'barCode'],
// // false
// hideAlbum: false,
// //ios zh-Hansen
// 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) {
// // uni.showToast({ title: '', icon: 'none' })
// formData.value.qrCode = ret.resp_result.split('qrcode=')[1]
// codeInBind()
// }
// // uni.showModal({
// // title: "",
// // // resp_code 10111000
// // // resp_message
// // // resp_result
// // content: JSON.stringify(ret),
// // showCancel: false,
// // confirmText: ""
// // })
// },
// )
}
if(ret.resp_code==1000){
// uni.showToast({ title: '', icon: 'none' })
formData.value.qrCode = ret.resp_result.split("qrcode=")[1]
}
//
const handleScanSuccess = (result) => {
formData.value.qrCode = ''
formData.value.qrCode = result?.text.split('qrcode=')[1] || ''
if (formData.value.qrCode === '') {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
} else {
codeInBind()
}
// uni.showModal({
// title: "",
// // resp_code 10111000
// // resp_message
// // resp_result
// content: JSON.stringify(ret),
// showCancel: false,
// confirmText: ""
// })
})
}
}
//
const handleScanError = (error) => {
console.error('扫描出错:', error.message)
uni.showToast({ title: error.message, icon: 'none' })
}
const codeInBind = async () => {
let param = {
qrCode: formData.value.qrCode,
taskId: queryParams.value.taskId
taskId: queryParams.value.taskId,
}
//
const res = await getTypeByQrcode(param)
console.log(res)
if(res.code==200){
maInfo.value=res.data[0];
if(queryParams.value.typeId!=res.data[0].typeId){
uni.showToast({ title: '扫码识别物资类型与当前绑定类型不符!', icon: 'none'})
if (res.code == 200) {
maInfo.value = res.data[0]
if (queryParams.value.typeId != res.data[0].typeId) {
uni.showToast({ title: '扫码识别物资类型与当前绑定类型不符!', icon: 'none' })
}
if(res.data[0].maCode&&res.data[0].maCode!=""){
uni.showToast({ title: '二维码已绑定过设备编码!', icon: 'none'})
if (res.data[0].maCode && res.data[0].maCode != '') {
uni.showToast({ title: '二维码已绑定过设备编码!', icon: 'none' })
}
}else{
maInfo.value.typeId=""
uni.showToast({ title: '扫码识别失败', icon: 'none'})
} else {
maInfo.value.typeId = ''
uni.showToast({ title: '扫码识别失败', icon: 'none' })
}
}
//
const onHandleBinding = debounce(async () => {
console.log(formData.value.qrCode)
if(formData.value.qrCode==undefined||formData.value.qrCode==""){
if (formData.value.qrCode == undefined || formData.value.qrCode == '') {
uni.showToast({ title: '请先扫码后绑定', icon: 'none' })
return
}else if(queryParams.value.typeId!=maInfo.value.typeId){
} else if (queryParams.value.typeId != maInfo.value.typeId) {
uni.showToast({ title: '扫码识别物资类型与当前绑定类型不符!', icon: 'none' })
return
}else if(formData.value.maCode==""){
} else if (formData.value.maCode == '') {
uni.showToast({ title: '请输入绑定的设备编码', icon: 'none' })
return
}else{
} else {
let codeList = [
{
typeName: queryParams.value.typeName,
@ -174,10 +207,10 @@ const onHandleBinding = debounce(async () => {
title: '编码绑定成功!',
icon: 'none',
})
formData.value.qrCode = '';
formData.value.maCode = '';
formData.value.outFacCode = '';
codeNun.value = codeNun.value + 1;
formData.value.qrCode = ''
formData.value.maCode = ''
formData.value.outFacCode = ''
codeNun.value = codeNun.value + 1
uni.$emit('onUpdate', codeNun.value)
setTimeout(() => {
scanStart()

View File

@ -1,6 +1,6 @@
<template>
<view class="page-container">
<view>
<!-- <view>
<live-pusher
v-once
id="livePusher"
@ -18,9 +18,9 @@
:style="[{ height: cameraHeight + 'rpx', width: '750rpx' }]"
>
</live-pusher>
</view>
</view> -->
<view class="table-list-item">
<view class="scan-btn" @click="handleInstruct('shutter')">
<view class="scan-btn" @click="handleInstruct()">
<text style="color: #fff">开始识别</text>
</view>
</view>
@ -47,9 +47,9 @@
<uni-forms :model="codeData" label-width="90" :border="true">
<uni-forms-item label="识别编码:" name="typeName">
<uni-easyinput
v-model="codeData.maCode"
:disabled="true"
placeholder="识别编码"
v-model="codeData.maCode"
/>
</uni-forms-item>
<uni-forms-item label="出厂编号:" name="typeModelName">
@ -125,52 +125,138 @@ export default {
},
})
},
handleInstruct(instruct) {
if (this.ready) {
this.ready = false
this.livePusher.snapshot({
success: async (res) => {
console.log('拍照成功', res)
this.ready = true
let base64 = await this.imgToBase64(res.message.tempImagePath)
console.log('base64', base64)
handleInstruct() {
uni.showActionSheet({
itemList: ['拍照', '从相册选择'],
success: (res) => {
if (res.tapIndex === 0) {
this.getCamera()
} else if (res.tapIndex === 1) {
//
this.getPhoto()
}
},
fail: (err) => {
console.error('操作菜单选择失败:', err)
},
})
// if (this.ready) {
// this.ready = false
// this.livePusher.snapshot({
// success: async (res) => {
// console.log('', res)
// this.ready = true
// let base64 = await this.imgToBase64(res.message.tempImagePath)
// console.log('base64', base64)
// let params = {
// image: base64,
// jiju_type: '12231',
// auth_lic:
// 'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4=',
// }
// // uni.request({
// // url: '/material/app/ocr/getOcrCode',
// // method: 'post',
// // data: params,
// // header: {
// // 'Content-Type': 'application/json', // POST JSON
// // },
// // success: (res) => {
// // console.log('88888888', res)
// // if (res.code == 200) {
// // uni.showToast({
// // title: '',
// // icon: 'none',
// // })
// // } else {
// // uni.showToast({ title: '', icon: 'none' })
// // }
// // },
// // fail: (err) => {
// // uni.showToast({
// // title: err,
// // icon: 'none',
// // })
// // },
// // })
// //this.$emit('getImage', res.message.tempImagePath)
// },
// })
// }
},
getCamera() {
console.log(1)
navigator.camera.getPicture(this.onCameraSuccess, this.onCameraError, {
quality: 50,
destinationType: window.Camera.DestinationType.DATA_URL,
sourceType: window.Camera.PictureSourceType.CAMERA,
})
},
getPhoto() {
console.log(2)
navigator.camera.getPicture(this.onCameraSuccess, this.onCameraError, {
quality: 50,
destinationType: window.Camera.DestinationType.DATA_URL,
sourceType: window.Camera.PictureSourceType.SAVEDPHOTOALBUM,
})
},
onCameraError(message) {
console.log(message)
},
onCameraSuccess(file) {
// const file1 = "data:image/jpeg;base64," + file;
const file1 = file
let params = {
image: base64,
jiju_type: '12231',
image: file1,
jiju_type: '',
auth_lic:
'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4=',
}
// uni.request({
// url: '/material/app/ocr/getOcrCode',
// method: 'post',
// data: params,
// header: {
// 'Content-Type': 'application/json', // POST JSON
// },
// success: (res) => {
// console.log('88888888', res)
// if (res.code == 200) {
// uni.showToast({
// title: '',
// icon: 'none',
// })
// } else {
// uni.showToast({ title: '', icon: 'none' })
// }
// },
// fail: (err) => {
// uni.showToast({
// title: err,
// icon: 'none',
// })
// },
// })
//this.$emit('getImage', res.message.tempImagePath)
this.testParams = params
// this.$http
// .post("/dzqm/uploadSignature", {
// base64Str: file1,
// })
// .then((res) => {
// console.log(res);
// if (res.code == 200) {
// // this.src = file
// this.$set(this.obj, "src", file1);
// this.$toast("");
// this.PictureVisible = false;
// }
// });
uni.request({
url: '/material/app/ocr/getOcrCode',
method: 'post',
data: params,
header: {
'Content-Type': 'application/json', // POST JSON
},
success: (res) => {
const { data: resData } = res
if (resData.data.data.result) {
// this.queryCodeParams.maCode = resData.data.data.result
this.codeData.maCode = resData.data.data.result
} else {
uni.showToast({
title: '识别失败!' + resData.data.msg,
icon: 'none',
})
}
},
fail: (err) => {
uni.showToast({
title: '请求失败:' + err.errMsg,
icon: 'none',
})
},
})
},
imgToBase64(filePath) {
// return new Promise((resolve, reject) => {
@ -252,7 +338,15 @@ export default {
})
},
//
async onHandleBind() {
if (this.codeData.maCode == '') {
uni.showToast({
title: '请先识别设备编码!',
icon: 'none',
})
return
}
// let paramsList = []
// paramsList.push({
// maCode: this.codeData.maCode,
@ -336,14 +430,14 @@ export default {
}
.outbound-btn {
position: fixed;
position: absolute;
bottom: 40rpx;
left: 20%;
/* transform: translateX(-50%); */
left: 50%;
transform: translateX(-50%);
/* width: 90%; */
height: 88rpx;
width: 620rpx;
margin: 0 10px;
/* margin: 0 10px; */
/* background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%); */
background: #4b8eff;
display: flex;

View File

@ -30,6 +30,11 @@
</uni-col> -->
</uni-row>
</view>
<scan-qr-code
ref="scanQrCodeRef"
@scanSuccess="handleScanSuccess"
@scanError="handleScanError"
/>
<scroll-view scroll-y @scrolltolower="onScrollTolower" style="padding-bottom: 50rpx">
<view class="table-list-item" v-for="item in codeDeviceList" :key="item.id">
<uni-row :gutter="24">
@ -67,33 +72,30 @@
</scroll-view>
<view class="outbound-btn" @tap="onHandleOutbound"> 入库 </view>
<view class="checked-btn" @tap="checkedAll">
<span>全选</span><span>({{total}})</span>
<span>全选</span><span>({{ total }})</span>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { getMachineById, setInboundCodeAPI,getTypeByQrcodeApi } from '@/services/purchase.js'
import { getMaCodeByQrCodeApi } from '@/services/index.js';
import { getInfoBindByCode,appWarehouseApi } from '@/services/standard.js'
import { getMachineById, setInboundCodeAPI, getTypeByQrcodeApi } from '@/services/purchase.js'
import { getMaCodeByQrCodeApi } from '@/services/index.js'
import { getInfoBindByCode, appWarehouseApi } from '@/services/standard.js'
import { getTypeByQrcode } from '@/services/new-purchase/bind.js'
import { onBackPress, onLoad,onShow } from '@dcloudio/uni-app'
import { onBackPress, onLoad, onShow } from '@dcloudio/uni-app'
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
const codeDeviceList = ref([])
const total = ref(0)//
const total = ref(0) //
// const query = defineProps() //
// const queryParams = JSON.parse(query.queryParams)
const queryParams = ref({})
const boxCode = ref("")
const boxCode = ref('')
const boxInfo = ref({})
const qrCode = ref("")
const qrCode = ref('')
const maInfo = ref({})
const scanQrCodeRef = ref(null)
// const typeId = ref('')
// const taskId = ref('')
// const maTypeName = ref('')
@ -108,51 +110,74 @@ const onCodeIdentify = () => {
//
const codeScan = async () => {
if(codeDeviceList.value.length==0){
uni.showToast({ title: '待入库数量为空', icon: 'none'})
}else{
qrCode.value=""
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({
// qrCodebarCode
'scanType': ['qrCode','barCode'],
// false
'hideAlbum': false,
//ios zh-Hansen
'language' : 'en',
//(ios)
'failedMsg': '未识别到二维码,请重试',
//Android
'screenType': 'full'
},(ret) => {
console.log(ret)
if(ret.resp_code==10){
uni.showToast({ title: '用户取消', icon: 'none' })
if (codeDeviceList.value.length == 0) {
uni.showToast({ title: '待入库数量为空', icon: 'none' })
} else {
qrCode.value = ''
if (scanQrCodeRef.value) {
scanQrCodeRef.value.scanQrCode()
}
if(ret.resp_code==11){
uni.showToast({ title: '扫码失败', icon: 'none' })
// var mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
// mpaasScanModule.mpaasScan(
// {
// // qrCodebarCode
// scanType: ['qrCode', 'barCode'],
// // false
// hideAlbum: false,
// //ios zh-Hansen
// 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) {
// qrCode.value = ret.resp_result.split('qrcode=')[1]
// codeInBound()
// }
// // uni.showModal({
// // title: "",
// // // resp_code 10111000
// // // resp_message
// // // resp_result
// // content: JSON.stringify(ret),
// // showCancel: false,
// // confirmText: ""
// // })
// },
// )
}
if(ret.resp_code==1000){
qrCode.value = ret.resp_result.split("qrcode=")[1];
}
//
const handleScanSuccess = (result) => {
qrCode.value = ''
qrCode.value = result?.text.split('qrcode=')[1] || ''
if (qrCode.value === '') {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
} else {
codeInBound()
}
// uni.showModal({
// title: "",
// // resp_code 10111000
// // resp_message
// // resp_result
// content: JSON.stringify(ret),
// showCancel: false,
// confirmText: ""
// })
})
}
}
//
const handleScanError = (error) => {
console.error('扫描出错:', error.message)
uni.showToast({ title: error.message, icon: 'none' })
}
//
const codeInBound = async () => {
if(qrCode.value==""){
uni.showToast({ title: '扫码识别失败', icon: 'none'})
}else{
if (qrCode.value == '') {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
} else {
let param = {
qrCode: qrCode.value,
}
@ -160,13 +185,13 @@ const codeInBound = async () => {
//
const res = await getMaCodeByQrCodeApi(param)
console.log(res)
if(res.code==200){
if (res.code == 200) {
maInfo.value = res.data
if(maInfo.value.maCode==undefined||maInfo.value.maCode==""){
uni.showToast({ title: '扫码二维码未绑定设备编码!', icon: 'none'})
}else if(maInfo.value.maStatus==1){
uni.showToast({ title: '扫码设备已在库!', icon: 'none'})
}else{
if (maInfo.value.maCode == undefined || maInfo.value.maCode == '') {
uni.showToast({ title: '扫码二维码未绑定设备编码!', icon: 'none' })
} else if (maInfo.value.maStatus == 1) {
uni.showToast({ title: '扫码设备已在库!', icon: 'none' })
} else {
uni.showModal({
title: '提示',
content: `扫码到二维码${qrCode.value}所绑定的设备编码为${maInfo.value.maCode},是否确定入库?`,
@ -176,22 +201,22 @@ const codeInBound = async () => {
if (res.confirm) {
confirmCodeInBound()
}
}
},
})
}
}else{
uni.showToast({ title: '扫码识别失败', icon: 'none'})
} else {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
}
}
}
//
const confirmCodeInBound = async () => {
let arr=[{"maCode":maInfo.value.maCode}]
let arr = [{ maCode: maInfo.value.maCode }]
let param = {
taskId: queryParams.value.taskId,
typeId: queryParams.value.typeId,
purchaseId: queryParams.value.id,
inPutList: arr
inPutList: arr,
}
const res = await setInboundCodeAPI(param)
@ -210,45 +235,48 @@ const confirmCodeInBound = async () => {
//
const boxScan = async () => {
boxCode.value=""
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({
boxCode.value = ''
var mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
mpaasScanModule.mpaasScan(
{
// qrCodebarCode
'scanType': ['qrCode','barCode'],
scanType: ['qrCode', 'barCode'],
// false
'hideAlbum': false,
hideAlbum: false,
//ios zh-Hansen
'language' : 'en',
language: 'en',
//(ios)
'failedMsg': '未识别到二维码,请重试',
failedMsg: '未识别到二维码,请重试',
//Android
'screenType': 'full'
},(ret) => {
screenType: 'full',
},
(ret) => {
console.log(ret)
if(ret.resp_code==10){
if (ret.resp_code == 10) {
uni.showToast({ title: '用户取消', icon: 'none' })
}
if(ret.resp_code==11){
if (ret.resp_code == 11) {
uni.showToast({ title: '扫码失败', icon: 'none' })
}
if(ret.resp_code==1000){
boxCode.value = ret.resp_result;
if (ret.resp_code == 1000) {
boxCode.value = ret.resp_result
boxInBound()
}
})
},
)
}
//
const boxInBound = async () => {
if(boxCode.value==""){
uni.showToast({ title: '扫码识别失败', icon: 'none'})
}else{
if (boxCode.value == '') {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
} else {
let param = {
boxCode: boxCode.value,
maTypeId:queryParams.value.typeId
maTypeId: queryParams.value.typeId,
}
const res = await getInfoBindByCode(param)
console.log(res)
if(res.code==200){
if (res.code == 200) {
boxInfo.value = res.data
uni.showModal({
title: '提示',
@ -257,14 +285,14 @@ const boxInBound = async () => {
cancelText: '取消',
success: async (res) => {
if (res.confirm) {
if(boxInfo.value.successMaTotal>0){
if (boxInfo.value.successMaTotal > 0) {
confirmBoxInBound()
}
}
}
},
})
}else{
uni.showToast({ title: '扫码识别失败', icon: 'none'})
} else {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
}
}
}
@ -281,7 +309,7 @@ const confirmBoxInBound = async () => {
icon: 'none',
})
getCodeDeviceListData()
}else{
} else {
uni.showToast({ title: '入库失败', icon: 'none' })
}
}
@ -303,8 +331,8 @@ const getCodeDeviceListData = async () => {
taskId: queryParams.value.taskId,
}
const res = await getMachineById(obj)
codeDeviceList.value=res.data;
total.value=0;
codeDeviceList.value = res.data
total.value = 0
if (codeDeviceList.value.length > 0) {
codeDeviceList.value = codeDeviceList.value.map((e) => {
return { ...e, checked: false }
@ -319,27 +347,27 @@ const onScrollTolower = () => {
//
const onChangeChecked = (item) => {
item.checked = !item.checked;
item.checked = !item.checked
let arr = []
codeDeviceList.value.forEach((e) => {
if(e.checked==true){
if (e.checked == true) {
return arr.push(e)
}
})
console.log(arr)
total.value=arr.length;
total.value = arr.length
}
//
const checkedAll = () => {
if(total.value<codeDeviceList.value.length){
total.value=codeDeviceList.value.length;
if (total.value < codeDeviceList.value.length) {
total.value = codeDeviceList.value.length
codeDeviceList.value.forEach((e) => {
e.checked=true;
e.checked = true
})
}else if(total.value==codeDeviceList.value.length){
total.value=0;
} else if (total.value == codeDeviceList.value.length) {
total.value = 0
codeDeviceList.value.forEach((e) => {
e.checked=false;
e.checked = false
})
}
}
@ -354,9 +382,9 @@ const onHandleOutbound = async () => {
})
return
}
let maxNum = Number(queryParams.value.purchaseNum)-Number(queryParams.value.inputNum)
let maxNum = Number(queryParams.value.purchaseNum) - Number(queryParams.value.inputNum)
console.log(maxNum)
if(total.value>maxNum){
if (total.value > maxNum) {
uni.showToast({
title: '勾选设备超过待入库数量!',
icon: 'none',
@ -379,7 +407,7 @@ const onHandleOutbound = async () => {
inPutList: paramsList,
}
const res = await setInboundCodeAPI(param)
console.log(res,"入库")
console.log(res, '入库')
if (res.code === 200) {
uni.showToast({
title: '入库成功!',
@ -387,7 +415,7 @@ const onHandleOutbound = async () => {
})
getCodeDeviceListData()
setTimeout(() => {
queryParams.value.inputNum=Number(queryParams.value.inputNum)+paramsList.length
queryParams.value.inputNum = Number(queryParams.value.inputNum) + paramsList.length
}, 800)
}
}
@ -464,7 +492,8 @@ const onHandleOutbound = async () => {
.line {
margin: 24rpx 0;
height: 2rpx;
background: linear-gradient(90deg,
background: linear-gradient(
90deg,
rgba(232, 232, 232, 0) 0%,
rgba(232, 232, 232, 1) 50%,
rgba(232, 232, 232, 0) 100%