pcpuma_unam_operador/components/tablas/TablaProgramas.vue

78 lines
2.0 KiB
Vue
Raw Normal View History

2022-07-25 12:49:16 +00:00
<template>
<b-table
2022-07-29 01:04:17 +00:00
class="pb-6"
2022-07-26 20:07:05 +00:00
:data="programas"
2022-07-25 12:49:16 +00:00
:loading="isLoadingTable"
:per-page="25"
:total="total"
hoverable
paginated
striped
>
2022-07-25 22:59:36 +00:00
<b-table-column field="programa" label="Software" v-slot="props" centered>
2022-07-26 20:07:05 +00:00
<p>{{ props.row.programa.programa }}</p>
2022-07-25 22:59:36 +00:00
</b-table-column>
2022-07-26 20:07:05 +00:00
<b-table-column
field="activo"
label="Status"
width="400"
v-slot="props"
centered
>
2022-07-25 22:59:36 +00:00
<BotonDesactivar
:activarDesactivar="activarDesactivar"
2022-07-26 20:07:05 +00:00
:row="props.row"
2022-07-25 22:59:36 +00:00
:msjWarning="`¿Estás segur@ de querer ${
2022-07-29 01:04:17 +00:00
props.row.mostrar ? 'desactivar' : 'activar'
2022-07-25 22:59:36 +00:00
} este tipo de software?`"
/>
</b-table-column>
2022-07-25 12:49:16 +00:00
</b-table>
</template>
<script>
2022-07-26 20:07:05 +00:00
import axios from 'axios'
2022-07-25 22:59:36 +00:00
import BotonDesactivar from '@/components/botones/BotonDesactivar'
2022-07-25 12:49:16 +00:00
export default {
2022-07-25 22:59:36 +00:00
components: { BotonDesactivar },
2022-07-25 12:49:16 +00:00
props: {
2022-07-26 20:07:05 +00:00
programas: { type: Array, required: true, default: () => [] },
2022-07-25 12:49:16 +00:00
isLoadingTable: { type: Boolean, required: true, default: false },
2022-07-25 22:59:36 +00:00
obtenerProgramas: {
type: Function,
required: true,
default: () => {},
},
updateIsLoading: { type: Function, required: true, default: () => {} },
2022-07-25 12:49:16 +00:00
total: { type: Number, required: true, default: 0 },
},
2022-07-25 22:59:36 +00:00
methods: {
activarDesactivar(institucionPrograma) {
const data = {
id_institucion_programa: institucionPrograma.id_institucion_programa,
mostrar: !institucionPrograma.mostrar,
}
this.updateIsLoading(true)
axios
.put(
`${process.env.api}/institucion-programa/`,
data,
this.$getToken.token()
)
.then((res) => {
this.obtenerProgramas()
this.updateIsLoading(false)
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
})
.catch((err) => {
this.updateIsLoading(false)
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
})
},
2022-07-25 12:49:16 +00:00
},
}
</script>