Commit 6045a0c18f38b65b0149ce4cab722e5b294f2482
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request modulos-npm/foca-crear-nota-pedido!11
Showing
3 changed files
Show diff stats
src/js/app.js
src/js/controller.js
... | ... | @@ -3,7 +3,7 @@ angular.module('focaCrearNotaPedido') |
3 | 3 | ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', |
4 | 4 | function($scope, $uibModal, $location, crearNotaPedidoService) { |
5 | 5 | $scope.show = false; |
6 | - | |
6 | + $scope.edit = false; | |
7 | 7 | $scope.dateOptions = { |
8 | 8 | maxDate: new Date(), |
9 | 9 | minDate: new Date(2010, 0, 1) |
... | ... | @@ -114,14 +114,16 @@ angular.module('focaCrearNotaPedido') |
114 | 114 | var newArt = |
115 | 115 | { |
116 | 116 | id: 0, |
117 | - codigo: producto.FiltroSectorCodigo, | |
117 | + codigo: producto.codigo, | |
118 | + sector: producto.sector, | |
119 | + descripcion: producto.descripcion, | |
118 | 120 | item: $scope.articulosTabla.length + 1, |
119 | 121 | nombre: producto.descripcion, |
120 | - precio: producto.precio, | |
122 | + precio: producto.precio.toFixed(2), | |
121 | 123 | costoUnitario: producto.costo, |
122 | 124 | cantidad: 1 |
123 | 125 | }; |
124 | - $scope.articulosTabla.unshift(newArt); | |
126 | + $scope.articuloACargar = newArt; | |
125 | 127 | }, function() { |
126 | 128 | // funcion ejecutada cuando se cancela el modal |
127 | 129 | } |
... | ... | @@ -195,17 +197,18 @@ angular.module('focaCrearNotaPedido') |
195 | 197 | } |
196 | 198 | ); |
197 | 199 | }; |
198 | - $scope.getSubTotal = function(item) { | |
199 | - var subTotal = 0; | |
200 | - var array = $scope.articulosTabla.filter( | |
201 | - function(a) { | |
202 | - return a.item <= item; | |
203 | - } | |
204 | - ); | |
200 | + $scope.getTotal = function() { | |
201 | + var total = 0; | |
202 | + var array = $scope.articulosTabla; | |
205 | 203 | for (var i = 0; i < array.length; i++) { |
206 | - subTotal += array[i].precio * array[i].cantidad; | |
204 | + total += array[i].precio * array[i].cantidad; | |
207 | 205 | } |
208 | - return subTotal.toFixed(2); | |
206 | + return total.toFixed(2); | |
207 | + }; | |
208 | + $scope.getSubTotal = function() { | |
209 | + if($scope.articuloACargar) { | |
210 | + return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | |
211 | + } | |
209 | 212 | }; |
210 | 213 | $scope.cargarArticulos = function() { |
211 | 214 | idLista = $scope.notaPedido.precioCondicion; |
... | ... | @@ -223,6 +226,8 @@ angular.module('focaCrearNotaPedido') |
223 | 226 | modalInstance.result.then( |
224 | 227 | function(precioCondicion) { |
225 | 228 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; |
229 | + idLista = precioCondicion.idListaPrecio; | |
230 | + $scope.articulosTabla = []; | |
226 | 231 | }, function() { |
227 | 232 | |
228 | 233 | } |
... | ... | @@ -248,6 +253,23 @@ angular.module('focaCrearNotaPedido') |
248 | 253 | ); |
249 | 254 | } |
250 | 255 | }; |
256 | + $scope.agregarATabla = function(key) { | |
257 | + if(key === 13) { | |
258 | + $scope.articulosTabla.unshift($scope.articuloACargar); | |
259 | + $scope.articuloACargar = undefined; | |
260 | + } | |
261 | + }; | |
262 | + $scope.quitarArticulo = function(key) { | |
263 | + $scope.articulosTabla.splice(key, 1); | |
264 | + }; | |
265 | + $scope.editarArticulo = function(key) { | |
266 | + if(key === 13) { | |
267 | + $scope.edit = false; | |
268 | + } | |
269 | + }; | |
270 | + $scope.cambioEdit = function() { | |
271 | + $scope.edit = !$scope.edit ? true : false; | |
272 | + }; | |
251 | 273 | } |
252 | 274 | ] |
253 | 275 | ) |
src/views/nota-pedido.html
... | ... | @@ -78,7 +78,7 @@ |
78 | 78 | <div class="form-group col-12 col-sm-6 col-md-4"> |
79 | 79 | <label>Flete</label> |
80 | 80 | <div class="form-check custom-radio custom-control-inline"> |
81 | - <input | |
81 | + <input | |
82 | 82 | class="form-check-input" |
83 | 83 | type="radio" |
84 | 84 | name="radioFlete" |
... | ... | @@ -139,13 +139,12 @@ |
139 | 139 | <tr> |
140 | 140 | <th>Sector</th> |
141 | 141 | <th>Cรณdigo</th> |
142 | - <th>Descripciรณn</th> | |
143 | - <th>Cantidad</th> | |
142 | + <th>Descripciรณn</th> | |
144 | 143 | <th>Precio Unitario</th> |
144 | + <th>Cantidad</th> | |
145 | 145 | <th>SubTotal</th> |
146 | - <th></th> | |
147 | 146 | <th> |
148 | - <button class="btn btn-outline-secondary selectable" style="float: right;" ng-click="show = !show"> | |
147 | + <button class="btn btn-outline-secondary selectable" style="float: right;" ng-click="show = !show; masMenos()" > | |
149 | 148 | <i class="fa fa-chevron-down" ng-hide="show" aria-hidden="true"></i> |
150 | 149 | <i class="fa fa-chevron-up" ng-show="show" aria-hidden="true"></i> |
151 | 150 | </button> |
... | ... | @@ -153,53 +152,68 @@ |
153 | 152 | </tr> |
154 | 153 | </thead> |
155 | 154 | <tbody> |
156 | - <tr> | |
157 | - <td colspan="2"><input class="form-control" readonly ng-click="seleccionarArticulo()"></td> | |
158 | - <td></td> | |
155 | + <tr ng-show="!articuloACargar"> | |
156 | + <td colspan="2"><input placeholder="Seleccione Articulo" class="form-control" readonly ng-click="seleccionarArticulo()"></td> | |
159 | 157 | <td></td> |
160 | 158 | <td></td> |
161 | 159 | <td></td> |
162 | 160 | <td></td> |
163 | 161 | <td></td> |
164 | 162 | </tr> |
165 | - <tr> | |
166 | - <td>1</td> | |
167 | - <td>1</td> | |
168 | - <td>Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...</td> | |
169 | - <td>{{10000 | number: 2}}</td> | |
170 | - <td>{{1000000000 | currency:'$'}}</td> | |
171 | - <td>{{1000000000 | currency:'$'}}</td> | |
172 | - <td></td> | |
173 | - <td class="text-center"> | |
174 | - <button class="btn btn-outline-secondary btn-sm" ng-click="quitarArticulo()"> | |
175 | - <i class="fa fa-trash"></i> | |
176 | - </button> | |
177 | - </td> | |
163 | + <tr ng-show="articuloACargar"> | |
164 | + <td><input | |
165 | + class="form-control" | |
166 | + ng-model="articuloACargar.sector" | |
167 | + readonly></td> | |
168 | + <td><input | |
169 | + class="form-control" | |
170 | + ng-model="articuloACargar.codigo" | |
171 | + readonly></td> | |
172 | + <td><input | |
173 | + class="form-control" | |
174 | + ng-model="articuloACargar.descripcion" | |
175 | + readonly></td> | |
176 | + <td><input | |
177 | + class="form-control" | |
178 | + ng-value="articuloACargar.precio | currency:'$'" | |
179 | + readonly></td> | |
180 | + <td><input | |
181 | + class="form-control" | |
182 | + type="number" | |
183 | + min="1" | |
184 | + value="1" | |
185 | + ng-model="articuloACargar.cantidad" | |
186 | + foca-focus="articuloACargar.cantidad == 1" | |
187 | + ng-keypress="agregarATabla($event.keyCode)"></td> | |
188 | + <td><input | |
189 | + class="form-control" | |
190 | + ng-value="getSubTotal() | currency:'$'" | |
191 | + readonly></td> | |
192 | + <td class="text-center"><button | |
193 | + class="btn btn-outline-secondary btn-sm" | |
194 | + ng-click="agregarATabla(13)"> | |
195 | + <i class="fa fa-save"></i> | |
196 | + </button></td> | |
178 | 197 | </tr> |
179 | - <tr ng-show="show"> | |
180 | - <td>1</td> | |
181 | - <td>2</td> | |
182 | - <td>Lorem Ipsum</td> | |
183 | - <td>1</td> | |
184 | - <td>{{1000000000 | currency:'U$D'}}</td> | |
185 | - <td>{{10 | currency:'$'}}</td> | |
186 | - <td></td> | |
187 | - <td class="text-center"> | |
188 | - <button class="btn btn-outline-secondary btn-sm" ng-click="quitarArticulo()"> | |
189 | - <i class="fa fa-trash"></i> | |
190 | - </button> | |
198 | + <tr ng-repeat="(key, articulo) in articulosTabla" ng-show="show || key == 0"> | |
199 | + <td ng-bind="articulo.sector"></td> | |
200 | + <td ng-bind="articulo.codigo"></td> | |
201 | + <td ng-bind="articulo.descripcion"></td> | |
202 | + <td ng-bind="articulo.precio | currency:'$'"></td> | |
203 | + <td><input | |
204 | + ng-show="edit" | |
205 | + ng-model="articulo.cantidad" | |
206 | + class="form-control" | |
207 | + type="number" | |
208 | + min="1" | |
209 | + value="1" | |
210 | + foca-focus="edit" | |
211 | + ng-keypress="editarArticulo($event.keyCode)"> | |
212 | + <i class="selectable" ng-click="cambioEdit()" ng-hide="edit" ng-bind="articulo.cantidad"></i> | |
191 | 213 | </td> |
192 | - </tr> | |
193 | - <tr ng-show="show"> | |
194 | - <td>1</td> | |
195 | - <td>2</td> | |
196 | - <td>Lorem Ipsum</td> | |
197 | - <td>1</td> | |
198 | - <td>{{10 | currency:'$'}}</td> | |
199 | - <td>{{10 | currency:'$'}}</td> | |
200 | - <td></td> | |
214 | + <td ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"></td> | |
201 | 215 | <td class="text-center"> |
202 | - <button class="btn btn-outline-secondary btn-sm" ng-click="quitarArticulo()"> | |
216 | + <button class="btn btn-outline-secondary btn-sm" ng-click="quitarArticulo(key)"> | |
203 | 217 | <i class="fa fa-trash"></i> |
204 | 218 | </button> |
205 | 219 | </td> |
... | ... | @@ -207,8 +221,8 @@ |
207 | 221 | </tbody> |
208 | 222 | <tfoot> |
209 | 223 | <tr class="table-secondary"> |
210 | - <td colspan="5"><b>Cantidad Items:</b> 3</td> | |
211 | - <td colspan="3">{{30 | currency:'$'}}</td> | |
224 | + <td colspan="5"><b>Cantidad Items:</b> <a ng-bind="articulosTabla.length"></a> </td> | |
225 | + <td colspan="3">{{getTotal() | currency:'$'}}</td> | |
212 | 226 | </tr> |
213 | 227 | </tfoot> |
214 | 228 | </table> |