pcpuma_unam_operador/components/operador/Scanner.vue

41 lines
915 B
Vue
Raw Normal View History

2022-07-11 20:03:39 +00:00
<template>
<QrcodeStream @decode="onDecode"> </QrcodeStream>
</template>
<script>
import { QrcodeStream } from 'vue-qrcode-reader'
export default {
components: { QrcodeStream },
props: {
prestamoIdPrestamo: { type: Function, required: true },
},
data() {
return { idPrestamo: '' }
},
methods: {
resetear() {
if (this.idPrestamo) this.idPrestamo = ''
},
onDecode(decodedString) {
let decodedData = {}
try {
decodedData = JSON.parse(decodedString)
} catch (err) {
this.resetear()
}
2022-08-19 16:47:30 +00:00
if (decodedData.id_prestamo) {
if (typeof decodedData.id_prestamo === 'number')
this.idPrestamo = decodedData.id_prestamo.toString()
else this.idPrestamo = decodedData.id_prestamo
2022-07-11 20:03:39 +00:00
}
if (this.idPrestamo)
this.prestamoIdPrestamo(this.idPrestamo, this.resetear)
},
},
}
</script>
<style></style>