97 lines
2.6 KiB
Vue
97 lines
2.6 KiB
Vue
<template>
|
|
<b-tab-item label="Motivos">
|
|
<div class="has-text-centered">
|
|
<BotonDescargarCatalogo
|
|
campo="reporte"
|
|
:nombreArchivo="`reporte_motivos_${carrito.modulo.modulo}_${carrito.carrito}`"
|
|
:obtener="obtenerMotivosReporte"
|
|
v-if="operador.tipoUsuario.id_tipo_usuario === 3"
|
|
/>
|
|
</div>
|
|
|
|
<TablaMotivosCarrito
|
|
:motivos="motivos"
|
|
:page="page"
|
|
:total="total"
|
|
:isLoadingTable="isLoadingTable"
|
|
:onPageChange="onPageChange"
|
|
/>
|
|
</b-tab-item>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
import moment from 'moment'
|
|
import BotonDescargarCatalogo from '@/components/botones/BotonDescargarCatalogo'
|
|
import TablaMotivosCarrito from '@/components/tablas/TablaMotivosCarrito'
|
|
|
|
export default {
|
|
components: { BotonDescargarCatalogo, TablaMotivosCarrito },
|
|
props: {
|
|
operador: { type: Object, required: true, default: () => ({}) },
|
|
carrito: { type: Object, required: true, default: () => ({}) },
|
|
},
|
|
data() {
|
|
return { motivos: [], page: 1, total: 0, isLoadingTable: false }
|
|
},
|
|
methods: {
|
|
obtenerMotivos() {
|
|
this.isLoadingTable = true
|
|
return axios
|
|
.get(
|
|
`${process.env.api}/carrito-motivo?pagina=${this.page}&id_carrito=${this.carrito.id_carrito}`,
|
|
this.$getToken.token()
|
|
)
|
|
.then((res) => {
|
|
this.motivos = res.data[0]
|
|
this.total = res.data[1]
|
|
this.isLoadingTable = false
|
|
})
|
|
.catch((err) => {
|
|
this.isLoadingTable = false
|
|
})
|
|
},
|
|
obtenerMotivosReporte() {
|
|
return axios
|
|
.get(
|
|
`${process.env.api}/carrito-motivo/reporte?id_carrito=${this.carrito.id_carrito}`,
|
|
this.$getToken.token()
|
|
)
|
|
.then((res) => {
|
|
const data = []
|
|
|
|
for (let i = 0; i < res.data.length; i++)
|
|
data.push({
|
|
id_motivo: res.data[i].id_motivo,
|
|
fecha_creacion: moment(res.data[i].fecha_creacion).format(
|
|
'DD/MM/YYYY hh:mm'
|
|
),
|
|
motivo: res.data[i].motivo,
|
|
laboratorioMovil: res.data[i].laboratorioMovil,
|
|
operador: res.data[i].operador.operador,
|
|
})
|
|
return data
|
|
})
|
|
.catch((err) => {
|
|
this.$alertsGenericos.imprimirError(
|
|
this.$buefy,
|
|
this.$router,
|
|
err.response.data
|
|
)
|
|
})
|
|
},
|
|
onPageChange(page) {
|
|
this.page = page
|
|
this.obtenerMotivos()
|
|
},
|
|
},
|
|
watch: {
|
|
carrito() {
|
|
this.obtenerMotivos()
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style></style>
|