Commit 50f657d6d90db9685d96c04d473803e724d3e265
1 parent
136adf0401
Exists in
develop
agrego componentes en comandas
Showing
3 changed files
with
15 additions
and
7 deletions
 
Show diff stats
src/app/modules/comanda/comanda.component.html
| 1 | <div class="container-fluid d-flex flex-column h-100 fade-in pb-4 pr-2"> | 1 | <div class="container-fluid d-flex flex-column h-100 fade-in pb-4 pr-2"> | 
| 2 | <div class="row pt-5 mt-n5"> | 2 | <div class="row pt-5 mt-n5"> | 
| 3 | <div class="col-12"> | 3 | <div class="col-12"> | 
| 4 | <p class="mb-3 h2 text-center mt-2">Pedidos a elaborar</p> | 4 | <p class="mb-3 h2 text-center mt-2">Pedidos a elaborar</p> | 
| 5 | </div> | 5 | </div> | 
| 6 | </div> | 6 | </div> | 
| 7 | <div class="row flex-fill m-0 scroll-y"> | 7 | <div class="row flex-fill m-0 scroll-y"> | 
| 8 | <div class="col-12 px-2"> | 8 | <div class="col-12 px-2"> | 
| 9 | <div class="card-columns h-100 m-1 fade-in disable-user-select"> | 9 | <div class="card-columns h-100 m-1 fade-in disable-user-select"> | 
| 10 | <div | 10 | <div | 
| 11 | *ngFor="let comanda of comandas" | 11 | *ngFor="let comanda of comandas" | 
| 12 | class="card fade-in rounded-xs shadow-sm mt-2" | 12 | class="card fade-in rounded-xs shadow-sm mt-2" | 
| 13 | [ngClass]="{ | 13 | [ngClass]="{ | 
| 14 | 'bg-light': comanda.estado === 1, | 14 | 'bg-light': comanda.estado === 1, | 
| 15 | 'bg-danger': comanda.estado === 2, | 15 | 'bg-danger': comanda.estado === 2, | 
| 16 | 'bg-success swing-out-top-bck': comanda.estado === 3 | 16 | 'bg-success swing-out-top-bck': comanda.estado === 3 | 
| 17 | }"> | 17 | }"> | 
| 18 | <div class="card-body p-2"> | 18 | <div class="card-body p-2"> | 
| 19 | <div class="row justify-content-between"> | 19 | <div class="row justify-content-between"> | 
| 20 | <img | 20 | <img | 
| 21 | src="../../../assets/img/para-llevar-fondo-sombra.png" | 21 | src="../../../assets/img/para-llevar-fondo-sombra.png" | 
| 22 | class="w-25 h-25 float-left ml-0 mt-n3" | 22 | class="w-25 h-25 float-left ml-0 mt-n3" | 
| 23 | *ngIf="comanda.paraLlevar == true"> | 23 | *ngIf="comanda.paraLlevar == true"> | 
| 24 | <div></div> | 24 | <div></div> | 
| 25 | <!-- NUMERO DE PEDIDO --> | 25 | <!-- NUMERO DE PEDIDO --> | 
| 26 | <p class="h1 text-right mr-3"> | 26 | <p class="h1 text-right mr-3"> | 
| 27 | {{rellenar(comanda.id.toString().slice(0), 3)}} | 27 | {{rellenar(comanda.id.toString().slice(0), 3)}} | 
| 28 | </p> | 28 | </p> | 
| 29 | </div> | 29 | </div> | 
| 30 | <div> | 30 | <div> | 
| 31 | <!-- PEDIDO A NOMBRE DE --> | 31 | <!-- PEDIDO A NOMBRE DE --> | 
| 32 | <p class="text-center m-0"> | 32 | <p class="text-center m-0"> | 
| 33 | {{comanda.pedidoAnombreDe ? comanda.pedidoAnombreDe.toUpperCase() : ''}} | 33 | {{comanda.pedidoAnombreDe ? comanda.pedidoAnombreDe.toUpperCase() : ''}} | 
| 34 | </p> | 34 | </p> | 
| 35 | <!-- TIMER PEDIDO --> | 35 | <!-- TIMER PEDIDO --> | 
| 36 | <div class="d-flex justify-content-between align-items-center mt-2"> | 36 | <div class="d-flex justify-content-between align-items-center mt-2"> | 
| 37 | <p><i class="fas fa-user-clock text-info"></i></p> | 37 | <p><i class="fas fa-user-clock text-info"></i></p> | 
| 38 | <p class="text-center mb-1"> | 38 | <p class="text-center mb-1"> | 
| 39 | {{comanda.hoursPedido}}:{{comanda.minutesPedido}}:{{comanda.secondsPedido}} | 39 | {{comanda.hoursPedido}}:{{comanda.minutesPedido}}:{{comanda.secondsPedido}} | 
| 40 | </p> | 40 | </p> | 
| 41 | <p><i class="far fa-clock fa-spin text-info"></i></p> | 41 | <p><i class="far fa-clock fa-spin text-info"></i></p> | 
| 42 | </div> | 42 | </div> | 
| 43 | <div *ngFor="let detalle of comanda.detalles"> | 43 | <div *ngFor="let detalle of comanda.detalles"> | 
| 44 | <p | 44 | <div | 
| 45 | class="card-text border-top pt-2 mb-2" | 45 | class="card-text border-top pt-2 mb-2" | 
| 46 | [ngClass]=" | 46 | [ngClass]=" | 
| 47 | { | 47 | { | 
| 48 | 'border-secondary': comanda.estado === 1, | 48 | 'border-secondary': comanda.estado === 1, | 
| 49 | 'border-light': comanda.estado != 1 | 49 | 'border-light': comanda.estado != 1 | 
| 50 | }"> | 50 | }"> | 
| 51 | <!-- DETALLE Y CANTIDAD --> | 51 | <!-- DETALLE Y CANTIDAD --> | 
| 52 | <small>{{detalle.DetLar}}</small><br> | 52 | <p> | 
| 53 | <small>CANT.{{detalle.cantidad}}</small> | 53 | <small>{{detalle.DetLar}}</small><br> | 
| 54 | </p> | 54 | <small>CANT.{{detalle.cantidad}}</small> | 
| 55 | <blockquote | 55 | </p> | 
| 56 | <div *ngFor="let componente of detalle.componentes"> | ||
| 57 | <p> | ||
| 58 | <small>{{componente.DetArt.toUpperCase()}}</small> | ||
| 59 | </p> | ||
| 60 | </div> | ||
| 61 | </div> | ||
| 62 | <!-- <blockquote | ||
| 56 | *ngIf="detalle.comentario"> | 63 | *ngIf="detalle.comentario"> | 
| 57 | <p class="text-muted font-italic px-4" *ngIf="comanda.estado === 1"><small>{{detalle.comentario}}</small></p> | 64 | <p class="text-muted font-italic px-4" *ngIf="comanda.estado === 1"><small>{{detalle.comentario}}</small></p> | 
| 58 | <p class="text-white font-italic px-4" *ngIf="comanda.estado !== 1"><small>{{detalle.comentario}}</small></p> | 65 | <p class="text-white font-italic px-4" *ngIf="comanda.estado !== 1"><small>{{detalle.comentario}}</small></p> | 
| 59 | </blockquote> | 66 | </blockquote> --> | 
| 60 | </div> | 67 | </div> | 
| 61 | <!-- BOTONES --> | 68 | <!-- BOTONES --> | 
| 62 | <button | 69 | <button | 
| 63 | *ngIf="comanda.estado === 1" | 70 | *ngIf="comanda.estado === 1" | 
| 64 | class="btn btn-block btn-primary shadow-sm btn-elaborar" | 71 | class="btn btn-block btn-primary shadow-sm btn-elaborar" | 
| 65 | (click)="updateComanda(comanda, 2, 'En elaboracion')"> | 72 | (click)="updateComanda(comanda, 2, 'En elaboracion')"> | 
| 66 | <div class="row justify-content-between"> | 73 | <div class="row justify-content-between"> | 
| 67 | <div></div> | 74 | <div></div> | 
| 68 | <p class="ml-4" style="color: #fff;">Elaborar</p> | 75 | <p class="ml-4" style="color: #fff;">Elaborar</p> | 
| 69 | <img | 76 | <img | 
| 70 | draggable="false" | 77 | draggable="false" | 
| 71 | ondragstart="return false;" | 78 | ondragstart="return false;" | 
| 72 | (contextmenu)="false" | 79 | (contextmenu)="false" | 
| 73 | class="icon-30 mr-2" | 80 | class="icon-30 mr-2" | 
| 74 | src="assets/img/ir.svg"> | 81 | src="assets/img/ir.svg"> | 
| 75 | </div> | 82 | </div> | 
| 76 | </button> | 83 | </button> | 
| 77 | <button | 84 | <button | 
| 78 | *ngIf="comanda.estado === 2" | 85 | *ngIf="comanda.estado === 2" | 
| 79 | class="btn btn-block shadow-sm btn-terminar" | 86 | class="btn btn-block shadow-sm btn-terminar" | 
| 80 | (click)="updateComanda(comanda, 3, 'Terminado')"> | 87 | (click)="updateComanda(comanda, 3, 'Terminado')"> | 
| 81 | <div class="row justify-content-between"> | 88 | <div class="row justify-content-between"> | 
| 82 | <div></div> | 89 | <div></div> | 
| 83 | <p class="ml-4">Terminar</p> | 90 | <p class="ml-4">Terminar</p> | 
| 84 | <img | 91 | <img | 
| 85 | draggable="false" | 92 | draggable="false" | 
| 86 | ondragstart="return false;" | 93 | ondragstart="return false;" | 
| 87 | (contextmenu)="false" | 94 | (contextmenu)="false" | 
| 88 | class="icon-30 mr-2" | 95 | class="icon-30 mr-2" | 
| 89 | src="assets/img/flecha-borde-color.svg"> | 96 | src="assets/img/flecha-borde-color.svg"> | 
| 90 | </div> | 97 | </div> | 
| 91 | </button> | 98 | </button> | 
| 92 | <button | 99 | <button | 
| 93 | *ngIf="comanda.estado === 2" | 100 | *ngIf="comanda.estado === 2" | 
| 94 | class="btn btn-block btn-deshacer btn-sm shadow-sm p-0" | 101 | class="btn btn-block btn-deshacer btn-sm shadow-sm p-0" | 
| 95 | (click)="updateComanda(comanda, 1, 'Pagado')"> | 102 | (click)="updateComanda(comanda, 1, 'Pagado')"> | 
| 96 | <div class="row justify-content-between"> | 103 | <div class="row justify-content-between"> | 
| 97 | <div></div> | 104 | <div></div> | 
| 98 | <span class="h6 ml-4"><small>Deshacer</small></span> | 105 | <span class="h6 ml-4"><small>Deshacer</small></span> | 
| 99 | <i class="fas fa-undo-alt text-info mr-4 my-auto"></i> | 106 | <i class="fas fa-undo-alt text-info mr-4 my-auto"></i> | 
| 100 | </div> | 107 | </div> | 
| 101 | </button> | 108 | </button> | 
| 102 | </div> | 109 | </div> | 
| 103 | <!-- TIMER DE ELABORACION --> | 110 | <!-- TIMER DE ELABORACION --> | 
| 104 | <div *ngIf="comanda.estado === 2" class="d-flex justify-content-between align-items-center mt-2"> | 111 | <div *ngIf="comanda.estado === 2" class="d-flex justify-content-between align-items-center mt-2"> | 
| 105 | <div *ngIf="comanda.estado !== 1"> | 112 | <div *ngIf="comanda.estado !== 1"> | 
| 106 | <i class="fa fa-utensils text-info" aria-hidden="true"></i> | 113 | <i class="fa fa-utensils text-info" aria-hidden="true"></i> | 
| 107 | </div> | 114 | </div> | 
| 108 | <span *ngIf="comanda.estado === 1" class="text-dark"> | 115 | <span *ngIf="comanda.estado === 1" class="text-dark"> | 
| 109 | {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}} | 116 | {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}} | 
| 110 | </span> | 117 | </span> | 
| 111 | <span *ngIf="comanda.estado !== 1" class="text-white"> | 118 | <span *ngIf="comanda.estado !== 1" class="text-white"> | 
| 112 | {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}} | 119 | {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}} | 
| 113 | </span> | 120 | </span> | 
| 114 | <i class="fas fa-clock fa-spin text-info"></i> | 121 | <i class="fas fa-clock fa-spin text-info"></i> | 
| 115 | </div> | 122 | </div> | 
| 116 | </div> | 123 | </div> | 
| 117 | </div> | 124 | </div> | 
| 118 | </div> | 125 | </div> | 
| 119 | </div> | 126 | </div> | 
| 120 | </div> | 127 | </div> | 
| 121 | </div> | 128 | </div> | 
| 122 | 129 | 
src/app/modules/comanda/comanda.component.ts
| 1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; | 
| 2 | import { IComanda, IComandaDetalle, IComponente } from 'src/app/interfaces/IComanda'; | 2 | import { IComanda, IComandaDetalle, IComponente } from 'src/app/interfaces/IComanda'; | 
| 3 | import { ComandaService } from 'src/app/services/comanda/comanda.service'; | 3 | import { ComandaService } from 'src/app/services/comanda/comanda.service'; | 
| 4 | import * as _ from 'lodash'; | 4 | import * as _ from 'lodash'; | 
| 5 | 5 | ||
| 6 | @Component({ | 6 | @Component({ | 
| 7 | selector: 'app-comanda', | 7 | selector: 'app-comanda', | 
| 8 | templateUrl: './comanda.component.html', | 8 | templateUrl: './comanda.component.html', | 
| 9 | styleUrls: ['./comanda.component.scss'] | 9 | styleUrls: ['./comanda.component.scss'] | 
| 10 | }) | 10 | }) | 
| 11 | export class ComandaComponent implements OnInit { | 11 | export class ComandaComponent implements OnInit { | 
| 12 | comandas: IComanda[] = []; | 12 | comandas: IComanda[] = []; | 
| 13 | detalles: [] = []; | ||
| 13 | cicloTime: any; | 14 | cicloTime: any; | 
| 14 | 15 | ||
| 15 | constructor( | 16 | constructor( | 
| 16 | private comandaService: ComandaService, | 17 | private comandaService: ComandaService, | 
| 17 | ) { } | 18 | ) { } | 
| 18 | 19 | ||
| 19 | ngOnInit() { | 20 | ngOnInit() { | 
| 20 | this.getComandas(); | 21 | this.getComandas(); | 
| 21 | this.timerGetComandas(); | 22 | this.timerGetComandas(); | 
| 22 | } | 23 | } | 
| 23 | 24 | ||
| 24 | OnDestroy() { | 25 | OnDestroy() { | 
| 25 | clearInterval(this.cicloTime); | 26 | clearInterval(this.cicloTime); | 
| 26 | } | 27 | } | 
| 27 | 28 | ||
| 28 | timerGetComandas() { | 29 | timerGetComandas() { | 
| 29 | this.cicloTime = setInterval(() => { | 30 | this.cicloTime = setInterval(() => { | 
| 30 | this.getComandas(); | 31 | this.getComandas(); | 
| 31 | }, 5000); | 32 | }, 5000); | 
| 32 | } | 33 | } | 
| 33 | 34 | ||
| 34 | getComandas() { | 35 | getComandas() { | 
| 35 | this.comandaService.getAll() | 36 | this.comandaService.getAll() | 
| 36 | .subscribe((resComandas: IComanda[]) => { | 37 | .subscribe((resComandas: IComanda[]) => { | 
| 37 | this.addNewComandas(resComandas); | 38 | this.addNewComandas(resComandas); | 
| 38 | }, e => console.error(e)); | 39 | }, e => console.error(e)); | 
| 39 | } | 40 | } | 
| 40 | 41 | ||
| 41 | addNewComandas(resComandas: IComanda[]) { | 42 | addNewComandas(resComandas: IComanda[]) { | 
| 42 | for (let j = 0; j < resComandas.length; j++) { | 43 | for (let j = 0; j < resComandas.length; j++) { | 
| 43 | for (const comanda of this.comandas) { | 44 | for (const comanda of this.comandas) { | 
| 44 | if (comanda.id === resComandas[j].id) { | 45 | if (comanda.id === resComandas[j].id) { | 
| 45 | resComandas.splice(j, 1); | 46 | resComandas.splice(j, 1); | 
| 46 | } | 47 | } | 
| 47 | } | 48 | } | 
| 48 | } | 49 | } | 
| 49 | if (!resComandas.length) return; | 50 | if (!resComandas.length) return; | 
| 50 | Array.prototype.push.apply(this.comandas, resComandas); | 51 | Array.prototype.push.apply(this.comandas, resComandas); | 
| 51 | this.startTimersPedido(resComandas); | 52 | this.startTimersPedido(resComandas); | 
| 52 | } | 53 | } | 
| 53 | 54 | ||
| 54 | updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) { | 55 | updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) { | 
| 55 | const data = { | 56 | const data = { | 
| 56 | idComanda: comanda.id, | 57 | idComanda: comanda.id, | 
| 57 | estado: estadoNuevo, | 58 | estado: estadoNuevo, | 
| 58 | observacion: observacionNueva, | 59 | observacion: observacionNueva, | 
| 59 | tiempoEspera: `${comanda.hoursPedido}:${comanda.secondsPedido}:${comanda.secondsPedido}`, | 60 | tiempoEspera: `${comanda.hoursPedido}:${comanda.secondsPedido}:${comanda.secondsPedido}`, | 
| 60 | tiempoElaboracion: `${comanda.hoursElaboracion}:${comanda.secondsElaboracion}:${comanda.secondsElaboracion}`, | 61 | tiempoElaboracion: `${comanda.hoursElaboracion}:${comanda.secondsElaboracion}:${comanda.secondsElaboracion}`, | 
| 61 | }; | 62 | }; | 
| 62 | if (data.estado === 3) { | 63 | if (data.estado === 3) { | 
| 63 | this.comandaService.imprimirComandaCocina(parseInt(data.idComanda, 10)) | 64 | this.comandaService.imprimirComandaCocina(parseInt(data.idComanda, 10)) | 
| 64 | .subscribe(res => { }, err => console.error(err) | 65 | .subscribe(res => { }, err => console.error(err) | 
| 65 | ); | 66 | ); | 
| 66 | } | 67 | } | 
| 67 | 68 | ||
| 68 | if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false); | 69 | if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false); | 
| 69 | 70 | ||
| 70 | this.comandaService.update(data) | 71 | this.comandaService.update(data) | 
| 71 | .subscribe((res: any) => { | 72 | .subscribe((res: any) => { | 
| 72 | if (res.data) { | 73 | if (res.data) { | 
| 73 | comanda.estado = estadoNuevo; | 74 | comanda.estado = estadoNuevo; | 
| 74 | comanda.observacion = observacionNueva; | 75 | comanda.observacion = observacionNueva; | 
| 75 | if (estadoNuevo === 2) { | 76 | if (estadoNuevo === 2) { | 
| 76 | this.startTimerElaboracion(comanda); | 77 | this.startTimerElaboracion(comanda); | 
| 77 | } else if (comanda.timerElaboracion) { | 78 | } else if (comanda.timerElaboracion) { | 
| 78 | clearInterval(comanda.timerElaboracion); | 79 | clearInterval(comanda.timerElaboracion); | 
| 79 | } | 80 | } | 
| 80 | } | 81 | } | 
| 81 | }, e => console.error(e)); | 82 | }, e => console.error(e)); | 
| 82 | } | 83 | } | 
| 83 | 84 | ||
| 84 | rellenar(relleno, longitud) { | 85 | rellenar(relleno, longitud) { | 
| 85 | relleno = '' + relleno; | 86 | relleno = '' + relleno; | 
| 86 | while (relleno.length < longitud) { | 87 | while (relleno.length < longitud) { | 
| 87 | relleno = '0' + relleno; | 88 | relleno = '0' + relleno; | 
| 88 | } | 89 | } | 
| 89 | return relleno; | 90 | return relleno; | 
| 90 | } | 91 | } | 
| 91 | 92 | ||
| 92 | toggleVerComponentes(detalle: IComandaDetalle, comanda: IComanda) { | 93 | toggleVerComponentes(detalle: IComandaDetalle, comanda: IComanda) { | 
| 93 | detalle.seeDetalle = !detalle.seeDetalle; | 94 | detalle.seeDetalle = !detalle.seeDetalle; | 
| 94 | } | 95 | } | 
| 95 | 96 | ||
| 96 | hasTipo(componentes: IComponente[]) { | 97 | hasTipo(componentes: IComponente[]) { | 
| 97 | return componentes.some(c => c.tipoArticulo === 6); | 98 | return componentes.some(c => c.tipoArticulo === 6); | 
| 98 | } | 99 | } | 
| 99 | 100 | ||
| 100 | //#region TIMERS | 101 | //#region TIMERS | 
| 101 | startTimersPedido(comandas) { | 102 | startTimersPedido(comandas) { | 
| 102 | comandas.forEach((comanda: IComanda) => { | 103 | comandas.forEach((comanda: IComanda) => { | 
| 103 | this.comandaService.startTimerComanda(comanda, 'Pedido'); | 104 | this.comandaService.startTimerComanda(comanda, 'Pedido'); | 
| 104 | if (comanda.estado === 2) { | 105 | if (comanda.estado === 2) { | 
| 105 | this.startTimerElaboracion(comanda); | 106 | this.startTimerElaboracion(comanda); | 
| 106 | } | 107 | } | 
| 107 | }); | 108 | }); | 
| 108 | } | 109 | } | 
| 109 | 110 | ||
| 110 | startTimerElaboracion(comanda: IComanda) { | 111 | startTimerElaboracion(comanda: IComanda) { | 
| 111 | this.comandaService.startTimerComanda(comanda, 'Elaboracion'); | 112 | this.comandaService.startTimerComanda(comanda, 'Elaboracion'); | 
| 112 | } | 113 | } | 
| 113 | //#endregion | 114 | //#endregion | 
| 114 | 115 | ||
| 115 | } | 116 | } | 
| 116 | 117 | 
src/app/modules/opcion-pedido/opcion-pedido.component.scss
| 1 | .reduce-card-1.media-pantalla { | 1 | .reduce-card-1.media-pantalla { | 
| 2 | position: absolute; | 2 | position: absolute; | 
| 3 | bottom: 150px; | 3 | bottom: 150px; | 
| 4 | -webkit-box-flex: 0; | 4 | -webkit-box-flex: 0; | 
| 5 | flex: 0 0 41.6666666667%; | 5 | flex: 0 0 41.6666666667%; | 
| 6 | max-width: 41.6666666667%; | 6 | max-width: 41.6666666667%; | 
| 7 | left: 10%; | 7 | left: 10%; | 
| 8 | margin-left: 0 !important; | 8 | margin-left: 0 !important; | 
| 9 | } | 9 | } | 
| 10 | 10 | ||
| 11 | .reduce-card-2.media-pantalla { | 11 | .reduce-card-2.media-pantalla { | 
| 12 | position: absolute; | 12 | position: absolute; | 
| 13 | bottom: 150px; | 13 | bottom: 150px; | 
| 14 | -webkit-box-flex: 0; | 14 | -webkit-box-flex: 0; | 
| 15 | flex: 0 0 41.6666666667%; | 15 | flex: 0 0 41.6666666667%; | 
| 16 | max-width: 41.6666666667%; | 16 | max-width: 41.6666666667%; | 
| 17 | right: 10%; | 17 | right: 10%; | 
| 18 | margin-right: 0 !important; | 18 | margin-right: 0 !important; | 
| 19 | } | 19 | } | 
| 20 | 20 | ||
| 21 | .heigth-80 { | 21 | .heigth-80 { | 
| 22 | height: 80px; | 22 | height: 80px; | 
| 23 | } | ||
| 23 | } |