Files
servicio_social_front/components/responsable/inputTable.vue
T

316 lines
8.0 KiB
Vue
Raw Normal View History

2020-11-10 22:38:34 -06:00
<template>
2021-05-14 14:56:34 -05:00
<section class="section">
2020-11-10 22:38:34 -06:00
<div class="columns">
2021-05-13 23:16:27 -05:00
<b-field class="column" label="Número de Cuenta">
<b-input
type="text"
placeholder="No.Cuenta"
icon="school"
rounded
v-model="numeroCuenta"
maxlength="9"
2021-05-15 01:18:15 -05:00
@keyup.enter.native="obtenerServicios()"
2021-05-13 23:16:27 -05:00
></b-input>
</b-field>
2020-11-16 13:48:12 -06:00
2021-05-13 23:16:27 -05:00
<b-field class="column" label="Nombre">
<b-input
type="name"
placeholder="Nombre"
icon="account"
rounded
v-model="nombre"
2021-05-15 01:18:15 -05:00
@keyup.enter.native="obtenerServicios()"
2021-05-13 23:16:27 -05:00
></b-input>
</b-field>
2020-11-16 13:48:12 -06:00
2021-05-13 23:16:27 -05:00
<b-field class="column" label="Status">
<b-select icon="information" expanded rounded v-model="idStatus">
2021-05-14 17:13:46 -05:00
<option value="">Status</option>
2021-05-13 23:16:27 -05:00
<option
v-for="(s, i) in status"
:key="i"
:value="s.idStatus"
v-show="i < 9"
>
{{ s.status }}
</option>
</b-select>
</b-field>
2020-11-16 13:48:12 -06:00
2021-05-13 23:16:27 -05:00
<b-button
type="is-info"
class="column is-align-self-center"
expanded
2021-05-14 17:13:46 -05:00
@click="obtenerServicios()"
2021-05-13 23:16:27 -05:00
>
Buscar
</b-button>
2020-11-18 19:02:13 -06:00
</div>
2020-11-16 13:48:12 -06:00
2021-05-14 09:51:43 -05:00
<b-table
:data="data"
2021-05-14 14:56:34 -05:00
:total="total"
:current-page="page"
:per-page="perPage"
2021-05-14 09:51:43 -05:00
:loading="isLoading"
2021-05-14 14:56:34 -05:00
@page-change="onPageChange"
2021-05-14 09:51:43 -05:00
hoverable
striped
paginated
backend-pagination
>
<b-table-column
field="numeroCuenta"
label="Número de Cuenta"
v-slot="props"
centered
>
<span>{{ props.row.Usuario.usuario }}</span>
</b-table-column>
2021-05-13 23:16:27 -05:00
2021-05-15 01:18:15 -05:00
<b-table-column field="nombre" label="Nombre" v-slot="props" centered>
<span>{{ props.row.Usuario.nombre }}</span>
</b-table-column>
2021-05-14 09:51:43 -05:00
<b-table-column field="carrera" label="Carrera" v-slot="props" centered>
<span>{{ props.row.Carrera.carrera }}</span>
</b-table-column>
2020-12-10 14:02:07 -06:00
2021-05-14 09:51:43 -05:00
<b-table-column
field="fechaInicio"
label="Fecha Inicio"
v-slot="props"
centered
>
<span>{{ fecha(props.row.fechaInicio) }}</span>
</b-table-column>
2020-12-10 14:02:07 -06:00
2021-05-14 09:51:43 -05:00
<b-table-column
field="fechaFin"
label="Fecha Fin"
v-slot="props"
centered
>
<span>{{ fecha(props.row.fechaFin) }}</span>
</b-table-column>
<b-table-column field="status" label="Status" v-slot="props" centered>
2021-05-14 17:13:46 -05:00
<b-button
type="is-danger"
size="is-small"
class="tag"
@click="responsableUpdate(props.row.idServicio, 'carta_aceptacion')"
v-if="props.row.Status.idStatus === 7"
>
2021-05-16 22:14:27 -05:00
Carta Aceptación Rechazada
2021-05-14 17:13:46 -05:00
</b-button>
<span :class="types(props.row.Status.idStatus)" v-else>{{
2021-05-14 09:51:43 -05:00
props.row.Status.status
}}</span>
</b-table-column>
2020-12-10 14:02:07 -06:00
2021-05-14 09:51:43 -05:00
<b-table-column
field="cartaTermino"
label="Carta Término"
v-slot="props"
centered
>
2021-05-14 14:56:34 -05:00
<div v-if="ultimosCampos(props.row.Status.idStatus)">
2021-05-14 09:51:43 -05:00
<span v-if="props.row.cartaTermino">
2021-05-14 14:56:34 -05:00
<b-icon icon="check" class="tag is-success"></b-icon>
2021-05-14 09:51:43 -05:00
</span>
2020-11-29 19:41:17 -06:00
2021-05-14 09:51:43 -05:00
<b-button
2021-05-14 14:56:34 -05:00
type="is-danger"
2021-05-14 09:51:43 -05:00
size="is-small"
2021-05-14 14:56:34 -05:00
class="tag"
@click="responsableUpdate(props.row.idServicio, 'carta_termino')"
v-else
2020-12-09 14:54:58 -06:00
>
2021-05-14 09:51:43 -05:00
Carta Término
</b-button>
</div>
</b-table-column>
2020-11-18 19:02:13 -06:00
2021-05-14 09:51:43 -05:00
<b-table-column
2021-05-14 14:56:34 -05:00
field="cuestionarioP"
2021-05-14 09:51:43 -05:00
label="Cuestionario"
v-slot="props"
centered
>
2021-05-14 14:56:34 -05:00
<div v-if="ultimosCampos(props.row.Status.idStatus)">
<span v-if="props.row.idCuestionarioPrograma">
<b-icon icon="check" class="tag is-success"></b-icon>
2021-05-14 09:51:43 -05:00
</span>
2020-12-09 14:54:58 -06:00
2021-05-14 09:51:43 -05:00
<b-button
2021-05-14 14:56:34 -05:00
type="is-danger"
2021-05-14 09:51:43 -05:00
size="is-small"
2021-05-14 14:56:34 -05:00
class="tag"
@click="responsableUpdate(props.row.idServicio, 'cuestionario')"
v-else
2020-12-09 14:54:58 -06:00
>
2021-05-14 09:51:43 -05:00
Cuestionario
</b-button>
</div>
</b-table-column>
</b-table>
2021-05-14 14:56:34 -05:00
</section>
2020-11-10 22:38:34 -06:00
</template>
<script>
2021-05-13 14:22:56 -05:00
import axios from 'axios'
import moment from 'moment'
2020-11-18 19:02:13 -06:00
2020-11-10 22:38:34 -06:00
export default {
2020-12-08 21:50:16 -06:00
data() {
2020-11-10 22:38:34 -06:00
return {
2021-05-14 14:56:34 -05:00
responsable: {},
2021-05-13 23:16:27 -05:00
status: [],
2020-11-27 19:49:26 -06:00
data: [],
2020-11-23 18:48:37 -06:00
page: 1,
2020-11-27 19:49:26 -06:00
perPage: 25,
2021-05-14 14:56:34 -05:00
total: 0,
isLoading: false,
busqueda: {},
2021-05-13 14:22:56 -05:00
numeroCuenta: '',
2021-05-14 14:56:34 -05:00
numeroCuentaAnterior: '',
2021-05-13 14:22:56 -05:00
nombre: '',
2021-05-14 14:56:34 -05:00
nombreAnterior: '',
2021-05-13 14:22:56 -05:00
idStatus: '',
2021-05-14 14:56:34 -05:00
idStatusAnterior: '',
token: {},
2021-05-13 14:22:56 -05:00
}
2020-11-12 22:40:56 -06:00
},
methods: {
2021-05-14 14:56:34 -05:00
ultimosCampos(idStatus) {
return idStatus >= 4 && idStatus != 7
2020-11-27 19:49:26 -06:00
},
2020-12-08 21:50:16 -06:00
types(idStatus) {
2021-05-14 09:51:43 -05:00
let style = 'tag'
if (idStatus === 1) style += ' is-dark'
2021-05-14 14:56:34 -05:00
if (idStatus === 2) style += ' is-info'
if (idStatus === 3) style += ' is-warning'
if (idStatus === 4) style += ' is-link'
if (idStatus === 5) style += ' is-success'
if (idStatus === 6) style += ' is-success is-light'
2021-05-15 00:58:24 -05:00
if (idStatus >= 7 && idStatus <= 9) style += ' is-danger'
2021-05-14 09:51:43 -05:00
return style
2020-11-12 22:40:56 -06:00
},
2021-05-14 14:56:34 -05:00
fecha(date) {
const fecha = moment(date.substr(0, 10))
return `${fecha.date()}/${fecha.month() + 1}/${fecha.year()}`
2020-11-16 13:48:12 -06:00
},
2021-05-14 14:56:34 -05:00
onPageChange(page) {
this.page = page
2021-05-14 17:13:46 -05:00
this.obtenerServicios()
2020-11-16 13:48:12 -06:00
},
2021-05-14 14:56:34 -05:00
responsableUpdate(idServicio, path) {
2021-05-16 22:14:27 -05:00
localStorage.setItem('idServicio', idServicio)
2021-05-14 17:13:46 -05:00
this.$router.push(`/responsable/${path}`)
2020-11-16 13:48:12 -06:00
},
2021-05-14 14:56:34 -05:00
getLocalhostInfo() {
this.responsable.idUsuario = localStorage.getItem('idUsuario')
this.responsable.idTipoUsuario = Number(
localStorage.getItem('idTipoUsuario')
)
2021-05-14 14:56:34 -05:00
this.responsable.tipoUsuario = localStorage.getItem('tipoUsuario')
this.token = {
headers: {
2021-05-16 22:14:27 -05:00
token: localStorage.getItem('token'),
2021-05-14 14:56:34 -05:00
},
2020-11-16 13:48:12 -06:00
}
},
2021-05-14 17:13:46 -05:00
obtenerServicios() {
2021-05-14 14:56:34 -05:00
let data = ''
2021-05-13 14:22:56 -05:00
this.isLoading = true
2021-05-14 14:56:34 -05:00
if (
this.numeroCuenta != this.numeroCuentaAnterior ||
this.nombre != this.nombreAnterior ||
this.idStatus != this.idStatusAnterior
) {
this.page = 1
this.numeroCuentaAnterior = this.numeroCuenta
this.nombreAnterior = this.nombre
this.idStatusAnterior = this.idStatus
}
if (this.idStatus) data += `&idStatus=${this.idStatus}`
if (this.nombre) data += `&nombre=${this.nombre}`
if (this.numeroCuenta) data = `&numeroCuenta=${this.numeroCuenta}`
2020-12-09 14:54:58 -06:00
axios
.get(
2021-05-14 14:56:34 -05:00
`${process.env.api}/servicio/servicios_responsable?idUsuario=${this.responsable.idUsuario}&pagina=${this.page}${data}`,
2021-01-05 16:43:09 -06:00
this.token
2020-12-09 14:54:58 -06:00
)
.then((res) => {
2021-05-14 09:51:43 -05:00
this.data = res.data.serviciosResponsable
2021-05-14 14:56:34 -05:00
this.total = res.data.count
this.isLoading = false
2021-01-05 18:54:43 -06:00
})
2021-05-14 14:56:34 -05:00
.catch((err) => {
2021-05-13 14:22:56 -05:00
this.isLoading = false
2021-05-14 14:56:34 -05:00
this.imprimirError(err.response.data)
2021-05-13 14:22:56 -05:00
})
2020-12-08 21:50:16 -06:00
},
2021-05-14 14:56:34 -05:00
obtenerCatalogoStatus() {
axios
.get(`${process.env.api}/status`, this.token)
.then((res) => {
this.status = res.data
})
.catch((err) => {
this.imprimirError(err.response.data)
})
2020-12-09 14:54:58 -06:00
},
2021-05-14 14:56:34 -05:00
imprimirError(err) {
2021-01-05 18:54:43 -06:00
this.$buefy.dialog.alert({
2021-05-13 14:22:56 -05:00
title: 'Error',
2021-05-14 14:56:34 -05:00
message: err.message,
2021-05-13 14:22:56 -05:00
type: 'is-danger',
2021-01-05 18:54:43 -06:00
hasIcon: true,
2021-05-13 14:22:56 -05:00
icon: 'alert-circle',
iconPack: 'mdi',
ariaRole: 'alertdialog',
2021-01-05 18:54:43 -06:00
ariaModal: true,
2021-05-13 14:22:56 -05:00
})
2021-05-14 14:56:34 -05:00
if (err.err === 'token error') {
2021-05-13 14:22:56 -05:00
localStorage.clear()
2021-05-14 14:56:34 -05:00
this.$router.push('/')
}
2021-05-13 23:16:27 -05:00
},
2020-11-25 15:16:10 -06:00
},
2020-12-09 14:54:58 -06:00
created() {
2021-05-14 14:56:34 -05:00
this.getLocalhostInfo()
if (this.responsable.idTipoUsuario === 2) {
this.obtenerCatalogoStatus()
this.obtenerServicios()
}
2020-12-09 14:54:58 -06:00
},
2021-05-13 14:22:56 -05:00
}
2020-11-10 22:38:34 -06:00
</script>
2020-11-16 13:48:12 -06:00
<style>
2020-12-08 21:50:16 -06:00
.input:focus {
border: #1b3d70;
2020-11-29 19:41:17 -06:00
box-shadow: 0 0 8px 0 #1b3d70;
}
2021-05-13 23:16:27 -05:00
2020-12-08 21:50:16 -06:00
.select select:focus {
2020-11-29 19:41:17 -06:00
border-color: #1b3d70;
box-shadow: 0 0 8px 0 #1b3d70;
}
2021-05-13 23:16:27 -05:00
2020-12-08 21:50:16 -06:00
.select:not(.is-multiple):not(.is-loading)::after {
2020-11-29 19:41:17 -06:00
border-color: #1b3d70;
}
2021-05-13 23:16:27 -05:00
2020-11-29 19:41:17 -06:00
.pagination-link.is-current {
background-color: #1b3d70;
border-color: #1b3d70;
}
2020-11-16 13:48:12 -06:00
</style>