Commit 76b515f08fba4c97c5f88c93966e472484a0f12f
1 parent
c0480eee32
Exists in
develop
arreglo de MR
Showing
3 changed files
with
18 additions
and
18 deletions
Show diff stats
angular.json
| 1 | { | 1 | { |
| 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", | 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", |
| 3 | "version": 1, | 3 | "version": 1, |
| 4 | "newProjectRoot": "projects", | 4 | "newProjectRoot": "projects", |
| 5 | "projects": { | 5 | "projects": { |
| 6 | "autoservicio-axion": { | 6 | "autoservicio-axion": { |
| 7 | "projectType": "application", | 7 | "projectType": "application", |
| 8 | "schematics": { | 8 | "schematics": { |
| 9 | "@schematics/angular:component": { | 9 | "@schematics/angular:component": { |
| 10 | "style": "scss" | 10 | "style": "scss" |
| 11 | } | 11 | } |
| 12 | }, | 12 | }, |
| 13 | "root": "", | 13 | "root": "", |
| 14 | "sourceRoot": "src", | 14 | "sourceRoot": "src", |
| 15 | "prefix": "app", | 15 | "prefix": "app", |
| 16 | "architect": { | 16 | "architect": { |
| 17 | "build": { | 17 | "build": { |
| 18 | "builder": "@angular-devkit/build-angular:browser", | 18 | "builder": "@angular-devkit/build-angular:browser", |
| 19 | "options": { | 19 | "options": { |
| 20 | "outputPath": "dist/autoservicio-axion", | 20 | "outputPath": "dist/autoservicio-axion", |
| 21 | "index": "src/index.html", | 21 | "index": "src/index.html", |
| 22 | "main": "src/main.ts", | 22 | "main": "src/main.ts", |
| 23 | "polyfills": "src/polyfills.ts", | 23 | "polyfills": "src/polyfills.ts", |
| 24 | "tsConfig": "tsconfig.app.json", | 24 | "tsConfig": "tsconfig.app.json", |
| 25 | "aot": false, | 25 | "aot": false, |
| 26 | "assets": [ | 26 | "assets": [ |
| 27 | "src/favicon.ico", | 27 | "src/favicon.ico", |
| 28 | "src/assets" | 28 | "src/assets" |
| 29 | ], | 29 | ], |
| 30 | "styles": [ | 30 | "styles": [ |
| 31 | "./node_modules/bootstrap/dist/css/bootstrap.min.css", | 31 | "./node_modules/bootstrap/dist/css/bootstrap.min.css", |
| 32 | "node_modules/@fortawesome/fontawesome-free/css/all.min.css", | 32 | "./node_modules/@fortawesome/fontawesome-free/css/all.min.css", |
| 33 | "src/styles.scss" | 33 | "src/styles.scss" |
| 34 | ], | 34 | ], |
| 35 | "scripts": [ | 35 | "scripts": [ |
| 36 | "./node_modules/jquery/dist/jquery.slim.min.js", | 36 | "./node_modules/jquery/dist/jquery.slim.min.js", |
| 37 | "./node_modules/popper.js/dist/umd/popper.min.js", | 37 | "./node_modules/popper.js/dist/umd/popper.min.js", |
| 38 | "node_modules/@fortawesome/fontawesome-free/js/all.min.js", | 38 | "./node_modules/@fortawesome/fontawesome-free/js/all.min.js", |
| 39 | "./node_modules/bootstrap/dist/js/bootstrap.min.js" | 39 | "./node_modules/bootstrap/dist/js/bootstrap.min.js" |
| 40 | ] | 40 | ] |
| 41 | }, | 41 | }, |
| 42 | "configurations": { | 42 | "configurations": { |
| 43 | "production": { | 43 | "production": { |
| 44 | "fileReplacements": [ | 44 | "fileReplacements": [ |
| 45 | { | 45 | { |
| 46 | "replace": "src/environments/environment.ts", | 46 | "replace": "src/environments/environment.ts", |
| 47 | "with": "src/environments/environment.prod.ts" | 47 | "with": "src/environments/environment.prod.ts" |
| 48 | } | 48 | } |
| 49 | ], | 49 | ], |
| 50 | "optimization": true, | 50 | "optimization": true, |
| 51 | "outputHashing": "all", | 51 | "outputHashing": "all", |
| 52 | "sourceMap": false, | 52 | "sourceMap": false, |
| 53 | "extractCss": true, | 53 | "extractCss": true, |
| 54 | "namedChunks": false, | 54 | "namedChunks": false, |
| 55 | "aot": true, | 55 | "aot": true, |
| 56 | "extractLicenses": true, | 56 | "extractLicenses": true, |
| 57 | "vendorChunk": false, | 57 | "vendorChunk": false, |
| 58 | "buildOptimizer": true, | 58 | "buildOptimizer": true, |
| 59 | "budgets": [ | 59 | "budgets": [ |
| 60 | { | 60 | { |
| 61 | "type": "initial", | 61 | "type": "initial", |
| 62 | "maximumWarning": "2mb", | 62 | "maximumWarning": "2mb", |
| 63 | "maximumError": "5mb" | 63 | "maximumError": "5mb" |
| 64 | }, | 64 | }, |
| 65 | { | 65 | { |
| 66 | "type": "anyComponentStyle", | 66 | "type": "anyComponentStyle", |
| 67 | "maximumWarning": "6kb", | 67 | "maximumWarning": "6kb", |
| 68 | "maximumError": "10kb" | 68 | "maximumError": "10kb" |
| 69 | } | 69 | } |
| 70 | ] | 70 | ] |
| 71 | } | 71 | } |
| 72 | } | 72 | } |
| 73 | }, | 73 | }, |
| 74 | "serve": { | 74 | "serve": { |
| 75 | "builder": "@angular-devkit/build-angular:dev-server", | 75 | "builder": "@angular-devkit/build-angular:dev-server", |
| 76 | "options": { | 76 | "options": { |
| 77 | "browserTarget": "autoservicio-axion:build" | 77 | "browserTarget": "autoservicio-axion:build" |
| 78 | }, | 78 | }, |
| 79 | "configurations": { | 79 | "configurations": { |
| 80 | "production": { | 80 | "production": { |
| 81 | "browserTarget": "autoservicio-axion:build:production" | 81 | "browserTarget": "autoservicio-axion:build:production" |
| 82 | } | 82 | } |
| 83 | } | 83 | } |
| 84 | }, | 84 | }, |
| 85 | "extract-i18n": { | 85 | "extract-i18n": { |
| 86 | "builder": "@angular-devkit/build-angular:extract-i18n", | 86 | "builder": "@angular-devkit/build-angular:extract-i18n", |
| 87 | "options": { | 87 | "options": { |
| 88 | "browserTarget": "autoservicio-axion:build" | 88 | "browserTarget": "autoservicio-axion:build" |
| 89 | } | 89 | } |
| 90 | }, | 90 | }, |
| 91 | "test": { | 91 | "test": { |
| 92 | "builder": "@angular-devkit/build-angular:karma", | 92 | "builder": "@angular-devkit/build-angular:karma", |
| 93 | "options": { | 93 | "options": { |
| 94 | "main": "src/test.ts", | 94 | "main": "src/test.ts", |
| 95 | "polyfills": "src/polyfills.ts", | 95 | "polyfills": "src/polyfills.ts", |
| 96 | "tsConfig": "tsconfig.spec.json", | 96 | "tsConfig": "tsconfig.spec.json", |
| 97 | "karmaConfig": "karma.conf.js", | 97 | "karmaConfig": "karma.conf.js", |
| 98 | "assets": [ | 98 | "assets": [ |
| 99 | "src/favicon.ico", | 99 | "src/favicon.ico", |
| 100 | "src/assets" | 100 | "src/assets" |
| 101 | ], | 101 | ], |
| 102 | "styles": [ | 102 | "styles": [ |
| 103 | "src/styles.scss" | 103 | "src/styles.scss" |
| 104 | ], | 104 | ], |
| 105 | "scripts": [] | 105 | "scripts": [] |
| 106 | } | 106 | } |
| 107 | }, | 107 | }, |
| 108 | "lint": { | 108 | "lint": { |
| 109 | "builder": "@angular-devkit/build-angular:tslint", | 109 | "builder": "@angular-devkit/build-angular:tslint", |
| 110 | "options": { | 110 | "options": { |
| 111 | "tsConfig": [ | 111 | "tsConfig": [ |
| 112 | "tsconfig.app.json", | 112 | "tsconfig.app.json", |
| 113 | "tsconfig.spec.json", | 113 | "tsconfig.spec.json", |
| 114 | "e2e/tsconfig.json" | 114 | "e2e/tsconfig.json" |
| 115 | ], | 115 | ], |
| 116 | "exclude": [ | 116 | "exclude": [ |
| 117 | "**/node_modules/**" | 117 | "**/node_modules/**" |
| 118 | ] | 118 | ] |
| 119 | } | 119 | } |
| 120 | }, | 120 | }, |
| 121 | "e2e": { | 121 | "e2e": { |
| 122 | "builder": "@angular-devkit/build-angular:protractor", | 122 | "builder": "@angular-devkit/build-angular:protractor", |
| 123 | "options": { | 123 | "options": { |
| 124 | "protractorConfig": "e2e/protractor.conf.js", | 124 | "protractorConfig": "e2e/protractor.conf.js", |
| 125 | "devServerTarget": "autoservicio-axion:serve" | 125 | "devServerTarget": "autoservicio-axion:serve" |
| 126 | }, | 126 | }, |
| 127 | "configurations": { | 127 | "configurations": { |
| 128 | "production": { | 128 | "production": { |
| 129 | "devServerTarget": "autoservicio-axion:serve:production" | 129 | "devServerTarget": "autoservicio-axion:serve:production" |
| 130 | } | 130 | } |
| 131 | } | 131 | } |
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | }}, | 134 | }}, |
| 135 | "defaultProject": "autoservicio-axion" | 135 | "defaultProject": "autoservicio-axion" |
| 136 | } | 136 | } |
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 overflow-scroll"> | 7 | <div class="row flex-fill m-0 overflow-scroll"> |
| 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 | <p |
| 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 | <small>{{detalle.DetLar}}</small><br> |
| 53 | <small>CANT.{{detalle.cantidad}}</small> | 53 | <small>CANT.{{detalle.cantidad}}</small> |
| 54 | </p> | 54 | </p> |
| 55 | </div> | 55 | </div> |
| 56 | <!-- BOTONES --> | 56 | <!-- BOTONES --> |
| 57 | <button | 57 | <button |
| 58 | *ngIf="comanda.estado === 1" | 58 | *ngIf="comanda.estado === 1" |
| 59 | class="btn btn-block btn-primary shadow-sm btn-elaborar" | 59 | class="btn btn-block btn-primary shadow-sm btn-elaborar" |
| 60 | (click)="updateComanda(comanda, 2, 'En elaboracion')"> | 60 | (click)="updateComanda(comanda, 2, 'En elaboracion')"> |
| 61 | <div class="row justify-content-between"> | 61 | <div class="row justify-content-between"> |
| 62 | <div></div> | 62 | <div></div> |
| 63 | <p class="ml-4" style="color: #fff;">Elaborar</p> | 63 | <p class="ml-4" style="color: #fff;">Elaborar</p> |
| 64 | <img | 64 | <img |
| 65 | draggable="false" | 65 | draggable="false" |
| 66 | ondragstart="return false;" | 66 | ondragstart="return false;" |
| 67 | (contextmenu)="false" | 67 | (contextmenu)="false" |
| 68 | class="icon-30 mr-2" | 68 | class="icon-30 mr-2" |
| 69 | src="assets/img/ir.svg"> | 69 | src="assets/img/ir.svg"> |
| 70 | </div> | 70 | </div> |
| 71 | </button> | 71 | </button> |
| 72 | <button | 72 | <button |
| 73 | *ngIf="comanda.estado === 2" | 73 | *ngIf="comanda.estado === 2" |
| 74 | class="btn btn-block shadow-sm btn-terminar" | 74 | class="btn btn-block shadow-sm btn-terminar" |
| 75 | (click)="updateComanda(comanda, 3, 'Terminado')"> | 75 | (click)="updateComanda(comanda, 3, 'Terminado')"> |
| 76 | <div class="row justify-content-between"> | 76 | <div class="row justify-content-between"> |
| 77 | <div></div> | 77 | <div></div> |
| 78 | <p class="ml-4">Terminar</p> | 78 | <p class="ml-4">Terminar</p> |
| 79 | <img | 79 | <img |
| 80 | draggable="false" | 80 | draggable="false" |
| 81 | ondragstart="return false;" | 81 | ondragstart="return false;" |
| 82 | (contextmenu)="false" | 82 | (contextmenu)="false" |
| 83 | class="icon-30 mr-2" | 83 | class="icon-30 mr-2" |
| 84 | src="assets/img/flecha-borde-color.svg"> | 84 | src="assets/img/flecha-borde-color.svg"> |
| 85 | </div> | 85 | </div> |
| 86 | </button> | 86 | </button> |
| 87 | <button | 87 | <button |
| 88 | *ngIf="comanda.estado === 2" | 88 | *ngIf="comanda.estado === 2" |
| 89 | class="btn btn-block btn-deshacer btn-sm shadow-sm p-0" | 89 | class="btn btn-block btn-deshacer btn-sm shadow-sm p-0" |
| 90 | (click)="updateComanda(comanda, 1, 'Pagado')"> | 90 | (click)="updateComanda(comanda, 1, 'Pagado')"> |
| 91 | <div class="row justify-content-between"> | 91 | <div class="row justify-content-between"> |
| 92 | <div></div> | 92 | <div></div> |
| 93 | <span class="h6 ml-4"><small>Deshacer</small></span> | 93 | <span class="h6 ml-4"><small>Deshacer</small></span> |
| 94 | <i class="fas fa-undo-alt text-info mr-4 my-auto"></i> | 94 | <i class="fas fa-undo-alt text-info mr-4 my-auto"></i> |
| 95 | </div> | 95 | </div> |
| 96 | </button> | 96 | </button> |
| 97 | </div> | 97 | </div> |
| 98 | <!-- TIMER DE ELABORACION --> | 98 | <!-- TIMER DE ELABORACION --> |
| 99 | <div *ngIf="comanda.estado === 2" class="d-flex justify-content-between align-items-center mt-2"> | 99 | <div *ngIf="comanda.estado === 2" class="d-flex justify-content-between align-items-center mt-2"> |
| 100 | <div *ngIf="comanda.estado !== 1"> | 100 | <div *ngIf="comanda.estado !== 1"> |
| 101 | <i class="fa fa-utensils text-info" aria-hidden="true"></i> | 101 | <i class="fa fa-utensils text-info" aria-hidden="true"></i> |
| 102 | </div> | 102 | </div> |
| 103 | <span *ngIf="comanda.estado === 1" class="text-dark"> | 103 | <span *ngIf="comanda.estado === 1" class="text-dark"> |
| 104 | {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}} | 104 | {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}} |
| 105 | </span> | 105 | </span> |
| 106 | <span *ngIf="comanda.estado !== 1" class="text-white"> | 106 | <span *ngIf="comanda.estado !== 1" class="text-white"> |
| 107 | {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}} | 107 | {{comanda.hoursElaboracion}}:{{comanda.minutesElaboracion}}:{{comanda.secondsElaboracion}} |
| 108 | </span> | 108 | </span> |
| 109 | <i class="fas fa-clock fa-spin text-info"></i> | 109 | <i class="fas fa-clock fa-spin text-info"></i> |
| 110 | </div> | 110 | </div> |
| 111 | </div> | 111 | </div> |
| 112 | </div> | 112 | </div> |
| 113 | </div> | 113 | </div> |
| 114 | </div> | 114 | </div> |
| 115 | </div> | 115 | </div> |
| 116 | </div> | ||
| 116 | </div> |
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 | import { NgxSpinnerService } from 'ngx-spinner' | 5 | import { NgxSpinnerService } from 'ngx-spinner' |
| 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 | comandas: IComanda[] = []; | 13 | comandas: IComanda[] = []; |
| 14 | cicloTime: any; | 14 | cicloTime: any; |
| 15 | 15 | ||
| 16 | constructor( | 16 | constructor( |
| 17 | private comandaService: ComandaService, | 17 | private comandaService: ComandaService, |
| 18 | private spinnerService: NgxSpinnerService, | 18 | private spinnerService: NgxSpinnerService, |
| 19 | ) { } | 19 | ) { } |
| 20 | 20 | ||
| 21 | ngOnInit() { | 21 | ngOnInit() { |
| 22 | this.getComandas(); | 22 | this.getComandas(); |
| 23 | this.timerGetComandas(); | 23 | this.timerGetComandas(); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | ngOnDestroy() { | 26 | ngOnDestroy() { |
| 27 | clearInterval(this.cicloTime); | 27 | clearInterval(this.cicloTime); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | timerGetComandas() { | 30 | timerGetComandas() { |
| 31 | this.cicloTime = setInterval(() => { | 31 | this.cicloTime = setInterval(() => { |
| 32 | this.getComandas(); | 32 | this.getComandas(); |
| 33 | }, 5000); | 33 | }, 5000); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | getComandas() { | 36 | getComandas() { |
| 37 | this.comandaService.getAll() | 37 | this.comandaService.getAll() |
| 38 | .subscribe((resComandas: IComanda[]) => { | 38 | .subscribe((resComandas: IComanda[]) => { |
| 39 | this.addNewComandas(resComandas); | 39 | this.addNewComandas(resComandas); |
| 40 | }, e => console.error(e)); | 40 | }, e => console.error(e)); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | addNewComandas(resComandas: IComanda[]) { | 43 | addNewComandas(resComandas: IComanda[]) { |
| 44 | for (let j = 0; j < resComandas.length; j++) { | 44 | for (let j = 0; j < resComandas.length; j++) { |
| 45 | for (let i = 0; i < this.comandas.length; i++) { | 45 | for (let i = 0; i < this.comandas.length; i++) { |
| 46 | if (this.comandas[i].id === resComandas[j].id) { | 46 | if (this.comandas[i].id === resComandas[j].id) { |
| 47 | resComandas.splice(j, 1); | 47 | resComandas.splice(j, 1); |
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | if (!resComandas.length) return; | 51 | if (!resComandas.length) return; |
| 52 | Array.prototype.push.apply(this.comandas, resComandas); | 52 | Array.prototype.push.apply(this.comandas, resComandas); |
| 53 | this.startTimersPedido(resComandas); | 53 | this.startTimersPedido(resComandas); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) { | 56 | updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) { |
| 57 | let data = { | 57 | let data = { |
| 58 | idComanda: comanda.id, | 58 | idComanda: comanda.id, |
| 59 | estado: estadoNuevo, | 59 | estado: estadoNuevo, |
| 60 | observacion: observacionNueva, | 60 | observacion: observacionNueva, |
| 61 | tiempoEspera: `${comanda.hoursPedido}:${comanda.secondsPedido}:${comanda.secondsPedido}`, | 61 | tiempoEspera: `${comanda.hoursPedido}:${comanda.secondsPedido}:${comanda.secondsPedido}`, |
| 62 | tiempoElaboracion: `${comanda.hoursElaboracion}:${comanda.secondsElaboracion}:${comanda.secondsElaboracion}`, | 62 | tiempoElaboracion: `${comanda.hoursElaboracion}:${comanda.secondsElaboracion}:${comanda.secondsElaboracion}`, |
| 63 | } | 63 | } |
| 64 | if (data.estado == 3) { | 64 | if (data.estado == 3) { |
| 65 | this.comandaService.imprimirComandaCocina(parseInt(data.idComanda)) | 65 | this.comandaService.imprimirComandaCocina(parseInt(data.idComanda)) |
| 66 | .subscribe(res => { }, err => console.error(err) | 66 | .subscribe(res => { }, err => console.error(err) |
| 67 | ); | 67 | ); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false); | 70 | if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false); |
| 71 | 71 | ||
| 72 | this.comandaService.update(data) | 72 | this.comandaService.update(data) |
| 73 | .subscribe((res: any) => { | 73 | .subscribe((res: any) => { |
| 74 | if (res.data) { | 74 | if (res.data) { |
| 75 | comanda.estado = estadoNuevo; | 75 | comanda.estado = estadoNuevo; |
| 76 | comanda.observacion = observacionNueva; | 76 | comanda.observacion = observacionNueva; |
| 77 | if (estadoNuevo == 2) { | 77 | if (estadoNuevo == 2) { |
| 78 | this.startTimerElaboracion(comanda); | 78 | this.startTimerElaboracion(comanda); |
| 79 | } else if (comanda.timerElaboracion) { | 79 | } else if (comanda.timerElaboracion) { |
| 80 | clearInterval(comanda.timerElaboracion) | 80 | clearInterval(comanda.timerElaboracion) |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | }, e => console.error(e)); | 83 | }, e => console.error(e)); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | rellenar(relleno, longitud) { | 86 | rellenar(relleno, longitud) { |
| 87 | relleno = '' + relleno; | 87 | relleno = '' + relleno; |
| 88 | while (relleno.length < longitud) { | 88 | while (relleno.length < longitud) { |
| 89 | relleno = '0' + relleno; | 89 | relleno = '0' + relleno; |
| 90 | } | 90 | } |
| 91 | return relleno; | 91 | return relleno; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | toggleVerComponentes(detalle: IComandaDetalle, comanda: IComanda) { | 94 | toggleVerComponentes(detalle: IComandaDetalle, comanda: IComanda) { |
| 95 | detalle.seeDetalle = !detalle.seeDetalle; | 95 | detalle.seeDetalle = !detalle.seeDetalle; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | hasTipo(componentes: IComponente[]) { | 98 | hasTipo(componentes: IComponente[]) { |
| 99 | return componentes.some(c => c.tipoArticulo === 6); | 99 | return componentes.some(c => c.tipoArticulo === 6); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | //#region TIMERS | 102 | //#region TIMERS |
| 103 | startTimersPedido(comandas) { | 103 | startTimersPedido(comandas) { |
| 104 | comandas.forEach((comanda: IComanda) => { | 104 | comandas.forEach((comanda: IComanda) => { |
| 105 | this.comandaService.startTimerComanda(comanda, 'Pedido'); | 105 | this.comandaService.startTimerComanda(comanda, 'Pedido'); |
| 106 | if (comanda.estado === 2) { | 106 | if (comanda.estado === 2) { |
| 107 | this.startTimerElaboracion(comanda); | 107 | this.startTimerElaboracion(comanda); |
| 108 | } | 108 | } |
| 109 | }); | 109 | }); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | startTimerElaboracion(comanda: IComanda) { | 112 | startTimerElaboracion(comanda: IComanda) { |
| 113 | this.spinnerService.show(comanda.id.toString()); | 113 | this.spinnerService.show(comanda.id.toString()); |
| 114 | this.comandaService.startTimerComanda(comanda, 'Elaboracion'); | 114 | this.comandaService.startTimerComanda(comanda, 'Elaboracion'); |
| 115 | } | 115 | } |
| 116 | //#endregion | 116 | //#endregion |
| 117 | 117 | ||
| 118 | } | 118 | } |
| 119 | 119 |