Commit 609df1b5417cafaae79f50bc7ee934339f096fe5
1 parent
aae1d8e6c3
Exists in
develop
Fix
Muestro nombre de articulo en modal de sinonimos
Showing
7 changed files
with
47 additions
and
37 deletions
Show diff stats
main.js
| 1 | const { app, BrowserWindow } = require('electron') | 1 | const { app, BrowserWindow } = require('electron') |
| 2 | 2 | ||
| 3 | require('electron-debug')({ showDevTools: true }); | 3 | require('electron-debug')({ showDevTools: true }); |
| 4 | 4 | ||
| 5 | let win; | 5 | let win; |
| 6 | 6 | ||
| 7 | function createWindow() { | 7 | function createWindow() { |
| 8 | // Create the browser window. | 8 | // Create the browser window. |
| 9 | win = new BrowserWindow({ | 9 | win = new BrowserWindow({ |
| 10 | backgroundColor: '#ffffff', | 10 | backgroundColor: '#ffffff', |
| 11 | autoHideMenuBar: true, | 11 | autoHideMenuBar: true, |
| 12 | icon: `file://${__dirname}/dist/assets/logo.png` | 12 | icon: `file://${__dirname}/dist/autoservicio-axion/favicon.ico` |
| 13 | }) | 13 | }) |
| 14 | 14 | ||
| 15 | win.loadURL(`file://${__dirname}/dist/autoservicio-axion/index.html`) | 15 | win.loadURL(`file://${__dirname}/dist/autoservicio-axion/index.html`) |
| 16 | 16 | ||
| 17 | win.setFullScreen(true); | 17 | win.setFullScreen(true); |
| 18 | 18 | ||
| 19 | // uncomment below to open the //DevTools. | 19 | // uncomment below to open the //DevTools. |
| 20 | win.webContents.openDevTools() | 20 | win.webContents.openDevTools() |
| 21 | 21 | ||
| 22 | // Event when the window is closed. | 22 | // Event when the window is closed. |
| 23 | win.on('closed', function () { | 23 | win.on('closed', function () { |
| 24 | win = null | 24 | win = null |
| 25 | }) | 25 | }) |
| 26 | 26 | ||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | // Create window on electron intialization | 29 | // Create window on electron intialization |
| 30 | app.on('ready', createWindow) | 30 | app.on('ready', createWindow) |
| 31 | 31 | ||
| 32 | // Quit when all windows are closed. | 32 | // Quit when all windows are closed. |
| 33 | app.on('window-all-closed', function () { | 33 | app.on('window-all-closed', function () { |
| 34 | 34 | ||
| 35 | // On macOS specific close process | 35 | // On macOS specific close process |
| 36 | if (process.platform !== 'darwin') { | 36 | if (process.platform !== 'darwin') { |
| 37 | app.quit() | 37 | app.quit() |
| 38 | } | 38 | } |
| 39 | }) | 39 | }) |
| 40 | 40 | ||
| 41 | app.on('activate', function () { | 41 | app.on('activate', function () { |
| 42 | // macOS specific close process | 42 | // macOS specific close process |
| 43 | if (win === null) { | 43 | if (win === null) { |
| 44 | createWindow() | 44 | createWindow() |
| 45 | } | 45 | } |
| 46 | }) | 46 | }) |
| 47 | 47 |
package.json
| 1 | { | 1 | { |
| 2 | "name": "autoservicio-axion", | 2 | "name": "autoservicio-axion", |
| 3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
| 4 | "main": "main.js", | 4 | "main": "main.js", |
| 5 | "scripts": { | 5 | "scripts": { |
| 6 | "ng": "ng", | 6 | "ng": "ng", |
| 7 | "start": "ng serve --port 4206 --host 0.0.0.0 --disableHostCheck", | 7 | "start": "ng serve --port 4206 --host 0.0.0.0 --disableHostCheck", |
| 8 | "build": "ng build", | 8 | "build": "ng build", |
| 9 | "build-prod": "ng build --prod --aot=true --build--optimizer=true", | 9 | "build-prod": "ng build --prod --aot=true --build--optimizer=true", |
| 10 | "test": "ng test", | 10 | "test": "ng test", |
| 11 | "lint": "ng lint", | 11 | "lint": "ng lint", |
| 12 | "e2e": "ng e2e", | 12 | "e2e": "ng e2e", |
| 13 | "electron": "electron .", | 13 | "electron": "electron .", |
| 14 | "electron-build": "ng build --prod --aot=true --build--optimizer=true && electron .", | 14 | "electron-build": "ng build --prod --aot=true --build--optimizer=true && electron .", |
| 15 | "build-exe": "electron-packager . --platform=win32 --arch=x64 --asar" | 15 | "build-exe": "electron-packager . --platform=win32 --arch=x64" |
| 16 | }, | 16 | }, |
| 17 | "private": true, | 17 | "private": true, |
| 18 | "dependencies": { | 18 | "dependencies": { |
| 19 | "@angular/animations": "~8.2.14", | 19 | "@angular/animations": "~8.2.14", |
| 20 | "@angular/common": "~8.2.14", | 20 | "@angular/common": "~8.2.14", |
| 21 | "@angular/compiler": "~8.2.14", | 21 | "@angular/compiler": "~8.2.14", |
| 22 | "@angular/core": "~8.2.14", | 22 | "@angular/core": "~8.2.14", |
| 23 | "@angular/forms": "~8.2.14", | 23 | "@angular/forms": "~8.2.14", |
| 24 | "@angular/platform-browser": "~8.2.14", | 24 | "@angular/platform-browser": "~8.2.14", |
| 25 | "@angular/platform-browser-dynamic": "~8.2.14", | 25 | "@angular/platform-browser-dynamic": "~8.2.14", |
| 26 | "@angular/router": "~8.2.14", | 26 | "@angular/router": "~8.2.14", |
| 27 | "@types/jquery": "^3.3.31", | 27 | "@types/jquery": "^3.3.31", |
| 28 | "bootstrap": "^4.4.1", | 28 | "bootstrap": "^4.4.1", |
| 29 | "electron-debug": "^3.0.1", | 29 | "electron-debug": "^3.0.1", |
| 30 | "hammerjs": "^2.0.8", | 30 | "hammerjs": "^2.0.8", |
| 31 | "jquery": "^3.4.1", | 31 | "jquery": "^3.4.1", |
| 32 | "js-sha256": "^0.9.0", | 32 | "js-sha256": "^0.9.0", |
| 33 | "lodash": "^4.17.15", | 33 | "lodash": "^4.17.15", |
| 34 | "ngx-bootstrap": "^5.2.0", | 34 | "ngx-bootstrap": "^5.2.0", |
| 35 | "popper.js": "^1.16.0", | 35 | "popper.js": "^1.16.0", |
| 36 | "rxjs": "~6.4.0", | 36 | "rxjs": "~6.4.0", |
| 37 | "tslib": "^1.10.0", | 37 | "tslib": "^1.10.0", |
| 38 | "zone.js": "~0.9.1" | 38 | "zone.js": "~0.9.1" |
| 39 | }, | 39 | }, |
| 40 | "devDependencies": { | 40 | "devDependencies": { |
| 41 | "@angular-devkit/build-angular": "~0.803.20", | 41 | "@angular-devkit/build-angular": "~0.803.20", |
| 42 | "@angular/cli": "~8.3.20", | 42 | "@angular/cli": "~8.3.20", |
| 43 | "@angular/compiler-cli": "~8.2.14", | 43 | "@angular/compiler-cli": "~8.2.14", |
| 44 | "@angular/language-service": "~8.2.14", | 44 | "@angular/language-service": "~8.2.14", |
| 45 | "@fortawesome/fontawesome-free": "^5.12.0", | 45 | "@fortawesome/fontawesome-free": "^5.12.0", |
| 46 | "@types/jasmine": "~3.3.8", | 46 | "@types/jasmine": "~3.3.8", |
| 47 | "@types/jasminewd2": "~2.0.3", | 47 | "@types/jasminewd2": "~2.0.3", |
| 48 | "@types/lodash": "^4.14.149", | 48 | "@types/lodash": "^4.14.149", |
| 49 | "@types/node": "~8.9.4", | 49 | "@types/node": "~8.9.4", |
| 50 | "codelyzer": "^5.0.0", | 50 | "codelyzer": "^5.0.0", |
| 51 | "devtron": "^1.4.0", | 51 | "devtron": "^1.4.0", |
| 52 | "electron": "^7.1.6", | 52 | "electron": "^7.1.6", |
| 53 | "jasmine-core": "~3.4.0", | 53 | "jasmine-core": "~3.4.0", |
| 54 | "jasmine-spec-reporter": "~4.2.1", | 54 | "jasmine-spec-reporter": "~4.2.1", |
| 55 | "karma": "~4.1.0", | 55 | "karma": "~4.1.0", |
| 56 | "karma-chrome-launcher": "~2.2.0", | 56 | "karma-chrome-launcher": "~2.2.0", |
| 57 | "karma-coverage-istanbul-reporter": "~2.0.1", | 57 | "karma-coverage-istanbul-reporter": "~2.0.1", |
| 58 | "karma-jasmine": "~2.0.1", | 58 | "karma-jasmine": "~2.0.1", |
| 59 | "karma-jasmine-html-reporter": "^1.4.0", | 59 | "karma-jasmine-html-reporter": "^1.4.0", |
| 60 | "protractor": "~5.4.0", | 60 | "protractor": "~5.4.0", |
| 61 | "ts-node": "~7.0.0", | 61 | "ts-node": "~7.0.0", |
| 62 | "tslint": "~5.15.0", | 62 | "tslint": "~5.15.0", |
| 63 | "typescript": "~3.5.3" | 63 | "typescript": "~3.5.3" |
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | 66 |
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
| 1 | import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit } from '@angular/core'; | 1 | import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit } from '@angular/core'; |
| 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; | 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; |
| 3 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 3 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 4 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 4 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
| 5 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 5 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
| 6 | import { ICategoria } from 'src/app/interfaces/ICategoria'; | 6 | import { ICategoria } from 'src/app/interfaces/ICategoria'; |
| 7 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; | 7 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
| 8 | import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; | 8 | import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; |
| 9 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; | 9 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; |
| 10 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; | 10 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; |
| 11 | import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component'; | 11 | import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component'; |
| 12 | import { FiltroCategoriasComponent } from './filtro-categorias/filtro-categorias.component'; | 12 | import { FiltroCategoriasComponent } from './filtro-categorias/filtro-categorias.component'; |
| 13 | import * as _ from 'lodash'; | 13 | import * as _ from 'lodash'; |
| 14 | import { ANIMATIONS } from 'src/app/utils/animations'; | 14 | import { ANIMATIONS } from 'src/app/utils/animations'; |
| 15 | 15 | ||
| 16 | @Component({ | 16 | @Component({ |
| 17 | selector: 'app-seleccion-articulos', | 17 | selector: 'app-seleccion-articulos', |
| 18 | templateUrl: './seleccion-articulos.component.html', | 18 | templateUrl: './seleccion-articulos.component.html', |
| 19 | styleUrls: ['./seleccion-articulos.component.scss'], | 19 | styleUrls: ['./seleccion-articulos.component.scss'], |
| 20 | animations: [ANIMATIONS.EnterLeaveY] | 20 | animations: [ANIMATIONS.EnterLeaveY] |
| 21 | }) | 21 | }) |
| 22 | export class SeleccionArticulosComponent implements OnInit, AfterViewInit, OnDestroy { | 22 | export class SeleccionArticulosComponent implements OnInit, AfterViewInit, OnDestroy { |
| 23 | showSpinner = true; | 23 | showSpinner = true; |
| 24 | timeoutHandler: any; | 24 | timeoutHandler: any; |
| 25 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 25 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
| 26 | articulos: IArticulo[] = []; | 26 | articulos: IArticulo[] = []; |
| 27 | auxArticulos: IArticulo[] = []; | 27 | auxArticulos: IArticulo[] = []; |
| 28 | showQuantity = 100; | 28 | showQuantity = 100; |
| 29 | searchTerm = ''; | 29 | searchTerm = ''; |
| 30 | ordenandoByVendidos = true; | 30 | ordenandoByVendidos = true; |
| 31 | modalRef: BsModalRef; | 31 | modalRef: BsModalRef; |
| 32 | total = 0; | 32 | total = 0; |
| 33 | @ViewChild(FiltroCategoriasComponent, { static: false }) filtroCategorias: FiltroCategoriasComponent; | 33 | @ViewChild(FiltroCategoriasComponent, { static: false }) filtroCategorias: FiltroCategoriasComponent; |
| 34 | 34 | ||
| 35 | constructor( | 35 | constructor( |
| 36 | public articuloService: ArticuloService, | 36 | public articuloService: ArticuloService, |
| 37 | private sinonimoService: SinonimoService, | 37 | private sinonimoService: SinonimoService, |
| 38 | private modalService: BsModalService, | 38 | private modalService: BsModalService, |
| 39 | private inactiveScreen: InactiveScreenService, | 39 | private inactiveScreen: InactiveScreenService, |
| 40 | ) { } | 40 | ) { } |
| 41 | 41 | ||
| 42 | ngOnInit() { } | 42 | ngOnInit() { } |
| 43 | 43 | ||
| 44 | ngAfterViewInit(): void { | 44 | ngAfterViewInit(): void { |
| 45 | this.filtroCategorias.getCategorias(); | 45 | this.filtroCategorias.getCategorias(); |
| 46 | this.mediaPantalla(); | 46 | this.mediaPantalla(); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | ngOnDestroy() { | 49 | ngOnDestroy() { |
| 50 | for (let i = 1; i <= this.modalService.getModalsCount(); i++) { | 50 | for (let i = 1; i <= this.modalService.getModalsCount(); i++) { |
| 51 | this.modalService.hide(i); | 51 | this.modalService.hide(i); |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | getProductos() { | 55 | getProductos() { |
| 56 | this.articuloService.getAll() | 56 | this.articuloService.getAll() |
| 57 | .subscribe((result: IArticulo[]) => { | 57 | .subscribe((result: IArticulo[]) => { |
| 58 | this.articuloService.setArticulosSinImagen(result); | 58 | this.articuloService.setArticulosSinImagen(result); |
| 59 | if (this.filtroCategorias.queMostrar === 'ordenar') { | 59 | if (this.filtroCategorias.queMostrar === 'ordenar') { |
| 60 | this.filtroCategorias.categorias.forEach((categoria: ICategoria) => { | 60 | this.filtroCategorias.categorias.forEach((categoria: ICategoria) => { |
| 61 | const tempArticulos = result.filter((articulo: IArticulo) => { | 61 | const tempArticulos = result.filter((articulo: IArticulo) => { |
| 62 | return articulo.categoria_selfservice === categoria.id; | 62 | return articulo.categoria_selfservice === categoria.id; |
| 63 | }); | 63 | }); |
| 64 | result = tempArticulos; | 64 | result = tempArticulos; |
| 65 | }); | 65 | }); |
| 66 | } | 66 | } |
| 67 | localStorage.setItem('articulos', JSON.stringify(result)); | 67 | localStorage.setItem('articulos', JSON.stringify(result)); |
| 68 | this.setProductos(); | 68 | this.setProductos(); |
| 69 | }, (error) => { | 69 | }, (error) => { |
| 70 | this.showSpinner = false; | 70 | this.showSpinner = false; |
| 71 | console.error(error); | 71 | console.error(error); |
| 72 | }); | 72 | }); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | setProductos() { | 75 | setProductos() { |
| 76 | this.articulos = JSON.parse(localStorage.getItem('articulos')); | 76 | this.articulos = JSON.parse(localStorage.getItem('articulos')); |
| 77 | this.filterItems(); | 77 | this.filterItems(); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | filterItems() { | 80 | filterItems() { |
| 81 | if (this.filtroCategorias.categoriaActive === 0) { | 81 | if (this.filtroCategorias.categoriaActive === 0) { |
| 82 | this.auxArticulos = this.articulos; | 82 | this.auxArticulos = this.articulos; |
| 83 | return; | 83 | return; |
| 84 | } | 84 | } |
| 85 | this.auxArticulos = this.articulos.filter(x => { | 85 | this.auxArticulos = this.articulos.filter(x => { |
| 86 | return x.categoria_selfservice === this.filtroCategorias.categoriaActive; | 86 | return x.categoria_selfservice === this.filtroCategorias.categoriaActive; |
| 87 | }); | 87 | }); |
| 88 | this.ordenar(); | 88 | this.ordenar(); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | ordenar() { | 91 | ordenar() { |
| 92 | if (this.ordenandoByVendidos) { | 92 | if (this.ordenandoByVendidos) { |
| 93 | this.auxArticulos.sort((a, b) => { | 93 | this.auxArticulos.sort((a, b) => { |
| 94 | return b.cantidadVendida - a.cantidadVendida; | 94 | return b.cantidadVendida - a.cantidadVendida; |
| 95 | }); | 95 | }); |
| 96 | } | 96 | } |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | selectArticulo(articulo: IArticulo) { | 99 | selectArticulo(articulo: IArticulo) { |
| 100 | this.getByID(articulo.id); | 100 | this.getByID(articulo.id); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | getByID(id: number) { | 103 | getByID(id: number) { |
| 104 | this.articuloService.getById(id) | 104 | this.articuloService.getById(id) |
| 105 | .subscribe((res: IArticulo) => { | 105 | .subscribe((res: IArticulo) => { |
| 106 | if (res.FPP) { | 106 | if (res.FPP) { |
| 107 | this.openModalPromos(res); | 107 | this.openModalPromos(res); |
| 108 | } else { | 108 | } else { |
| 109 | this.getSinonimos(res); | 109 | this.getSinonimos(res); |
| 110 | } | 110 | } |
| 111 | }, err => console.error(err)); | 111 | }, err => console.error(err)); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | getSinonimos(articulo: IArticulo) { | 114 | getSinonimos(articulo: IArticulo) { |
| 115 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) | 115 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) |
| 116 | .subscribe((res: any[]) => { | 116 | .subscribe((res: any[]) => { |
| 117 | if (res.length) { | 117 | if (res.length) { |
| 118 | const sinonimos = []; | 118 | const sinonimos = []; |
| 119 | const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); | 119 | const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); |
| 120 | Object.keys(gruposArticulos).forEach(key => { | 120 | Object.keys(gruposArticulos).forEach(key => { |
| 121 | sinonimos.push({ productos: gruposArticulos[key] }); | 121 | sinonimos.push({ productos: gruposArticulos[key] }); |
| 122 | }); | 122 | }); |
| 123 | res = sinonimos; | 123 | res = sinonimos; |
| 124 | this.openModalSinonimos(res, articulo); | 124 | this.openModalSinonimos(res, articulo); |
| 125 | } else { | 125 | } else { |
| 126 | this.articuloService.setArticulo(articulo); | 126 | this.articuloService.setArticulo(articulo); |
| 127 | } | 127 | } |
| 128 | }); | 128 | }); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | openModalPromos(articulo: IArticulo) { | 131 | openModalPromos(articulo: IArticulo) { |
| 132 | this.modalRef = this.modalService.show(PromocionComponent, { | 132 | this.modalRef = this.modalService.show(PromocionComponent, { |
| 133 | initialState: { articulosPromo: [articulo] }, | 133 | initialState: { articulosPromo: [articulo] }, |
| 134 | class: 'modal-promo modal-dialog-centered' | 134 | class: 'modal-promo modal-dialog-centered' |
| 135 | }); | 135 | }); |
| 136 | this.mediaPantalla(); | 136 | this.mediaPantalla(); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { | 139 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { |
| 140 | this.modalRef = this.modalService.show(SinonimoComponent, { | 140 | this.modalRef = this.modalService.show(SinonimoComponent, { |
| 141 | initialState: { sinonimos: sinonimosData }, | 141 | initialState: { |
| 142 | sinonimos: sinonimosData, | ||
| 143 | articulo: articulo | ||
| 144 | }, | ||
| 142 | class: 'modal-promo modal-dialog-centered' | 145 | class: 'modal-promo modal-dialog-centered' |
| 143 | }); | 146 | }); |
| 144 | 147 | ||
| 145 | this.modalRef.content.onClose | 148 | this.modalRef.content.onClose |
| 146 | .subscribe((res: any) => { | 149 | .subscribe((res: any) => { |
| 147 | for (const a of articulo.productos) { | 150 | for (const a of articulo.productos) { |
| 148 | for (const aRes of res.articulos) { | 151 | for (const aRes of res.articulos) { |
| 149 | if (a.idSinonimo === aRes.ID_SIN) { | 152 | if (a.idSinonimo === aRes.ID_SIN) { |
| 150 | a.CODA = aRes.CodArt; | 153 | a.CODA = aRes.CodArt; |
| 151 | a.CodArt = aRes.CodArt; | 154 | a.CodArt = aRes.CodArt; |
| 152 | a.SECA = aRes.CodSec; | 155 | a.SECA = aRes.CodSec; |
| 153 | aRes.CodSec = aRes.CodSec; | 156 | aRes.CodSec = aRes.CodSec; |
| 154 | a.PreVen = aRes.PreVen; | 157 | a.PreVen = aRes.PreVen; |
| 155 | a.id = aRes.id; | 158 | a.id = aRes.id; |
| 156 | a.DET_LAR = aRes.DET_LAR; | 159 | a.DET_LAR = aRes.DET_LAR; |
| 157 | a.DetArt = aRes.DetArt; | 160 | a.DetArt = aRes.DetArt; |
| 158 | } | 161 | } |
| 159 | } | 162 | } |
| 160 | } | 163 | } |
| 161 | this.articuloService.setArticulo(articulo); | 164 | this.articuloService.setArticulo(articulo); |
| 162 | }); | 165 | }); |
| 163 | this.mediaPantalla(); | 166 | this.mediaPantalla(); |
| 164 | } | 167 | } |
| 165 | 168 | ||
| 166 | deleteArticulo(index: number) { | 169 | deleteArticulo(index: number) { |
| 167 | this.articuloService.deleteArticulo(index); | 170 | this.articuloService.deleteArticulo(index); |
| 168 | } | 171 | } |
| 169 | 172 | ||
| 170 | increaseShow() { | 173 | increaseShow() { |
| 171 | this.showQuantity += 100; | 174 | this.showQuantity += 100; |
| 172 | } | 175 | } |
| 173 | 176 | ||
| 174 | @HostListener('scroll', ['$event']) | 177 | @HostListener('scroll', ['$event']) |
| 175 | scrollEvent(event: Event) { | 178 | scrollEvent(event: Event) { |
| 176 | clearTimeout(this.inactiveScreen.timerReposo); | 179 | clearTimeout(this.inactiveScreen.timerReposo); |
| 177 | this.inactiveScreen.startTimeOutInactividad(); | 180 | this.inactiveScreen.startTimeOutInactividad(); |
| 178 | } | 181 | } |
| 179 | 182 | ||
| 180 | mouseup() { | 183 | mouseup() { |
| 181 | if (!this.timeoutHandler) return; | 184 | if (!this.timeoutHandler) return; |
| 182 | clearInterval(this.timeoutHandler); | 185 | clearInterval(this.timeoutHandler); |
| 183 | } | 186 | } |
| 184 | 187 | ||
| 185 | scrollY(el: HTMLElement, value) { | 188 | scrollY(el: HTMLElement, value) { |
| 186 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); | 189 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
| 187 | this.timeoutHandler = setInterval(() => { | 190 | this.timeoutHandler = setInterval(() => { |
| 188 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); | 191 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
| 189 | }, 500); | 192 | }, 500); |
| 190 | } | 193 | } |
| 191 | 194 | ||
| 192 | scrollX(el: HTMLElement, value) { | 195 | scrollX(el: HTMLElement, value) { |
| 193 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); | 196 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); |
| 194 | this.timeoutHandler = setInterval(() => { | 197 | this.timeoutHandler = setInterval(() => { |
| 195 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); | 198 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); |
| 196 | }, 500); | 199 | }, 500); |
| 197 | } | 200 | } |
| 198 | 201 | ||
| 199 | mediaPantalla() { | 202 | mediaPantalla() { |
| 200 | if ($('body').hasClass('media-pantalla')) { | 203 | if ($('body').hasClass('media-pantalla')) { |
| 201 | $(`.cat-content,#cat-content,#content,.cat-btn,#boxCarrito, | 204 | $(`.cat-content,#cat-content,#content,.cat-btn,#boxCarrito, |
| 202 | .cat-box,.img-categoria, .modal-content`) | 205 | .cat-box,.img-categoria, .modal-content`) |
| 203 | .addClass('media-pantalla') | 206 | .addClass('media-pantalla') |
| 204 | .addBack('media-pantalla'); | 207 | .addBack('media-pantalla'); |
| 205 | } | 208 | } |
| 206 | } | 209 | } |
| 207 | } | 210 | } |
| 208 | 211 |
src/app/shared/header-publicidad/header-publicidad.component.ts
| 1 | import { Component, OnInit, TemplateRef } from '@angular/core'; | 1 | import { Component, OnInit, TemplateRef } from '@angular/core'; |
| 2 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 2 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
| 3 | import { IPublicidad } from 'src/app/interfaces/IPublicidad'; | 3 | import { IPublicidad } from 'src/app/interfaces/IPublicidad'; |
| 4 | import { PublicidadService } from 'src/app/services/publicidad/publicidad.service'; | 4 | import { PublicidadService } from 'src/app/services/publicidad/publicidad.service'; |
| 5 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 5 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
| 6 | import { PromocionComponent } from '../promocion/promocion.component'; | 6 | import { PromocionComponent } from '../promocion/promocion.component'; |
| 7 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; | 7 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; |
| 8 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 8 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 9 | import { ConfirmacionComponent } from '../confirmacion/confirmacion.component'; | 9 | import { ConfirmacionComponent } from '../confirmacion/confirmacion.component'; |
| 10 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; | 10 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; |
| 11 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; | 11 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
| 12 | import { SinonimoComponent } from '../sinonimo/sinonimo.component'; | 12 | import { SinonimoComponent } from '../sinonimo/sinonimo.component'; |
| 13 | import * as _ from 'lodash'; | 13 | import * as _ from 'lodash'; |
| 14 | 14 | ||
| 15 | @Component({ | 15 | @Component({ |
| 16 | selector: 'app-header-publicidad', | 16 | selector: 'app-header-publicidad', |
| 17 | templateUrl: './header-publicidad.component.html', | 17 | templateUrl: './header-publicidad.component.html', |
| 18 | styleUrls: ['./header-publicidad.component.scss'] | 18 | styleUrls: ['./header-publicidad.component.scss'] |
| 19 | }) | 19 | }) |
| 20 | export class HeaderPublicidadComponent implements OnInit { | 20 | export class HeaderPublicidadComponent implements OnInit { |
| 21 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 21 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
| 22 | publicidades: IPublicidad[] = []; | 22 | publicidades: IPublicidad[] = []; |
| 23 | modalRef: BsModalRef; | 23 | modalRef: BsModalRef; |
| 24 | 24 | ||
| 25 | constructor( | 25 | constructor( |
| 26 | private publicidadService: PublicidadService, | 26 | private publicidadService: PublicidadService, |
| 27 | private articuloService: ArticuloService, | 27 | private articuloService: ArticuloService, |
| 28 | private modalService: BsModalService, | 28 | private modalService: BsModalService, |
| 29 | private sinonimoService: SinonimoService | 29 | private sinonimoService: SinonimoService |
| 30 | ) { } | 30 | ) { } |
| 31 | 31 | ||
| 32 | ngOnInit() { | 32 | ngOnInit() { |
| 33 | this.getPublicidades(); | 33 | this.getPublicidades(); |
| 34 | this.mediaPantalla(); | 34 | this.mediaPantalla(); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | getPublicidades() { | 37 | getPublicidades() { |
| 38 | this.publicidadService.getAll() | 38 | this.publicidadService.getAll() |
| 39 | .subscribe((res: IPublicidad[]) => { | 39 | .subscribe((res: IPublicidad[]) => { |
| 40 | this.publicidades = res; | 40 | this.publicidades = res; |
| 41 | }, err => console.error(err)); | 41 | }, err => console.error(err)); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | elegirArticulo(publicidad: IPublicidad) { | 44 | elegirArticulo(publicidad: IPublicidad) { |
| 45 | if (publicidad.id_articulo) this.getByID(publicidad.id_articulo); | 45 | if (publicidad.id_articulo) this.getByID(publicidad.id_articulo); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | getByID(id: number) { | 48 | getByID(id: number) { |
| 49 | this.articuloService.getById(id) | 49 | this.articuloService.getById(id) |
| 50 | .subscribe((res: IArticulo) => { | 50 | .subscribe((res: IArticulo) => { |
| 51 | if (res.FPP) { | 51 | if (res.FPP) { |
| 52 | this.openModalPromos(res); | 52 | this.openModalPromos(res); |
| 53 | return; | 53 | return; |
| 54 | } else { | 54 | } else { |
| 55 | this.openModalConfirmacion(res); | 55 | this.openModalConfirmacion(res); |
| 56 | return; | 56 | return; |
| 57 | } | 57 | } |
| 58 | }, err => console.error(err)); | 58 | }, err => console.error(err)); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | openModalPromos(articulo: IArticulo) { | 61 | openModalPromos(articulo: IArticulo) { |
| 62 | this.modalRef = this.modalService.show(PromocionComponent, | 62 | this.modalRef = this.modalService.show(PromocionComponent, |
| 63 | { | 63 | { |
| 64 | initialState: { | 64 | initialState: { |
| 65 | idArticulo: articulo.id | 65 | idArticulo: articulo.id |
| 66 | }, | 66 | }, |
| 67 | class: 'modal-promo modal-dialog-centered' | 67 | class: 'modal-promo modal-dialog-centered' |
| 68 | }); | 68 | }); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | openModalConfirmacion(articulo: IArticulo) { | 71 | openModalConfirmacion(articulo: IArticulo) { |
| 72 | this.modalRef = this.modalService.show(ConfirmacionComponent, | 72 | this.modalRef = this.modalService.show(ConfirmacionComponent, |
| 73 | { | 73 | { |
| 74 | initialState: { | 74 | initialState: { |
| 75 | titleMessage: articulo.DET_LAR, | 75 | titleMessage: articulo.DET_LAR, |
| 76 | imagenPath: articulo.imagenes.length ? articulo.imagenes[0].imagen : 'assets/img/imagen-no-encontrada.jpg', | 76 | imagenPath: articulo.imagenes.length ? articulo.imagenes[0].imagen : 'assets/img/imagen-no-encontrada.jpg', |
| 77 | footerMessageFirst: `¿DESEA AGREGAR ESTE ARTÍCULO`, | 77 | footerMessageFirst: `¿DESEA AGREGAR ESTE ARTÍCULO`, |
| 78 | footerMessageSecond: `a su carrito?`, | 78 | footerMessageSecond: `a su carrito?`, |
| 79 | footerConfirmation: articulo.PreVen, | 79 | footerConfirmation: articulo.PreVen, |
| 80 | footerClose: `volver` | 80 | footerClose: `volver` |
| 81 | }, | 81 | }, |
| 82 | class: 'modal-promo modal-dialog-centered' | 82 | class: 'modal-promo modal-dialog-centered' |
| 83 | }); | 83 | }); |
| 84 | this.modalRef.content.onClose.subscribe(() => { | 84 | this.modalRef.content.onClose.subscribe(() => { |
| 85 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) | 85 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) |
| 86 | .subscribe((res: ISinonimo[]) => { | 86 | .subscribe((res: ISinonimo[]) => { |
| 87 | if (res.length) { | 87 | if (res.length) { |
| 88 | const sinonimos = []; | 88 | const sinonimos = []; |
| 89 | const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); | 89 | const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); |
| 90 | Object.keys(gruposArticulos).forEach(key => { | 90 | Object.keys(gruposArticulos).forEach(key => { |
| 91 | sinonimos.push({ productos: gruposArticulos[key] }); | 91 | sinonimos.push({ productos: gruposArticulos[key] }); |
| 92 | }); | 92 | }); |
| 93 | res = sinonimos; | 93 | res = sinonimos; |
| 94 | this.openModalSinonimos(res, articulo); | 94 | this.openModalSinonimos(res, articulo); |
| 95 | } else { | 95 | } else { |
| 96 | articulo.cantidad = 1; | 96 | articulo.cantidad = 1; |
| 97 | this.articuloService.setArticulo(articulo); | 97 | this.articuloService.setArticulo(articulo); |
| 98 | } | 98 | } |
| 99 | }, err => console.error(err)); | 99 | }, err => console.error(err)); |
| 100 | }); | 100 | }); |
| 101 | this.mediaPantalla(); | 101 | this.mediaPantalla(); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { | 104 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { |
| 105 | const modalSinonimo = this.modalService.show(SinonimoComponent, { | 105 | const modalSinonimo = this.modalService.show(SinonimoComponent, { |
| 106 | initialState: { sinonimos: sinonimosData }, | 106 | initialState: { |
| 107 | sinonimos: sinonimosData, | ||
| 108 | articulo: articulo | ||
| 109 | }, | ||
| 107 | class: 'modal-promo modal-dialog-centered' | 110 | class: 'modal-promo modal-dialog-centered' |
| 108 | }); | 111 | }); |
| 109 | modalSinonimo.content.onClose | 112 | modalSinonimo.content.onClose |
| 110 | .subscribe((res: any) => { | 113 | .subscribe((res: any) => { |
| 111 | for (const a of articulo.productos) { | 114 | for (const a of articulo.productos) { |
| 112 | for (const aRes of res.articulos) { | 115 | for (const aRes of res.articulos) { |
| 113 | if (a.idSinonimo === aRes.ID_SIN) { | 116 | if (a.idSinonimo === aRes.ID_SIN) { |
| 114 | a.CODA = aRes.CodArt; | 117 | a.CODA = aRes.CodArt; |
| 115 | a.CodArt = aRes.CodArt; | 118 | a.CodArt = aRes.CodArt; |
| 116 | a.SECA = aRes.CodSec; | 119 | a.SECA = aRes.CodSec; |
| 117 | aRes.CodSec = aRes.CodSec; | 120 | aRes.CodSec = aRes.CodSec; |
| 118 | a.PreVen = aRes.PreVen; | 121 | a.PreVen = aRes.PreVen; |
| 119 | a.id = aRes.id; | 122 | a.id = aRes.id; |
| 120 | a.DET_LAR = aRes.DET_LAR; | 123 | a.DET_LAR = aRes.DET_LAR; |
| 121 | a.DetArt = aRes.DetArt; | 124 | a.DetArt = aRes.DetArt; |
| 125 | } | ||
| 122 | } | 126 | } |
| 123 | } | 127 | } |
| 124 | } | 128 | this.articuloService.setArticulo(articulo); |
| 125 | this.articuloService.setArticulo(articulo); | 129 | }); |
| 126 | }); | 130 | } |
| 127 | } | ||
| 128 | 131 | ||
| 129 | mediaPantalla() { | 132 | mediaPantalla() { |
| 130 | if ($('body').hasClass('media-pantalla')) { | 133 | if ($('body').hasClass('media-pantalla')) { |
| 131 | $('#headerPublicidad,#headerPad').addClass('media-pantalla'); | 134 | $('#headerPublicidad,#headerPad').addClass('media-pantalla'); |
| 132 | } | 135 | } |
| 133 | } | 136 | } |
| 134 | } | 137 | } |
src/app/shared/promocion/promocion.component.ts
| 1 | import { Component, OnInit, HostListener } from '@angular/core'; | 1 | import { Component, OnInit, HostListener } from '@angular/core'; |
| 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; | 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; |
| 3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
| 4 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 4 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 5 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; | 5 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; |
| 6 | import { Subject } from 'rxjs'; | 6 | import { Subject } from 'rxjs'; |
| 7 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 7 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
| 8 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; | 8 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; |
| 9 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; | 9 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; |
| 10 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; | 10 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
| 11 | import { SinonimoComponent } from '../sinonimo/sinonimo.component'; | 11 | import { SinonimoComponent } from '../sinonimo/sinonimo.component'; |
| 12 | import * as _ from 'lodash'; | 12 | import * as _ from 'lodash'; |
| 13 | 13 | ||
| 14 | @Component({ | 14 | @Component({ |
| 15 | selector: 'app-promocion', | 15 | selector: 'app-promocion', |
| 16 | templateUrl: './promocion.component.html', | 16 | templateUrl: './promocion.component.html', |
| 17 | styleUrls: ['./promocion.component.scss'] | 17 | styleUrls: ['./promocion.component.scss'] |
| 18 | }) | 18 | }) |
| 19 | export class PromocionComponent implements OnInit { | 19 | export class PromocionComponent implements OnInit { |
| 20 | articulosPromo: IArticulo[] = []; | 20 | articulosPromo: IArticulo[] = []; |
| 21 | promociones: IArticulo[] = []; | 21 | promociones: IArticulo[] = []; |
| 22 | onClose: Subject<any>; | 22 | onClose: Subject<any>; |
| 23 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 23 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
| 24 | 24 | ||
| 25 | constructor( | 25 | constructor( |
| 26 | public modalPromocion: BsModalRef, | 26 | public modalPromocion: BsModalRef, |
| 27 | private modalService: BsModalService, | 27 | private modalService: BsModalService, |
| 28 | private articuloService: ArticuloService, | 28 | private articuloService: ArticuloService, |
| 29 | private promocionService: PromocionService, | 29 | private promocionService: PromocionService, |
| 30 | private sinonimoService: SinonimoService, | 30 | private sinonimoService: SinonimoService, |
| 31 | private inactiveScreen: InactiveScreenService, | 31 | private inactiveScreen: InactiveScreenService, |
| 32 | ) { | 32 | ) { |
| 33 | this.onClose = new Subject(); | 33 | this.onClose = new Subject(); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | ngOnInit() { | 36 | ngOnInit() { |
| 37 | this.getPromociones(); | 37 | this.getPromociones(); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | selectPromo(promo: IArticulo) { | 40 | selectPromo(promo: IArticulo) { |
| 41 | this.sinonimoService.getSinonimos(promo.CodSec, promo.CodArt) | 41 | this.sinonimoService.getSinonimos(promo.CodSec, promo.CodArt) |
| 42 | .subscribe((res: ISinonimo[]) => { | 42 | .subscribe((res: ISinonimo[]) => { |
| 43 | if (res.length) { | 43 | if (res.length) { |
| 44 | const sinonimos = []; | 44 | const sinonimos = []; |
| 45 | const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); | 45 | const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); |
| 46 | Object.keys(gruposArticulos).forEach(key => { | 46 | Object.keys(gruposArticulos).forEach(key => { |
| 47 | sinonimos.push({ productos: gruposArticulos[key] }); | 47 | sinonimos.push({ productos: gruposArticulos[key] }); |
| 48 | }); | 48 | }); |
| 49 | res = sinonimos; | 49 | res = sinonimos; |
| 50 | this.openModalSinonimos(res, promo); | 50 | this.openModalSinonimos(res, promo); |
| 51 | } else { | 51 | } else { |
| 52 | promo.cantidad = 1; | 52 | promo.cantidad = 1; |
| 53 | this.articuloService.setArticulo(promo); | 53 | this.articuloService.setArticulo(promo); |
| 54 | this.modalPromocion.hide(); | 54 | this.modalPromocion.hide(); |
| 55 | } | 55 | } |
| 56 | }, err => console.error(err)); | 56 | }, err => console.error(err)); |
| 57 | this.mediaPantalla(); | 57 | this.mediaPantalla(); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { | 60 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { |
| 61 | const modalSinonimo = this.modalService.show(SinonimoComponent, { | 61 | const modalSinonimo = this.modalService.show(SinonimoComponent, { |
| 62 | initialState: { sinonimos: sinonimosData }, | 62 | initialState: { |
| 63 | sinonimos: sinonimosData, | ||
| 64 | articulo: articulo | ||
| 65 | }, | ||
| 63 | class: 'modal-promo modal-dialog-centered' | 66 | class: 'modal-promo modal-dialog-centered' |
| 64 | }); | 67 | }); |
| 65 | 68 | ||
| 66 | modalSinonimo.content.onClose | 69 | modalSinonimo.content.onClose |
| 67 | .subscribe((res: any) => { | 70 | .subscribe((res: any) => { |
| 68 | for (const a of articulo.productos) { | 71 | for (const a of articulo.productos) { |
| 69 | for (const aRes of res.articulos) { | 72 | for (const aRes of res.articulos) { |
| 70 | if (a.idSinonimo === aRes.ID_SIN) { | 73 | if (a.idSinonimo === aRes.ID_SIN) { |
| 71 | a.CODA = aRes.CodArt; | 74 | a.CODA = aRes.CodArt; |
| 72 | a.CodArt = aRes.CodArt; | 75 | a.CodArt = aRes.CodArt; |
| 73 | a.SECA = aRes.CodSec; | 76 | a.SECA = aRes.CodSec; |
| 74 | aRes.CodSec = aRes.CodSec; | 77 | aRes.CodSec = aRes.CodSec; |
| 75 | a.PreVen = aRes.PreVen; | 78 | a.PreVen = aRes.PreVen; |
| 76 | a.id = aRes.id; | 79 | a.id = aRes.id; |
| 77 | a.DET_LAR = aRes.DET_LAR; | 80 | a.DET_LAR = aRes.DET_LAR; |
| 78 | a.DetArt = aRes.DetArt; | 81 | a.DetArt = aRes.DetArt; |
| 79 | } | 82 | } |
| 80 | } | 83 | } |
| 81 | } | 84 | } |
| 82 | this.articuloService.setArticulo(articulo); | 85 | this.articuloService.setArticulo(articulo); |
| 83 | this.modalPromocion.hide(); | 86 | this.modalPromocion.hide(); |
| 84 | }); | 87 | }); |
| 85 | } | 88 | } |
| 86 | 89 | ||
| 87 | getPromociones() { | 90 | getPromociones() { |
| 88 | const sector = this.articulosPromo[0].CodSec; | 91 | const sector = this.articulosPromo[0].CodSec; |
| 89 | const codigo = this.articulosPromo[0].CodArt; | 92 | const codigo = this.articulosPromo[0].CodArt; |
| 90 | this.promocionService.getPromociones(sector, codigo) | 93 | this.promocionService.getPromociones(sector, codigo) |
| 91 | .subscribe((res: IArticulo[]) => { | 94 | .subscribe((res: IArticulo[]) => { |
| 92 | this.promociones = res; | 95 | this.promociones = res; |
| 93 | }, error => { console.error(error); }); | 96 | }, error => { console.error(error); }); |
| 94 | } | 97 | } |
| 95 | 98 | ||
| 96 | @HostListener('document:click', ['$event']) | 99 | @HostListener('document:click', ['$event']) |
| 97 | eventListener(event: Event) { | 100 | eventListener(event: Event) { |
| 98 | clearTimeout(this.inactiveScreen.timerReposo); | 101 | clearTimeout(this.inactiveScreen.timerReposo); |
| 99 | this.inactiveScreen.startTimeOutInactividad(); | 102 | this.inactiveScreen.startTimeOutInactividad(); |
| 100 | } | 103 | } |
| 101 | 104 | ||
| 102 | @HostListener('scroll', ['$event']) | 105 | @HostListener('scroll', ['$event']) |
| 103 | scrollEvent(event: Event) { | 106 | scrollEvent(event: Event) { |
| 104 | clearTimeout(this.inactiveScreen.timerReposo); | 107 | clearTimeout(this.inactiveScreen.timerReposo); |
| 105 | this.inactiveScreen.startTimeOutInactividad(); | 108 | this.inactiveScreen.startTimeOutInactividad(); |
| 106 | } | 109 | } |
| 107 | 110 | ||
| 108 | mediaPantalla() { | 111 | mediaPantalla() { |
| 109 | if ($('body').hasClass('media-pantalla')) { | 112 | if ($('body').hasClass('media-pantalla')) { |
| 110 | $('.modal-content').addClass('media-pantalla'); | 113 | $('.modal-content').addClass('media-pantalla'); |
| 111 | } | 114 | } |
| 112 | } | 115 | } |
| 113 | } | 116 | } |
| 114 | 117 |
src/app/shared/sinonimo/sinonimo.component.html
| 1 | <div class="bg-primary rounded text-white"> | 1 | <div class="bg-primary rounded text-white"> |
| 2 | <div class="modal-header"> | 2 | <div class="modal-header"> |
| 3 | <p class="h4 col-6 px-0 align-self-center">Eliga opciones {{sinonimos.length}}</p> | 3 | <p class="col-7 h4 px-0 align-self-center">{{articulo.DetArt}}</p> |
| 4 | <div class="col-6 text-right"> | 4 | <div class="col-5 pr-0 text-right"> |
| 5 | <p *ngFor="let s of sinonimos; let i = index"> | 5 | <p *ngFor="let s of sinonimos; let i = index"> |
| 6 | <span | 6 | <span |
| 7 | class="btn-effect" | 7 | class="btn-effect" |
| 8 | (click)="scrollTo(i)"> | 8 | (click)="scrollTo(i)"> |
| 9 | Ir a opción {{i+1}} | 9 | Ir a opción {{i+1}} |
| 10 | <i class="far fa-hand-point-left"></i> | 10 | <i class="far fa-hand-point-left"></i> |
| 11 | </span> | 11 | </span> |
| 12 | </p> | 12 | </p> |
| 13 | </div> | 13 | </div> |
| 14 | </div> | 14 | </div> |
| 15 | 15 | ||
| 16 | <div class="modal-body lista-sinonimos scroll-y-visible my-2 mr-2"> | 16 | <div class="modal-body lista-sinonimos scroll-y-visible my-2 mr-2"> |
| 17 | <div *ngFor="let s of sinonimos; let i = index"> | 17 | <div *ngFor="let s of sinonimos; let i = index"> |
| 18 | <div [id]="i"></div> | 18 | <div [id]="i"></div> |
| 19 | <hr [hidden]="i === 0" class="bg-white"> | 19 | <hr [hidden]="i === 0" class="bg-white"> |
| 20 | <div *ngFor="let articulo of s.productos"> | 20 | <div *ngFor="let articulo of s.productos"> |
| 21 | <div class="custom-control custom-checkbox"> | 21 | <div class="custom-control custom-checkbox"> |
| 22 | <input | 22 | <input |
| 23 | type="checkbox" | 23 | type="checkbox" |
| 24 | class="custom-control-input" | 24 | class="custom-control-input" |
| 25 | [(ngModel)]="articulo.seleccionado" | 25 | [(ngModel)]="articulo.seleccionado" |
| 26 | (click)="selectSinonimo(i, articulo)" | 26 | (click)="selectSinonimo(i, articulo)" |
| 27 | [id]="articulo.id"> | 27 | [id]="articulo.id"> |
| 28 | <label | 28 | <label |
| 29 | class="custom-control-label" | 29 | class="custom-control-label" |
| 30 | [for]="articulo.id"> | 30 | [for]="articulo.id"> |
| 31 | {{articulo.DET_LAR.toUpperCase()}} | 31 | {{articulo.DET_LAR.toUpperCase()}} |
| 32 | </label> | 32 | </label> |
| 33 | </div> | 33 | </div> |
| 34 | </div> | 34 | </div> |
| 35 | </div> | 35 | </div> |
| 36 | </div> | 36 | </div> |
| 37 | 37 | ||
| 38 | <div class="modal-footer"> | 38 | <div class="modal-footer"> |
| 39 | <div | 39 | <div |
| 40 | [ngClass]="validate()" | 40 | [ngClass]="validate()" |
| 41 | class="d-inline-block py-1 bg-white badge-pill text-primary" | 41 | class="d-inline-block py-1 bg-white badge-pill text-primary" |
| 42 | (click)="continue()"> | 42 | (click)="continue()"> |
| 43 | CONTINUAR | 43 | CONTINUAR |
| 44 | <img | 44 | <img |
| 45 | draggable="false" | 45 | draggable="false" |
| 46 | ondragstart="return false;" | 46 | ondragstart="return false;" |
| 47 | (contextmenu)="false" | 47 | (contextmenu)="false" |
| 48 | class="icon-30" | 48 | class="icon-30" |
| 49 | src="assets/img/ir-color.svg"> | 49 | src="assets/img/ir-color.svg"> |
| 50 | </div> | 50 | </div> |
| 51 | </div> | 51 | </div> |
| 52 | </div> | 52 | </div> |
| 53 | 53 |
src/app/shared/sinonimo/sinonimo.component.ts
| 1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; | 2 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
| 3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
| 4 | import { BsModalRef } from 'ngx-bootstrap/modal'; | 4 | import { BsModalRef } from 'ngx-bootstrap/modal'; |
| 5 | import { Subject, forkJoin } from 'rxjs'; | 5 | import { Subject, forkJoin } from 'rxjs'; |
| 6 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 6 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 7 | import { element } from 'protractor'; | 7 | import { element } from 'protractor'; |
| 8 | 8 | ||
| 9 | @Component({ | 9 | @Component({ |
| 10 | selector: 'app-sinonimo', | 10 | selector: 'app-sinonimo', |
| 11 | templateUrl: './sinonimo.component.html', | 11 | templateUrl: './sinonimo.component.html', |
| 12 | styleUrls: ['./sinonimo.component.scss'] | 12 | styleUrls: ['./sinonimo.component.scss'] |
| 13 | }) | 13 | }) |
| 14 | export class SinonimoComponent implements OnInit { | 14 | export class SinonimoComponent implements OnInit { |
| 15 | sinonimos: ISinonimo[] = []; | 15 | sinonimos: ISinonimo[] = []; |
| 16 | isValid: boolean; | 16 | isValid: boolean; |
| 17 | onClose: Subject<any>; | 17 | onClose: Subject<any>; |
| 18 | articulosSelected: IArticulo[] = []; | 18 | articulosSelected: IArticulo[] = []; |
| 19 | articulo: IArticulo; | ||
| 19 | 20 | ||
| 20 | constructor( | 21 | constructor( |
| 21 | private modalRef: BsModalRef, | 22 | private modalRef: BsModalRef, |
| 22 | private articuloService: ArticuloService, | 23 | private articuloService: ArticuloService, |
| 23 | ) { | 24 | ) { |
| 24 | this.onClose = new Subject(); | 25 | this.onClose = new Subject(); |
| 25 | this.articulosSelected.length = this.sinonimos.length; | 26 | this.articulosSelected.length = this.sinonimos.length; |
| 26 | } | 27 | } |
| 27 | 28 | ||
| 28 | ngOnInit() { } | 29 | ngOnInit() { } |
| 29 | 30 | ||
| 30 | selectSinonimo(index: number, articulo: IArticulo) { | 31 | selectSinonimo(index: number, articulo: IArticulo) { |
| 31 | for (const a of this.sinonimos[index].productos) { | 32 | for (const a of this.sinonimos[index].productos) { |
| 32 | a.seleccionado = false; | 33 | a.seleccionado = false; |
| 33 | } | 34 | } |
| 34 | articulo.seleccionado = true; | 35 | articulo.seleccionado = true; |
| 35 | this.articulosSelected[index] = articulo; | 36 | this.articulosSelected[index] = articulo; |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | validate() { | 39 | validate() { |
| 39 | this.isValid = true; | 40 | this.isValid = true; |
| 40 | for (const s of this.sinonimos) { | 41 | for (const s of this.sinonimos) { |
| 41 | for (const a of s.productos) { | 42 | for (const a of s.productos) { |
| 42 | this.isValid = (!a.seleccionado) ? false : true; | 43 | this.isValid = (!a.seleccionado) ? false : true; |
| 43 | if (this.isValid) break; | 44 | if (this.isValid) break; |
| 44 | } | 45 | } |
| 45 | if (!this.isValid) break; | 46 | if (!this.isValid) break; |
| 46 | } | 47 | } |
| 47 | return !this.isValid ? 'disabled' : 'btn-effect'; | 48 | return !this.isValid ? 'disabled' : 'btn-effect'; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | continue() { | 51 | continue() { |
| 51 | if (!this.isValid) return; | 52 | if (!this.isValid) return; |
| 52 | const ID_SINS = []; | 53 | const ID_SINS = []; |
| 53 | const observables = []; | 54 | const observables = []; |
| 54 | 55 | ||
| 55 | for (const articulo of this.articulosSelected) { | 56 | for (const articulo of this.articulosSelected) { |
| 56 | ID_SINS.push(articulo.ID_SIN); | 57 | ID_SINS.push(articulo.ID_SIN); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | for (const articulo of this.articulosSelected) { | 60 | for (const articulo of this.articulosSelected) { |
| 60 | observables.push(this.articuloService.getById(articulo.id)); | 61 | observables.push(this.articuloService.getById(articulo.id)); |
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | forkJoin(observables) | 64 | forkJoin(observables) |
| 64 | .subscribe((res: IArticulo[]) => { | 65 | .subscribe((res: IArticulo[]) => { |
| 65 | for (const articulo of res) { | 66 | for (const articulo of res) { |
| 66 | for (const ID_SIN of ID_SINS) { | 67 | for (const ID_SIN of ID_SINS) { |
| 67 | articulo.ID_SIN = ID_SIN; | 68 | articulo.ID_SIN = ID_SIN; |
| 68 | } | 69 | } |
| 69 | } | 70 | } |
| 70 | this.modalRef.hide(); | 71 | this.modalRef.hide(); |
| 71 | this.onClose.next({ | 72 | this.onClose.next({ |
| 72 | articulos: res, | 73 | articulos: res, |
| 73 | }); | 74 | }); |
| 74 | }, err => console.error(err)); | 75 | }, err => console.error(err)); |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | scrollTo(index: number) { | 78 | scrollTo(index: number) { |
| 78 | const el = document.getElementById(index.toString()); | 79 | const el = document.getElementById(index.toString()); |
| 79 | el.scrollIntoView({ behavior: 'smooth', block: 'center' }); | 80 | el.scrollIntoView({ behavior: 'smooth', block: 'center' }); |
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | } | 83 | } |
| 83 | 84 |