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
|
|
|
|
v-for="(s, i) in status"
|
|
|
|
:key="i"
|
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-05 05:33:43 +00:00
|
|
|
<!-- <b-field
|
2022-05-31 04:22:49 +00:00
|
|
|
label="Programa"
|
2022-07-05 05:33:43 +00:00
|
|
|
v-if="equipo.carrito.tipoCarrito.id_tipo_carrito === 3"
|
2022-05-31 04:22:49 +00:00
|
|
|
>
|
|
|
|
<b-select icon="list-status" v-model="idPrograma" expanded rounded>
|
|
|
|
<option
|
|
|
|
v-for="(p, i) in programa"
|
|
|
|
:key="i"
|
2022-07-05 05:33:43 +00:00
|
|
|
:value="p.id_programa"
|
|
|
|
v-show="equipo.programa"
|
2022-05-31 04:22:49 +00:00
|
|
|
>
|
|
|
|
{{ p.programa }}
|
|
|
|
</option>
|
|
|
|
</b-select>
|
|
|
|
</b-field>
|
|
|
|
|
2022-07-05 05:33:43 +00:00
|
|
|
<b-field
|
|
|
|
label="Carrito"
|
|
|
|
v-if="this.operador.tipoUsuario.id_tipo_usuario === 3"
|
|
|
|
>
|
2022-05-31 04:22:49 +00:00
|
|
|
<b-select icon="list-status" v-model="idCarrito" expanded rounded>
|
|
|
|
<option
|
|
|
|
v-for="(c, i) in carritos"
|
|
|
|
:key="i"
|
|
|
|
:value="c.idCarrito"
|
2022-07-05 05:33:43 +00:00
|
|
|
v-show="equipo.id_equipo"
|
2022-05-31 04:22:49 +00:00
|
|
|
>
|
|
|
|
{{ c.carrito }}
|
|
|
|
</option>
|
|
|
|
</b-select>
|
2022-07-05 05:33:43 +00:00
|
|
|
</b-field> -->
|
2022-05-31 04:22:49 +00:00
|
|
|
|
|
|
|
<b-button
|
|
|
|
class="my-5"
|
|
|
|
type="is-link"
|
2022-07-05 05:33:43 +00:00
|
|
|
v-show="equipo.id_equipo"
|
2022-05-31 04:22:49 +00:00
|
|
|
@click="statusPrograma()"
|
|
|
|
: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 },
|
|
|
|
imprimirError: { type: Function, required: true },
|
|
|
|
imprimirWarning: { type: Function, required: true },
|
|
|
|
imprimirMensaje: { type: Function, required: true },
|
|
|
|
updateIsLoading: { type: Function, required: true },
|
|
|
|
buscar: { type: Function, required: true },
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
idStatus: '',
|
|
|
|
idPrograma: '',
|
|
|
|
idCarrito: '',
|
|
|
|
status: [],
|
|
|
|
programa: [],
|
|
|
|
carritos: [],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
statusPrograma() {
|
2022-07-05 05:33:43 +00:00
|
|
|
if (this.idStatus != this.equipo.status.id_status) this.prompt()
|
2022-05-31 04:22:49 +00:00
|
|
|
else
|
|
|
|
this.imprimirWarning(
|
|
|
|
`¿Estas segur@ que deseas cambiar de programa?`,
|
|
|
|
this.cambiarStatus
|
|
|
|
)
|
|
|
|
},
|
|
|
|
mostrarBoton() {
|
|
|
|
if (
|
2022-07-05 05:33:43 +00:00
|
|
|
this.idStatus != this.equipo.status.id_status ||
|
|
|
|
(this.equipo.programa &&
|
|
|
|
this.idPrograma != this.equipo.programa.id_programa) ||
|
|
|
|
this.idCarrito != this.equipo.carrito.id_carrito
|
2022-05-31 04:22:49 +00:00
|
|
|
)
|
|
|
|
return false
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
cambiarStatus(motivo = '') {
|
|
|
|
const data = {
|
2022-07-05 05:33:43 +00:00
|
|
|
id_equipo: this.equipo.id_equipo,
|
|
|
|
id_carrito: this.idCarrito,
|
|
|
|
id_status:
|
|
|
|
this.idStatus != this.equipo.status.id_status ? this.idStatus : null,
|
|
|
|
// idPrograma: this.idPrograma ? this.idPrograma : null,
|
2022-05-31 04:22:49 +00:00
|
|
|
motivo,
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
this.imprimirMensaje(res.data.message)
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.updateIsLoading(false)
|
|
|
|
this.imprimirError(err.response.data)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
obtenerCatalogoStatus() {
|
|
|
|
axios
|
|
|
|
.get(`${process.env.api}/status`, this.operador.token)
|
|
|
|
.then((res) => {
|
|
|
|
this.status = res.data
|
2022-07-05 05:33:43 +00:00
|
|
|
// this.obtenerCatalogoCarritos()
|
2022-05-31 04:22:49 +00:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.imprimirError(err.response.data)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
obtenerCatalogoProgramas() {
|
|
|
|
axios
|
|
|
|
.get(`${process.env.api}/programa`, this.operador.token)
|
|
|
|
.then((res) => {
|
|
|
|
this.programa = res.data
|
2022-07-05 05:33:43 +00:00
|
|
|
// this.obtenerCatalogoCarritos()
|
2022-05-31 04:22:49 +00:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.imprimirError(err.response.data)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
obtenerCatalogoCarritos() {
|
|
|
|
axios
|
|
|
|
.get(`${process.env.api}/carrito/carritos`, this.operador.token)
|
|
|
|
.then((res) => {
|
|
|
|
this.carritos = res.data
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.imprimirError(err.response.data)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
prompt() {
|
|
|
|
this.$buefy.dialog.prompt({
|
|
|
|
type: 'is-warning',
|
|
|
|
title: '¡Espera un minuto!',
|
|
|
|
message: `¿Estas segur@ que quieres cambiar el status de este equipo?`,
|
|
|
|
inputAttrs: {
|
|
|
|
type: 'text',
|
|
|
|
placeholder: 'Motivo del cambio',
|
|
|
|
min: 1,
|
|
|
|
max: 500,
|
|
|
|
},
|
|
|
|
trapFocus: true,
|
|
|
|
hasIcon: true,
|
|
|
|
iconPack: 'mdi',
|
|
|
|
icon: 'help-circle',
|
|
|
|
cancelText: 'Cancelar',
|
|
|
|
onConfirm: (value) => this.cambiarStatus(value),
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
equipo() {
|
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
|
|
|
},
|
|
|
|
},
|
|
|
|
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>
|