diff --git a/src/views/User.vue b/src/views/User.vue index 067101d..699c071 100644 --- a/src/views/User.vue +++ b/src/views/User.vue @@ -20,6 +20,17 @@ placeholder="Número de inventario" /> +
+ +
@@ -32,7 +43,7 @@ - + {{ item.noInventario }} {{ item.activoFijo }} {{ item.modelo }} @@ -81,7 +92,8 @@ + class="btn btn-lg btn-success mt-3">Descargar +
import axios from 'axios'; import config from '../config/config'; -/*import strinify from "csv-stringify"; -import fs from "file-system"; -*/ import MiXLSX from 'xlsx'; export default { @@ -154,11 +163,16 @@ export default { "Descripción adicional" ], respuesta: [], + tipo: [], + datosmios : [], + seleccionado: String, } }, created() { this.getComputers(); + this.traetipo(); + this.seleccionado = "0"; }, methods: { @@ -182,6 +196,18 @@ export default { .then(res => this.respuesta = res.data.printers) .catch(err => console.log(err)); }, + async traetipo(){ + console.log("Inicia Consulta"); + const localToken = window.localStorage.token; + axios.get(`${ config.api }/api/tipo`, { + headers: { + token: localToken + } + }) + .then(res => this.tipo = res.data.tipo) + .catch(err => console.log(err)); + console.log("Termina Consulta"); + }, watchRow() { if(JSON.parse(window.localStorage.isAdmin)) this.$router.push('./updateEquip') @@ -202,12 +228,25 @@ export default { }, onDescarga(datos){ console.log("Descargar"); - let miDato = MiXLSX.utils.json_to_sheet(datos); + for (let i = 0, j = 0; i < datos.length; i++){ + if (this.seleccionado == "0" || this.seleccionado == datos[i].activoFijo){ + this.datosmios[j++] = datos[i]; + } + } + var miDato = MiXLSX.utils.json_to_sheet(this.pcHeads,{ + header : this.pcHeads + }); + MiXLSX.utils.sheet_add_json(miDato,this.datosmios,{ + skipHeader:true, origin : "A2"}); const LibroTrabajo = MiXLSX.utils.book_new(); MiXLSX.utils.book_append_sheet(LibroTrabajo, miDato, "SalidaFalsa"); MiXLSX.writeFile(LibroTrabajo, "SalidaFalsa.xlsx"); console.log("Terminado"); - } + }, + buscaValor(){ + this.seleccionado = document.getElementById("tipo").value; + console.log(this.seleccionado); + }, }, }