Commit a78a5ef8bf75cd003105c362f5364cec6aa523f4

Authored by Jose Pinto
1 parent b2fc56e26e
Exists in master

Nuevo diseño

src/js/controller.js
1 angular.module('focaAbmPreciosCondiciones') 1 angular.module('focaAbmPreciosCondiciones')
2 .controller('focaAbmPreciosCondicionesController', [ 2 .controller('focaAbmPreciosCondicionesController', [
3 '$scope', 'focaAbmPreciosCondicionesService', '$location', 3 '$scope', 'focaAbmPreciosCondicionesService', '$location',
4 'focaModalService', 'focaBotoneraLateralService', '$timeout', 4 'focaModalService', 'focaBotoneraLateralService', '$timeout',
5 function($scope, focaAbmPreciosCondicionesService, $location, 5 function($scope, focaAbmPreciosCondicionesService, $location,
6 focaModalService, focaBotoneraLateralService, $timeout) { 6 focaModalService, focaBotoneraLateralService, $timeout) {
7 focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { 7 focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) {
8 console.log(datos.data);
8 $scope.preciosCondiciones = datos.data; 9 $scope.preciosCondiciones = datos.data;
10 $scope.preciosCondiciones.forEach(function(precioCondicion) {
11 precioCondicion.plazoPago.sort(function(a, b) {
12 return a.dias- b.dias;
13 });
14 });
9 }); 15 });
10 16
11 $timeout(function() { 17 $timeout(function() {
12 focaBotoneraLateralService.showSalir(true); 18 focaBotoneraLateralService.showSalir(true);
13 focaBotoneraLateralService.showPausar(false); 19 focaBotoneraLateralService.showPausar(false);
14 focaBotoneraLateralService.showCancelar(false); 20 focaBotoneraLateralService.showCancelar(false);
15 focaBotoneraLateralService.showGuardar(false); 21 focaBotoneraLateralService.showGuardar(false);
16 }); 22 });
17 23
18 $scope.now = new Date(); 24 $scope.now = new Date();
19 $scope.editar = function(id) { 25 $scope.editar = function(id) {
20 $location.path('/precio-condicion/' + id); 26 $location.path('/precio-condicion/' + id);
21 }; 27 };
22 $scope.solicitarConfirmacion = function(precioCondicion) { 28 $scope.solicitarConfirmacion = function(precioCondicion) {
23 focaModalService.confirm('¿Está seguro que desea borrar el precio condición' + 29 focaModalService.confirm('¿Está seguro que desea borrar el precio condición' +
24 precioCondicion.codigo + ' ' + precioCondicion.nombre + ' ?').then( 30 precioCondicion.codigo + ' ' + precioCondicion.nombre + ' ?').then(
25 function(data) { 31 function(data) {
26 if (data) { 32 if (data) {
27 focaAbmPreciosCondicionesService 33 focaAbmPreciosCondicionesService
28 .borrarPrecioCondicion(precioCondicion.id); 34 .borrarPrecioCondicion(precioCondicion.id);
29 $scope.preciosCondiciones.splice( 35 $scope.preciosCondiciones.splice(
30 $scope.preciosCondiciones.indexOf(precioCondicion), 1 36 $scope.preciosCondiciones.indexOf(precioCondicion), 1
31 ); 37 );
32 } 38 }
33 } 39 }
34 ); 40 );
35 }; 41 };
36 } 42 }
37 ]) 43 ])
38 .controller('focaAbmPrecioCondicionController', [ 44 .controller('focaAbmPrecioCondicionController', [
39 '$scope', 'focaAbmPreciosCondicionesService', 'focaBotoneraLateralService', 45 '$scope', 'focaAbmPreciosCondicionesService', 'focaBotoneraLateralService',
40 '$routeParams', '$location', 'focaModalService', '$timeout', 46 '$routeParams', '$location', 'focaModalService', '$timeout', '$uibModal', '$window',
41 function( 47 function(
42 $scope, focaAbmPreciosCondicionesService, focaBotoneraLateralService, 48 $scope, focaAbmPreciosCondicionesService, focaBotoneraLateralService,
43 $routeParams, $location, focaModalService, $timeout 49 $routeParams, $location, focaModalService, $timeout, $uibModal, $window
44 ) { 50 ) {
51 $scope.plazosAEliminar = [];
45 $scope.mostrarPlazos = $routeParams.id > 0; 52 $scope.mostrarPlazos = $routeParams.id > 0;
53 $scope.now = new Date();
54 $scope.listaPrecioLabel = '';
46 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) 55 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id)
47 .then(function(datos) { 56 .then(function(datos) {
48 $scope.precioCondicion = { 57 $scope.precioCondicion = {
49 id: 0, 58 id: 0,
50 codigo: '', 59 codigo: '',
51 nombre: '', 60 nombre: '',
52 descripcion: '', 61 descripcion: '',
53 idListaPrecio: 0, 62 idListaPrecio: 0,
54 vigencia: new Date() 63 vigencia: new Date()
55 }; 64 };
56 if (datos.data.id) { 65 if(datos.data.id) {
57 $scope.precioCondicion = datos.data; 66 $scope.precioCondicion = datos.data;
67 $scope.listaPrecioLabel = datos.data.listaPrecio.ID.trim() +
68 ' - ' + datos.data.listaPrecio.DES;
69 $scope.$broadcast('addCabecera', {
70 label: 'Precio y condición:',
71 valor: datos.data.nombre
72 });
58 focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) 73 focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id)
59 .then(function(datos) { 74 .then(function(datos) {
60 $scope.precioCondicion.plazos = datos.data; 75 $scope.precioCondicion.plazos = datos.data;
76 $scope.precioCondicion.plazos.sort(function(a, b) {
77 return a.dias- b.dias;
78 });
79 $scope.plazoACargar =
80 {
81 item: datos.data.length + 1
82 };
61 }); 83 });
62 } 84 }
63 }); 85 });
64 86
65 $timeout(function() { 87 $timeout(function() {
66 focaBotoneraLateralService.showSalir(false); 88 focaBotoneraLateralService.showSalir(false);
67 focaBotoneraLateralService.showPausar(true); 89 focaBotoneraLateralService.showPausar(true);
68 focaBotoneraLateralService.showCancelar(true); 90 focaBotoneraLateralService.showCancelar(true);
69 focaBotoneraLateralService.showGuardar(true, $scope.guardar); 91 focaBotoneraLateralService.showGuardar(true, $scope.guardar);
70 }); 92 });
71 93
72 $scope.cancelar = function() { 94 $scope.cancelar = function() {
73 $location.path('/precio-condicion'); 95 $location.path('/precio-condicion');
74 }; 96 };
75 $scope.guardar = function(precioCondicion) { 97 $scope.guardar = function() {
76 focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) 98 var promises = [];
77 .then(function() { 99 var precioCondicion = $scope.precioCondicion;
78 $location.path('/precio-condicion'); 100 precioCondicion.idListaPrecio = precioCondicion.listaPrecio.ID;
101 delete precioCondicion.listaPrecio;
102 if($scope.mostrarPlazos) {
103 promises.push(
104 focaAbmPreciosCondicionesService
105 .guardarPlazosPago($scope.precioCondicion.plazos)
106 );
107 $scope.plazosAEliminar.forEach(function(id) {
108 promises.push(
109 focaAbmPreciosCondicionesService
110 .borrarPlazoPago(id)
111 );
79 }); 112 });
80 }; 113 }
81 $scope.editarPlazoPago = function(id) { 114 promises.push(
82 $location.path( 115 focaAbmPreciosCondicionesService
83 '/precio-condicion/' + $scope.precioCondicion.id + 116 .guardarPrecioCondicion(precioCondicion)
84 '/plazo-pago/' + id
85 ); 117 );
118
119 Promise.all(promises).then(function() {
120 $window.location.assign('/#!/precio-condicion');
121 }, function(err){
122 console.error(err);
123 });
124 };
125
126 $scope.agregarPlazo = function(key) {
127 if(key === 13) {
128 if(!$scope.plazoACargar.dias) {
129 focaModalService.alert('Ingrese cantidad de días');
130 return;
131 }
132 var tieneEseDia = $scope.precioCondicion.plazos.filter(function(a) {
133 return a.dias === $scope.plazoACargar.dias;
134 });
135 if(tieneEseDia.length > 0) {
136 focaModalService.alert('Ya ha ingresado un plazo con esos días');
137 return;
138 }
139 $scope.plazoACargar.idPreciosCondiciones = $scope.precioCondicion.id;
140 $scope.plazoACargar.activo = true;
141 $scope.precioCondicion.plazos.push($scope.plazoACargar);
142 $scope.plazoACargar =
143 {
144 item: $scope.precioCondicion.plazos.length + 1
145 };
146 }
147 };
148 $scope.quitarPlazo = function(key) {
149 if($scope.precioCondicion.plazos[key].id)
150 $scope.plazosAEliminar.push($scope.precioCondicion.plazos[key].id);
151
152 $scope.precioCondicion.plazos.splice(key, 1);
153 $scope.plazoACargar =
154 {
155 item: $scope.precioCondicion.plazos.length + 1
156 };
86 }; 157 };
87 $scope.solicitarConfirmacionPlazoPago = function(plazoPago) { 158 $scope.solicitarConfirmacionPlazoPago = function(plazoPago) {
88 focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago ' + 159 focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago ' +
89 plazoPago.item + ' ' + plazoPago.dias + ' ?').then( 160 plazoPago.item + ' ' + plazoPago.dias + ' ?').then(
90 function(confirm) { 161 function(confirm) {
91 if (confirm) { 162 if (confirm) {
92 focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id); 163 focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id);
93 $scope.precioCondicion.plazos.splice( 164 $scope.precioCondicion.plazos.splice(
94 $scope.precioCondicion.plazos.indexOf(plazoPago), 1 165 $scope.precioCondicion.plazos.indexOf(plazoPago), 1
95 ); 166 );
96 } 167 }
97 } 168 }
98 ); 169 );
99 }; 170 };
171
172 $scope.seleccionarListaPrecio = function() {
173 var modalInstance = $uibModal.open(
174 {
175 ariaLabelledBy: 'Busqueda de Listas de precio',
176 templateUrl: 'modal-lista-precio.html',
177 controller: 'focaModalListaPrecioCtrl',
178 size: 'lg'
179 }
180 );
181 modalInstance.result.then(function(listaPrecio) {
182 $scope.precioCondicion.listaPrecio = listaPrecio;
183 $scope.listaPrecioLabel = listaPrecio.ID + ' - ' + listaPrecio.DES;
184 });
185 };
100 } 186 }
101 ]); 187 ]);
1 angular.module('focaAbmPreciosCondiciones') 1 angular.module('focaAbmPreciosCondiciones')
2 .service('focaAbmPreciosCondicionesService', [ 2 .service('focaAbmPreciosCondicionesService', [
3 '$http', 'API_ENDPOINT', 3 '$http', 'API_ENDPOINT',
4 function($http, API_ENDPOINT) { 4 function($http, API_ENDPOINT) {
5 return { 5 return {
6 obtenerPreciosCondiciones: function() { 6 obtenerPreciosCondiciones: function() {
7 return $http.get(API_ENDPOINT.URL + '/precio-condicion'); 7 return $http.get(API_ENDPOINT.URL + '/precio-condicion');
8 }, 8 },
9 obtenerPrecioCondicion: function(id) { 9 obtenerPrecioCondicion: function(id) {
10 return $http.get(API_ENDPOINT.URL + '/precio-condicion/' + id); 10 return $http.get(API_ENDPOINT.URL + '/precio-condicion/' + id);
11 }, 11 },
12 guardarPrecioCondicion: function(precioCondicion) { 12 guardarPrecioCondicion: function(precioCondicion) {
13 return $http.post( 13 return $http.post(
14 API_ENDPOINT.URL + '/precio-condicion', 14 API_ENDPOINT.URL + '/precio-condicion',
15 {precioCondicion: precioCondicion} 15 {precioCondicion: precioCondicion}
16 ); 16 );
17 }, 17 },
18 borrarPrecioCondicion: function(id) { 18 borrarPrecioCondicion: function(id) {
19 return $http.delete(API_ENDPOINT.URL + '/precio-condicion/' + id); 19 return $http.delete(API_ENDPOINT.URL + '/precio-condicion/' + id);
20 }, 20 },
21 obtenerPlazoPago: function(idPrecioCondicion) { 21 obtenerPlazoPago: function(idPrecioCondicion) {
22 return $http.get( 22 return $http.get(
23 API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + idPrecioCondicion 23 API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + idPrecioCondicion
24 ); 24 );
25 }, 25 },
26 borrarPlazoPago: function(id) { 26 borrarPlazoPago: function(id) {
27 return $http.delete(API_ENDPOINT.URL + '/plazo-pago/' + id); 27 return $http.delete(API_ENDPOINT.URL + '/plazo-pago/' + id);
28 },
29 guardarPlazosPago: function(plazos){
30 return $http.post(
31 API_ENDPOINT.URL + '/plazos-pago',
32 {plazosPago: plazos}
33 );
28 } 34 }
29 }; 35 };
30 } 36 }
31 ]); 37 ]);
32 38
src/views/foca-abm-precios-condiciones-item.html
1 <h4>Precios y Condiciones</h4> 1 <div class="row">
2 <form> 2 <foca-cabecera-facturador
3 <input type="hidden" name="id" ng-model="precioCondicion.id" /> 3 titulo="'Precios y condiciones'"
4 <div class="form-group row"> 4 fecha="now"
5 <label class="offset-sm-1 col-sm-2 col-form-label">Código</label> 5 class="mb-0 col-lg-12"
6 <div class="col-sm-4"> 6 ></foca-cabecera-facturador>
7 <input 7 </div>
8 class="form-control" 8 <div class="row">
9 type="text" 9 <form class="col-md-10">
10 name="codigo" 10 <input type="hidden" name="id" ng-model="precioCondicion.id" />
11 ng-model="precioCondicion.codigo" 11 <div class="row mb-3">
12 autocomplete="off" 12 <label class="col-sm-2 col-form-label">Código</label>
13 teclado-virtual 13 <input
14 /> 14 class="form-control col-sm-4"
15 </div> 15 type="text"
16 </div> 16 name="codigo"
17 <div class="form-group row"> 17 ng-model="precioCondicion.codigo"
18 <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> 18 autocomplete="off"
19 <div class="col-sm-4"> 19 teclado-virtual
20 <input 20 />
21 class="form-control" 21 <label class="col-sm-2 col-form-label">Nombre</label>
22 type="text" 22 <input
23 name="nombre" 23 class="form-control col-sm-4"
24 ng-model="precioCondicion.nombre" 24 type="text"
25 autocomplete="off" 25 name="nombre"
26 teclado-virtual 26 ng-model="precioCondicion.nombre"
27 /> 27 autocomplete="off"
28 teclado-virtual
29 />
28 </div> 30 </div>
29 </div> 31 <div class="form-group row">
30 <div class="form-group row"> 32 <label class="col-sm-2 col-form-label">Descripción</label>
31 <label class="offset-sm-1 col-sm-2 col-form-label">Descripción</label>
32 <div class="col-sm-4">
33 <input 33 <input
34 class="form-control" 34 class="form-control col-sm-10"
35 type="text" 35 type="text"
36 name="nombre" 36 name="nombre"
37 ng-model="precioCondicion.descripcion" 37 ng-model="precioCondicion.descripcion"
38 autocomplete="off" 38 autocomplete="off"
39 teclado-virtual 39 teclado-virtual
40 /> 40 />
41 </div> 41 </div>
42 </div> 42 <div class="row">
43 <div class="form-group row"> 43 <label class="col-sm-2 col-form-label">Lista de precios</label>
44 <label class="offset-sm-1 col-sm-2 col-form-label">Lista de precios</label> 44 <div class="col-sm-4 input-group p-0">
45 <div class="col-sm-4"> 45 <input
46 <input 46 ng-model="listaPrecioLabel"
47 class="form-control" 47 class="form-control"
48 type="text" 48 readonly
49 name="nombre" 49 />
50 ng-model="precioCondicion.idListaPrecio" 50 <div class="input-group-append">
51 autocomplete="off" 51 <button
52 /> 52 ladda="searchLoading"
53 </div> 53 class="btn btn-outline-secondary form-control"
54 </div> 54 title="Buscar"
55 <div class="form-group row" ng-show="mostrarPlazos"> 55 type="button"
56 <label class="offset-sm-1 col-sm-2 col-form-label">Plazos</label> 56 ng-click="seleccionarListaPrecio()"
57 <div class="col-sm-4"> 57 foca-focus="focused == 3"
58 <table class="table table-sm table-hover lista"> 58 >
59 <thead> 59 <i class="fa fa-search" aria-hidden="true"></i>
60 <tr> 60 </button>
61 <th>Item</th> 61 </div>
62 <th>Dias</th> 62 </div>
63 <th colspan="2" class="text-center"> 63 <label class="col-sm-2 col-form-label" ng-show="mostrarPlazos">Plazos</label>
64 <button class="btn btn-default boton-accion" ng-click="editarPlazoPago(0)"> 64 <div class="col-sm-4 p-0" ng-show="mostrarPlazos">
65 <i class="fa fa-plus"></i> 65 <div class="input-group p-0">
66 </button> 66 <input
67 </th> 67 type="number"
68 </tr> 68 class="form-control text-right"
69 </thead> 69 min="0"
70 <tbody> 70 ng-model="plazoACargar.dias"
71 <tr ng-repeat="plazo in precioCondicion.plazos"> 71 ng-keypress="agregarPlazo($event.keyCode)"
72 <td ng-bind="plazo.item"></td> 72 foca-focus="ingreso"
73 <td ng-bind="plazo.dias"></td> 73 placeholder="Días"
74 <td class="text-center"> 74 />
75 <button class="btn btn-default boton-accion" ng-click="editarPlazoPago(plazo.id)"> 75 <div class="input-group-append">
76 <i class="fa fa-pencil"></i> 76 <button
77 </button> 77 class="btn btn-outline-secondary form-control"
78 <button 78 title="Agregar"
79 class="btn btn-default boton-accion" 79 type="button"
80 ng-click="solicitarConfirmacionPlazoPago(plazo)" 80 ng-click="agregarPlazo(13)"
81 > 81 foca-focus="focused == 3"
82 <i class="fa fa-trash"></i> 82 >
83 </button> 83 <i class="fa fa-save" aria-hidden="true"></i>
84 </td> 84 </button>
85 </tr> 85 </div>
86 </tbody> 86 </div>
87 </table> 87 <table class="table table-striped table-sm">
88 <tbody>
89 <tr ng-repeat="(key, plazo) in precioCondicion.plazos">
90 <td class="text-right" >
91 <span ng-bind="plazo.dias + ' días'"></span>
92 <button
93 title="Eliminar"
94 class="btn btn-outline-secondary ml-1"
95 ng-click="quitarPlazo(key)"
96 >
97 <i class="fa fa-trash"></i>
98 </button>
99 </td>
100 </tr>
101 </tbody>
102 </table>
103 </div>
88 </div> 104 </div>
src/views/foca-abm-precios-condiciones-listado.html
1 <foca-cabecera-facturador 1 <div class="row">
2 <foca-cabecera-facturador
2 titulo="'Precios y condiciones'" 3 titulo="'Precios y condiciones'"
3 fecha="now" 4 fecha="now"
4 class="mb-0 col-lg-12" 5 class="mb-0 col-lg-12"
5 ></foca-cabecera-facturador> 6 ></foca-cabecera-facturador>
6 <div class="lista"> 7 </div>
7 <table class="table table-sm table-hover table-nonfluid"> 8 <div class="row">
8 <thead> 9 <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded">
9 <tr> 10 <table class="table table-default table-hover table-sm table-abm table-striped mb-0">
10 <th>Código</th> 11 <thead>
11 <th>Nombre</th> 12 <tr>
12 <th colspan="2" class="text-center"> 13 <th>Nombre</th>
13 <button class="btn btn-default boton-accion" ng-click="editar(0)"> 14 <th>Lista de precio</th>
14 <i class="fa fa-plus"></i> 15 <th>Plazos</th>
15 </button> 16 <th colspan="2" class="text-center">
16 </th> 17 <button
17 </tr> 18 title="Agregar"
18 </thead> 19 class="btn btn-outline-debo boton-accion"
19 <tbody> 20 ng-click="editar(0)">
20 <tr ng-repeat="precioCondicion in preciosCondiciones"> 21 <i class="fa fa-plus"></i>
21 <td ng-bind="precioCondicion.codigo"></td> 22 </button>
22 <td ng-bind="precioCondicion.nombre"></td> 23 </th>
23 <td> 24 </tr>
24 <button class="btn btn-default boton-accion" ng-click="editar(precioCondicion.id)"> 25 </thead>
25 <i class="fa fa-pencil"></i> 26 <tbody>
26 </button> 27 <tr ng-repeat="precioCondicion in preciosCondiciones">
27 <button class="btn btn-default boton-accion" ng-click="solicitarConfirmacion(precioCondicion)"> 28 <td ng-bind="precioCondicion.nombre"></td>
28 <i class="fa fa-trash"></i> 29 <td ng-bind="precioCondicion.listaPrecio.ID + ' - ' + precioCondicion.listaPrecio.DES + ' - ' + precioCondicion.listaPrecio.moneda.DETALLE"></td>
29 </button> 30 <td><span
30 </td> 31 ng-repeat="plazo in precioCondicion.plazoPago"
31 </tr> 32 ng-if="plazo.activo"
32 </tbody> 33 ng-bind="$last ? plazo.dias : plazo.dias + ', '"></span></td>
33 </table> 34 <td class="text-center">
35 <button
36 title="Editar"
37 class="btn btn-outline-dark boton-accion"
38 ng-click="editar(precioCondicion.id)">
39 <i class="fa fa-pencil"></i>
40 </button>
41 <button
42 title="Eliminar"
43 class="btn btn-outline-dark boton-accion"
44 ng-click="solicitarConfirmacion(precioCondicion)">
45 <i class="fa fa-trash"></i>
46 </button>
47 </td>
48 </tr>
49 </tbody>
50 </table>
51 </div>
34 </div> 52 </div>
35 53