2022-05-31 04:22:49 +00:00
|
|
|
<template>
|
|
|
|
<div class="column is-4">
|
|
|
|
<h3 class="is-size-4 mb-4">Administrador</h3>
|
|
|
|
|
|
|
|
<b-field label="Status">
|
|
|
|
<b-select icon="list-status" v-model="idStatus" expanded rounded>
|
|
|
|
<option
|
2022-07-10 06:56:46 +00:00
|
|
|
v-for="(s, index) in status"
|
|
|
|
:key="index"
|
2022-07-05 05:33:43 +00:00
|
|
|
:value="s.id_status"
|
|
|
|
v-show="equipo.id_equipo"
|
|
|
|
:disabled="s.id_status < 4 || equipo.entregaInmediata"
|
2022-05-31 04:22:49 +00:00
|
|
|
>
|
|
|
|
{{ s.status }}
|
|
|
|
</option>
|
|
|
|
</b-select>
|
|
|
|
</b-field>
|
|
|
|
|
2022-07-10 06:56:46 +00:00
|
|
|
<b-field label="Motivo" v-if="mostrarMotivo">
|
|
|
|
<b-input v-model="motivo" type="textarea" maxlength="150" />
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field label="Tipo de entrada">
|
|
|
|
<b-select icon="list-status" v-model="idTipoEntrada" expanded rounded>
|
|
|
|
<option
|
|
|
|
v-for="(tipoEntrada, index) in tipoEntradas"
|
|
|
|
:key="index"
|
|
|
|
:value="tipoEntrada.tipoEntrada.id_tipo_entrada"
|
|
|
|
>
|
|
|
|
{{ tipoEntrada.tipoEntrada.tipo_entrada }}
|
|
|
|
</option>
|
|
|
|
</b-select>
|
|
|
|
</b-field>
|
|
|
|
|
2022-07-11 08:22:57 +00:00
|
|
|
<b-field
|
2022-05-31 04:22:49 +00:00
|
|
|
label="Programa"
|
2022-07-08 08:19:56 +00:00
|
|
|
v-if="equipo.carrito.tipoCarrito.id_tipo_carrito === 2"
|
2022-05-31 04:22:49 +00:00
|
|
|
>
|
|
|
|
<b-select icon="list-status" v-model="idPrograma" expanded rounded>
|
2022-07-10 06:56:46 +00:00
|
|
|
<option
|
|
|
|
v-for="(programa, index) in programas"
|
|
|
|
:key="index"
|
|
|
|
:value="programa.programa.id_programa"
|
|
|
|
>
|
2022-07-08 08:19:56 +00:00
|
|
|
{{ programa.programa.programa }}
|
2022-05-31 04:22:49 +00:00
|
|
|
</option>
|
|
|
|
</b-select>
|
2022-07-11 08:22:57 +00:00
|
|
|
</b-field>
|
2022-07-10 06:56:46 +00:00
|
|
|
|
|
|
|
<b-field
|
|
|
|
label="Cambiar nombre del equipo"
|
|
|
|
v-if="equipo.carrito.tipoCarrito.id_tipo_carrito"
|
|
|
|
>
|
|
|
|
<b-input
|
|
|
|
icon="list-status"
|
|
|
|
v-model="nuevoNombreEquipo"
|
|
|
|
placeholder="Nuevo nombre del equipo"
|
|
|
|
rounded
|
|
|
|
/>
|
2022-05-31 04:22:49 +00:00
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-button
|
|
|
|
class="my-5"
|
|
|
|
type="is-link"
|
2022-07-05 05:33:43 +00:00
|
|
|
v-show="equipo.id_equipo"
|
2022-07-10 06:56:46 +00:00
|
|
|
@click="
|
2022-07-11 14:15:10 +00:00
|
|
|
$alertsGenericos.imprimirWarning(
|
|
|
|
$buefy,
|
2022-07-10 06:56:46 +00:00
|
|
|
`¿Estas segur@ que deseas cambiar esta información?`,
|
2022-07-11 08:22:57 +00:00
|
|
|
updateInformacion
|
2022-07-10 06:56:46 +00:00
|
|
|
)
|
|
|
|
"
|
2022-05-31 04:22:49 +00:00
|
|
|
:disabled="mostrarBoton()"
|
|
|
|
rounded
|
|
|
|
expanded
|
|
|
|
>
|
|
|
|
Actualizar Información
|
|
|
|
</b-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
operador: { type: Object, required: true },
|
|
|
|
equipo: { type: Object, required: true },
|
|
|
|
updateIsLoading: { type: Function, required: true },
|
|
|
|
buscar: { type: Function, required: true },
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
idStatus: '',
|
|
|
|
idPrograma: '',
|
|
|
|
idCarrito: '',
|
2022-07-10 06:56:46 +00:00
|
|
|
idTipoEntrada: '',
|
2022-05-31 04:22:49 +00:00
|
|
|
status: [],
|
2022-07-08 08:19:56 +00:00
|
|
|
programas: [],
|
2022-05-31 04:22:49 +00:00
|
|
|
carritos: [],
|
2022-07-10 06:56:46 +00:00
|
|
|
tipoEntradas: [],
|
|
|
|
|
|
|
|
motivo: '',
|
|
|
|
mostrarMotivo: false,
|
|
|
|
|
|
|
|
nuevoNombreEquipo: '',
|
2022-05-31 04:22:49 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
mostrarBoton() {
|
2022-07-10 06:56:46 +00:00
|
|
|
// if (
|
|
|
|
// this.idStatus != this.equipo.status.id_status ||
|
|
|
|
// (this.equipo.programa &&
|
|
|
|
// this.idPrograma != this.equipo.programa.id_programa) ||
|
|
|
|
// this.idCarrito != this.equipo.carrito.id_carrito
|
|
|
|
// )
|
|
|
|
// return false
|
|
|
|
// return true
|
|
|
|
|
2022-05-31 04:22:49 +00:00
|
|
|
if (
|
2022-07-05 05:33:43 +00:00
|
|
|
this.idStatus != this.equipo.status.id_status ||
|
2022-07-10 06:56:46 +00:00
|
|
|
this.nuevoNombreEquipo != this.equipo.equipo
|
2022-05-31 04:22:49 +00:00
|
|
|
)
|
|
|
|
return false
|
|
|
|
return true
|
|
|
|
},
|
2022-07-11 08:22:57 +00:00
|
|
|
updateInformacion() {
|
|
|
|
if (
|
|
|
|
this.idStatus != this.equipo.status.id_status ||
|
|
|
|
this.nuevoNombreEquipo != ''
|
|
|
|
) {
|
|
|
|
this.updateEquipo()
|
|
|
|
this.motivo = ''
|
|
|
|
}
|
|
|
|
for (let i = 0; i < this.programas.length; i++) {
|
|
|
|
if (this.idPrograma) {
|
|
|
|
if (
|
2022-07-11 08:54:28 +00:00
|
|
|
this.equipo.programas.length === 0 ||
|
2022-07-11 08:22:57 +00:00
|
|
|
this.idPrograma != this.equipo.programas[i].programa.id_programa
|
|
|
|
) {
|
|
|
|
this.updateProgramas()
|
|
|
|
this.idPrograma = ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (let i = 0; i < this.tipoEntradas.length; i++) {
|
|
|
|
if (this.idTipoEntrada != '') {
|
|
|
|
if (
|
2022-07-11 08:53:51 +00:00
|
|
|
this.equipo.tiposEntradas.length === 0 ||
|
2022-07-11 08:22:57 +00:00
|
|
|
this.idTipoEntrada !=
|
2022-07-11 08:53:51 +00:00
|
|
|
this.equipo.tiposEntradas[i].tipoEntrada.id_tipo_entrada
|
2022-07-11 08:22:57 +00:00
|
|
|
) {
|
|
|
|
this.updateTipoEntradas()
|
|
|
|
this.idTipoEntrada = ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-07-10 06:56:46 +00:00
|
|
|
updateEquipo() {
|
2022-05-31 04:22:49 +00:00
|
|
|
const data = {
|
2022-07-05 05:33:43 +00:00
|
|
|
id_equipo: this.equipo.id_equipo,
|
2022-07-10 06:56:46 +00:00
|
|
|
equipo: this.nuevoNombreEquipo
|
|
|
|
? this.nuevoNombreEquipo
|
|
|
|
: this.equipo.equpo,
|
|
|
|
id_operador: this.operador.id_operador,
|
2022-07-05 05:33:43 +00:00
|
|
|
id_status:
|
|
|
|
this.idStatus != this.equipo.status.id_status ? this.idStatus : null,
|
2022-07-10 06:56:46 +00:00
|
|
|
motivo: this.motivo,
|
2022-07-11 08:22:57 +00:00
|
|
|
idPrograma: this.idPrograma ? this.idPrograma : null,
|
2022-05-31 04:22:49 +00:00
|
|
|
}
|
|
|
|
this.updateIsLoading(true)
|
|
|
|
axios
|
2022-07-05 05:33:43 +00:00
|
|
|
.put(`${process.env.api}/equipo`, data, this.operador.token)
|
2022-05-31 04:22:49 +00:00
|
|
|
.then((res) => {
|
|
|
|
this.buscar()
|
|
|
|
this.updateIsLoading(false)
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
|
2022-05-31 04:22:49 +00:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.updateIsLoading(false)
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-05-31 04:22:49 +00:00
|
|
|
})
|
|
|
|
},
|
2022-07-11 08:22:57 +00:00
|
|
|
updateProgramas() {
|
|
|
|
const data = {
|
|
|
|
id_equipo: this.equipo.id_equipo,
|
|
|
|
id_programa: this.idPrograma,
|
|
|
|
}
|
|
|
|
this.updateIsLoading(true)
|
|
|
|
axios
|
|
|
|
.post(`${process.env.api}/equipo-programa`, data, this.operador.token)
|
|
|
|
.then((res) => {
|
|
|
|
this.buscar()
|
|
|
|
this.updateIsLoading(false)
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
|
2022-07-11 08:22:57 +00:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.updateIsLoading(false)
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-07-11 08:22:57 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
updateTipoEntradas() {
|
|
|
|
const data = {
|
|
|
|
id_equipo: this.equipo.id_equipo,
|
|
|
|
id_tipo_entrada: this.idTipoEntrada,
|
|
|
|
}
|
|
|
|
this.updateIsLoading(true)
|
|
|
|
axios
|
|
|
|
.post(
|
|
|
|
`${process.env.api}/equipo-tipo-entrada`,
|
|
|
|
data,
|
|
|
|
this.operador.token
|
|
|
|
)
|
|
|
|
.then((res) => {
|
|
|
|
this.buscar()
|
|
|
|
this.updateIsLoading(false)
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
|
2022-07-11 08:22:57 +00:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.updateIsLoading(false)
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-07-11 08:22:57 +00:00
|
|
|
})
|
|
|
|
},
|
2022-05-31 04:22:49 +00:00
|
|
|
obtenerCatalogoStatus() {
|
|
|
|
axios
|
|
|
|
.get(`${process.env.api}/status`, this.operador.token)
|
|
|
|
.then((res) => {
|
|
|
|
this.status = res.data
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-05-31 04:22:49 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
obtenerCatalogoProgramas() {
|
|
|
|
axios
|
2022-07-10 06:56:46 +00:00
|
|
|
.get(
|
|
|
|
`${process.env.api}/institucion-programa/programas-mostrar?id_institucion=${this.operador.institucion.id_institucion}`,
|
|
|
|
this.operador.token
|
|
|
|
)
|
2022-05-31 04:22:49 +00:00
|
|
|
.then((res) => {
|
2022-07-10 06:56:46 +00:00
|
|
|
this.programas = res.data
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-07-10 06:56:46 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
obtenerCatalogoTipoEntradas() {
|
|
|
|
axios
|
|
|
|
.get(
|
|
|
|
`${process.env.api}/institucion-tipo-entrada/tipos-entrada-mostrar?id_institucion=${this.operador.institucion.id_institucion}`,
|
|
|
|
this.operador.token
|
|
|
|
)
|
|
|
|
.then((res) => {
|
|
|
|
this.tipoEntradas = res.data
|
2022-05-31 04:22:49 +00:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-05-31 04:22:49 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
obtenerCatalogoCarritos() {
|
|
|
|
axios
|
2022-07-10 06:56:46 +00:00
|
|
|
.get(
|
|
|
|
`${process.env.api}/carrito/carritos?pagina=1&id_institucion=${this.operador.institucion.id_institucion}&id_tipo_carrito=${this.equipo.carrito.tipoCarrito.id_tipo_carrito}`,
|
|
|
|
this.operador.token
|
|
|
|
)
|
2022-05-31 04:22:49 +00:00
|
|
|
.then((res) => {
|
2022-07-10 06:56:46 +00:00
|
|
|
this.carritos = res.data[0]
|
2022-05-31 04:22:49 +00:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-05-31 04:22:49 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
equipo() {
|
2022-07-11 08:22:57 +00:00
|
|
|
this.obtenerCatalogoProgramas()
|
2022-07-10 06:56:46 +00:00
|
|
|
this.obtenerCatalogoTipoEntradas()
|
|
|
|
this.obtenerCatalogoCarritos()
|
2022-07-05 05:33:43 +00:00
|
|
|
this.idStatus = this.equipo.status.id_status
|
|
|
|
this.idCarrito = this.equipo.carrito.id_carrito
|
|
|
|
if (this.equipo.programa)
|
|
|
|
this.idPrograma = this.equipo.programa.id_programa
|
2022-05-31 04:22:49 +00:00
|
|
|
},
|
2022-07-10 06:56:46 +00:00
|
|
|
idStatus(value) {
|
|
|
|
if (value != this.equipo.status.id_status) this.mostrarMotivo = true
|
|
|
|
},
|
2022-05-31 04:22:49 +00:00
|
|
|
},
|
|
|
|
created() {
|
2022-07-05 05:33:43 +00:00
|
|
|
if (this.operador.tipoUsuario.id_tipo_usuario === 3) {
|
2022-05-31 04:22:49 +00:00
|
|
|
this.obtenerCatalogoStatus()
|
2022-07-05 05:33:43 +00:00
|
|
|
this.idStatus = this.equipo.status.id_status
|
2022-05-31 04:22:49 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style></style>
|