carga masiva usuario
This commit is contained in:
parent
94fbce212a
commit
1281da1d6a
54
components/admin/ActivarDesactivar.vue
Normal file
54
components/admin/ActivarDesactivar.vue
Normal file
@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-button
|
||||
:type="operador.activo ? 'is-success' : 'is-danger'"
|
||||
@click="
|
||||
imprimirWarning(
|
||||
'¿Esta segur@ de querer cambiar el status a esta operador?',
|
||||
activarDesactivar
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ operador.activo ? 'Activo' : 'Inactivo' }}
|
||||
</b-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
admin: { type: Object, required: true },
|
||||
imprimirMensaje: { type: Function, required: true },
|
||||
imprimirWarning: { type: Function, required: true },
|
||||
imprimirError: { type: Function, required: true },
|
||||
operador: { type: Object, required: true },
|
||||
updateActualizarTabla: { type: Function, required: true },
|
||||
updateIsLoading: { type: Function, required: true },
|
||||
},
|
||||
methods: {
|
||||
activarDesactivar() {
|
||||
const data = {
|
||||
idOperador: this.operador.idOperador,
|
||||
activo: this.operador.activo ? 'desactivar' : 'activar',
|
||||
}
|
||||
|
||||
this.updateIsLoading(true)
|
||||
axios
|
||||
.put(`${process.env.api}/operador/update`, data, this.admin.token)
|
||||
.then((res) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirMensaje(res.data.message)
|
||||
this.updateActualizarTabla(true)
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
30
components/admin/AvisosErrores.vue
Normal file
30
components/admin/AvisosErrores.vue
Normal file
@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<section class="mb-6">
|
||||
<div class="panel">
|
||||
<h6 class="panel-heading">Avisos</h6>
|
||||
|
||||
<p v-for="(a, i) in avisos" :key="i" class="panel-block">
|
||||
{{ a }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h6 class="panel-heading">Errores</h6>
|
||||
|
||||
<p v-for="(e, i) in errores" :key="i" class="panel-block">
|
||||
{{ e }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
avisos: { type: Array, required: true },
|
||||
errores: { type: Array, required: true },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
102
components/admin/CrearOperador.vue
Normal file
102
components/admin/CrearOperador.vue
Normal file
@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<section class="mb-6">
|
||||
<h3 class="is-size-4 mb-3">Crear Operador</h3>
|
||||
|
||||
<div class="box">
|
||||
<dir class="columns is-align-items-flex-end pl-0 pb-4">
|
||||
<b-field class="column mb-0 pb-0" label="Operador">
|
||||
<b-input
|
||||
type="text"
|
||||
placeholder="Operador"
|
||||
icon="account"
|
||||
v-model="operador"
|
||||
rounded
|
||||
@keyup.enter.native="
|
||||
imprimirWarning(
|
||||
'¿Esta segur@ de querer crear este operador?',
|
||||
crearOperador
|
||||
)
|
||||
"
|
||||
/>
|
||||
</b-field>
|
||||
|
||||
<b-field class="column mb-0 pb-0" label="Contraseña">
|
||||
<b-input
|
||||
type="password"
|
||||
placeholder="Contraseña"
|
||||
icon="lock"
|
||||
v-model="password"
|
||||
rounded
|
||||
@keyup.enter.native="
|
||||
imprimirWarning(
|
||||
'¿Esta segur@ de querer crear este operador?',
|
||||
crearOperador
|
||||
)
|
||||
"
|
||||
/>
|
||||
</b-field>
|
||||
|
||||
<b-button
|
||||
type="is-info"
|
||||
class="column"
|
||||
@click="
|
||||
imprimirWarning(
|
||||
'¿Esta segur@ de querer crear este operador?',
|
||||
crearOperador
|
||||
)
|
||||
"
|
||||
:disabled="!operador || !password"
|
||||
expanded
|
||||
rounded
|
||||
>
|
||||
Crear
|
||||
</b-button>
|
||||
</dir>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
operador: '',
|
||||
password: '',
|
||||
}
|
||||
},
|
||||
props: {
|
||||
admin: { type: Object, required: true },
|
||||
imprimirMensaje: { type: Function, required: true },
|
||||
imprimirWarning: { type: Function, required: true },
|
||||
imprimirError: { type: Function, required: true },
|
||||
updateActualizarTabla: { type: Function, required: true },
|
||||
updateIsLoading: { type: Function, required: true },
|
||||
},
|
||||
methods: {
|
||||
crearOperador() {
|
||||
if (this.password && this.operador) {
|
||||
let data = { operador: this.operador, password: this.password }
|
||||
|
||||
this.updateIsLoading(true)
|
||||
axios
|
||||
.post(`${process.env.api}/operador/crear`, data, this.admin.token)
|
||||
.then((res) => {
|
||||
this.operador = ''
|
||||
this.password = ''
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirMensaje(res.data.message)
|
||||
this.updateActualizarTabla(true)
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
104
components/admin/SubirCsv.vue
Normal file
104
components/admin/SubirCsv.vue
Normal file
@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<section>
|
||||
<b-field>
|
||||
<b-upload
|
||||
type="is-black"
|
||||
class="mb-5"
|
||||
@input="validarCsv()"
|
||||
v-model="csv"
|
||||
drag-drop
|
||||
expanded
|
||||
>
|
||||
<section
|
||||
class="section is-flex is-align-items-center is-justify-content-center drag-drop"
|
||||
>
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<b-icon icon="upload" size="is-large"></b-icon>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{
|
||||
csv.name || 'Arrastra aquí tu archivo o da click para buscar'
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</b-upload>
|
||||
</b-field>
|
||||
|
||||
<div class="has-text-centered mb-6">
|
||||
<b-button
|
||||
type="is-info"
|
||||
:disabled="!csv.name"
|
||||
@click="
|
||||
imprimirWarning(
|
||||
'¿Esta segur@ de querer subir este archivo?',
|
||||
cargaMasiva
|
||||
)
|
||||
"
|
||||
>
|
||||
Subir
|
||||
</b-button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
admin: { type: Object, required: true },
|
||||
imprimirMensaje: { type: Function, required: true },
|
||||
imprimirWarning: { type: Function, required: true },
|
||||
imprimirError: { type: Function, required: true },
|
||||
updateIsLoading: { type: Function, required: true },
|
||||
path: { type: String, required: true },
|
||||
manejarRespuesta: { type: Function, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
csv: {},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
validarCsv() {
|
||||
const extPermitidas = /(.csv)$/i
|
||||
|
||||
if (!extPermitidas.exec(this.csv.name)) {
|
||||
this.csv = {}
|
||||
this.imprimirError({
|
||||
message:
|
||||
'El archivo seleccionado no es un csv. Asegurese de escoger un archivo valido.',
|
||||
})
|
||||
}
|
||||
},
|
||||
cargaMasiva() {
|
||||
const formData = new FormData()
|
||||
|
||||
this.updateIsLoading(true)
|
||||
formData.append('csv', this.csv)
|
||||
axios
|
||||
.post(`${process.env.api}/${this.path}`, formData)
|
||||
.then((res) => {
|
||||
this.manejarRespuesta(res.data)
|
||||
|
||||
this.csv = {}
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirMensaje(res.data.message)
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.drag-drop {
|
||||
height: 50vh;
|
||||
}
|
||||
</style>
|
55
components/admin/TablaEquiposNuevos.vue
Normal file
55
components/admin/TablaEquiposNuevos.vue
Normal file
@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<section class="mb-5">
|
||||
<h3 class="is-size-4 mb-3">Previsualización de los datos</h3>
|
||||
|
||||
<b-table :data="data" hoverable striped>
|
||||
<b-table-column
|
||||
field="numeroInventario"
|
||||
label="Número de Inventario"
|
||||
v-slot="props"
|
||||
centered
|
||||
>
|
||||
<span>{{ props.row.numeroInventario }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column
|
||||
field="numeroSerie"
|
||||
label="Número de Serie"
|
||||
v-slot="props"
|
||||
centered
|
||||
>
|
||||
<span>{{ props.row.numeroSerie }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="equipo" label="Equipo" v-slot="props" centered>
|
||||
<span>{{ props.row.equipo }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="tipo" label="Tipo" v-slot="props" centered>
|
||||
<span>{{ props.row.Carrito.TipoCarrito.tipoCarrito }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="programa" label="Programa" v-slot="props" centered>
|
||||
<span v-if="props.row.Programa">{{ props.row.Programa.programa }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="carrito" label="Carrito" v-slot="props" centered>
|
||||
<span>{{ props.row.Carrito.carrito }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="modulo" label="Módulo" v-slot="props" centered>
|
||||
<span>{{ props.row.Carrito.Modulo.modulo }}</span>
|
||||
</b-table-column>
|
||||
</b-table>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
data: { type: Array, required: true },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
147
components/admin/TablaOperadores.vue
Normal file
147
components/admin/TablaOperadores.vue
Normal file
@ -0,0 +1,147 @@
|
||||
<template>
|
||||
<section>
|
||||
<h3 class="is-size-4 mb-3">Buscar Operador</h3>
|
||||
|
||||
<div class="columns mb-5 is-align-items-flex-end">
|
||||
<b-field class="column is-3 mb-0 pb-0" label="Operador">
|
||||
<b-input
|
||||
type="text"
|
||||
placeholder="Operador"
|
||||
icon="account"
|
||||
@keyup.enter.native="obtenerOperadores()"
|
||||
v-model="search.operador"
|
||||
rounded
|
||||
/>
|
||||
</b-field>
|
||||
|
||||
<b-button
|
||||
type="is-success"
|
||||
class="column is-3"
|
||||
@click="obtenerOperadores()"
|
||||
expanded
|
||||
rounded
|
||||
>
|
||||
Buscar
|
||||
</b-button>
|
||||
</div>
|
||||
|
||||
<b-table
|
||||
:data="data"
|
||||
:total="total"
|
||||
:current-page="page"
|
||||
:per-page="25"
|
||||
:loading="isLoadingTable"
|
||||
@page-change="onPageChange"
|
||||
class="mb-6"
|
||||
hoverable
|
||||
striped
|
||||
paginated
|
||||
backend-pagination
|
||||
>
|
||||
<b-table-column field="operador" label="Operador" v-slot="props" centered>
|
||||
<span>{{ props.row.operador }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="activo" label="Status" v-slot="props" centered>
|
||||
<ActivarDesactivar
|
||||
:admin="admin"
|
||||
:imprimirMensaje="imprimirMensaje"
|
||||
:imprimirWarning="imprimirWarning"
|
||||
:imprimirError="imprimirError"
|
||||
:operador="props.row"
|
||||
:updateActualizarTabla="updateActualizarTabla"
|
||||
:updateIsLoading="updateIsLoading"
|
||||
/>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column
|
||||
field="password"
|
||||
label="Cambiar Contraseña"
|
||||
v-slot="props"
|
||||
centered
|
||||
>
|
||||
<UpdatePassword
|
||||
:admin="admin"
|
||||
:imprimirMensaje="imprimirMensaje"
|
||||
:imprimirWarning="imprimirWarning"
|
||||
:imprimirError="imprimirError"
|
||||
:operador="props.row"
|
||||
:updateIsLoading="updateIsLoading"
|
||||
v-if="props.row.activo"
|
||||
/>
|
||||
</b-table-column>
|
||||
</b-table>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
import ActivarDesactivar from '@/components/admin/ActivarDesactivar'
|
||||
import UpdatePassword from '@/components/admin/UpdatePassword'
|
||||
|
||||
export default {
|
||||
components: { UpdatePassword, ActivarDesactivar },
|
||||
data() {
|
||||
return {
|
||||
data: [],
|
||||
page: 1,
|
||||
total: 0,
|
||||
search: {},
|
||||
lastSearch: {},
|
||||
isLoadingTable: false,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
admin: { type: Object, required: true },
|
||||
imprimirMensaje: { type: Function, required: true },
|
||||
imprimirWarning: { type: Function, required: true },
|
||||
imprimirError: { type: Function, required: true },
|
||||
actualizarTabla: { type: Boolean, required: true },
|
||||
updateActualizarTabla: { type: Function, required: true },
|
||||
updateIsLoading: { type: Function, required: true },
|
||||
},
|
||||
methods: {
|
||||
onPageChange(page) {
|
||||
this.page = page
|
||||
this.obtenerOperadores()
|
||||
},
|
||||
obtenerOperadores() {
|
||||
let data = ''
|
||||
|
||||
this.isLoadingTable = true
|
||||
if (this.search.operador != this.lastSearch.operador) {
|
||||
this.page = 1
|
||||
this.lastSearch.operador = this.search.operador
|
||||
}
|
||||
if (this.search.operador) data = `&operador=${this.search.operador}`
|
||||
axios
|
||||
.get(
|
||||
`${process.env.api}/operador/operadores?pagina=${this.page}${data}`,
|
||||
this.admin.token
|
||||
)
|
||||
.then((res) => {
|
||||
this.data = res.data.rows
|
||||
this.total = res.data.count
|
||||
this.isLoadingTable = false
|
||||
})
|
||||
.catch((err) => {
|
||||
this.isLoadingTable = false
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
actualizarTabla() {
|
||||
if (this.actualizarTabla) {
|
||||
this.obtenerOperadores()
|
||||
this.updateActualizarTabla(false)
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
if (this.admin.idTipoUsuario === 1) this.obtenerOperadores()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
57
components/admin/TablaUsuariosNuevos.vue
Normal file
57
components/admin/TablaUsuariosNuevos.vue
Normal file
@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<section class="mb-5">
|
||||
<h3 class="is-size-4 mb-3">Previsualización de los datos</h3>
|
||||
|
||||
<b-table :data="data" class="mb-5" hoverable striped>
|
||||
<b-table-column
|
||||
field="usuario"
|
||||
label="Número de cuenta"
|
||||
v-slot="props"
|
||||
centered
|
||||
>
|
||||
<span>{{ props.row.usuario }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column field="nombre" label="Nombre" v-slot="props" centered>
|
||||
<span>{{ props.row.nombre }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column
|
||||
field="posgrado"
|
||||
label="Carrera/Posgrado"
|
||||
v-slot="props"
|
||||
centered
|
||||
>
|
||||
<span v-if="props.row.Carrera">{{ props.row.Carrera.carrera }}</span>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column
|
||||
field="tipoUsuario"
|
||||
label="Tipo Usuario"
|
||||
v-slot="props"
|
||||
centered
|
||||
>
|
||||
<span>{{ props.row.TipoUsuario.tipoUsuario }}</span>
|
||||
</b-table-column>
|
||||
</b-table>
|
||||
|
||||
<div class="panel">
|
||||
<p class="panel-heading">Alumnos Actualizados</p>
|
||||
|
||||
<p v-for="(uU, i) in usuariosUpdate" :key="i" class="panel-block">
|
||||
{{ uU }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
data: { type: Array, required: true },
|
||||
usuariosUpdate: { type: Array, required: true },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
85
components/admin/UpdatePassword.vue
Normal file
85
components/admin/UpdatePassword.vue
Normal file
@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<div class="columns is-vcentered">
|
||||
<b-field class="column is-8 m-0">
|
||||
<b-input
|
||||
type="password"
|
||||
placeholder="Contraseña Nueva"
|
||||
icon="lock"
|
||||
@keyup.enter.native="
|
||||
imprimirWarning(
|
||||
'¿Esta segur@ de querer camibar la contraseña de este operador?',
|
||||
updatePassword
|
||||
)
|
||||
"
|
||||
v-model="newPassword"
|
||||
rounded
|
||||
password-reveal
|
||||
/>
|
||||
</b-field>
|
||||
|
||||
<div class="column">
|
||||
<b-button
|
||||
type="is-info"
|
||||
:disabled="!newPassword"
|
||||
@click="
|
||||
imprimirWarning(
|
||||
'¿Esta segur@ de querer camibar la contraseña de este operador?',
|
||||
updatePassword
|
||||
)
|
||||
"
|
||||
expanded
|
||||
rounded
|
||||
>
|
||||
Cambiar
|
||||
</b-button>
|
||||
</div>
|
||||
|
||||
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="false" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
newPassword: '',
|
||||
isLoading: false,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
admin: { type: Object, required: true },
|
||||
imprimirMensaje: { type: Function, required: true },
|
||||
imprimirWarning: { type: Function, required: true },
|
||||
imprimirError: { type: Function, required: true },
|
||||
updateIsLoading: { type: Function, required: true },
|
||||
operador: { type: Object, required: true },
|
||||
},
|
||||
methods: {
|
||||
updatePassword() {
|
||||
if (this.newPassword) {
|
||||
const data = {
|
||||
idOperador: this.operador.idOperador,
|
||||
password: this.newPassword,
|
||||
}
|
||||
|
||||
this.isLoading = true
|
||||
axios
|
||||
.put(`${process.env.api}/operador/update`, data, this.admin.token)
|
||||
.then((res) => {
|
||||
this.newPassword = ''
|
||||
this.isLoading = false
|
||||
this.imprimirMensaje(res.data.message)
|
||||
})
|
||||
.catch((err) => {
|
||||
this.isLoading = false
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
@ -250,7 +250,7 @@ export default {
|
||||
const objeto = JSON.parse(localStorage.getItem('usuario'))
|
||||
// this.operador = objeto.operador
|
||||
this.idTipoUsuario = objeto.operador.tipoUsuario.id_tipo_usuario
|
||||
// console.log(this.operador.tipoUsuario.id_tipo_usuario)
|
||||
console.log(objeto.operador)
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
@ -0,0 +1,145 @@
|
||||
<template>
|
||||
<div>
|
||||
<Title title="Carga Masiva Equipos" :operador="admin.operador" />
|
||||
|
||||
<SubirCsv
|
||||
:admin="admin"
|
||||
:imprimirMensaje="imprimirMensaje"
|
||||
:imprimirWarning="imprimirWarning"
|
||||
:imprimirError="imprimirError"
|
||||
:manejarRespuesta="manejarRespuesta"
|
||||
:updateIsLoading="updateIsLoading"
|
||||
:path="path"
|
||||
/>
|
||||
|
||||
<TablaEquiposNuevos :data="data" />
|
||||
|
||||
<AvisosErrores :avisos="avisos" :errores="errores" />
|
||||
|
||||
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="false" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AvisosErrores from '@/components/admin/AvisosErrores'
|
||||
import SubirCsv from '@/components/admin/SubirCsv'
|
||||
import TablaEquiposNuevos from '@/components/admin/TablaEquiposNuevos'
|
||||
import Title from '@/components/layouts/Title'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
AvisosErrores,
|
||||
SubirCsv,
|
||||
TablaEquiposNuevos,
|
||||
Title,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
admin: {},
|
||||
data: [],
|
||||
avisos: [],
|
||||
errores: [],
|
||||
path: '',
|
||||
isLoading: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
manejarRespuesta(data) {
|
||||
this.data = data.equiposNuevos
|
||||
this.avisos = data.avisos
|
||||
this.errores = data.errores
|
||||
},
|
||||
updateIsLoading(valorBooleano) {
|
||||
this.isLoading = valorBooleano
|
||||
},
|
||||
imprimirError(err = {}, title = '¡Hubo un error!', onConfirm = () => {}) {
|
||||
this.$buefy.dialog.alert({
|
||||
ariaRole: 'alertdialog',
|
||||
ariaModal: true,
|
||||
type: 'is-danger',
|
||||
title,
|
||||
message: err.message,
|
||||
confirmText: 'Entendido',
|
||||
hasIcon: true,
|
||||
iconPack: 'mdi',
|
||||
icon: 'alert-octagon',
|
||||
onConfirm,
|
||||
})
|
||||
if (err.err && err.err === 'token error') {
|
||||
localStorage.clear()
|
||||
this.$router.push('/')
|
||||
}
|
||||
},
|
||||
imprimirMensaje(message, onConfirm = () => {}, title = '¡Felicidades!') {
|
||||
this.$buefy.dialog.alert({
|
||||
ariaRole: 'alertdialog',
|
||||
ariaModal: true,
|
||||
type: 'is-success',
|
||||
title,
|
||||
message,
|
||||
confirmText: 'Ok',
|
||||
hasIcon: true,
|
||||
iconPack: 'mdi',
|
||||
icon: 'check-circle',
|
||||
onConfirm,
|
||||
})
|
||||
},
|
||||
imprimirWarning(
|
||||
message,
|
||||
onConfirm = () => {},
|
||||
title = '¡Espera un minuto!',
|
||||
onCancel = () => {}
|
||||
) {
|
||||
this.$buefy.dialog.alert({
|
||||
ariaRole: 'alertdialog',
|
||||
ariaModal: true,
|
||||
type: 'is-warning',
|
||||
title,
|
||||
message,
|
||||
confirmText: 'Confirmar',
|
||||
canCancel: true,
|
||||
cancelText: 'Cancelar',
|
||||
hasIcon: true,
|
||||
iconPack: 'mdi',
|
||||
icon: 'help-circle',
|
||||
onConfirm,
|
||||
onCancel,
|
||||
})
|
||||
},
|
||||
getLocalhostInfo() {
|
||||
// this.admin.idOperador = localStorage.getItem('idOperador')
|
||||
// this.admin.operador = localStorage.getItem('operador')
|
||||
// this.admin.idModulo = Number(localStorage.getItem('idModulo'))
|
||||
// this.admin.tipoUsuario = localStorage.getItem('tipoUsuario')
|
||||
// this.admin.idTipoUsuario = Number(localStorage.getItem('idTipoUsuario'))
|
||||
// this.admin.token = {
|
||||
// headers: {
|
||||
// 'Content-Type': 'multipart/form-data',
|
||||
// token: localStorage.getItem('token'),
|
||||
// },
|
||||
// }
|
||||
const objeto = JSON.parse(localStorage.getItem('usuario'))
|
||||
this.admin.idOperador = objeto.operador.id_operador
|
||||
this.admin.operador = objeto.operador
|
||||
this.admin.tipoUsuario = objeto.operador.tipoUsuario.tipo_usuario
|
||||
this.admin.idTipoUsuario = objeto.operador.tipoUsuario.id_tipo_usuario
|
||||
this.admin.idInstitucion = objeto.operador.institucion.id_institucion
|
||||
this.admin.token = {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
token: localStorage.getItem('token'),
|
||||
},
|
||||
}
|
||||
console.log(this.admin.idInstitucion)
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getLocalhostInfo()
|
||||
this.path = `upload-file/carga-masiva-equipos?id_institucion=${this.admin.idInstitucion}`
|
||||
if (this.admin.idTipoUsuario != 2 && this.admin.idTipoUsuario != 3)
|
||||
this.$router.push('/operador/prestamo_devolucion')
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
@ -0,0 +1,147 @@
|
||||
<template>
|
||||
<div>
|
||||
<Title title="Carga Masiva Usuarios" :operador="admin.operador" />
|
||||
|
||||
<SubirCsv
|
||||
:admin="admin"
|
||||
:imprimirMensaje="imprimirMensaje"
|
||||
:imprimirWarning="imprimirWarning"
|
||||
:imprimirError="imprimirError"
|
||||
:manejarRespuesta="manejarRespuesta"
|
||||
:updateIsLoading="updateIsLoading"
|
||||
:path="path"
|
||||
/>
|
||||
|
||||
<!-- <TablaUsuariosNuevos :data="data" :usuariosUpdate="usuariosUpdate" /> -->
|
||||
|
||||
<AvisosErrores :avisos="avisos" :errores="errores" />
|
||||
|
||||
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="false" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AvisosErrores from '@/components/admin/AvisosErrores'
|
||||
import SubirCsv from '@/components/admin/SubirCsv'
|
||||
import TablaUsuariosNuevos from '@/components/admin/TablaUsuariosNuevos'
|
||||
import Title from '@/components/layouts/Title'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
AvisosErrores,
|
||||
SubirCsv,
|
||||
TablaUsuariosNuevos,
|
||||
Title,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
admin: {},
|
||||
data: [],
|
||||
avisos: [],
|
||||
errores: [],
|
||||
usuariosUpdate: [],
|
||||
isLoading: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
manejarRespuesta(data) {
|
||||
console.log(data)
|
||||
this.data = data.usuariosNuevos
|
||||
// this.usuariosUpdate = data.usuariosUpdate
|
||||
this.avisos = data.mensajes
|
||||
this.errores = data.errores
|
||||
},
|
||||
updateIsLoading(valorBooleano) {
|
||||
this.isLoading = valorBooleano
|
||||
},
|
||||
imprimirError(err = {}, title = '¡Hubo un error!', onConfirm = () => {}) {
|
||||
this.$buefy.dialog.alert({
|
||||
ariaRole: 'alertdialog',
|
||||
ariaModal: true,
|
||||
type: 'is-danger',
|
||||
title,
|
||||
message: err.message,
|
||||
confirmText: 'Entendido',
|
||||
hasIcon: true,
|
||||
iconPack: 'mdi',
|
||||
icon: 'alert-octagon',
|
||||
onConfirm,
|
||||
})
|
||||
if (err.err && err.err === 'token error') {
|
||||
localStorage.clear()
|
||||
this.$router.push('/')
|
||||
}
|
||||
},
|
||||
imprimirMensaje(message, onConfirm = () => {}, title = '¡Felicidades!') {
|
||||
this.$buefy.dialog.alert({
|
||||
ariaRole: 'alertdialog',
|
||||
ariaModal: true,
|
||||
type: 'is-success',
|
||||
title,
|
||||
message,
|
||||
confirmText: 'Ok',
|
||||
hasIcon: true,
|
||||
iconPack: 'mdi',
|
||||
icon: 'check-circle',
|
||||
onConfirm,
|
||||
})
|
||||
},
|
||||
imprimirWarning(
|
||||
message,
|
||||
onConfirm = () => {},
|
||||
title = '¡Espera un minuto!',
|
||||
onCancel = () => {}
|
||||
) {
|
||||
this.$buefy.dialog.alert({
|
||||
ariaRole: 'alertdialog',
|
||||
ariaModal: true,
|
||||
type: 'is-warning',
|
||||
title,
|
||||
message,
|
||||
confirmText: 'Confirmar',
|
||||
canCancel: true,
|
||||
cancelText: 'Cancelar',
|
||||
hasIcon: true,
|
||||
iconPack: 'mdi',
|
||||
icon: 'help-circle',
|
||||
onConfirm,
|
||||
onCancel,
|
||||
})
|
||||
},
|
||||
getLocalhostInfo() {
|
||||
// this.admin.idOperador = localStorage.getItem('idOperador')
|
||||
// this.admin.operador = localStorage.getItem('operador')
|
||||
// this.admin.idModulo = Number(localStorage.getItem('idModulo'))
|
||||
// this.admin.tipoUsuario = localStorage.getItem('tipoUsuario')
|
||||
// this.admin.idTipoUsuario = Number(localStorage.getItem('idTipoUsuario'))
|
||||
// this.admin.token = {
|
||||
// headers: {
|
||||
// 'Content-Type': 'multipart/form-data',
|
||||
// token: localStorage.getItem('token'),
|
||||
// },
|
||||
// }
|
||||
const objeto = JSON.parse(localStorage.getItem('usuario'))
|
||||
this.admin.idOperador = objeto.operador.id_operador
|
||||
this.admin.operador = objeto.operador
|
||||
this.admin.tipoUsuario = objeto.operador.tipoUsuario.tipo_usuario
|
||||
this.admin.idTipoUsuario = objeto.operador.tipoUsuario.id_tipo_usuario
|
||||
this.admin.idInstitucion = objeto.operador.institucion.id_institucion
|
||||
this.admin.token = {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
token: localStorage.getItem('token'),
|
||||
},
|
||||
}
|
||||
console.log(this.admin.idTipoUsuario)
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getLocalhostInfo()
|
||||
this.path = `upload-file/carga-masiva-usuarios?id_institucion=${this.admin.idInstitucion}`
|
||||
if (this.admin.idTipoUsuario != 2 && this.admin.idTipoUsuario != 3)
|
||||
this.$router.push('/operador/prestamo_devolucion')
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
Loading…
Reference in New Issue
Block a user