pcpuma_unam_operador/components/tablas/CarritosModulo.vue

60 lines
1.3 KiB
Vue
Raw Normal View History

<template>
<TablaCarritos
:carritos="carritos"
:isLoadingTable="isLoadingTable"
:onPageChange="onPageChange"
:page="page"
:total="total"
/>
</template>
<script>
2022-07-26 04:30:07 +00:00
import axios from 'axios'
import TablaCarritos from '@/components/tablas/TablaCarritos'
export default {
components: { TablaCarritos },
props: {
modulo: { type: Object, required: true, default: () => ({}) },
},
data() {
return {
carritos: [],
page: 1,
total: 0,
isLoadingTable: false,
}
},
methods: {
obtenerCarritos() {
this.isLoadingTable = true
axios
.get(
`${process.env.api}/carrito/carritos?pagina=${this.page}&id_modulo=${this.modulo.id_modulo}`,
this.$getToken.token()
)
.then(async (res) => {
this.carritos = res.data[0]
this.total = res.data[1]
this.isLoadingTable = false
})
.catch((err) => {
this.isLoadingTable = false
2022-08-05 23:41:37 +00:00
this.$alertsGenericos.imprimirError(
this.$buefy,
this.$router,
err.response.data
)
})
},
onPageChange(page) {
this.page = page
this.obtenerCarritos()
},
},
created() {
this.obtenerCarritos()
},
}
</script>