领料出库二维码识别功能

This commit is contained in:
hongchao 2024-12-26 15:51:32 +08:00
parent 453e655c89
commit c1e08bd4cf
3 changed files with 76 additions and 16 deletions

View File

@ -50,12 +50,13 @@
</uni-row> </uni-row>
</view> </view>
<view class="table-list-item"> <view class="table-list-item">
<scroll-view class="scroll-view" scroll-y="true" style="height: 300rpx;">
<uni-forms :model="codeData" label-width="100" :border="true"> <uni-forms :model="codeData" label-width="100" :border="true">
<uni-forms-item label="物资类型:" name="materialName"> <uni-forms-item label="物资类型:" name="typeName">
<span class="form-view">{{ codeData.materialName }}</span> <span class="form-view">{{ codeData.typeName }}</span>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="规格型号:" name="materialModel"> <uni-forms-item label="规格型号:" name="typeModelName">
<span class="form-view">{{ codeData.materialModel }}</span> <span class="form-view">{{ codeData.typeModelName }}</span>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="设备状态:" name="statusName"> <uni-forms-item label="设备状态:" name="statusName">
<span class="form-view">{{ codeData.statusName }}</span> <span class="form-view">{{ codeData.statusName }}</span>
@ -64,6 +65,7 @@
<span class="form-view">1</span> <span class="form-view">1</span>
</uni-forms-item> </uni-forms-item>
</uni-forms> </uni-forms>
</scroll-view>
</view> </view>
<view class="outbound-btn" @tap="onHandleOutbound"> 出库 </view> <view class="outbound-btn" @tap="onHandleOutbound"> 出库 </view>
@ -90,9 +92,13 @@ const queryCodeParams = ref({
typeId: '', typeId: '',
maStatus: 1, maStatus: 1,
maCode: '', maCode: '',
qrCode: '',
}) })
const qrCodeScan = ref('')
onLoad((options) => { onLoad((options) => {
console.log('options', options)
queryParams.value = JSON.parse(options.queryParams) queryParams.value = JSON.parse(options.queryParams)
queryCodeParams.value.typeId = queryParams.value.typeId queryCodeParams.value.typeId = queryParams.value.typeId
}) })
@ -106,15 +112,22 @@ const maxNum = computed(() => {
const scanStart = () => { const scanStart = () => {
console.log('编码识别--') console.log('编码识别--')
// //
uni.scanCode({ // uni.scanCode({
onlyFromCamera: true, // onlyFromCamera: true,
scanType: ['qrCode', 'pdf417'], // scanType: ['qrCode', 'pdf417'],
success: (res) => { // success: (res) => {
console.log('扫码结果:' + res.result) // console.log('' + res.result)
queryCodeParams.value.maCode = res.result.split("qrcode=")[1] // qrCodeScan.value = res.result.split("qrcode=")[1]
}, // queryCodeParams.value.maCode = res.result.split("qrcode=")[1]
fail: (err) => {}, // if (qrCodeScan.value=="") {
}) // uni.showToast({ title: '', icon: 'none'})
// }else{
// getMaInfoScan()
// }
// },
// fail: (err) => {},
// })
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module") var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({ mpaasScanModule.mpaasScan({
@ -132,8 +145,21 @@ const scanStart = () => {
if(ret.resp_code==10){ if(ret.resp_code==10){
uni.showToast({ title: '用户取消', icon: 'none' }) uni.showToast({ title: '用户取消', icon: 'none' })
} }
if(ret.resp_code==11){
uni.showToast({ title: '扫码失败', icon: 'none' })
}
if(ret.resp_code==1000){ if(ret.resp_code==1000){
uni.showToast({ title: '成功', icon: 'none' }) uni.showToast({ title: '成功', icon: 'none' })
console.log('1111',ret.resp_result)
qrCodeScan.value = ret.resp_result.split("qrcode=")[1]
// queryCodeParams.value.maCode = ret.resp_result.split("qrcode=")[1]
queryCodeParams.value.qrCode = ret.resp_result.split("qrcode=")[1]
if (qrCodeScan.value=="") {
uni.showToast({ title: '扫码识别失败', icon: 'none'})
}else{
getMaInfoScan()
//
}
} }
// uni.showModal({ // uni.showModal({
// title: "", // title: "",
@ -148,6 +174,25 @@ const scanStart = () => {
} }
//
const getMaInfoScan = async () => {
const res = await getCodeDeviceListAPI(queryCodeParams.value)
console.log(res)
if (res.code == 200) {
if (res.data && res.data.recordList.length > 0) {
// codeData.value = res.rows[0]
queryCodeParams.value.maCode = res.data.recordList[0].maCode
codeData.value = res.data.recordList[0]
uni.showToast({ title: res.data.msg, icon: 'none'})
}else{
uni.showToast({ title: res.data.msg, icon: 'none'})
}
} else {
uni.showToast({ title: res.data.msg, icon: 'none' })
}
}
// //
const getMaInfo = async () => { const getMaInfo = async () => {
console.log('queryCodeParams', queryCodeParams.value) console.log('queryCodeParams', queryCodeParams.value)
@ -165,7 +210,21 @@ const getMaInfo = async () => {
// //
const onHandleOutbound = async () => { const onHandleOutbound = async () => {
// //
const paramsList = [codeData.value] let paramsList = []
paramsList.push({
maCode: codeData.value.maCode,
maId: codeData.value.maId,
leaseType:0,
outType:2,
outNum:1,
typeId:codeData.value.typeId,
manageType: codeData.value.manageType,
parentId: queryParams.value.parentId,
typeName: codeData.value.typeName,
typeModelName: codeData.value.typeModelName,
})
console.log('333333333', paramsList)
const res = await setOutboundNumAPI({ leaseOutDetailsList: paramsList }) const res = await setOutboundNumAPI({ leaseOutDetailsList: paramsList })
if (res.code === 200) { if (res.code === 200) {
uni.showToast({ uni.showToast({
@ -184,6 +243,7 @@ onShow(() => {
// scanStart() // scanStart()
}, 500) }, 500)
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -346,7 +346,7 @@ const onHandleOutbound = async () => {
}) })
} }
}) })
console.log()
const res = await setOutboundNumAPI({ leaseOutDetailsList: paramsList }) const res = await setOutboundNumAPI({ leaseOutDetailsList: paramsList })
if (res.code === 200) { if (res.code === 200) {

View File

@ -35,7 +35,7 @@ export const setOutboundNumAPI = (data) => {
export const getCodeDeviceListAPI = (data) => { export const getCodeDeviceListAPI = (data) => {
return http({ return http({
method: 'GET', method: 'GET',
url: '/material/ma_machine/list', url: '/material/lease_apply_info/getInfoByQrcode',
data, data,
}) })
} }