Commit d661a13633bd703280018b9a8c383e8a23e60731
1 parent
e9ecb68964
Exists in
master
and in
1 other branch
funcionamiento grilla articulos
Showing
2 changed files
with
47 additions
and
19 deletions
Show diff stats
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) |
| ... | ... | @@ -197,17 +197,18 @@ angular.module('focaCrearNotaPedido') |
| 197 | 197 | } |
| 198 | 198 | ); |
| 199 | 199 | }; |
| 200 | - $scope.getSubTotal = function(item) { | |
| 201 | - var subTotal = 0; | |
| 202 | - var array = $scope.articulosTabla.filter( | |
| 203 | - function(a) { | |
| 204 | - return a.item <= item; | |
| 205 | - } | |
| 206 | - ); | |
| 200 | + $scope.getTotal = function() { | |
| 201 | + var total = 0; | |
| 202 | + var array = $scope.articulosTabla; | |
| 207 | 203 | for (var i = 0; i < array.length; i++) { |
| 208 | - subTotal += array[i].precio * array[i].cantidad; | |
| 204 | + total += array[i].precio * array[i].cantidad; | |
| 209 | 205 | } |
| 210 | - 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 | + } | |
| 211 | 212 | }; |
| 212 | 213 | $scope.cargarArticulos = function() { |
| 213 | 214 | idLista = $scope.notaPedido.precioCondicion; |
| ... | ... | @@ -226,6 +227,7 @@ angular.module('focaCrearNotaPedido') |
| 226 | 227 | function(precioCondicion) { |
| 227 | 228 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; |
| 228 | 229 | idLista = precioCondicion.idListaPrecio; |
| 230 | + $scope.articulosTabla = []; | |
| 229 | 231 | }, function() { |
| 230 | 232 | |
| 231 | 233 | } |
| ... | ... | @@ -257,6 +259,17 @@ angular.module('focaCrearNotaPedido') |
| 257 | 259 | $scope.articuloACargar = undefined; |
| 258 | 260 | } |
| 259 | 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 | + }; | |
| 260 | 273 | } |
| 261 | 274 | ] |
| 262 | 275 | ) |
src/views/nota-pedido.html
| ... | ... | @@ -71,7 +71,7 @@ |
| 71 | 71 | type="text" |
| 72 | 72 | readonly="true" |
| 73 | 73 | ng-model="notaPedido.precioCondicion" |
| 74 | - ng-click="abrirModalListaPrecio()" | |
| 74 | + ng-click="abrirModalListaPrecio()" | |
| 75 | 75 | placeholder="Seleccione Lista de precio" |
| 76 | 76 | > |
| 77 | 77 | </div> |
| ... | ... | @@ -153,7 +153,7 @@ |
| 153 | 153 | </thead> |
| 154 | 154 | <tbody> |
| 155 | 155 | <tr ng-show="!articuloACargar"> |
| 156 | - <td colspan="2"><input class="form-control" readonly ng-click="seleccionarArticulo()"></td> | |
| 156 | + <td colspan="2"><input placeholder="Seleccione Articulo" class="form-control" readonly ng-click="seleccionarArticulo()"></td> | |
| 157 | 157 | <td></td> |
| 158 | 158 | <td></td> |
| 159 | 159 | <td></td> |
| ... | ... | @@ -175,7 +175,7 @@ |
| 175 | 175 | readonly></td> |
| 176 | 176 | <td><input |
| 177 | 177 | class="form-control" |
| 178 | - ng-model="articuloACargar.precio" | |
| 178 | + ng-value="articuloACargar.precio | currency:'$'" | |
| 179 | 179 | readonly></td> |
| 180 | 180 | <td><input |
| 181 | 181 | class="form-control" |
| ... | ... | @@ -185,20 +185,35 @@ |
| 185 | 185 | ng-model="articuloACargar.cantidad" |
| 186 | 186 | foca-focus="articuloACargar.cantidad == 1" |
| 187 | 187 | ng-keypress="agregarATabla($event.keyCode)"></td> |
| 188 | - <td><input | |
| 188 | + <td><input | |
| 189 | 189 | class="form-control" |
| 190 | - ng-model="(articuloACargar.precio * articuloACargar.cantidad)" | |
| 190 | + ng-value="getSubTotal() | currency:'$'" | |
| 191 | 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> | |
| 192 | 197 | </tr> |
| 193 | 198 | <tr ng-repeat="(key, articulo) in articulosTabla" ng-show="show || key == 0"> |
| 194 | 199 | <td ng-bind="articulo.sector"></td> |
| 195 | 200 | <td ng-bind="articulo.codigo"></td> |
| 196 | 201 | <td ng-bind="articulo.descripcion"></td> |
| 197 | 202 | <td ng-bind="articulo.precio | currency:'$'"></td> |
| 198 | - <td><input ng-model="articulo.cantidad" class="form-control" type="number" min="1" value="1"></td> | |
| 199 | - <td ng-bind="(articulo.precio * articulo.cantidad)"></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> | |
| 213 | + </td> | |
| 214 | + <td ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"></td> | |
| 200 | 215 | <td class="text-center"> |
| 201 | - <button class="btn btn-outline-secondary btn-sm" ng-click="quitarArticulo()"> | |
| 216 | + <button class="btn btn-outline-secondary btn-sm" ng-click="quitarArticulo(key)"> | |
| 202 | 217 | <i class="fa fa-trash"></i> |
| 203 | 218 | </button> |
| 204 | 219 | </td> |
| ... | ... | @@ -207,7 +222,7 @@ |
| 207 | 222 | <tfoot> |
| 208 | 223 | <tr class="table-secondary"> |
| 209 | 224 | <td colspan="5"><b>Cantidad Items:</b> <a ng-bind="articulosTabla.length"></a> </td> |
| 210 | - <td colspan="3">{{getSubTotal(articulosTabla[0].item) | currency:'$'}}</td> | |
| 225 | + <td colspan="3">{{getTotal() | currency:'$'}}</td> | |
| 211 | 226 | </tr> |
| 212 | 227 | </tfoot> |
| 213 | 228 | </table> |