change routes to update and create lib
This commit is contained in:
@@ -86,8 +86,7 @@
|
||||
<b-row class="mb-2">
|
||||
<b-col>
|
||||
<b-form-file
|
||||
id="pdf"
|
||||
v-model="pdf"
|
||||
id="pdfNuevo"
|
||||
placeholder="Seleccione el PDF o arrastre..."
|
||||
accept=".pdf"
|
||||
></b-form-file>
|
||||
@@ -95,10 +94,9 @@
|
||||
|
||||
<b-col>
|
||||
<b-form-file
|
||||
id="imagen"
|
||||
v-model="imagen"
|
||||
id="imagenNuevo"
|
||||
placeholder="Seleccione la imagen o arrastre..."
|
||||
accept=".png"
|
||||
accept=".png, .jpg"
|
||||
></b-form-file>
|
||||
</b-col>
|
||||
</b-row>
|
||||
@@ -155,8 +153,6 @@ export default {
|
||||
version:"",
|
||||
descripcion:"",
|
||||
year:"",
|
||||
imagen: null,
|
||||
pdf: null
|
||||
|
||||
};
|
||||
},
|
||||
@@ -173,8 +169,8 @@ export default {
|
||||
|
||||
|
||||
var formData = new FormData();
|
||||
var imagen = document.querySelector('#imagen');
|
||||
var pdf = document.querySelector('#pdf');
|
||||
var imagen = document.querySelector('#imagenNuevo');
|
||||
var pdf = document.querySelector('#pdfNuevo');
|
||||
if(this.isbn !== "") formData.append("isbn", this.isbn); else return this.faltaCampo("ISBN");
|
||||
if(this.titulo !== "") formData.append("titulo", this.titulo); else return this.faltaCampo("Titulo");
|
||||
if(this.categoria !== "Categoria") formData.append("categoria", this.categoria); else return this.faltaCampo("Categoria");
|
||||
@@ -187,15 +183,15 @@ export default {
|
||||
if(this.year !== "") formData.append("year", this.year); else return this.faltaCampo("Año de publicación");
|
||||
if(imagen.files.length > 0) formData.append("imagen", imagen.files[0]); else return this.faltaCampo("Imagen");
|
||||
if(pdf.files.length > 0) formData.append("pdf", pdf.files[0]); else return this.faltaCampo("Pdf");
|
||||
|
||||
await axios.post( `${config.api}/agregarLibro`, formData ,{ headers: { 'Content-Type': 'multipart/form-data' } });
|
||||
formData.append("type", 'addLibro');
|
||||
await axios.post( `${config.api}/actualizarLibro`, formData ,{ headers: { 'Content-Type': 'multipart/form-data' } });
|
||||
await Swal.fire(
|
||||
'Libro agregada con exito',
|
||||
'Libro agregado con exito',
|
||||
'',
|
||||
'success'
|
||||
);
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
catch(error){
|
||||
console.log(error);
|
||||
Swal.fire({
|
||||
|
||||
Reference in New Issue
Block a user