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: {
|
2022-10-03 02:55:30 +00:00
|
|
|
prestamoIdPrestamo: { type: Function, required: true, default: () => {} },
|
|
|
|
resetTab: { type: Function, required: true, default: () => {} },
|
2022-07-11 20:03:39 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return { idPrestamo: '' }
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
resetear() {
|
|
|
|
if (this.idPrestamo) this.idPrestamo = ''
|
|
|
|
},
|
|
|
|
onDecode(decodedString) {
|
|
|
|
let decodedData = {}
|
|
|
|
|
|
|
|
try {
|
|
|
|
decodedData = JSON.parse(decodedString)
|
|
|
|
} catch (err) {
|
|
|
|
this.resetear()
|
|
|
|
}
|
2022-10-03 02:55:30 +00:00
|
|
|
this.resetTab()
|
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>
|