领料出库二维码识别功能

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>
</view>
<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-item label="物资类型:" name="materialName">
<span class="form-view">{{ codeData.materialName }}</span>
<uni-forms-item label="物资类型:" name="typeName">
<span class="form-view">{{ codeData.typeName }}</span>
</uni-forms-item>
<uni-forms-item label="规格型号:" name="materialModel">
<span class="form-view">{{ codeData.materialModel }}</span>
<uni-forms-item label="规格型号:" name="typeModelName">
<span class="form-view">{{ codeData.typeModelName }}</span>
</uni-forms-item>
<uni-forms-item label="设备状态:" name="statusName">
<span class="form-view">{{ codeData.statusName }}</span>
@ -64,6 +65,7 @@
<span class="form-view">1</span>
</uni-forms-item>
</uni-forms>
</scroll-view>
</view>
<view class="outbound-btn" @tap="onHandleOutbound"> 出库 </view>
@ -90,9 +92,13 @@ const queryCodeParams = ref({
typeId: '',
maStatus: 1,
maCode: '',
qrCode: '',
})
const qrCodeScan = ref('')
onLoad((options) => {
console.log('options', options)
queryParams.value = JSON.parse(options.queryParams)
queryCodeParams.value.typeId = queryParams.value.typeId
})
@ -106,15 +112,22 @@ const maxNum = computed(() => {
const scanStart = () => {
console.log('编码识别--')
//
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode', 'pdf417'],
success: (res) => {
console.log('扫码结果:' + res.result)
queryCodeParams.value.maCode = res.result.split("qrcode=")[1]
},
fail: (err) => {},
})
// uni.scanCode({
// onlyFromCamera: true,
// scanType: ['qrCode', 'pdf417'],
// success: (res) => {
// console.log('' + res.result)
// qrCodeScan.value = res.result.split("qrcode=")[1]
// queryCodeParams.value.maCode = res.result.split("qrcode=")[1]
// if (qrCodeScan.value=="") {
// uni.showToast({ title: '', icon: 'none'})
// }else{
// getMaInfoScan()
// }
// },
// fail: (err) => {},
// })
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({
@ -132,8 +145,21 @@ const scanStart = () => {
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' })
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({
// 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 () => {
console.log('queryCodeParams', queryCodeParams.value)
@ -165,7 +210,21 @@ const getMaInfo = 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 })
if (res.code === 200) {
uni.showToast({
@ -184,6 +243,7 @@ onShow(() => {
// scanStart()
}, 500)
})
</script>
<style lang="scss" scoped>

View File

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

View File

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