84 lines
2.1 KiB
Vue
84 lines
2.1 KiB
Vue
<template>
|
|
<StreamBarcodeReader @decode="onDecode"> </StreamBarcodeReader>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
import { StreamBarcodeReader } from 'vue-barcode-reader'
|
|
|
|
export default {
|
|
components: { StreamBarcodeReader },
|
|
data() {
|
|
return {
|
|
idAlumno: '',
|
|
idAlumnoAnterior: '',
|
|
leyendo: false,
|
|
isLoading: false,
|
|
}
|
|
},
|
|
props: {
|
|
imprimirWarning: { type: Function, required: true },
|
|
imprimirError: { type: Function, required: true },
|
|
imprimirMensaje: { type: Function, required: true },
|
|
actualizarIsLoading: { type: Function, required: true },
|
|
actualizarUpdateTabla: { type: Function, required: true },
|
|
},
|
|
methods: {
|
|
resetear() {
|
|
this.idAlumno = ''
|
|
this.leyendo = false
|
|
},
|
|
noSeguir() {
|
|
this.resetear()
|
|
this.idAlumnoAnterior = ''
|
|
},
|
|
confirmarAsistencia() {
|
|
const data = { idAlumno: this.idAlumno }
|
|
|
|
this.actualizarIsLoading(true)
|
|
axios
|
|
.put(`${process.env.api}/alumno/pasar_lista`, data)
|
|
.then((res) => {
|
|
this.resetear()
|
|
this.actualizarUpdateTabla(true)
|
|
this.actualizarIsLoading(false)
|
|
this.imprimirMensaje(res.data.message)
|
|
})
|
|
.catch((err) => {
|
|
this.actualizarIsLoading(false)
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
},
|
|
onDecode(decodedString) {
|
|
try {
|
|
this.idAlumno = JSON.parse(decodedString).idAlumno
|
|
} catch (err) {
|
|
this.idAlumno = ''
|
|
this.imprimirError({ message: 'Este QR no es valido.' })
|
|
}
|
|
if (!this.leyendo) {
|
|
if (this.idAlumno && this.idAlumno != this.idAlumnoAnterior) {
|
|
this.leyendo = true
|
|
this.idAlumnoAnterior = this.idAlumno
|
|
this.imprimirWarning(
|
|
'Estas a punto de pasar asistencia a este alumno ¿Esta seguro de querer realizar esta acción?',
|
|
this.confirmarAsistencia,
|
|
this.noSeguir
|
|
)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
video {
|
|
width: 100%;
|
|
}
|
|
|
|
.laser,
|
|
.overlay-element {
|
|
display: none;
|
|
}
|
|
</style> |