Commit 2561b18c56283d8102d96bf718e511e210f34f44
1 parent
2b95972827
Exists in
master
First commit
Showing
8 changed files
with
500 additions
and
0 deletions
Show diff stats
.gitignore
File was created | 1 | /node_modules | |
2 | /dist | ||
3 | package-lock\.json | ||
4 |
index.html
File was created | 1 | <html ng-app="focaCrearNotaPedido"> | |
2 | <head> | ||
3 | <meta charset="UTF-8"/> | ||
4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
5 | |||
6 | <!--CSS--> | ||
7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> | ||
8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> | ||
9 | |||
10 | <!--VENDOR JS--> | ||
11 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | ||
12 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | ||
13 | <script src="node_modules/angular/angular.min.js"></script> | ||
14 | <script src="node_modules/angular-route/angular-route.min.js"></script> | ||
15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | ||
16 | |||
17 | <script src="src/js/app.js"></script> | ||
18 | <script src="src/js/controller.js"></script> | ||
19 | <script src="src/js/service.js"></script> | ||
20 | |||
21 | </head> | ||
22 | <body ng-view> | ||
23 | |||
24 | </body> | ||
25 | </html> | ||
26 |
package.json
File was created | 1 | { | |
2 | "name": "foca-crear-nota-pedido", | ||
3 | "version": "0.0.2", | ||
4 | "description": "Módulo foca", | ||
5 | "main": "index.js", | ||
6 | "scripts": { | ||
7 | "test": "echo \"Error: no test specified\" && exit 1", | ||
8 | "compile": "gulp uglify && gulp html", | ||
9 | "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js" | ||
10 | }, | ||
11 | "repository": { | ||
12 | "type": "git", | ||
13 | "url": "https://192.168.0.11/modulos-npm/foca-crear-nota-pedido.git" | ||
14 | }, | ||
15 | "author": "Foca Software", | ||
16 | "license": "ISC", | ||
17 | "dependencies": { | ||
18 | "angular": "^1.7.x", | ||
19 | "angular-route": "^1.7.4", | ||
20 | "bootstrap": "^4.1.x", | ||
21 | "font-awesome": "^4.7.x", | ||
22 | "gulp": "^3.9.x", | ||
23 | "gulp-concat": "2.6.x", | ||
24 | "gulp-jshint": "^2.1.x", | ||
25 | "gulp-rename": "^1.4.x", | ||
26 | "gulp-replace": "^1.0.x", | ||
27 | "gulp-uglify-es": "^1.0.x", | ||
28 | "jquery": "^3.3.x", | ||
29 | "jshint": "^2.9.x", | ||
30 | "pump": "^3.0.x", | ||
31 | "ui-bootstrap4": "^3.0.5" | ||
32 | }, | ||
33 | "devDependencies": { | ||
34 | "gulp-connect": "^5.6.1", | ||
35 | "jasmine-core": "3.2.1", | ||
36 | "pre-commit": "^1.2.2" | ||
37 | } | ||
38 | } | ||
39 |
src/js/app.js
File was created | 1 | angular.module('focaCrearNotaPedido', ['ngRoute', 'ui.bootstrap']) | |
2 | .config(['$routeProvider', function($routeProvider) { | ||
3 | $routeProvider.when('/venta-nota-pedido', { | ||
4 | controller: 'notaPedidoListaCtrl', | ||
5 | templateUrl: 'src/views/nota-pedido-lista.html' | ||
6 | }); | ||
7 | }]) | ||
8 | .config(['$routeProvider', function($routeProvider) { | ||
9 | $routeProvider.when('/venta-nota-pedido/abm', { | ||
10 | controller: 'notaPedidoCtrl', | ||
11 | templateUrl: 'src/views/nota-pedido.html' | ||
12 | }); | ||
13 | }]); | ||
14 |
src/js/controller.js
File was created | 1 | angular.module('focaCrearNotaPedido') | |
2 | .controller('notaPedidoCtrl', | ||
3 | [ | ||
4 | '$scope', | ||
5 | '$uibModal', | ||
6 | 'crearNotaPedidoService', | ||
7 | function ($scope, $uibModal, crearNotaPedidoService) { | ||
8 | $scope.notaPedido = {}; | ||
9 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | ||
10 | var domiciliosCliente = [ | ||
11 | { | ||
12 | dom: 'sanjuan', | ||
13 | id: 3 | ||
14 | }, | ||
15 | { | ||
16 | dom: 'mendoza', | ||
17 | id: 2 | ||
18 | } | ||
19 | ] | ||
20 | if (notaPedidoTemp != undefined) { | ||
21 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | ||
22 | $scope.notaPedido = notaPedidoTemp; | ||
23 | $scope.notaPedido.domicilio = domiciliosCliente; | ||
24 | } else { | ||
25 | $scope.notaPedido.fechaCarga = new Date(); | ||
26 | |||
27 | $scope.notaPedido.domicilio = domiciliosCliente; | ||
28 | } | ||
29 | $scope.precioCondiciones = [ | ||
30 | { nombre: 'Precio y condicion 1' }, | ||
31 | { nombre: 'Precio y condicion 2' }, | ||
32 | { nombre: 'Precio y condicion 3' } | ||
33 | ] | ||
34 | $scope.articulosTabla = [ | ||
35 | { | ||
36 | codigo: '1', | ||
37 | item: 1, | ||
38 | nombre: 'naftaaskdahsñodaskdjhañslkdjahslñkjdhalskjdhaksjdhkasjhasddddddddddddddddddddddddddddddddddddddddddddddddd', | ||
39 | precio: '14,50', | ||
40 | costoUnitario: '14', | ||
41 | cantidad: 1, | ||
42 | subtotal: '19,22' | ||
43 | } | ||
44 | ] | ||
45 | $scope.notaPedido.bomba = '1'; | ||
46 | $scope.notaPedido.flete = '1'; | ||
47 | $scope.addNewDom = function () { | ||
48 | $scope.notaPedido.domicilio.push({ 'id': 0 }); | ||
49 | } | ||
50 | $scope.removeNewChoice = function (choice) { | ||
51 | if ($scope.notaPedido.domicilio.length > 1) { | ||
52 | $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex(c => c.$$hashKey == choice.$$hashKey), 1) | ||
53 | } | ||
54 | } | ||
55 | $scope.crearNotaPedido = function () { | ||
56 | var notaPedido = { | ||
57 | idNotaPedido: 0, | ||
58 | precioCondicion: $scope.notaPedido.precioCondicion, | ||
59 | fechaCarga: $scope.notaPedido.clientefechaCarga, | ||
60 | vendedor: $scope.notaPedido.vendedor, | ||
61 | cliente: $scope.notaPedido.cliente, | ||
62 | producto: $scope.notaPedido.producto, | ||
63 | bomba: $scope.notaPedido.bomba, | ||
64 | petrolera: $scope.notaPedido.petrolera, | ||
65 | domicilio: $scope.notaPedido.domicilio, | ||
66 | kilometros: $scope.notaPedido.kilometros, | ||
67 | jurisdiccionIIBB: $scope.notaPedido.jurisdiccion, | ||
68 | costoFinanciacion: $scope.notaPedido.costoFinanciacion, | ||
69 | flete: $scope.notaPedido.flete, | ||
70 | costoUnitarioKmFlete: $scope.costoUnitarioKmFlete | ||
71 | } | ||
72 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | ||
73 | function (res) { | ||
74 | alert('Nota pedido creada') | ||
75 | } | ||
76 | ) | ||
77 | } | ||
78 | $scope.siguienteTab = function () { | ||
79 | $scope.active = 1; | ||
80 | } | ||
81 | $scope.seleccionarArticulo = function () { | ||
82 | var modalIntance = $uibModal.open( | ||
83 | { | ||
84 | ariaLabelledBy: 'Busqueda de Productos', | ||
85 | templateUrl: 'modal-busqueda-productos.html', | ||
86 | controller: 'modalBusquedaProductosCtrl', | ||
87 | size: 'md' | ||
88 | } | ||
89 | ) | ||
90 | modalInstance.result.then( | ||
91 | function (producto) { | ||
92 | console.info(producto); | ||
93 | // variable producto tiene el producto seleccionado en el modal | ||
94 | }, function () { | ||
95 | // funcion ejecutada cuando se cancela el modal | ||
96 | } | ||
97 | ); | ||
98 | } | ||
99 | $scope.obtenerDomicilios = function (id) { | ||
100 | crearNotaPedidoService.getDomicilios(id).then( | ||
101 | function (res) { | ||
102 | $scope.notaPedido.domicilio = res.data; | ||
103 | } | ||
104 | ) | ||
105 | } | ||
106 | } | ||
107 | ] | ||
108 | ) | ||
109 | .controller('notaPedidoListaCtrl', [ | ||
110 | '$scope', | ||
111 | 'crearNotaPedidoService', | ||
112 | '$location', | ||
113 | function ($scope, crearNotaPedidoService, $location) { | ||
114 | crearNotaPedidoService.obtenerNotaPedido().then(function (datos) { | ||
115 | $scope.notaPedidos = datos.data; | ||
116 | }); | ||
117 | $scope.editar = function (notaPedido) { | ||
118 | crearNotaPedidoService.setNotaPedido(notaPedido); | ||
119 | $location.path('/venta-nota-pedido/abm/'); | ||
120 | }; | ||
121 | } | ||
122 | ]) | ||
123 | |||
124 |
src/js/service.js
File was created | 1 | angular.module('focaCrearNotaPedido') | |
2 | .service('crearNotaPedidoService', ['$http',function($http) { | ||
3 | var route = 'http://192.168.0.23:9900'; | ||
4 | var notaPedido; | ||
5 | return { | ||
6 | crearNotaPedido: function(obj) { | ||
7 | return; | ||
8 | }, | ||
9 | obtenerNotaPedido: function() { | ||
10 | return $http.get(route +'/nota-pedido'); | ||
11 | }, | ||
12 | setNotaPedido: function(notaPedido) { | ||
13 | this.notaPedido = notaPedido; | ||
14 | }, | ||
15 | getNotaPedido: function() { | ||
16 | return this.notaPedido; | ||
17 | }, | ||
18 | getDomicilios: function(id) { | ||
19 | // return $http.get(route + '/'+id) | ||
20 | var domicilio = [ | ||
21 | { | ||
22 | id: 1, | ||
23 | nombre: 'godoy Cruz' | ||
24 | }, | ||
25 | { | ||
26 | id: 2, | ||
27 | nombre: 'capital' | ||
28 | }, | ||
29 | { | ||
30 | id: 3, | ||
31 | nombre: 'mendoza' | ||
32 | } | ||
33 | ] | ||
34 | return | ||
35 | } | ||
36 | } | ||
37 | }]) | ||
38 |
src/views/nota-pedido-lista.html
File was created | 1 | <table class="table table-sm table-hover table-nonfluid"> | |
2 | <thead> | ||
3 | <tr> | ||
4 | <th>Código</th> | ||
5 | <th>Vendedor</th> | ||
6 | <th>Cliente</th> | ||
7 | <th>Petrolera</th> | ||
8 | <th></th> | ||
9 | </tr> | ||
10 | </thead> | ||
11 | <tbody> | ||
12 | <tr ng-repeat="item in notaPedidos"> | ||
13 | <td ng-bind="item.id"></td> | ||
14 | <td ng-bind="item.vendedor"></td> | ||
15 | <td ng-bind="item.cliente"></td> | ||
16 | <td ng-bind="item.petrolera"></td> | ||
17 | <td> | ||
18 | <button ng-click="editar(item)"><i class="glyphicon glyphicon-pencil"></i></button> | ||
19 | <button ng-click="borrar(item.id)"><i class="glyphicon glyphicon-trash"></i></button> | ||
20 | </td> | ||
21 | </tr> | ||
22 | </tbody> | ||
23 | </table> |
src/views/nota-pedido.html
File was created | 1 | <form name="formCrearNota" ng-submit="siguienteTab()"> | |
2 | <uib-tabset active="active"> | ||
3 | <uib-tab index="0" heading="General"> | ||
4 | <input type="hidden" name="id" ng-model="notaPedido.id" /> | ||
5 | <div> | ||
6 | <div class="col-auto my-2"> | ||
7 | <button type="submit" title="Siguiente" class="btn btn-primary float-right">Siguiente</button> | ||
8 | </div> | ||
9 | </div> | ||
10 | <br> | ||
11 | <br> | ||
12 | <div class="row"> | ||
13 | <div class="col-md-2"> | ||
14 | <div class="col-auto"> | ||
15 | <label>Fecha de carga</label> | ||
16 | </div> | ||
17 | </div> | ||
18 | <div class="col-md-3"> | ||
19 | <div class="col-auto"> | ||
20 | <input type="date" class="form-control" ng-model="notaPedido.fechaCarga" ng-required="true"> | ||
21 | </div> | ||
22 | </div> | ||
23 | <div class="col-md-2"> | ||
24 | <div class="col-auto"> | ||
25 | <label>Kilómetros</label> | ||
26 | </div> | ||
27 | </div> | ||
28 | <div class="col-md-3"> | ||
29 | <div class="col-auto"> | ||
30 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Kilómetros recorridos para la entrega en el cliente" | ||
31 | ng-model="notaPedido.kilometros" ng-required="true"> | ||
32 | </div> | ||
33 | </div> | ||
34 | </div> | ||
35 | <div class="row my-3"> | ||
36 | <div class="col-md-2"> | ||
37 | <div class="col-auto"> | ||
38 | <label>Jurisdicción de IIBB</label> | ||
39 | </div> | ||
40 | </div> | ||
41 | <div class="col-md-3"> | ||
42 | <div class="col-auto"> | ||
43 | <input type="text" class="form-control" placeholder="Jurisdicción de IIBB donde se realiza la entrega" | ||
44 | ng-model="notaPedido.jurisdiccion" ng-required="true"> | ||
45 | </div> | ||
46 | </div> | ||
47 | <div class="col-md-2"> | ||
48 | <div class="col-auto"> | ||
49 | <label>Costo de financiación</label> | ||
50 | </div> | ||
51 | </div> | ||
52 | <div class="col-md-3"> | ||
53 | <div class="col-auto"> | ||
54 | <div class="input-group mb-2"> | ||
55 | <div class="input-group-prepend"> | ||
56 | <div class="input-group-text">$</div> | ||
57 | </div> | ||
58 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo de financiación" | ||
59 | ng-model="notaPedido.costoFinanciacion"> | ||
60 | </div> | ||
61 | </div> | ||
62 | </div> | ||
63 | </div> | ||
64 | <div class="row"> | ||
65 | <div class="col-md-2"> | ||
66 | <div class="col-auto"> | ||
67 | <label>Bomba</label> | ||
68 | </div> | ||
69 | </div> | ||
70 | <div class="col-md-1"> | ||
71 | <div class="col-auto"> | ||
72 | <div class="form-check custom-radio custom-control-inline"> | ||
73 | <input class="form-check-input" type="radio" name="radioBomba" value="1" ng-model="notaPedido.bomba"> | ||
74 | <label class="form-check-label"> | ||
75 | Si | ||
76 | </label> | ||
77 | </div> | ||
78 | <div class="form-check custom-radio custom-control-inline"> | ||
79 | <input class="form-check-input" type="radio" name="radioBomba" value="0" ng-model="notaPedido.bomba"> | ||
80 | <label class="form-check-label"> | ||
81 | No | ||
82 | </label> | ||
83 | </div> | ||
84 | </div> | ||
85 | </div> | ||
86 | <div class="col-md-1"> | ||
87 | <div class="col-auto"> | ||
88 | <label>Flete</label> | ||
89 | </div> | ||
90 | </div> | ||
91 | <div class="col-md-1"> | ||
92 | <div class="col-auto"> | ||
93 | <div class="form-check custom-radio custom-control-inline"> | ||
94 | <input class="form-check-input" type="radio" name="radioFlete" value="1" ng-model="notaPedido.flete"> | ||
95 | <label class="form-check-label"> | ||
96 | Si | ||
97 | </label> | ||
98 | </div> | ||
99 | <div class="form-check custom-radio custom-control-inline"> | ||
100 | <input class="form-check-input" type="radio" name="radioFlete" value="0" ng-model="notaPedido.flete"> | ||
101 | <label class="form-check-label"> | ||
102 | FOB | ||
103 | </label> | ||
104 | </div> | ||
105 | </div> | ||
106 | </div> | ||
107 | <div class="col-md-2"> | ||
108 | <div class="col-auto"> | ||
109 | <label>Costo unitario kilometro flete</label> | ||
110 | </div> | ||
111 | </div> | ||
112 | <div class="col-md-3"> | ||
113 | <div class="col-auto"> | ||
114 | <div class="input-group mb-2"> | ||
115 | <div class="input-group-prepend"> | ||
116 | <div class="input-group-text">$</div> | ||
117 | </div> | ||
118 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo unitario del kilometro del flete" | ||
119 | ng-model="notaPedido.costoUnitarioKmFlete" ng-required="true"> | ||
120 | </div> | ||
121 | </div> | ||
122 | </div> | ||
123 | </div> | ||
124 | <div class="row my-3"> | ||
125 | <div class="col-md-2"> | ||
126 | <div class="col-auto"> | ||
127 | <label>Vendedor</label> | ||
128 | </div> | ||
129 | </div> | ||
130 | <div class="col-md-3"> | ||
131 | <div class="col-auto"> | ||
132 | <input type="text" class="form-control" placeholder="Seleccione vendedor" ng-model="notaPedido.vendedor" | ||
133 | readonly> | ||
134 | </div> | ||
135 | </div> | ||
136 | <div class="col-md-2"> | ||
137 | <div class="col-auto"> | ||
138 | <label>Petrolera</label> | ||
139 | </div> | ||
140 | </div> | ||
141 | <div class="col-md-3"> | ||
142 | <div class="col-auto"> | ||
143 | <input type="text" class="form-control" placeholder="Seleccione petrolera" ng-model="notaPedido.petrolera" | ||
144 | readonly> | ||
145 | </div> | ||
146 | </div> | ||
147 | </div> | ||
148 | </div> | ||
149 | <div class="row"> | ||
150 | <div class="col-md-2"> | ||
151 | <div class="col-auto"> | ||
152 | <label>Cliente</label> | ||
153 | </div> | ||
154 | </div> | ||
155 | <div class="col-md-3"> | ||
156 | <div class="col-auto"> | ||
157 | <input type="text" class="form-control" placeholder="Seleccione cliente" ng-model="notaPedido.cliente" | ||
158 | ng-change="obtenerDomicilios()" readonly> | ||
159 | </div> | ||
160 | </div> | ||
161 | <div class="col-md-2"> | ||
162 | <div class="col-auto"> | ||
163 | <label>Domicilio</label> | ||
164 | </div> | ||
165 | </div> | ||
166 | <div class="col-md-4"> | ||
167 | <div class="col-md-12 row" ng-repeat="domicilio in notaPedido.domicilio"> | ||
168 | <div class="col-auto"> | ||
169 | <select class="form-control" ng-options="domi as domi.dom for domi in domiciliosCliente" | ||
170 | ng-model="domicilio.id" ng-required="true"> | ||
171 | </select> | ||
172 | </div> | ||
173 | <a class="btn" ng-click="removeNewChoice(domicilio)" ng-if="domicilio.id==0">-</a> | ||
174 | <a class="btn" ng-click="addNewDom()">+</a> | ||
175 | </div> | ||
176 | </div> | ||
177 | </div> | ||
178 | </uib-tab> | ||
179 | <uib-tab index="1" heading="Producto" disable="formCrearNota.$invalid"> | ||
180 | <div> | ||
181 | <div class="col-auto my-2"> | ||
182 | <button type="submit" title="Siguiente" class="btn btn-primary float-right">Abrir</button> | ||
183 | </div> | ||
184 | </div> | ||
185 | <br> | ||
186 | <br> | ||
187 | <div class="row"> | ||
188 | <div class="col-md-2"> | ||
189 | <div class="col-auto"> | ||
190 | <label>Precios y condiciones</label> | ||
191 | </div> | ||
192 | </div> | ||
193 | <div class="col-md-4"> | ||
194 | <div class="col-auto"> | ||
195 | <select class="form-control" ng-model="notaPedido.precioCondicion" ng-options="preCond.nombre for preCond in precioCondiciones"> | ||
196 | </select> | ||
197 | </div> | ||
198 | </div> | ||
199 | <div class="col-md-2"> | ||
200 | <div class="col-auto"> | ||
201 | <label>Producto</label> | ||
202 | </div> | ||
203 | </div> | ||
204 | <div class="col-md-4"> | ||
205 | <div class="col-auto"> | ||
206 | <input type="text" class="form-control" placeholder="Seleccione producto" ng-model="notaPedido.producto" | ||
207 | ng-click="seleccionarArticulo()" readonly> | ||
208 | </div> | ||
209 | </div> | ||
210 | </div> | ||
211 | <div class="row"> | ||
212 | <table class="table my-3 table-hover table-nonfluid"> | ||
213 | <thead> | ||
214 | <tr> | ||
215 | <th>Código</th> | ||
216 | <th>Nombre</th> | ||
217 | <th>Precio unitario</th> | ||
218 | <th>Costo unitario bruto</th> | ||
219 | <th>Cantidad</th> | ||
220 | <th>Subtotal</th> | ||
221 | </tr> | ||
222 | </thead> | ||
223 | <tbody> | ||
224 | <tr ng-repeat="articulo in articulosTabla"> | ||
225 | <td ng-bind="articulo.codigo"></td> | ||
226 | <td ng-bind="articulo.nombre"></td> | ||
227 | <td ng-bind="articulo.precio"></td> | ||
228 | <td ng-bind="articulo.costoUnitario"></td> | ||
229 | <td ng-bind="articulo.cantidad"></td> | ||
230 | <td ng-bind="articulo.subtotal"></td> | ||
231 | </tr> | ||
232 | </tbody> | ||
233 | </table> | ||
234 | </div> | ||
235 | </uib-tab> | ||
236 | </uib-tabset> | ||
237 | </form> |