forked from nathalie/pedi2
		
	ver dinero total del pedido en la barra de navegacion (total de chismosa)
This commit is contained in:
		
							parent
							
								
									b700239e18
								
							
						
					
					
						commit
						6f532eaf05
					
				
					 6 changed files with 49 additions and 14 deletions
				
			
		|  | @ -17,11 +17,11 @@ class SubpedidoResource extends JsonResource | ||||||
|         return [ |         return [ | ||||||
|             'id' => $this->id, |             'id' => $this->id, | ||||||
|             'nombre' => $this->nombre, |             'nombre' => $this->nombre, | ||||||
|             'subtotal_productos' => $this->getSubtotalProductos(), |             'subtotal_productos' => number_format($this->getSubtotalProductos(),2), | ||||||
|             'subtotal_bonos' => $this->getSubtotalBonos(), |             'subtotal_bonos' => number_format($this->getSubtotalBonos(),2), | ||||||
|             'bonos_de_transporte' => $this->cantidadBDT(), |             'bonos_de_transporte' => $this->cantidadBDT(), | ||||||
|             'subtotal_bonos_de_transporte' => $this->getSubtotalBDT(), |             'subtotal_bonos_de_transporte' => number_format($this->getSubtotalBDT(),2), | ||||||
|             'total' => $this->getTotal(), |             'total' => number_format($this->getTotal(),2), | ||||||
|             'grupo_de_compra' => $this->grupoDeCompra |             'grupo_de_compra' => $this->grupoDeCompra | ||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								public/assets/chismosa.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/assets/chismosa.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 2.4 KiB | 
							
								
								
									
										33
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										33
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
								
							|  | @ -8,6 +8,10 @@ Vue.component('nav-bar', { | ||||||
|               <img src="/assets/logoMPS.png" height="28"> |               <img src="/assets/logoMPS.png" height="28"> | ||||||
|             </a> |             </a> | ||||||
|             <p style="margin:0 auto" class="navbar-item"><slot name="subpedido"></slot></p> |             <p style="margin:0 auto" class="navbar-item"><slot name="subpedido"></slot></p> | ||||||
|  |             <a class="navbar-item" href="#"> | ||||||
|  |               <img style="padding:0 0.3em;" src="/assets/chismosa.png" height="28"> | ||||||
|  |               <p style="margin:0 auto; color:white">$ <span v-text="subpedido == null ? 0 : subpedido.total"></span></p> | ||||||
|  |             </a> | ||||||
|             <a role="button" class="navbar-burger" :class="{'is-active':isActive}" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample" @click="toggleState"> |             <a role="button" class="navbar-burger" :class="{'is-active':isActive}" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample" @click="toggleState"> | ||||||
|               <span aria-hidden="true"></span> |               <span aria-hidden="true"></span> | ||||||
|               <span aria-hidden="true"></span> |               <span aria-hidden="true"></span> | ||||||
|  | @ -30,14 +34,31 @@ Vue.component('nav-bar', { | ||||||
|         </nav>`, |         </nav>`, | ||||||
| 	data() { | 	data() { | ||||||
| 		return { | 		return { | ||||||
| 			isActive: false | 			isActive: false, | ||||||
|  |       totalChismosa: 0, | ||||||
|  |       subpedido: null | ||||||
| 		} | 		} | ||||||
| 	}, | 	}, | ||||||
|   	methods: { | 	methods: { | ||||||
|   		toggleState() { | 		toggleState() { | ||||||
|   			this.isActive = !this.isActive; | 			this.isActive = !this.isActive; | ||||||
|   		} | 		}, | ||||||
|   	} |     actualizarSubpedido(){ | ||||||
|  |       axios.get("/api/subpedidos/" + this.subpedido.id) | ||||||
|  |         .then(response => { | ||||||
|  |           this.subpedido = response.data.data; | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  | 	}, mounted() { | ||||||
|  |     axios.get("/subpedidos/obtener_sesion").then(response => { | ||||||
|  |       this.subpedido = response.data.subpedido; | ||||||
|  |       this.actualizarSubpedido() | ||||||
|  |     }); | ||||||
|  |     //Emitir un evento subpedido-actualizado al agregar o eliminar un producto del subpedido para que el total de la chismosa se muestre correctamente
 | ||||||
|  |     Event.$on('subpedido-actualizado', () => { | ||||||
|  |       this.actualizarSubpedido(); | ||||||
|  |     }); | ||||||
|  |   } | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| Vue.component('nav-migas', { | Vue.component('nav-migas', { | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								public/js/subpedidos-create.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								public/js/subpedidos-create.js
									
										
									
									
										vendored
									
									
								
							|  | @ -16,7 +16,7 @@ Vue.component('subpedido-select', { | ||||||
| 	props: ["gdcid"], | 	props: ["gdcid"], | ||||||
| 	mounted() { | 	mounted() { | ||||||
| 		console.log("ready"); | 		console.log("ready"); | ||||||
|   	}, | 	}, | ||||||
| 	methods: { | 	methods: { | ||||||
|   		onType() { |   		onType() { | ||||||
|         if (!this.subpedido){ |         if (!this.subpedido){ | ||||||
|  | @ -37,10 +37,14 @@ Vue.component('subpedido-select', { | ||||||
|   				nombre: this.subpedido, |   				nombre: this.subpedido, | ||||||
|   				grupo_de_compra_id: this.gdcid |   				grupo_de_compra_id: this.gdcid | ||||||
|   			}).then(response => { |   			}).then(response => { | ||||||
|           //se creo el subpedido, guardamos el subpedido en sesion
 |           //se creo el subpedido
 | ||||||
|           this.guardarSubpedidoEnSesion(response.data); |           this.elegirSubpedido(response.data); | ||||||
|   			}); |   			}); | ||||||
|   		}, |   		}, | ||||||
|  |       elegirSubpedido(subpedido){ | ||||||
|  |         //lo guardamos en sesion
 | ||||||
|  |         this.guardarSubpedidoEnSesion(subpedido); | ||||||
|  |       }, | ||||||
|       guardarSubpedidoEnSesion(subpedido) { |       guardarSubpedidoEnSesion(subpedido) { | ||||||
|         axios.post("/subpedidos/guardar_sesion", { |         axios.post("/subpedidos/guardar_sesion", { | ||||||
|           subpedido: subpedido |           subpedido: subpedido | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ | ||||||
|   				<div class="columns is-mobile" v-for="(subpedidoExistente, index) in subpedidosExistentes" :class="{'has-background-grey-lighter': index % 2}"> |   				<div class="columns is-mobile" v-for="(subpedidoExistente, index) in subpedidosExistentes" :class="{'has-background-grey-lighter': index % 2}"> | ||||||
|   					<div class="column is-half-mobile is-two-thirds-desktop is-two-thirds-tablet"><p style="padding-top: calc(.5em - 1px); margin-bottom: .5rem" v-text="subpedidoExistente.nombre"></p></div> |   					<div class="column is-half-mobile is-two-thirds-desktop is-two-thirds-tablet"><p style="padding-top: calc(.5em - 1px); margin-bottom: .5rem" v-text="subpedidoExistente.nombre"></p></div> | ||||||
| 					<div class="buttons column is-half-mobile is-one-third-desktop is-one-third-tablet"> | 					<div class="buttons column is-half-mobile is-one-third-desktop is-one-third-tablet"> | ||||||
| 					  	<button class="button is-danger" @click="guardarSubpedidoEnSesion(subpedidoExistente)">Continuar pedido</button> | 						<button class="button is-danger" @click="elegirSubpedido(subpedidoExistente)">Continuar pedido</button> | ||||||
|   					</div> |   					</div> | ||||||
|   				</div> |   				</div> | ||||||
| 			</div>		 | 			</div>		 | ||||||
|  |  | ||||||
|  | @ -35,5 +35,15 @@ Route::middleware('auth')->group( function() { | ||||||
| 	        session(["subpedido_id" => $r["subpedido"]["id"]]); | 	        session(["subpedido_id" => $r["subpedido"]["id"]]); | ||||||
| 	        return "Subpedido guardado en sesión"; | 	        return "Subpedido guardado en sesión"; | ||||||
| 		})->name('guardarSesion'); | 		})->name('guardarSesion'); | ||||||
|  | 
 | ||||||
|  | 		Route::get('obtener_sesion', function() { | ||||||
|  | 			$sesion = [ | ||||||
|  | 				'subpedido' => [ | ||||||
|  | 					'nombre' => session("subpedido_nombre"), | ||||||
|  | 					'id' => session("subpedido_id") | ||||||
|  | 				] | ||||||
|  | 			]; | ||||||
|  | 	        return $sesion; | ||||||
|  | 		})->name('obtenerSesion'); | ||||||
| 	}); | 	}); | ||||||
| }); | }); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 nat
						nat