forked from nathalie/pedi2
agregado id de grupo de compra a la cookie para poder (des)habilitar devoluciones
This commit is contained in:
parent
057170118d
commit
9781d63a60
|
@ -72,6 +72,12 @@ const app = new Vue({
|
||||||
cantidad(producto) {
|
cantidad(producto) {
|
||||||
let pedido = this.productos.some(p => p.id == producto.id)
|
let pedido = this.productos.some(p => p.id == producto.id)
|
||||||
return pedido ? this.productos.find(p => p.id == producto.id).pivot.cantidad : 0
|
return pedido ? this.productos.find(p => p.id == producto.id).pivot.cantidad : 0
|
||||||
|
},
|
||||||
|
settearDevoluciones() {
|
||||||
|
axios.get(`/api/grupos-de-compra/${this.gdc}/devoluciones`)
|
||||||
|
.then(response => {
|
||||||
|
this.devoluciones = response.data.devoluciones;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -79,16 +85,18 @@ const app = new Vue({
|
||||||
axios.get('/subpedidos/obtener_sesion')
|
axios.get('/subpedidos/obtener_sesion')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.subpedido.id) {
|
if (response.data.subpedido.id) {
|
||||||
this.pedido = response.data.subpedido.id
|
this.gdc = response.data.gdc;
|
||||||
|
this.settearDevoluciones();
|
||||||
|
this.pedido = response.data.subpedido.id;
|
||||||
axios.get('/api/subpedidos/' + this.pedido)
|
axios.get('/api/subpedidos/' + this.pedido)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.pedido = response.data.data
|
this.pedido = response.data.data;
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
axios.get('/admin/obtener_sesion')
|
axios.get('/admin/obtener_sesion')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.gdc = response.data.gdc
|
this.gdc = response.data.gdc
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -79,7 +79,8 @@
|
||||||
},
|
},
|
||||||
guardarSubpedidoEnSesion(subpedido) {
|
guardarSubpedidoEnSesion(subpedido) {
|
||||||
axios.post("/subpedidos/guardar_sesion", {
|
axios.post("/subpedidos/guardar_sesion", {
|
||||||
subpedido: subpedido
|
subpedido: subpedido,
|
||||||
|
grupo_de_compra_id: this.gdcid
|
||||||
}).then(_ => {
|
}).then(_ => {
|
||||||
Event.$emit('obtener-sesion')
|
Event.$emit('obtener-sesion')
|
||||||
window.location.href = 'productos';
|
window.location.href = 'productos';
|
||||||
|
|
|
@ -54,8 +54,12 @@ Route::middleware('auth')->group( function() {
|
||||||
if (!isset($r["subpedido"])) {
|
if (!isset($r["subpedido"])) {
|
||||||
throw new HttpException(400, "La request necesita un subpedido para guardar en sesión");
|
throw new HttpException(400, "La request necesita un subpedido para guardar en sesión");
|
||||||
}
|
}
|
||||||
|
if (!isset($r["grupo_de_compra_id"])) {
|
||||||
|
throw new HttpException(400, "La request necesita un grupo de compra para guardar en sesión");
|
||||||
|
}
|
||||||
session(["subpedido_nombre" => $r["subpedido"]["nombre"]]);
|
session(["subpedido_nombre" => $r["subpedido"]["nombre"]]);
|
||||||
session(["subpedido_id" => $r["subpedido"]["id"]]);
|
session(["subpedido_id" => $r["subpedido"]["id"]]);
|
||||||
|
session(["gdc" => $r["grupo_de_compra_id"]]);
|
||||||
return "Subpedido guardado en sesión";
|
return "Subpedido guardado en sesión";
|
||||||
})->name('guardarSesion');
|
})->name('guardarSesion');
|
||||||
|
|
||||||
|
@ -64,7 +68,8 @@ Route::middleware('auth')->group( function() {
|
||||||
'subpedido' => [
|
'subpedido' => [
|
||||||
'nombre' => session("subpedido_nombre"),
|
'nombre' => session("subpedido_nombre"),
|
||||||
'id' => session("subpedido_id")
|
'id' => session("subpedido_id")
|
||||||
]
|
],
|
||||||
|
'gdc' => session("gdc")
|
||||||
];
|
];
|
||||||
return $sesion;
|
return $sesion;
|
||||||
})->name('obtenerSesion');
|
})->name('obtenerSesion');
|
||||||
|
|
Loading…
Reference in New Issue