Commit 089381c5a5b687b6b9c15f98c44bdacdca157969
1 parent
271a79f1ee
Exists in
master
and in
1 other branch
Arreglo en delete de imagenes
Showing
2 changed files
with
24 additions
and
20 deletions
Show diff stats
src/app/components/amb-imagenes/amb-imagenes.component.html
src/app/components/amb-imagenes/amb-imagenes.component.ts
... | ... | @@ -38,20 +38,23 @@ export class AmbImagenesComponent implements OnInit { |
38 | 38 | |
39 | 39 | this.onLoad(file) |
40 | 40 | .then(result => { |
41 | - | |
42 | - articulo.imagenes.push({ | |
43 | - name: file.name, | |
44 | - fromGallery: true, | |
45 | - imagen: result, | |
46 | - id_articulo: articulo.id | |
47 | - }); | |
48 | - | |
49 | - this.saveInBase({ | |
50 | - name: file.name, | |
51 | - base64: result, | |
52 | - codigo: articulo.CodArt, | |
53 | - sector: articulo.CodSec | |
54 | - }); | |
41 | + // articulo.imagenes.push({ | |
42 | + // name: file.name + articulo.CodArt + articulo.CodSec, | |
43 | + // fromGallery: true, | |
44 | + // imagen: result, | |
45 | + // id_articulo: articulo.id | |
46 | + // }); | |
47 | + let imagenAguardar = { | |
48 | + imagen: { | |
49 | + name: `${articulo.CodSec}${articulo.CodArt}${file.name}`, | |
50 | + base64: result, | |
51 | + codigo: articulo.CodArt, | |
52 | + sector: articulo.CodSec, | |
53 | + id_articulo: articulo.id | |
54 | + }, | |
55 | + articulo: articulo | |
56 | + }; | |
57 | + this.saveInBase(imagenAguardar); | |
55 | 58 | }); |
56 | 59 | }) |
57 | 60 | } |
... | ... | @@ -65,12 +68,13 @@ export class AmbImagenesComponent implements OnInit { |
65 | 68 | }); |
66 | 69 | } |
67 | 70 | |
71 | + saveInBase(imagenAguardar) { | |
68 | 72 | |
69 | - saveInBase(img) { | |
70 | - | |
71 | - this.productoService.saveInBase(img) | |
72 | - .subscribe(data => { | |
73 | - | |
73 | + this.productoService.saveInBase(imagenAguardar.imagen) | |
74 | + .subscribe(res => { | |
75 | + imagenAguardar.imagen['id'] = res[0]; | |
76 | + imagenAguardar.imagen['fromGallery'] = true; | |
77 | + imagenAguardar.articulo.imagenes.push(imagenAguardar.imagen); | |
74 | 78 | }, error => console.error(error)); |
75 | 79 | } |
76 | 80 |