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
3 changed files with 37 additions and 23 deletions
44
resources/js/app.js
vendored
44
resources/js/app.js
vendored
|
@ -72,26 +72,34 @@ 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() {
|
||||||
Event.$on('obtener-sesion', () => {
|
Event.$on('obtener-sesion', () => {
|
||||||
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;
|
||||||
axios.get('/api/subpedidos/' + this.pedido)
|
this.settearDevoluciones();
|
||||||
.then(response => {
|
this.pedido = response.data.subpedido.id;
|
||||||
this.pedido = response.data.data
|
axios.get('/api/subpedidos/' + this.pedido)
|
||||||
})
|
.then(response => {
|
||||||
} else {
|
this.pedido = response.data.data;
|
||||||
axios.get('/admin/obtener_sesion')
|
});
|
||||||
.then(response => {
|
} else {
|
||||||
this.gdc = response.data.gdc
|
axios.get('/admin/obtener_sesion')
|
||||||
})
|
.then(response => {
|
||||||
}
|
this.gdc = response.data.gdc
|
||||||
})
|
});
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
Event.$on('sync-subpedido', (cantidad, id) => {
|
Event.$on('sync-subpedido', (cantidad, id) => {
|
||||||
if (this.pedido.aprobado) {
|
if (this.pedido.aprobado) {
|
||||||
this.$toast('No se puede modificar un pedido ya aprobado', 2000);
|
this.$toast('No se puede modificar un pedido ya aprobado', 2000);
|
||||||
|
|
|
@ -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';
|
||||||
|
|
|
@ -34,11 +34,11 @@ Route::get('/admin/obtener_sesion', function() {
|
||||||
|
|
||||||
Route::middleware(['auth', 'admin'])->group( function () {
|
Route::middleware(['auth', 'admin'])->group( function () {
|
||||||
Route::get('/admin/pedidos', 'AdminController@index')->name('admin_login.index');
|
Route::get('/admin/pedidos', 'AdminController@index')->name('admin_login.index');
|
||||||
|
|
||||||
Route::get('/admin/exportar-planillas-a-pdf/{gdc}', 'AdminController@exportarPlanillasAPdf');
|
Route::get('/admin/exportar-planillas-a-pdf/{gdc}', 'AdminController@exportarPlanillasAPdf');
|
||||||
|
|
||||||
Route::get('/admin/exportar-pedido-a-csv/{gdc}', 'AdminController@exportarPedidoACSV');
|
Route::get('/admin/exportar-pedido-a-csv/{gdc}', 'AdminController@exportarPedidoACSV');
|
||||||
|
|
||||||
Route::get('/admin/exportar-pedido-con-nucleos-a-csv/{gdc}', 'AdminController@exportarPedidoConNucleosACSV');
|
Route::get('/admin/exportar-pedido-con-nucleos-a-csv/{gdc}', 'AdminController@exportarPedidoConNucleosACSV');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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…
Add table
Reference in a new issue