Commit 7e604dd701068fe8cc7f7b726a927e70d1080406

Authored by Marcelo Puebla
1 parent dd6738d0d6
Exists in master and in 1 other branch validar_pve

Borradas banderas.

src/app/components/inicio/inicio.component.html
1 <div class="row m-0 fade-in"> 1 <div class="row m-0 fade-in">
2 <div class="col-12 p-0"> 2 <div class="col-12 p-0">
3 3
4 <!-- NOMBRE DE SECCION --> 4 <!-- NOMBRE DE SECCION -->
5 <div class="row m-0"> 5 <div class="row m-0">
6 <div class="col-12 p-0"> 6 <div class="col-12 p-0">
7 <p class="h5 py-1 bg-gray text-muted text-center">Inicio</p> 7 <p class="h5 py-1 bg-gray text-muted text-center">Inicio</p>
8 </div> 8 </div>
9 </div> 9 </div>
10 10
11 <div class="row m-3 d-flex align-items-start disable-user-select"> 11 <div class="row m-3 d-flex align-items-start disable-user-select">
12 <div class="col-md-5 d-flex align-items-end flex-column"> 12 <div class="col-md-5 d-flex align-items-end flex-column">
13 13
14 <!-- PROMOCIONES --> 14 <!-- PROMOCIONES -->
15 <div class="card bg-white border-0 shadow rounded w-100 mb-auto"> 15 <div class="card bg-white border-0 shadow rounded w-100 mb-auto">
16 <div class="card-body text-left px-4 py-3"> 16 <div class="card-body text-left px-4 py-3">
17 <div class="row"> 17 <div class="row">
18 <div class="col-7"> 18 <div class="col-7">
19 <p class="h3 card-title">Promociones</p> 19 <p class="h3 card-title">Promociones</p>
20 </div> 20 </div>
21 <div class="col-5 p-0"> 21 <div class="col-5 p-0">
22 <img src="{{apiUrl}}/imagenes/primario.promociones.png" class="icon-dim m-0"> 22 <img src="{{apiUrl}}/imagenes/primario.promociones.png" class="icon-dim m-0">
23 </div> 23 </div>
24 </div> 24 </div>
25 <p class="h5 card-text text-muted font-weight-light">Conozca las ofertas del momento.</p> 25 <p class="h5 card-text text-muted font-weight-light">Conozca las ofertas del momento.</p>
26 </div> 26 </div>
27 <div id="carouselIndicators" class="carousel slide" data-ride="carousel"> 27 <div id="carouselIndicators" class="carousel slide" data-ride="carousel">
28 <div class="carousel-inner"> 28 <div class="carousel-inner">
29 <div class="carousel-item active"> 29 <div class="carousel-item active">
30 <img src="{{apiUrl}}/imagenes/testImg3.jpg" class="d-block w-100 m-auto rounded"> 30 <img src="{{apiUrl}}/imagenes/testImg3.jpg" class="d-block w-100 m-auto rounded">
31 </div> 31 </div>
32 <div class="carousel-item"> 32 <div class="carousel-item">
33 <img src="{{apiUrl}}/imagenes/testImg3.jpg" class="d-block w-100 m-auto rounded"> 33 <img src="{{apiUrl}}/imagenes/testImg3.jpg" class="d-block w-100 m-auto rounded">
34 </div> 34 </div>
35 <div class="carousel-item"> 35 <div class="carousel-item">
36 <img src="{{apiUrl}}/imagenes/testImg3.jpg" class="d-block w-100 m-auto rounded"> 36 <img src="{{apiUrl}}/imagenes/testImg3.jpg" class="d-block w-100 m-auto rounded">
37 </div> 37 </div>
38 </div> 38 </div>
39 </div> 39 </div>
40 </div> 40 </div>
41 41
42 <!-- ORDENAR --> 42 <!-- ORDENAR -->
43 <div class="card card-effect bg-white border-0 shadow rounded w-100 mt-4"> 43 <div class="card card-effect bg-white border-0 shadow rounded w-100 mt-4">
44 <div class="card-body text-left px-4 py-3"> 44 <div class="card-body text-left px-4 py-3">
45 <div class="row"> 45 <div class="row">
46 <div class="col-5"> 46 <div class="col-5">
47 <p class="h3 card-title">Ordenar Pedido</p> 47 <p class="h3 card-title">Ordenar Pedido</p>
48 </div> 48 </div>
49 <div class="col-7 p-0"> 49 <div class="col-7 p-0">
50 <img src="{{apiUrl}}/imagenes/primario.ordenar.png" class="icon-dim"> 50 <img src="{{apiUrl}}/imagenes/primario.ordenar.png" class="icon-dim">
51 </div> 51 </div>
52 </div> 52 </div>
53 <p class="h5 card-text text-muted font-weight-light">Arme su pedido y solo pase a retirar.</p> 53 <p class="h5 card-text text-muted font-weight-light">Arme su pedido y solo pase a retirar.</p>
54 </div> 54 </div>
55 <img 55 <img
56 class="card-img-bottom d-block w-100 mx-auto rounded" 56 class="card-img-bottom d-block w-100 mx-auto rounded"
57 src="{{apiUrl}}/imagenes/cafe.jpg"> 57 src="{{apiUrl}}/imagenes/cafe.jpg">
58 </div> 58 </div>
59 </div> 59 </div>
60 60
61 <div class="col-md-7 d-flex align-items-end flex-column mt-4 mt-md-0"> 61 <div class="col-md-7 d-flex align-items-end flex-column mt-4 mt-md-0">
62 62
63 <!-- CARGAR PRODUCTOS --> 63 <!-- CARGAR PRODUCTOS -->
64 <ng-template #popTemplate> 64 <ng-template #popTemplate>
65 <app-popover-promos 65 <app-popover-promos
66 *ngIf="productoAcargar && !productoEsPromo" 66 *ngIf="promociones.length > 0 && sinonimos.length === 0"
67 [popover]="popoverDirective" 67 [popover]="popoverDirective"
68 [popoverContent]="promociones" 68 [popoverContent]="promociones"
69 (promoSeleccionada)="promoSeleccionada($event)" 69 (promoSeleccionada)="promoSeleccionada($event)"
70 class="text-white rounded-sm border-0"> 70 class="text-white rounded-sm border-0">
71 </app-popover-promos> 71 </app-popover-promos>
72 <app-popover-sinonimos 72 <app-popover-sinonimos
73 *ngIf="promoAcargar && productoEsPromo" 73 *ngIf="sinonimos.length > 0"
74 [popover]="popoverDirective" 74 [popover]="popoverDirective"
75 [popoverContent]="sinonimos" 75 [popoverContent]="sinonimos"
76 (sinonimoSeleccionado)="sinonimoSeleccionado($event)"
76 class="text-white rounded-sm border-0"> 77 class="text-white rounded-sm border-0">
77 </app-popover-sinonimos> 78 </app-popover-sinonimos>
78 </ng-template> 79 </ng-template>
79 <div 80 <div
80 placement="left" 81 placement="left"
81 triggers="" 82 triggers=""
82 [popover]="popTemplate" 83 [popover]="popTemplate"
83 class="w-100" 84 class="w-100"
84 #pop="bs-popover"> 85 #pop="bs-popover">
85 <div class="card bg-white border-0 shadow rounded mb-auto"> 86 <div class="card bg-white border-0 shadow rounded mb-auto">
86 <div class="card-body text-left px-4 py-3"> 87 <div class="card-body text-left px-4 py-3">
87 <div class="row"> 88 <div class="row">
88 <div class="col-6"> 89 <div class="col-6">
89 <p class="h3 card-title">Cargar Productos</p> 90 <p class="h3 card-title">Cargar Productos</p>
90 </div> 91 </div>
91 <div class="col-6 p-0"> 92 <div class="col-6 p-0">
92 <img src="{{apiUrl}}/imagenes/escanear.png" class="icon-dim mb-2"> 93 <img src="{{apiUrl}}/imagenes/escanear.png" class="icon-dim mb-2">
93 </div> 94 </div>
94 </div> 95 </div>
95 <p class="h5 card-text text-muted font-weight-light"> 96 <p class="h5 card-text text-muted font-weight-light">
96 Coloque el código de<br> 97 Coloque el código de<br>
97 barras o QR frente al scanner. 98 barras o QR frente al scanner.
98 </p> 99 </p>
99 </div> 100 </div>
100 <div class="row m-4"> 101 <div class="row m-4">
101 <div class="col card bg-white shadow border-0 w-75 p-0 mx-auto rounded-sm"> 102 <div class="col card bg-white shadow border-0 w-75 p-0 mx-auto rounded-sm">
102 <!-- IMAGEN DE ESCANER --> 103 <!-- IMAGEN DE ESCANER -->
103 <img 104 <img
104 *ngIf="!productoAcargar" 105 *ngIf="!productoAcargar"
105 class="card-img-top d-block w-100 mx-auto rounded-sm" 106 class="card-img-top d-block w-100 mx-auto rounded-sm"
106 src="{{apiUrl}}/imagenes/escanner.jpg"> 107 src="{{apiUrl}}/imagenes/escanner.jpg">
107 108
108 <!-- PRODUCTO A CARGAR --> 109 <!-- PRODUCTO A CARGAR -->
109 <div class="fade-in m-0" *ngIf="productoAcargar && !productoEsPromo"> 110 <div class="fade-in m-0" *ngIf="productoAcargar && !promoAcargar">
110 <img 111 <img
111 class="card-img-top d-block w-100 mx-auto rounded-sm" 112 class="card-img-top d-block w-100 mx-auto rounded-sm"
112 src="{{apiUrl}}/imagenes/testImg3.jpg"> 113 src="{{apiUrl}}/imagenes/testImg3.jpg">
113 114
114 <div class="row justify-content-between m-3"> 115 <div class="row justify-content-between m-3">
115 <div class="col-12 text-left px-1"> 116 <div class="col-12 text-left px-1">
116 <p class="h6 font-weight-bold mb-0">{{productoAcargar.DetArt}}</p> 117 <p class="h6 font-weight-bold mb-0">{{productoAcargar.DetArt}}</p>
117 </div> 118 </div>
118 <div class="col-12 text-right mt-2"> 119 <div class="col-12 text-right mt-2">
119 <p class="h5 font-weight-bold mb-0">{{productoAcargar.PreVen | currency}}</p> 120 <p class="h5 font-weight-bold mb-0">{{productoAcargar.PreVen | currency}}</p>
120 </div> 121 </div>
121 </div> 122 </div>
122 </div> 123 </div>
123 124
124 <!-- PROMO A CARGAR --> 125 <!-- PROMO A CARGAR -->
125 <div class="fade-in m-0" *ngIf="promoAcargar && productoEsPromo"> 126 <div class="fade-in m-0" *ngIf="promoAcargar">
126 <img 127 <img
127 class="card-img-top d-block w-100 mx-auto rounded-sm" 128 class="card-img-top d-block w-100 mx-auto rounded-sm"
128 src="{{apiUrl}}/imagenes/testImg3.jpg"> 129 src="{{apiUrl}}/imagenes/testImg3.jpg">
129 130
130 <div class="row justify-content-between m-3"> 131 <div class="row justify-content-between m-3">
131 <div class="col-12 text-left px-1"> 132 <div class="col-12 text-left px-1">
132 <p class="h6 font-weight-bold mb-0">{{promoAcargar.nombrePromo}}</p> 133 <p class="h6 font-weight-bold mb-0">{{promoAcargar.nombrePromo}}</p>
133 </div> 134 </div>
134 <div class="col-12 text-right mt-2 align-self-end"> 135 <div class="col-12 text-right mt-2 align-self-end">
135 <p class="h5 font-weight-bold mb-0">{{productoAcargar.PreVen | currency}}</p> 136 <p class="h5 font-weight-bold mb-0">{{promoAcargar.precioTotal | currency}}</p>
136 </div> 137 </div>
137 </div> 138 </div>
138 </div> 139 </div>
139 140
140 </div> 141 </div>
141 <!-- BOTONES DE CARGAR PRODUCTOS--> 142 <!-- BOTONES DE CARGAR PRODUCTOS-->
142 <div 143 <div
143 class="col-5 pr-0" 144 class="col-5 pr-0"
144 *ngIf="productoAcargar && tienePromo"> 145 *ngIf="promociones.length > 0">
145 <button 146 <button
146 *ngIf="productoEsPromo && promoAcargar.sinonimos" 147 *ngIf="sinonimos.length > 0"
147 type="button" 148 type="button"
148 class="btn btn-light btn-block shadow-sm" 149 class="btn btn-light btn-block shadow-sm"
149 (click)="pop.show()"> 150 (click)="pop.show()">
150 <span class="pr-2">Personalizar</span> 151 <span class="pr-2">Personalizar</span>
151 <i class="fa fa-hand-o-up text-purple" aria-hidden="true"></i> 152 <i class="fa fa-hand-o-up text-purple" aria-hidden="true"></i>
152 </button> 153 </button>
153 <button 154 <button
154 *ngIf="!productoEsPromo" 155 *ngIf="!promoAcargar"
155 type="button" 156 type="button"
156 class="btn btn-primary btn-block shadow-sm" 157 class="btn btn-primary btn-block shadow-sm"
157 (click)="pop.show()"> 158 (click)="pop.show()">
158 <span class="pr-2">Mostrar promociones</span> 159 <span class="pr-2">Mostrar promociones</span>
159 <i class="fa fa-bullhorn fa-flip-horizontal" aria-hidden="true"></i> 160 <i class="fa fa-bullhorn fa-flip-horizontal" aria-hidden="true"></i>
160 </button> 161 </button>
161 <button type="button" class="btn btn-light btn-block shadow-sm my-3"> 162 <button type="button" class="btn btn-light btn-block shadow-sm my-3">
162 <span class="pr-2 font-weight-bold">Confirmar</span> 163 <span class="pr-2 font-weight-bold">Confirmar</span>
163 <i class="fa fa-check text-success" aria-hidden="true"></i> 164 <i class="fa fa-check text-success" aria-hidden="true"></i>
164 </button> 165 </button>
165 <button 166 <button
166 type="button" 167 type="button"
167 class="btn btn-light btn-block shadow-sm" 168 class="btn btn-light btn-block shadow-sm"
168 (click)="deshacerCarga()"> 169 (click)="deshacerCarga()">
169 <span class="pr-2">Deshacer</span> 170 <span class="pr-2">Deshacer</span>
170 <i class="fa fa-undo text-warning" aria-hidden="true"></i> 171 <i class="fa fa-undo text-warning" aria-hidden="true"></i>
171 </button> 172 </button>
172 </div> 173 </div>
173 </div> 174 </div>
174 </div> 175 </div>
175 </div> 176 </div>
176 177
177 <!-- BUSCAR PRODUCTOS --> 178 <!-- BUSCAR PRODUCTOS -->
178 <div (click)="goPage('busqueda-productos')" 179 <div (click)="goPage('busqueda-productos')"
179 class="card card-effect bg-white border-0 shadow rounded w-100 mt-4"> 180 class="card card-effect bg-white border-0 shadow rounded w-100 mt-4">
180 <div class="card-body text-left px-4 py-3"> 181 <div class="card-body text-left px-4 py-3">
181 <div class="row"> 182 <div class="row">
182 <div class="col-6"> 183 <div class="col-6">
183 <p class="h3 card-title">Buscar Productos</p> 184 <p class="h3 card-title">Buscar Productos</p>
184 <p class="h5 card-text text-muted font-weight-light"> 185 <p class="h5 card-text text-muted font-weight-light">
185 Busque aquí los productos<br> 186 Busque aquí los productos<br>
186 que no tienen código </p> 187 que no tienen código </p>
187 </div> 188 </div>
188 <div class="col-6 p-0"> 189 <div class="col-6 p-0">
189 <img src="{{apiUrl}}/imagenes/primario.buscar.png" class="icon-dim mb-2"> 190 <img src="{{apiUrl}}/imagenes/primario.buscar.png" class="icon-dim mb-2">
190 </div> 191 </div>
191 </div> 192 </div>
192 193
193 </div> 194 </div>
194 </div> 195 </div>
195 196
196 </div> 197 </div>
197 198
198 </div> 199 </div>
199 200
200 </div> 201 </div>
201 </div> 202 </div>
202 203
src/app/components/inicio/inicio.component.ts
1 import { Component, OnInit, ViewChild } from '@angular/core'; 1 import { Component, OnInit, ViewChild } from '@angular/core';
2 import { PopoverDirective } from 'ngx-bootstrap'; 2 import { PopoverDirective } from 'ngx-bootstrap';
3 import { appSettings } from 'src/etc/AppSettings'; 3 import { appSettings } from 'src/etc/AppSettings';
4 import { Producto } from 'src/app/wrappers/producto'; 4 import { Producto } from 'src/app/wrappers/producto';
5 import { ProductoService } from 'src/app/services/producto.service'; 5 import { ProductoService } from 'src/app/services/producto.service';
6 import { Router } from '@angular/router'; 6 import { Router } from '@angular/router';
7 import { Promocion } from 'src/app/wrappers/promocion'; 7 import { Promocion } from 'src/app/wrappers/promocion';
8 import { Sinonimo } from 'src/app/wrappers/sinonimo'; 8 import { Sinonimo } from 'src/app/wrappers/sinonimo';
9 9
10 10
11 @Component({ 11 @Component({
12 selector: 'app-inicio', 12 selector: 'app-inicio',
13 templateUrl: './inicio.component.html', 13 templateUrl: './inicio.component.html',
14 styleUrls: ['./inicio.component.scss'] 14 styleUrls: ['./inicio.component.scss']
15 }) 15 })
16 export class InicioComponent implements OnInit { 16 export class InicioComponent implements OnInit {
17 17
18 @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective; 18 @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective;
19 private productoAcargar: Producto; 19 private productoAcargar: Producto;
20 private promoAcargar: Promocion; 20 private promoAcargar: Promocion;
21 private tienePromo = false; 21 private sinonimoAcargar: Sinonimo;
22 private productoEsPromo = false;
23 22
24 promociones: Promocion[] = []; 23 promociones: Promocion[] = [];
25 sinonimos: Sinonimo[] = []; 24 sinonimos: Sinonimo[] = [];
26 apiUrl: string = appSettings.apiUrl 25 apiUrl: string = appSettings.apiUrl
27 26
28 constructor( 27 constructor(
29 private router: Router, 28 private router: Router,
30 private productoService: ProductoService) { } 29 private productoService: ProductoService) { }
31 30
32 ngOnInit() { 31 ngOnInit() {
33 32
34 this.productoAcargar = this.productoService.productoAcargar; 33 this.productoAcargar = this.productoService.productoAcargar;
35 if (this.productoAcargar) { 34 if (this.productoAcargar) {
36 var sector = this.productoAcargar.CodSec; 35 var sector = this.productoAcargar.CodSec;
37 var codigo = this.productoAcargar.CodArt; 36 var codigo = this.productoAcargar.CodArt;
38 this.productoService.getPromocion(sector, codigo) 37 this.productoService.getPromocion(sector, codigo)
39 .subscribe((res: Promocion[]) => { 38 .subscribe((res: Promocion[]) => {
40 39
41 if (res.length === 0) { 40 if (res.length === 0) {
42 //Si no tiene promociones la cargará al carrito despues de un tiempo 41 //Si no tiene promociones la cargará al carrito despues de un tiempo
43 setTimeout(() => { 42 setTimeout(() => {
44 this.productoService.productos.push(this.productoAcargar); 43 this.productoService.productos.push(this.productoAcargar);
45 this.productoAcargar = undefined; 44 this.productoAcargar = undefined;
46 this.tienePromo = false;
47 }, 2000) 45 }, 2000)
48 } else { 46 } else {
49 47
50 this.promociones = res; 48 this.promociones = res;
51 this.tienePromo = true;
52 this.popoverDirective.show(); 49 this.popoverDirective.show();
53 } 50 }
54 }, error => { console.error(error); }) 51 }, error => { console.error(error); })
55 } 52 }
56 } 53 }
57 54
58 showPopover() { 55 showPopover() {
59 56
60 this.popoverDirective.show(); 57 this.popoverDirective.show();
61 } 58 }
62 59
63 private goPage(pageUrl) { 60 private goPage(pageUrl) {
64 61
65 this.router.navigate([pageUrl]); 62 this.router.navigate([pageUrl]);
66 } 63 }
67 64
68 deshacerCarga() { 65 deshacerCarga() {
69 if (this.productoEsPromo) { 66
67 if (this.sinonimoAcargar || this.sinonimos.length > 0) {
68 this.sinonimos = [];
69 this.sinonimoAcargar = undefined;
70 this.popoverDirective.hide();
71 }
72
73 if (this.promoAcargar) {
70 this.promoAcargar = undefined; 74 this.promoAcargar = undefined;
71 this.productoEsPromo = false;
72 this.popoverDirective.show(); 75 this.popoverDirective.show();
73 } else { 76 } else {
74 this.productoAcargar = undefined; 77 this.productoAcargar = undefined;
75 this.tienePromo = false; 78 this.promociones = [];
76 this.popoverDirective.hide(); 79 this.popoverDirective.hide();
77 } 80 }
78 } 81 }
79 82
80 promoSeleccionada($event: Promocion) { 83 promoSeleccionada($event: Promocion) {
81 84
82 this.productoEsPromo = true;
83 this.promoAcargar = $event; 85 this.promoAcargar = $event;
84 this.popoverDirective.hide(); 86 this.popoverDirective.hide();
85 if (this.promoAcargar.sinonimos) { 87 if (this.promoAcargar.sinonimos) {
86 var sector = this.promoAcargar.sector; 88 var sector = this.promoAcargar.sector;
87 var codigo = this.promoAcargar.codigo; 89 var codigo = this.promoAcargar.codigo;
88 this.productoService.getPromocionSinonimos(sector, codigo) 90 this.productoService.getPromocionSinonimos(sector, codigo)
89 .subscribe((res : Sinonimo[]) => { 91 .subscribe((res: Sinonimo[]) => {
90 92
91 this.sinonimos = res; 93 this.sinonimos = res;
92 this.showPopover(); 94 this.showPopover();
93 }) 95 })
94 } 96 }
95 } 97 }
96 98
99 sinonimoSeleccionado($event: Sinonimo) {
100