Files
servicio_social_front/components/admin/inputTableA.vue
T

154 lines
4.0 KiB
Vue
Raw Normal View History

2021-01-05 16:43:09 -06:00
<template>
2021-06-08 13:19:51 -05:00
<div>
<h3 class="title">Servicios Sociales</h3>
2021-01-05 16:43:09 -06:00
<div class="columns">
2021-05-14 18:47:35 -05:00
<b-field class="column" label="Número de Cuenta">
<b-input
type="text"
placeholder="No.Cuenta"
icon="school"
maxlength="9"
2021-06-07 23:42:00 -05:00
v-model="busqueda.numeroCuenta"
2021-05-15 01:18:15 -05:00
@keyup.enter.native="obtenerServicios()"
2021-06-07 23:42:00 -05:00
rounded
2021-08-04 16:12:05 -05:00
/>
2021-05-14 18:47:35 -05:00
</b-field>
2021-01-05 16:43:09 -06:00
2021-05-14 18:47:35 -05:00
<b-field class="column" label="Nombre">
<b-input
type="name"
placeholder="Nombre"
icon="account"
2021-06-07 23:42:00 -05:00
v-model="busqueda.nombre"
2021-05-15 01:18:15 -05:00
@keyup.enter.native="obtenerServicios()"
2021-06-07 23:42:00 -05:00
rounded
2021-08-04 16:12:05 -05:00
/>
2021-05-14 18:47:35 -05:00
</b-field>
2021-01-05 16:43:09 -06:00
2021-05-14 18:47:35 -05:00
<b-field class="column" label="Status">
2021-06-07 23:42:00 -05:00
<b-select icon="information" v-model="busqueda.idStatus" rounded>
2021-05-14 18:47:35 -05:00
<option value="">Status</option>
<option
v-for="(s, i) in status"
:key="i"
:value="s.idStatus"
v-show="i < 10"
2021-01-05 16:43:09 -06:00
>
2021-05-14 18:47:35 -05:00
{{ s.status }}
</option>
</b-select>
</b-field>
2021-01-05 16:43:09 -06:00
2021-06-07 23:42:00 -05:00
<div class="column is-align-self-center">
<b-button type="is-info" @click="obtenerServicios()" expanded rounded>
Buscar
</b-button>
</div>
2021-01-05 16:43:09 -06:00
</div>
2021-08-04 16:12:05 -05:00
<TablaServiciosSociales
:isLoading="isLoading"
2021-05-14 18:47:35 -05:00
:data="data"
2021-08-04 16:12:05 -05:00
:page="page"
:onPageChange="onPageChange"
2021-05-14 18:47:35 -05:00
:total="total"
2021-08-04 16:12:05 -05:00
:idTipoUsuario="admin.idTipoUsuario"
2021-08-05 13:52:10 -05:00
:path="'/admin/servicio'"
2021-08-04 16:12:05 -05:00
/>
2021-06-07 23:42:00 -05:00
</div>
2021-01-05 16:43:09 -06:00
</template>
<script>
2021-05-13 14:22:56 -05:00
import axios from 'axios'
2021-08-04 16:12:05 -05:00
import TablaServiciosSociales from '@/components/TablaServiciosSociales'
2021-01-05 16:43:09 -06:00
export default {
2021-08-04 16:12:05 -05:00
components: { TablaServiciosSociales },
2021-01-05 16:43:09 -06:00
data() {
return {
2021-06-07 23:42:00 -05:00
servicioSeleccionado: {},
2021-05-14 18:47:35 -05:00
status: [],
2021-01-05 16:43:09 -06:00
data: [],
page: 1,
perPage: 25,
2021-05-14 18:47:35 -05:00
total: 0,
isLoading: false,
2021-06-07 23:42:00 -05:00
busqueda: {
idStatus: '',
},
busquedaAnterior: {},
2021-05-13 14:22:56 -05:00
}
2021-01-05 16:43:09 -06:00
},
2021-08-04 16:12:05 -05:00
props: {
admin: { type: Object, required: true },
imprimirMensaje: { type: Function, required: true },
imprimirWarning: { type: Function, required: true },
imprimirError: { type: Function, required: true },
},
2021-01-05 16:43:09 -06:00
methods: {
2021-05-14 18:47:35 -05:00
onPageChange(page) {
this.page = page
this.obtenerServicios()
},
obtenerServicios() {
let data = ''
2021-01-05 16:43:09 -06:00
2021-05-14 18:47:35 -05:00
this.isLoading = true
if (
2021-06-07 23:42:00 -05:00
this.busqueda.numeroCuenta != this.busquedaAnterior.numeroCuenta ||
this.busqueda.nombre != this.busquedaAnterior.nombre ||
this.busqueda.idStatus != this.busquedaAnterior.idStatus
2021-05-14 18:47:35 -05:00
) {
this.page = 1
2021-06-07 23:42:00 -05:00
this.busquedaAnterior.numeroCuenta = this.busqueda.numeroCuenta
this.busquedaAnterior.nombre = this.busqueda.nombre
this.busquedaAnterior.idStatus = this.busqueda.idStatus
2021-05-14 18:47:35 -05:00
}
2021-06-07 23:42:00 -05:00
if (this.busqueda.idStatus) data += `&idStatus=${this.busqueda.idStatus}`
if (this.busqueda.nombre) data += `&nombre=${this.busqueda.nombre}`
if (this.busqueda.numeroCuenta)
2021-06-08 12:21:19 -05:00
data += `&numeroCuenta=${this.busqueda.numeroCuenta}`
2021-01-05 16:43:09 -06:00
axios
.get(
2021-05-14 18:47:35 -05:00
`${process.env.api}/servicio/servicios_admin?&pagina=${this.page}${data}`,
2021-08-04 16:12:05 -05:00
this.admin.token
2021-01-05 16:43:09 -06:00
)
.then((res) => {
2021-05-14 18:47:35 -05:00
this.data = res.data.serviciosAdmin
this.total = res.data.count
this.isLoading = false
2021-01-05 18:54:43 -06:00
})
2021-05-14 18:47:35 -05:00
.catch((err) => {
2021-05-13 14:22:56 -05:00
this.isLoading = false
2021-05-14 18:47:35 -05:00
this.imprimirError(err.response.data)
2021-05-13 14:22:56 -05:00
})
2021-01-05 16:43:09 -06:00
},
2021-05-14 18:47:35 -05:00
obtenerCatalogoStatus() {
axios
2021-08-04 16:12:05 -05:00
.get(`${process.env.api}/status`, this.admin.token)
2021-05-14 18:47:35 -05:00
.then((res) => {
this.status = res.data
})
.catch((err) => {
this.imprimirError(err.response.data)
})
2021-01-05 16:43:09 -06:00
},
2021-05-14 18:47:35 -05:00
},
watch: {
servicioSeleccionado() {
2021-05-16 22:14:27 -05:00
localStorage.setItem('idServicio', this.servicioSeleccionado.idServicio)
2021-05-14 18:47:35 -05:00
this.$router.push(`/admin/servicio`)
},
2021-01-05 16:43:09 -06:00
},
created() {
if (this.admin.idTipoUsuario === 1) {
this.obtenerCatalogoStatus()
this.obtenerServicios()
}
2021-01-05 16:43:09 -06:00
},
2021-05-13 14:22:56 -05:00
}
2021-01-05 16:43:09 -06:00
</script>
2021-08-05 14:12:22 -05:00
<style></style>