Commit 3fa5b2492d6e43d8d23fde36da9108efa03f873f
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master(mpuebla) See merge request !88
Showing
4 changed files
Show diff stats
src/app/components/comanda/comanda.component.ts
| 1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | import { appSettings } from 'src/etc/AppSettings'; | ||
| 3 | import { ComandaService } from 'src/app/services/comanda.service'; | 2 | import { ComandaService } from 'src/app/services/comanda.service'; |
| 4 | import { Comanda } from 'src/app/wrappers/comanda'; | 3 | import { Comanda } from 'src/app/wrappers/comanda'; |
| 5 | import * as _ from 'lodash'; | 4 | import * as _ from 'lodash'; |
| 5 | import { Title } from '@angular/platform-browser'; | ||
| 6 | 6 | ||
| 7 | @Component({ | 7 | @Component({ |
| 8 | selector: 'app-comanda', | 8 | selector: 'app-comanda', |
| 9 | templateUrl: './comanda.component.html', | 9 | templateUrl: './comanda.component.html', |
| 10 | styleUrls: ['./comanda.component.scss'] | 10 | styleUrls: ['./comanda.component.scss'] |
| 11 | }) | 11 | }) |
| 12 | export class ComandaComponent implements OnInit { | 12 | export class ComandaComponent implements OnInit { |
| 13 | 13 | ||
| 14 | private comandas: Comanda[] = []; | 14 | private comandas: Comanda[] = []; |
| 15 | private cicloTime; | 15 | private cicloTime; |
| 16 | 16 | ||
| 17 | constructor( | 17 | constructor( |
| 18 | private comandaService: ComandaService | 18 | private comandaService: ComandaService, |
| 19 | ) { } | 19 | private titleService: Title |
| 20 | ) { | ||
| 21 | |||
| 22 | this.titleService.setTitle('Comanda'); | ||
| 23 | } | ||
| 20 | 24 | ||
| 21 | ngOnInit() { | 25 | ngOnInit() { |
| 22 | 26 | ||
| 23 | this.buscar(); | 27 | this.buscar(); |
| 24 | this.ciclo(); | 28 | this.ciclo(); |
| 25 | } | 29 | } |
| 26 | 30 | ||
| 27 | ngOnDestroy() { | 31 | ngOnDestroy() { |
| 28 | 32 | ||
| 29 | clearTimeout(this.cicloTime); | 33 | clearTimeout(this.cicloTime); |
| 30 | } | 34 | } |
| 31 | 35 | ||
| 32 | buscar() { | 36 | buscar() { |
| 33 | 37 | ||
| 34 | this.comandaService.getAll() | 38 | this.comandaService.getAll() |
| 35 | .subscribe((res: Comanda[]) => { | 39 | .subscribe((res: Comanda[]) => { |
| 36 | 40 | ||
| 37 | if (!_.isEqual(res, this.comandas)) { | 41 | if (!_.isEqual(res, this.comandas)) { |
| 38 | 42 | ||
| 39 | this.comandas = res; | 43 | this.comandas = res; |
| 40 | console.log(this.comandas); | 44 | console.log(this.comandas); |
| 41 | } | 45 | } |
| 42 | }, e => console.error(e)) | 46 | }, e => console.error(e)) |
| 43 | } | 47 | } |
| 44 | 48 | ||
| 45 | ciclo() { | 49 | ciclo() { |
| 46 | 50 | ||
| 47 | this.cicloTime = setTimeout(() => { | 51 | this.cicloTime = setTimeout(() => { |
| 48 | 52 | ||
| 49 | this.buscar(); | 53 | this.buscar(); |
| 50 | this.ciclo(); | 54 | this.ciclo(); |
| 51 | }, 5000); | 55 | }, 5000); |
| 52 | } | 56 | } |
| 53 | 57 | ||
| 54 | updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) { | 58 | updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) { |
| 55 | 59 | ||
| 56 | this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva) | 60 | this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva) |
| 57 | .subscribe(res => { | 61 | .subscribe(res => { |
| 58 | 62 | ||
| 59 | if (res.data) { | 63 | if (res.data) { |
| 60 | comanda.estado = estadoNuevo; | 64 | comanda.estado = estadoNuevo; |
| 61 | comanda.observacion = observacionNueva; | 65 | comanda.observacion = observacionNueva; |
| 62 | } | 66 | } |
| 63 | }, e => console.error(e)) | 67 | }, e => console.error(e)) |
| 64 | } | 68 | } |
| 65 | 69 | ||
| 66 | } | 70 | } |
src/app/components/pedidos-salientes/pedidos-salientes.component.html
| 1 | <div class="bg-primary-gradient vh-100 disable-user-select"> | 1 | <div class="bg-primary-gradient vh-100 disable-user-select"> |
| 2 | <div class="d-flex justify-content-center"> | 2 | <div class="d-flex justify-content-center"> |
| 3 | <div class="row z-index-0 fixed-top m-0 w-100"> | 3 | <div class="row z-index-0 fixed-top m-0 w-100"> |
| 4 | <div class="col-12 p-3"> | 4 | <div class="col-12 p-3"> |
| 5 | <img class="w-15 float-right" src="../../../assets/img/debo-gray.png"> | 5 | <img class="w-15 float-right" src="../../../assets/img/debo-gray.png"> |
| 6 | </div> | 6 | </div> |
| 7 | </div> | 7 | </div> |
| 8 | <div class="row m-5 text-white text-center"> | 8 | <div class="row m-5 text-white text-center"> |
| 9 | 9 | ||
| 10 | <div class="col-12 p-0"> | 10 | <div class="col-12 p-0"> |
| 11 | <p class="h1 m-0">Su pedido ya esta listo.</p> | 11 | <p class="h1 m-0">Pedidos terminados.</p> |
| 12 | <p class="h2 m-0">Nº de Pedido</p> | 12 | <p class="h2 m-0">Nº de Pedido</p> |
| 13 | </div> | 13 | </div> |
| 14 | 14 | ||
| 15 | <div | 15 | <div |
| 16 | *ngIf="pedidosRecientes.length" | 16 | *ngIf="pedidosRecientes.length" |
| 17 | class="col-12 p-2"> | 17 | class="col-12 p-2"> |
| 18 | <div class="border rounded shadow h-big"> | 18 | <div class="border rounded shadow h-big"> |
| 19 | <div class="font-weight-bold heartbeat m-0 h-100"> | 19 | <div class="font-weight-bold m-0 h-100"> |
| 20 | {{rellenar(pedidosRecientes[0].id.toString().slice(pedidosRecientes[0].id.toString().length - 2), 2)}} | 20 | {{rellenar(pedidosRecientes[0].id.toString().slice(pedidosRecientes[0].id.toString().length - 2), 2)}} |
| 21 | </div> | 21 | </div> |
| 22 | </div> | 22 | </div> |
| 23 | </div> | 23 | </div> |
| 24 | 24 | ||
| 25 | <div | 25 | <div |
| 26 | *ngFor="let pedido of pedidosRecientes; let i = index" | 26 | *ngFor="let pedido of pedidosRecientes; let i = index" |
| 27 | [hidden]="i == 0 || i > 8" | 27 | [hidden]="i == 0 || i > 8" |
| 28 | class="col-3 p-2"> | 28 | class="col-3 p-2"> |
| 29 | <p class="font-weight-bold display-1 m-0 py-1 border rounded shadow"> | 29 | <p class="font-weight-bold display-1 m-0 py-1 border rounded shadow"> |
| 30 | {{rellenar(pedido.id.toString().slice(pedido.id.toString().length - 2), 2)}} | 30 | {{rellenar(pedido.id.toString().slice(pedido.id.toString().length - 2), 2)}} |
| 31 | </p> | 31 | </p> |
| 32 | </div> | 32 | </div> |
| 33 | 33 | ||
| 34 | </div> | 34 | </div> |
| 35 | </div> | 35 | </div> |
| 36 | </div> | 36 | </div> |
| 37 | 37 |
src/app/components/pedidos-salientes/pedidos-salientes.component.ts
| 1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | import { ComandaService } from 'src/app/services/comanda.service'; | 2 | import { ComandaService } from 'src/app/services/comanda.service'; |
| 3 | import { Title } from '@angular/platform-browser'; | ||
| 3 | 4 | ||
| 4 | @Component({ | 5 | @Component({ |
| 5 | selector: 'app-pedidos-salientes', | 6 | selector: 'app-pedidos-salientes', |
| 6 | templateUrl: './pedidos-salientes.component.html', | 7 | templateUrl: './pedidos-salientes.component.html', |
| 7 | styleUrls: ['./pedidos-salientes.component.scss'] | 8 | styleUrls: ['./pedidos-salientes.component.scss'] |
| 8 | }) | 9 | }) |
| 9 | export class PedidosSalientesComponent implements OnInit { | 10 | export class PedidosSalientesComponent implements OnInit { |
| 10 | 11 | ||
| 11 | private pedidosRecientes = []; | 12 | private pedidosRecientes = []; |
| 12 | private cicloTime; | 13 | private cicloTime; |
| 13 | 14 | ||
| 14 | constructor(private comandaService: ComandaService) { } | 15 | constructor( |
| 16 | private comandaService: ComandaService, | ||
| 17 | private titleService: Title | ||
| 18 | ) { | ||
| 19 | |||
| 20 | this.titleService.setTitle('Pedidos Salientes'); | ||
| 21 | } | ||
| 15 | 22 | ||
| 16 | ngOnInit() { | 23 | ngOnInit() { |
| 17 | 24 | ||
| 18 | this.buscar(); | 25 | this.buscar(); |
| 19 | this.ciclo(); | 26 | this.ciclo(); |
| 20 | } | 27 | } |
| 21 | 28 | ||
| 22 | ngOnDestroy() { | 29 | ngOnDestroy() { |
| 23 | 30 | ||
| 24 | clearTimeout(this.cicloTime); | 31 | clearTimeout(this.cicloTime); |
| 25 | } | 32 | } |
| 26 | 33 | ||
| 27 | ciclo() { | 34 | ciclo() { |
| 28 | 35 | ||
| 29 | this.cicloTime = setTimeout(() => { | 36 | this.cicloTime = setTimeout(() => { |
| 30 | 37 | ||
| 31 | this.buscar(); | 38 | this.buscar(); |
| 32 | this.ciclo(); | 39 | this.ciclo(); |
| 33 | }, 5000) | 40 | }, 5000) |
| 34 | } | 41 | } |
| 35 | 42 | ||
| 36 | buscar() { | 43 | buscar() { |
| 37 | this.comandaService | 44 | this.comandaService |
| 38 | .getPendientesEntrega() | 45 | .getPendientesEntrega() |
| 39 | .subscribe((pedidos: []) => { | 46 | .subscribe((pedidos: []) => { |
| 40 | 47 | ||
| 41 | this.pedidosRecientes = pedidos; | 48 | this.pedidosRecientes = pedidos; |
| 42 | }, console.log); | 49 | }, console.log); |
| 43 | } | 50 | } |
| 44 | 51 | ||
| 45 | rellenar(relleno, longitud) { | 52 | rellenar(relleno, longitud) { |
| 46 | relleno = '' + relleno; | 53 | relleno = '' + relleno; |
| 47 | while (relleno.length < longitud) { | 54 | while (relleno.length < longitud) { |
| 48 | relleno = '0' + relleno; | 55 | relleno = '0' + relleno; |
| 49 | } | 56 | } |
| 50 | return relleno; | 57 | return relleno; |
| 51 | } | 58 | } |
| 52 | } | 59 | } |
| 53 | 60 |
src/app/components/sidebar/sidebar.component.html
| 1 | <div class="disable-user-select d-flex align-items-center flex-column h-100 text-center"> | 1 | <div class="disable-user-select d-flex align-items-center flex-column h-100 text-center"> |
| 2 | 2 | ||
| 3 | <!-- ENCABEZADO --> | 3 | <!-- ENCABEZADO --> |
| 4 | <p class="h4 border-bottom border-white text-white pb-2"> | 4 | <p class="h4 border-bottom border-white text-white pb-2"> |
| 5 | Mi compra | 5 | Mi compra |
| 6 | <i class="fa fa-shopping-cart" aria-hidden="true"></i> | 6 | <i class="fa fa-shopping-cart" aria-hidden="true"></i> |
| 7 | </p> | 7 | </p> |
| 8 | 8 | ||
| 9 | <div class="overflow-scroll px-1 mb-1 w-100"> | 9 | <div class="overflow-scroll px-1 mb-1 w-100"> |
| 10 | <!-- PRODUCTOS CARRITO --> | 10 | <!-- PRODUCTOS CARRITO --> |
| 11 | <div class="row m-0" | 11 | <div class="row m-0" |
| 12 | *ngFor="let producto of productosCarrito"> | 12 | *ngFor="let producto of productosCarrito"> |
| 13 | <div class="col p-0 my-1 bg-white border-0 rounded-sm"> | 13 | <div class="col p-0 my-1 bg-white border-0 rounded-sm"> |
| 14 | <div class="row m-0"> | 14 | <div class="row m-0"> |
| 15 | <div class="col-6 pl-1 pr-0 my-auto"> | 15 | <div class="col-6 pl-1 pr-0 my-auto"> |
| 16 | <img | 16 | <img |
| 17 | class="w-100 float-left rounded-sm shadow" | 17 | class="w-100 float-left rounded-sm shadow" |
| 18 | src="{{apiImagenes}}/imagenes/{{producto.imagenes[0].imagen}}"> | 18 | src="{{apiImagenes}}/imagenes/{{producto.imagenes[0].imagen}}"> |
| 19 | </div> | 19 | </div> |
| 20 | <div class="col-6 px-1"> | 20 | <div class="col-6 px-1"> |
| 21 | <!-- BOTONES --> | 21 | <!-- BOTONES --> |
| 22 | <div class="row m-0 d-flex justify-content-between"> | 22 | <div class="row m-0 d-flex justify-content-between"> |
| 23 | 23 | ||
| 24 | <!-- SUMAR - RESTAR CANTIDAD --> | 24 | <!-- SUMAR - RESTAR CANTIDAD --> |
| 25 | <div class="col p-1"> | 25 | <div class="col p-1"> |
| 26 | <div class="btn-group-sm btn-group float-left" role="group"> | 26 | <div class="btn-group-sm btn-group float-left" role="group"> |
| 27 | <button | 27 | <button |
| 28 | type="button" | 28 | type="button" |
| 29 | class="btn btn-light btn-sm border shadow" | 29 | class="btn btn-light btn-sm border shadow" |
| 30 | (click)="aumentarCantidad(producto)"> | 30 | (click)="aumentarCantidad(producto)"> |
| 31 | <i class="fa fa-plus" aria-hidden="true"></i> | 31 | <i class="fa fa-plus" aria-hidden="true"></i> |
| 32 | </button> | 32 | </button> |
| 33 | <div class="bg-white border border-white my-auto px-2 text-dark h5 shadow"> | 33 | <div class="bg-white border border-white my-auto px-2 text-dark h5 shadow"> |
| 34 | <small>{{producto.cantidad}}</small> | 34 | <small>{{producto.cantidad}}</small> |
| 35 | </div> | 35 | </div> |
| 36 | <button | 36 | <button |
| 37 | type="button" | 37 | type="button" |
| 38 | class="btn btn-light btn-sm border shadow" | 38 | class="btn btn-light btn-sm border shadow" |
| 39 | (click)="restarCantidad(producto)"> | 39 | (click)="restarCantidad(producto)"> |
| 40 | <i class="fa fa-minus" aria-hidden="true"></i> | 40 | <i class="fa fa-minus" aria-hidden="true"></i> |
| 41 | </button> | 41 | </button> |
| 42 | </div> | 42 | </div> |
| 43 | </div> | 43 | </div> |
| 44 | 44 | ||
| 45 | <!-- PERSONALIZAR --> | 45 | <!-- PERSONALIZAR --> |
| 46 | <div class="col p-1"> | 46 | <div class="col p-1"> |
| 47 | <button | 47 | <button |
| 48 | *ngIf="producto.tieneSinonimos" | 48 | *ngIf="producto.tieneSinonimos" |
| 49 | type="button" | 49 | type="button" |
| 50 | class="btn btn-light btn-sm float-left border shadow" | 50 | class="btn btn-light btn-sm float-left border shadow" |
| 51 | (click)="personalizarPromo(producto, i)"> | 51 | (click)="personalizarPromo(producto, i)"> |
| 52 | <i class="fa fa-refresh text-purple" aria-hidden="true"></i> | 52 | <i class="fa fa-refresh text-purple" aria-hidden="true"></i> |
| 53 | </button> | 53 | </button> |
| 54 | </div> | 54 | </div> |
| 55 | 55 | ||
| 56 | <!-- BORRAR --> | 56 | <!-- BORRAR --> |
| 57 | <div class="col p-1"> | 57 | <div class="col p-1"> |
| 58 | <button | 58 | <button |
| 59 | type="button" | 59 | type="button" |
| 60 | class="btn btn-secondary btn-sm float-right shadow" | 60 | class="btn btn-secondary btn-sm float-right shadow" |
| 61 | (click)="deleteProducto(producto, i)"> | 61 | (click)="deleteProducto(producto, i)"> |
| 62 | <i class="fa fa-trash" aria-hidden="true"></i> | 62 | <i class="fa fa-trash" aria-hidden="true"></i> |
| 63 | </button> | 63 | </button> |
| 64 | </div> | 64 | </div> |
| 65 | </div> | 65 | </div> |
| 66 | </div> | 66 | </div> |
| 67 | </div> | 67 | </div> |
| 68 | <div class="row m-0 shadow rounded-sm"> | 68 | <div class="row m-0 shadow rounded-sm"> |
| 69 | <div class="col px-2"> | 69 | <div class="col px-2"> |
| 70 | <p class="m-0 text-left h6"><small>{{producto.DetArt}}</small></p> | 70 | <p class="m-0 text-left h6"><small>{{producto.DetArt}}</small></p> |
| 71 | <p class="m-0 text-right font-weight-bold h6">{{producto.PreVen | currency}}</p> | 71 | <p class="m-0 text-right font-weight-bold h6">{{producto.PreVen | currency}}</p> |
| 72 | </div> | 72 | </div> |
| 73 | </div> | 73 | </div> |
| 74 | </div> | 74 | </div> |
| 75 | </div> | 75 | </div> |
| 76 | </div> | 76 | </div> |
| 77 | 77 | ||
| 78 | <!-- TOTAL --> | 78 | <!-- TOTAL --> |
| 79 | <div class="card rounded-top-sm mx-2 mt-auto blue-gradient border-0"> | 79 | <div class="card rounded-top-sm mx-2 mt-auto blue-gradient border-0"> |
| 80 | <div class="card-body p-2 pt-3 row m-0"> | 80 | <div class="card-body p-2 pt-3 row m-0"> |
| 81 | <div class="col-12 p-0"> | 81 | <div class="col-12 p-0"> |
| 82 | <p | 82 | <p |
| 83 | class="h4 border-bottom border-secondary text-secondary pb-2"> | 83 | class="h4 border-bottom border-secondary text-secondary pb-2"> |
| 84 | ({{getCantidadProductos()}}) artículos | 84 | ({{getCantidadProductos()}}) artículos |
| 85 | </p> | 85 | </p> |
| 86 | <p class="h4 text-secondary">Total</p> | 86 | <p class="h4 text-secondary">Total</p> |
| 87 | <p class="h4 font-weight-bold">{{getTotal() | currency}}</p> | 87 | <p class="h2 font-weight-bold">{{getTotal() | currency}}</p> |
| 88 | </div> | 88 | </div> |
| 89 | <div class="col-12 p-0"> | 89 | <div class="col-12 p-0"> |
| 90 | <button | 90 | <button |
| 91 | *ngIf="getCantidadProductos() > 0" | 91 | *ngIf="getCantidadProductos() > 0" |
| 92 | type="button" | 92 | type="button" |
| 93 | class="btn btn-block btn-light btn-lg shadow mb-2 p-1" | 93 | class="btn btn-block btn-light btn-lg shadow mb-2 p-1" |
| 94 | routerLink="/confirmacion-carrito"> | 94 | routerLink="/confirmacion-carrito"> |
| 95 | <span class="font-weight-bold pr-1">Pagar</span> | 95 | <span class="font-weight-bold pr-1">Pagar</span> |
| 96 | <i class="fa fa-check text-success" aria-hidden="true"></i> | 96 | <i class="fa fa-check text-success" aria-hidden="true"></i> |
| 97 | </button> | 97 | </button> |
| 98 | <button | 98 | <button |
| 99 | type="button" | 99 | type="button" |
| 100 | class="btn btn-block btn-light shadow btn-sm shadow" | 100 | class="btn btn-block btn-light shadow btn-sm shadow" |
| 101 | [routerLink]="['/cancelar-compra']"> | 101 | [routerLink]="['/cancelar-compra']"> |
| 102 | <span class="pr-1">Cancelar</span> | 102 | <span class="pr-1">Cancelar</span> |
| 103 | <i class="fa fa-times text-danger" aria-hidden="true"></i> | 103 | <i class="fa fa-times text-danger" aria-hidden="true"></i> |
| 104 | </button> | 104 | </button> |
| 105 | </div> | 105 | </div> |
| 106 | </div> | 106 | </div> |
| 107 | </div> | 107 | </div> |
| 108 | </div> | 108 | </div> |
| 109 | 109 |