Files
pcpuma-front/src/components/inicio/Equipo.vue
T

238 lines
6.5 KiB
Vue
Raw Normal View History

2018-11-05 21:40:16 -06:00
<template lang="pug">
section
2019-01-25 14:23:18 +00:00
.modal#modal
.modal-background
.modal-card
header.modal-card-head
p.modal-card-title Multa Usuario : {{multar.idUsuario}}
button.delete(v-on:click="toggleModal()")
section.modal-card-body
table.table
thead
tr
2019-08-01 02:47:08 -05:00
th(width="10%")
th(width="20%") No Semanas
2019-01-25 14:23:18 +00:00
th(width="70%") Descripción
tbody
tr(v-for="m in multa")
td
2019-08-01 02:47:08 -05:00
.control
2019-01-25 14:23:18 +00:00
label.radio
input(type='radio' name="multa" v-bind:value="m.semanas" v-model="multar.multa")
2019-01-25 14:23:18 +00:00
td {{m.semanas}}
td {{m.nombre}}
footer.modal-card-foot
2019-08-01 02:47:08 -05:00
button.button.is-success(v-on:click="SaveMultar()") Guardar
2019-01-25 14:23:18 +00:00
button.button(v-on:click="toggleModal()") Cancelar
2019-03-19 19:39:46 +00:00
p.has-text-centered
2019-08-22 16:46:35 -05:00
span.is-size-6.space(v-for="s in status") {{` ${s.Tipo.nombre.toUpperCase()} : ${s.cuenta}`}}
2019-03-14 18:11:50 +00:00
br
2019-08-21 18:44:36 -05:00
.columns
.column.is-3
.field
.control.has-icons-left
input.input(v-model="search" placeholder="Buscar")
span.icon.is-small.is-left
font-awesome-icon(icon="search")
2018-11-12 18:43:21 -06:00
table.table.is-fullwidth.is-hoverable.is-narrow
thead
tr
2018-11-28 21:27:09 -06:00
th Carrito
2019-01-24 20:46:08 +00:00
th Equipo
2018-11-12 18:43:21 -06:00
th Tipo
2019-01-24 20:46:08 +00:00
th No Inventario
th Usuario
2018-11-12 18:43:21 -06:00
th Hora inicio
th Hora maximo
2019-01-25 14:23:18 +00:00
th Multar
2019-01-24 20:46:08 +00:00
th Regresar
2018-11-12 18:43:21 -06:00
tbody
2019-08-21 18:44:36 -05:00
tr(v-bind:class="{'warn-time':timeWarn(p.fechaInicio)}" v-for="p in filteredEquipo")
2019-08-01 02:47:08 -05:00
td {{p.Equipo.Carrito.alias}}
td {{p.Equipo.equipo_carrito}}
td {{p.Equipo.Tipo.nombre}}
td {{p.Equipo.no_inventario}}
td {{p.idUsuario}}
td {{fecha(p.fechaInicio)}}
td {{maxFecha(p.fechaInicio)}}
2019-01-24 20:46:08 +00:00
td
a.button.is-danger.is-outlined(v-on:click="upMultar(p.idUsuario)")
2019-01-25 14:23:18 +00:00
span.icon.is-small
font-awesome-icon(icon="flag")
td
2019-08-02 17:51:07 -05:00
a.button.is-u-blue.is-outlined(v-on:click="regresar(p.idPrestamo, p.idUsuario)")
2019-01-24 20:46:08 +00:00
span.icon.is-small
font-awesome-icon(icon="undo")
2018-11-05 13:59:26 -06:00
</template>
<script>
2019-01-24 20:46:08 +00:00
import swal from 'sweetalert'
2018-11-12 18:43:21 -06:00
import api from '../../api'
const axios = require('axios')
2018-11-05 13:59:26 -06:00
export default {
2018-11-12 18:43:21 -06:00
data () {
return {
2019-01-25 14:23:18 +00:00
prestamo: [],
2019-03-14 18:11:50 +00:00
status: [],
2019-01-25 14:23:18 +00:00
multa: [],
multar: {},
2019-08-21 18:44:36 -05:00
time: true,
search: ''
2018-11-12 18:43:21 -06:00
}
},
mounted () {
console.log(this.$store.getters.kiosko)
axios.get(api.url + '/prestamo?kiosko=' + this.$store.getters.kiosko, {
headers: {
'token': this.$store.getters.token
}
})
.then(response => {
2019-08-22 16:46:35 -05:00
this.prestamo = response.data.info
this.status = response.data.status
console.log(this.prestamo)
})
.catch(error => {
swal('Error', error.response.data.err, 'error')
})
axios.get(api.url + '/multa', {
headers: {
'token': this.$store.getters.token
}
})
.then(response => {
console.log(response.data.data)
this.multa = response.data
})
.catch(error => {
swal('Error', error.response.data.err, 'error')
})
},
2019-08-21 18:44:36 -05:00
computed: {
filteredEquipo: function () {
return this.prestamo.filter(dat => {
console.log(this.search)
if (this.search == '') {
return true
}
if (parseInt(this.search) == dat.Equipo.equipo_carrito) {
return true
}
return false
})
}
},
2018-11-12 18:43:21 -06:00
methods: {
2019-01-25 14:23:18 +00:00
toggleModal: function () {
let modal = document.getElementById('modal')
if (!modal.classList.contains('is-active')) {
modal.classList.add('is-active')
} else {
modal.classList.remove('is-active')
}
},
SaveMultar: function () {
axios({
method: 'put',
2019-01-25 14:23:18 +00:00
url: api.url + '/multar',
data: this.multar,
headers: {
2019-08-01 02:47:08 -05:00
'token': this.$store.getters.token
2019-01-25 14:23:18 +00:00
}
})
.then(response => {
swal('Exito', 'Multa completa ', 'success')
})
.catch(error => {
console.log(error)
2019-01-25 14:23:18 +00:00
swal('Error', error.response.data.err, 'error')
})
},
2019-03-13 17:26:46 +00:00
timeWarn: function (date) {
let dt = new Date(date)
dt.setHours(dt.getHours() + 2)
dt.setMinutes(dt.getMinutes() + 15)
if (dt < new Date()) {
return true
}
return false
},
2019-01-25 14:23:18 +00:00
upMultar: function (usr, eq) {
this.toggleModal()
this.multar.idUsuario = usr
},
2019-01-17 00:51:05 -06:00
fecha: function (date) {
2018-11-12 18:43:21 -06:00
let dt = new Date(date)
2019-08-21 18:44:36 -05:00
var options = { year:'numeric', month: 'numeric',day:'numeric' ,hour: 'numeric', minute: '2-digit' }
return dt.toLocaleString('en-US',options)
2018-11-12 18:43:21 -06:00
},
2019-01-17 00:51:05 -06:00
maxFecha: function (date) {
2018-11-12 18:43:21 -06:00
let dt = new Date(date)
2019-08-21 18:44:36 -05:00
var options = { year:'numeric', month: 'numeric',day:'numeric' ,hour: 'numeric', minute: '2-digit' }
2019-02-01 12:37:04 +00:00
dt.setHours(dt.getHours() + 2)
2019-08-21 18:44:36 -05:00
dt.setMinutes(dt.getMinutes() + 15)
let cierre = new Date()
2019-08-21 18:58:29 -05:00
cierre.setHours(20, 0, 0)
2019-08-21 18:44:36 -05:00
if (dt > cierre) {
return cierre.toLocaleString('en-US',options)
2019-02-20 17:08:47 +00:00
}
2019-08-21 18:44:36 -05:00
return dt.toLocaleString('en-US',options)
2019-01-24 20:46:08 +00:00
},
2019-08-02 17:51:07 -05:00
regresar: function (idPrestamo,idUsuario) {
2019-01-24 20:46:08 +00:00
axios({
method: 'put',
url: api.url + '/devolucion',
data: {
2019-08-02 17:51:07 -05:00
idPrestamo,
idUsuario,
2019-08-12 12:47:44 -05:00
idOperador: this.$store.getters.operador
2019-01-24 20:46:08 +00:00
},
headers: {
2019-08-01 02:47:08 -05:00
'token': this.$store.getters.token
2019-01-24 20:46:08 +00:00
}
})
.then(res => {
swal('Exito', 'Peticion exitosa ', 'success')
axios.get(api.url + '/prestamo?kiosko=' + this.$store.getters.kiosko, {
2019-01-24 20:46:08 +00:00
headers: {
2019-08-01 02:47:08 -05:00
'token': this.$store.getters.token
2019-01-24 20:46:08 +00:00
}
})
.then(response => {
this.prestamo = response.data.info
this.status = response.data.status
console.log(this.prestamo)
2019-01-24 20:46:08 +00:00
})
.catch(error => {
swal('Error', error.response.data.err, 'error')
})
})
.catch(err => {
swal('Error', err.response.data.err, 'error')
})
2018-11-12 18:43:21 -06:00
}
}
2018-11-05 13:59:26 -06:00
}
</script>
2019-03-13 17:26:46 +00:00
<style lang="scss" scoped>
.warn-time{
background-color: rgba(255, 56, 96,.2) !important;
}
.warn-time:hover{
background-color: rgba(255, 56, 96,.6) !important;
}
tr {
td{
text-align: center;
}
th{
text-align: center !important;
}
}
2019-03-14 18:11:50 +00:00
.space{
margin-left: 20px;
}
2019-03-13 17:26:46 +00:00
2018-11-05 13:59:26 -06:00
</style>