Compare commits
35 commits
5a0cf73218
...
5b9908e0b5
Author | SHA1 | Date | |
---|---|---|---|
5b9908e0b5 | |||
f837b7f066 | |||
0dba210a6a | |||
571b02382e | |||
2f071e631d | |||
1e830e3cfd | |||
0381bb0567 | |||
adabd09ea7 | |||
a9ca04811e | |||
5458fae6d9 | |||
5023032ac2 | |||
fb0e13089f | |||
21aa36e3d1 | |||
f81141d18b | |||
8f0d715f8c | |||
45dcf643bf | |||
5468b79562 | |||
08a731673b | |||
94e384c83c | |||
a594e8a049 | |||
fd055cd7c6 | |||
d4df72afe2 | |||
442d35eac8 | |||
154e21fae6 | |||
1a8f9eda18 | |||
128dd05b9a | |||
181fbf924f | |||
8d1eb03ffc | |||
baeff66aaf | |||
1709468f1f | |||
b46b56159b | |||
b8390c4ac6 | |||
36af26a647 | |||
cdf5663b16 | |||
8fbfa75144 |
33 changed files with 528 additions and 485 deletions
|
@ -35,7 +35,7 @@ class SubpedidoController extends Controller
|
|||
$s->nombre = $validado["nombre"];
|
||||
$s->grupo_de_compra_id = $validado["grupo_de_compra_id"];
|
||||
$s->save();
|
||||
return $s;
|
||||
return $this->show($s);
|
||||
}
|
||||
|
||||
protected function validateSubpedido(): array
|
||||
|
@ -57,7 +57,7 @@ class SubpedidoController extends Controller
|
|||
// recibe request, saca producto y cantidad, valida, y pasa a syncProducto en Subpedido
|
||||
public function syncProductos(Subpedido $subpedido) {
|
||||
if ($subpedido->aprobado)
|
||||
return new SubpedidoResource($subpedido);
|
||||
abort(400, "No se puede modificar un pedido aprobado.");
|
||||
|
||||
$valid = request()->validate([
|
||||
'cantidad' => ['integer','required','min:0'],
|
||||
|
@ -84,7 +84,8 @@ class SubpedidoController extends Controller
|
|||
}
|
||||
|
||||
public function syncDevoluciones(Subpedido $subpedido) {
|
||||
if ($subpedido->aprobado) return new SubpedidoResource($subpedido);
|
||||
if ($subpedido->aprobado)
|
||||
abort(400, "No se puede modificar un pedido aprobado.");
|
||||
|
||||
$valid = request()->validate([
|
||||
'total' => 'required|min:0',
|
||||
|
|
|
@ -18,7 +18,7 @@ class RouteController extends Controller
|
|||
|
||||
switch ($request->user()->role_id) {
|
||||
case $barrio->id:
|
||||
return redirect('/productos');
|
||||
return redirect('/pedido');
|
||||
case $admin->id:
|
||||
return redirect('/admin');
|
||||
case $comision->id:
|
||||
|
@ -27,4 +27,8 @@ class RouteController extends Controller
|
|||
abort(400, 'Rol de usuario invalido');
|
||||
}
|
||||
}
|
||||
|
||||
function main(Request $request) {
|
||||
return view('main');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,16 @@ use Illuminate\Support\Facades\Auth;
|
|||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function rol(Request $request) {
|
||||
return ["rol" => UserRole::find($request->user()->role_id)->nombre];
|
||||
}
|
||||
|
||||
public function grupoDeCompra(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$result = [ 'grupo_de_compra' => null, ];
|
||||
$grupo_de_compra = GrupoDeCompra::find($user->grupo_de_compra_id);
|
||||
switch (UserRole::find($user->role_id)->nombre ?? 'error') {
|
||||
switch (UserRole::findOrFail($user->role_id)->nombre) {
|
||||
case 'barrio':
|
||||
$result['grupo_de_compra'] = new GrupoDeCompraReducido($grupo_de_compra);
|
||||
break;
|
||||
|
|
85
resources/js/app.js
vendored
85
resources/js/app.js
vendored
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
import axios from 'axios';
|
||||
import Vue from 'vue';
|
||||
|
||||
window.Vue = require('vue');
|
||||
window.Event = new Vue();
|
||||
window.axios = axios;
|
||||
|
@ -19,12 +20,10 @@ window.bulmaToast = require('bulma-toast');
|
|||
*/
|
||||
import './components';
|
||||
import store from "./store";
|
||||
|
||||
/**
|
||||
* Global methods
|
||||
*/
|
||||
Vue.prototype.$settearProducto = function(cantidad, id) {
|
||||
Event.$emit("sync-subpedido", this.cant, this.producto.id)
|
||||
}
|
||||
Vue.prototype.$toast = function (mensaje, duration = 2000) {
|
||||
return window.bulmaToast.toast({
|
||||
message: mensaje,
|
||||
|
@ -39,86 +38,8 @@ Vue.prototype.$toast = function(mensaje, duration = 2000) {
|
|||
* the page. Then, you may begin adding components to this application
|
||||
* or customize the JavaScript scaffolding to fit your unique needs.
|
||||
*/
|
||||
const app = new Vue({
|
||||
new Vue({
|
||||
el: '#root',
|
||||
store,
|
||||
data() {
|
||||
return {
|
||||
gdc: null,
|
||||
pedido: null,
|
||||
devoluciones: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
productos: function() {
|
||||
return this.pedido.productos
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cantidad(producto) {
|
||||
let pedido = this.productos.some(p => p.id == producto.id)
|
||||
return pedido ? this.productos.find(p => p.id == producto.id).pivot.cantidad : 0
|
||||
},
|
||||
notas(producto) {
|
||||
let pedido = this.productos.some(p => p.id == producto.id);
|
||||
return pedido ? this.productos.find(p => p.id == producto.id).pivot.notas : "";
|
||||
},
|
||||
settearDevoluciones() {
|
||||
axios.get(`/api/grupos-de-compra/${this.gdc}/devoluciones`)
|
||||
.then(response => {
|
||||
this.devoluciones = response.data.devoluciones;
|
||||
});
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('obtener-sesion', () => {
|
||||
if (!window.location.pathname.startsWith('/admin')) {
|
||||
axios.get('/subpedidos/obtener_sesion')
|
||||
.then(response => {
|
||||
this.gdc = response.data.gdc;
|
||||
// this.settearDevoluciones();
|
||||
this.pedido = response.data.subpedido.id;
|
||||
axios.get('/api/subpedidos/' + this.pedido)
|
||||
.then(response => {
|
||||
this.pedido = response.data.data;
|
||||
Event.$emit("pedido-actualizado");
|
||||
});
|
||||
})
|
||||
}
|
||||
})
|
||||
Event.$on('sync-subpedido', (cantidad, id, notas) => {
|
||||
if (this.pedido.aprobado) {
|
||||
this.$toast('No se puede modificar un pedido ya aprobado', 2000);
|
||||
return;
|
||||
}
|
||||
axios.post("/api/subpedidos/" + this.pedido.id + "/sync", {
|
||||
cantidad: cantidad,
|
||||
producto_id: id,
|
||||
notas: notas,
|
||||
}).then((response) => {
|
||||
this.pedido = response.data.data
|
||||
this.$toast('Pedido actualizado exitosamente')
|
||||
Event.$emit("pedido-actualizado");
|
||||
});
|
||||
});
|
||||
// Actualizar monto y notas de devoluciones
|
||||
Event.$on('sync-devoluciones', (total, notas) => {
|
||||
if (this.pedido.aprobado) {
|
||||
this.$toast('No se puede modificar un pedido ya aprobado', 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
axios.post("api/subpedidos/" + this.pedido.id + "/sync_devoluciones", {
|
||||
total: total,
|
||||
notas: notas,
|
||||
}).then((response) => {
|
||||
this.pedido = response.data.data;
|
||||
this.$toast('Pedido actualizado');
|
||||
Event.$emit("pedido-actualizado");
|
||||
});
|
||||
});
|
||||
if (window.location.pathname.startsWith('/productos'))
|
||||
Event.$emit('obtener-sesion')
|
||||
},
|
||||
});
|
||||
|
||||
|
|
30
resources/js/components/AppMain.vue
Normal file
30
resources/js/components/AppMain.vue
Normal file
|
@ -0,0 +1,30 @@
|
|||
<script>
|
||||
import NavBar from "./comunes/NavBar.vue";
|
||||
import { mapActions, mapState } from "vuex";
|
||||
export default {
|
||||
name: 'Main',
|
||||
components: { NavBar },
|
||||
computed: {
|
||||
...mapState('login',["rol"]),
|
||||
},
|
||||
methods: {
|
||||
...mapActions('login',["getRol"]),
|
||||
},
|
||||
async mounted() {
|
||||
await this.getRol();
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div id="app-main">
|
||||
<nav-bar></nav-bar>
|
||||
<pedidos-body v-if="rol === 'barrio'"></pedidos-body>
|
||||
<admin-body v-if="rol === 'admin_barrio'"></admin-body>
|
||||
<compras-body v-if="rol === 'comision'"></compras-body>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div v-if="region_elegida !== null" class="block">
|
||||
<div class="field">
|
||||
<label class="label" :class="admin ? 'has-text-white' : ''">
|
||||
<label class="label" :class="adminUrl ? 'has-text-white' : ''">
|
||||
Seleccioná tu barrio o grupo de compra
|
||||
</label>
|
||||
<div class="control">
|
||||
|
@ -35,7 +35,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
...mapState('login',["region_elegida","grupos_de_compra","grupo_de_compra_elegido"]),
|
||||
...mapGetters('login',["admin"]),
|
||||
...mapGetters('login',["adminUrl"]),
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div v-if="grupo_de_compra_elegido !== null" class="block">
|
||||
<div class="field">
|
||||
<label class="label"
|
||||
:class="admin ? 'has-text-white' : ''">{{ mensajes.mensaje }}</label>
|
||||
:class="adminUrl ? 'has-text-white' : ''">{{ mensajes.mensaje }}</label>
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
<input required class="input" :type="this.passwordType" name="password" :placeholder="mensajes.mensaje">
|
||||
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<p class="help"
|
||||
:class="admin ? 'has-text-white' : ''">{{ mensajes.ayuda }}</p>
|
||||
:class="adminUrl ? 'has-text-white' : ''">{{ mensajes.ayuda }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
|
@ -37,7 +37,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
...mapState('login',["grupo_de_compra_elegido"]),
|
||||
...mapGetters('login',["admin","mensajes"]),
|
||||
...mapGetters('login',["adminUrl","mensajes"]),
|
||||
},
|
||||
methods: {
|
||||
togglePassword() {
|
||||
|
|
|
@ -20,10 +20,10 @@ export default {
|
|||
await this.getRegiones();
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('login',["admin"]),
|
||||
...mapGetters('login',["adminUrl"]),
|
||||
...mapState('login',["grupo_de_compra_elegido"]),
|
||||
nombre() {
|
||||
return `${this.grupo_de_compra_elegido}${this.admin ? '_admin' : ''}`;
|
||||
return `${this.grupo_de_compra_elegido}${this.adminUrl ? '_admin' : ''}`;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -4,14 +4,15 @@
|
|||
<a class="navbar-item" href="https://mps.org.uy">
|
||||
<img src="/assets/logoMPS.png" height="28">
|
||||
</a>
|
||||
<p class="navbar-item hide-below-1024">
|
||||
</p>
|
||||
<p class="navbar-item">
|
||||
<div class="navbar-item" id="datos-pedido" v-if="pedidoDefinido">
|
||||
<p class="hide-below-1024">
|
||||
{{ `Núcleo: ${nombre} - Barrio: ${grupo_de_compra}` }}
|
||||
</p>
|
||||
</div>
|
||||
<chismosa-dropdown
|
||||
v-if="pedidoDefinido"
|
||||
class="hide-above-1023"
|
||||
id="mobile">
|
||||
ariaControls="mobile">
|
||||
</chismosa-dropdown>
|
||||
<a role="button" class="navbar-burger" :class="{'is-active':burgerActiva}" aria-label="menu"
|
||||
aria-expanded="false" data-target="nav-bar" @click="toggleBurger">
|
||||
|
@ -34,7 +35,7 @@
|
|||
<chismosa-dropdown
|
||||
v-if="pedidoDefinido"
|
||||
class="hide-below-1024"
|
||||
id="wide">
|
||||
ariaControls="wide">
|
||||
</chismosa-dropdown>
|
||||
<div class="block navbar-item">
|
||||
<a onclick="event.preventDefault(); document.getElementById('logout-form').submit();"
|
||||
|
@ -50,7 +51,7 @@
|
|||
|
||||
<script>
|
||||
import ChismosaDropdown from '../pedidos/ChismosaDropdown.vue';
|
||||
import { mapActions, mapGetters } from "vuex";
|
||||
import { mapActions, mapGetters, mapMutations, mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
components: { ChismosaDropdown },
|
||||
|
@ -62,9 +63,12 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
...mapGetters('pedido', ["pedidoDefinido"]),
|
||||
...mapState('pedido',["nombre"]),
|
||||
...mapState('barrio',["grupo_de_compra"]),
|
||||
},
|
||||
methods: {
|
||||
...mapActions('productos', ["filtrarProductos"]),
|
||||
...mapMutations('ui',["addMiga"]),
|
||||
toggleBurger() {
|
||||
this.burgerActiva = !this.burgerActiva
|
||||
},
|
||||
|
@ -72,7 +76,7 @@ export default {
|
|||
if (this.burgerActiva)
|
||||
this.toggleBurger();
|
||||
this.filtrarProductos({ filtro: "nombre", valor: this.searchString });
|
||||
Event.$emit('migas-agregar', { nombre: this.searchString });
|
||||
this.addMiga({ nombre: this.searchString });
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="block">
|
||||
<div class="field">
|
||||
<label class="label" :class="admin ? 'has-text-white' : ''">
|
||||
<label class="label" :class="adminUrl ? 'has-text-white' : ''">
|
||||
Seleccioná tu región
|
||||
</label>
|
||||
<div class="control">
|
||||
|
@ -38,7 +38,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
...mapState('login',["regiones","region_elegida"]),
|
||||
...mapGetters('login',["admin"]),
|
||||
...mapGetters('login',["adminUrl"]),
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,32 +1,21 @@
|
|||
<template>
|
||||
<div class="columns ml-3 mr-3">
|
||||
<categorias-container :class="chismosaActiva ? 'hide-below-1024' : ''"></categorias-container>
|
||||
<productos-container :class="chismosaActiva ? 'hide-below-1024' : ''"></productos-container>
|
||||
<chismosa v-show="chismosaActiva"></chismosa>
|
||||
<div id="pedidos-body">
|
||||
<cartel-pedido-aprobado></cartel-pedido-aprobado>
|
||||
<pedido-select-section v-if="!pedidoDefinido"></pedido-select-section>
|
||||
<pedido v-else></pedido>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from "vuex";
|
||||
import Chismosa from "./Chismosa.vue";
|
||||
import ProductosContainer from "./ProductosContainer.vue";
|
||||
import CategoriasContainer from "./CategoriasContainer.vue";
|
||||
import { mapGetters } from "vuex";
|
||||
import PedidoSelectSection from "./PedidoSelectSection.vue";
|
||||
import Pedido from "./Pedido.vue";
|
||||
import CartelPedidoAprobado from "./CartelPedidoAprobado.vue";
|
||||
|
||||
export default {
|
||||
components: { CategoriasContainer, ProductosContainer, Chismosa },
|
||||
data() {
|
||||
return {
|
||||
chismosaActiva: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('productos',["init"]),
|
||||
},
|
||||
async mounted() {
|
||||
await this.init();
|
||||
Event.$on('toggle-chismosa', (activa) => {
|
||||
this.chismosaActiva = activa;
|
||||
});
|
||||
components: { CartelPedidoAprobado, Pedido, Productos: Pedido, PedidoSelectSection },
|
||||
computed: {
|
||||
...mapGetters('pedido',["pedidoDefinido"]),
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,30 +1,17 @@
|
|||
<template>
|
||||
<div v-show="aprobado" class="notification is-warning has-text-centered">
|
||||
<div v-if="aprobado" class="notification is-warning has-text-centered">
|
||||
Tu pedido fue <strong>aprobado</strong>, por lo que no puede ser modificado
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
aprobado: false,
|
||||
name: 'CartelPedidoAprobado',
|
||||
computed: {
|
||||
...mapState('pedido',["aprobado"]),
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('pedido-actualizado', this.actualizarEstado);
|
||||
if (this.$root.pedido != null) {
|
||||
this.actualizarEstado();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
pedidoAprobado: function() {
|
||||
return this.$root.pedido.aprobado;
|
||||
},
|
||||
actualizarEstado: function() {
|
||||
this.aprobado = this.pedidoAprobado();
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from "vuex";
|
||||
import { mapActions, mapMutations, mapState } from "vuex";
|
||||
export default {
|
||||
name: 'CategoriasContainer',
|
||||
computed: {
|
||||
|
@ -29,9 +29,10 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
...mapActions('productos',["seleccionarCategoria"]),
|
||||
...mapMutations('ui',["addMiga"]),
|
||||
seleccionar(categoria) {
|
||||
this.seleccionarCategoria({ categoria: categoria });
|
||||
Event.$emit('migas-agregar', { nombre: categoria });
|
||||
this.addMiga({ nombre: categoria });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,20 +12,20 @@
|
|||
<tfoot>
|
||||
<tr>
|
||||
<th><abbr title="Bonos de Transporte">B. Transporte</abbr></th>
|
||||
<th class="has-text-right">{{ cantidad_bonos_transporte }}</th>
|
||||
<th class="has-text-right">{{ total_bonos_transporte }}</th>
|
||||
<th class="has-text-right">{{ cantidad_transporte }}</th>
|
||||
<th class="has-text-right">{{ total_transporte }}</th>
|
||||
</tr>
|
||||
<tr v-if="this.$root.devoluciones">
|
||||
<tr v-if="devoluciones_habilitadas">
|
||||
<th><p>Devoluciones</p></th>
|
||||
<td>
|
||||
<abbr :title="notas_devoluciones">{{ notas_devoluciones_abbr }}</abbr>
|
||||
<button @click.capture="modificarDevoluciones()" class="button is-warning is-small">
|
||||
<abbr :title="devoluciones_notas">{{ notas_abreviadas }}</abbr>
|
||||
<button @click.capture="toggleDevoluciones()" class="button is-warning is-small">
|
||||
<span class="icon">
|
||||
<i class="fas fa-edit"></i>
|
||||
</span>
|
||||
</button>
|
||||
</td>
|
||||
<th class="has-text-right">-{{ devoluciones }}</th>
|
||||
<th class="has-text-right">-{{ devoluciones_total }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total total</th>
|
||||
|
@ -46,48 +46,29 @@
|
|||
|
||||
<script>
|
||||
import ProductoRow from "./ProductoRow.vue";
|
||||
import { mapMutations, mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
components: { ProductoRow },
|
||||
data() {
|
||||
return {
|
||||
mostrar_tabla: false,
|
||||
cantidad_bonos_transporte: 0,
|
||||
total_bonos_transporte: 0,
|
||||
devoluciones: 0,
|
||||
notas_devoluciones: "",
|
||||
notas_devoluciones_abbr: "",
|
||||
total: 0,
|
||||
productos: [],
|
||||
}
|
||||
computed: {
|
||||
...mapState('barrio',["devoluciones_habilitadas"]),
|
||||
...mapState('pedido',[
|
||||
"productos",
|
||||
"total",
|
||||
"total_transporte",
|
||||
"cantidad_transporte",
|
||||
"devoluciones_total",
|
||||
"devoluciones_notas",
|
||||
]),
|
||||
notas_abreviadas() {
|
||||
return this.devoluciones_notas.substring(0, 15) + (this.devoluciones_notas.length > 15 ? "..." : "");
|
||||
},
|
||||
mostrar_tabla() {
|
||||
return this.productos?.length !== 0;
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('pedido-actualizado', this.pedidoActualizado);
|
||||
Event.$on('toggle-chismosa', this.pedidoActualizado);
|
||||
},
|
||||
methods: {
|
||||
pedidoActualizado: function() {
|
||||
this.mostrar_tabla = this.$root.productos.length > 0;
|
||||
this.cantidad_bonos_transporte = this.cantidadBonosDeTransporte();
|
||||
this.total_bonos_transporte = this.totalBonosDeTransporte();
|
||||
this.devoluciones = this.$root.pedido.devoluciones_total;
|
||||
this.notas_devoluciones = this.$root.pedido.devoluciones_notas;
|
||||
this.notas_devoluciones_abbr = this.notas_devoluciones.substring(0, 15);
|
||||
if (this.notas_devoluciones.length > 15) {
|
||||
this.notas_devoluciones_abbr += "...";
|
||||
}
|
||||
this.total = this.$root.pedido.total;
|
||||
this.productos = this.$root.productos;
|
||||
},
|
||||
modificarDevoluciones: function() {
|
||||
Event.$emit("modificar-devoluciones");
|
||||
},
|
||||
cantidadBonosDeTransporte: function() {
|
||||
return this.$root.pedido.cantidad_transporte;
|
||||
},
|
||||
totalBonosDeTransporte: function() {
|
||||
return this.$root.pedido.total_transporte
|
||||
},
|
||||
...mapMutations('ui',["toggleDevoluciones"]),
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
@ -96,6 +77,7 @@
|
|||
.tabla-chismosa {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fixed-right {
|
||||
position: fixed;
|
||||
overflow-y: auto;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="dropdown is-right navbar-item" :class="{'is-active':activa}">
|
||||
<div class="dropdown is-right navbar-item" :class="{'is-active': show_chismosa}">
|
||||
<div class="dropdown-trigger">
|
||||
<a class="text-a" aria-haspopup="true" :aria-controls="id" @click.capture="toggle">
|
||||
<a class="text-a" aria-haspopup="true" :aria-controls="ariaControls" @click.capture="toggleChismosa">
|
||||
<span class="icon is-small mr-1">
|
||||
<img src="/assets/chismosa.png">
|
||||
</span>
|
||||
|
@ -13,33 +13,23 @@
|
|||
|
||||
<script>
|
||||
import Chismosa from './Chismosa.vue'
|
||||
import { mapMutations, mapState } from "vuex";
|
||||
export default {
|
||||
components: {
|
||||
Chismosa
|
||||
},
|
||||
props: {
|
||||
id: {
|
||||
ariaControls: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
activa: false,
|
||||
total: 0,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('pedido-actualizado', this.actualizar);
|
||||
computed: {
|
||||
...mapState('pedido',["total"]),
|
||||
...mapState('ui',["show_chismosa"]),
|
||||
},
|
||||
methods: {
|
||||
toggle() {
|
||||
this.activa = !this.activa;
|
||||
Event.$emit("toggle-chismosa", this.activa);
|
||||
},
|
||||
actualizar() {
|
||||
this.total = this.$root.pedido.total;
|
||||
},
|
||||
...mapMutations('ui',["toggleChismosa"]),
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,67 +1,71 @@
|
|||
<template>
|
||||
<div v-bind:class="visible ? 'is-active modal' : 'modal'">
|
||||
<div :class="show_devoluciones ? 'is-active modal' : 'modal'">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-card">
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">Devoluciones</p>
|
||||
<button class="delete" aria-label="close" @click.capture="cerrar"></button>
|
||||
<button class="delete" aria-label="close" @click.capture="toggleDevoluciones()"></button>
|
||||
</header>
|
||||
<section class="modal-card-body">
|
||||
<div class="field has-addons is-centered is-thin-centered">
|
||||
<p class="control">
|
||||
Total:
|
||||
<input id="total" class="input" type="number" v-model="total" style="text-align: center">
|
||||
<input id="totalControl" class="input" type="number" v-model="totalControl"
|
||||
style="text-align: center">
|
||||
</p>
|
||||
</div>
|
||||
<div class="field has-addons is-centered is-thin-centered">
|
||||
<p class="control">
|
||||
Notas:
|
||||
<input id="notas" class="input" type="text" v-model.text="notas">
|
||||
<input id="notasControl" class="input" type="text" v-model.text="notasControl">
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
<footer class="modal-card-foot">
|
||||
<button class="button is-success" @click="modificar">Aceptar</button>
|
||||
<button class="button" @click.capture="cerrar">Cancelar</button>
|
||||
<button class="button" @click.capture="toggleDevoluciones()">Cancelar</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapMutations, mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
name: 'DevolucionesModal',
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
total: 0,
|
||||
notas: "",
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
miga: function() {
|
||||
return {
|
||||
nombre: "Devoluciones",
|
||||
href: "#devoluciones",
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
cerrar() {
|
||||
this.visible = false;
|
||||
Event.$emit("migas-pop");
|
||||
},
|
||||
modificar() {
|
||||
Event.$emit('sync-devoluciones', this.total, this.notas);
|
||||
this.cerrar();
|
||||
totalControl: 0,
|
||||
notasControl: "",
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('modificar-devoluciones', () => {
|
||||
this.visible = true;
|
||||
this.total = this.$root.pedido.devoluciones_total;
|
||||
this.notas = this.$root.pedido.devoluciones_notas;
|
||||
Event.$emit("migas-agregar", this.miga);
|
||||
});
|
||||
this.actualizar();
|
||||
},
|
||||
watch: {
|
||||
cantidadEnChismosa() {
|
||||
this.actualizar();
|
||||
},
|
||||
notasEnChismosa() {
|
||||
this.actualizar();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState('ui', ["show_devoluciones"]),
|
||||
...mapState('pedido', ["devoluciones_total", "devoluciones_notas"])
|
||||
},
|
||||
methods: {
|
||||
...mapMutations('ui', ["toggleDevoluciones"]),
|
||||
...mapActions('pedido', ["modificarDevoluciones"]),
|
||||
modificar() {
|
||||
this.modificarDevoluciones({ monto: this.totalControl, notas: this.notasControl });
|
||||
this.toggleDevoluciones();
|
||||
},
|
||||
actualizar() {
|
||||
this.totalControl = this.devoluciones_total;
|
||||
this.notasControl = this.devoluciones_notas;
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
|
@ -3,7 +3,7 @@
|
|||
aria-label="breadcrumbs" v-show="visible">
|
||||
<ul class="mt-4">
|
||||
<li v-for="(miga, i) in migas" :key="i" :class="{'is-active': i === migaActiva}">
|
||||
<a :href="miga.href" v-text="miga.nombre"
|
||||
<a @click="clickMiga({ miga: miga })" v-text="miga.nombre"
|
||||
:class="{'has-text-danger': i !== migaActiva}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -11,39 +11,23 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import { mapActions, mapGetters, mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
initial: [{ nombre: 'Categorías', href: '/productos' }],
|
||||
migas: [{ nombre: 'Categorías', href: '/productos' }],
|
||||
}
|
||||
methods: {
|
||||
...mapActions('productos',["getProductos"]),
|
||||
...mapActions('ui',["clickMiga"]),
|
||||
},
|
||||
computed: {
|
||||
...mapState('ui',["migas"]),
|
||||
...mapGetters('pedido',["pedidoDefinido"]),
|
||||
visible: function () {
|
||||
visible() {
|
||||
return this.migas.length > 0
|
||||
},
|
||||
migaActiva: function () {
|
||||
migaActiva() {
|
||||
return this.migas.length - 1
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('migas-setear-como-inicio', (miga) => {
|
||||
this.migas = [];
|
||||
this.migas.push(miga);
|
||||
});
|
||||
Event.$on('migas-agregar', (miga) => {
|
||||
this.migas.push(miga);
|
||||
});
|
||||
Event.$on('migas-reset', () => {
|
||||
this.migas = this.initial;
|
||||
});
|
||||
Event.$on('migas-pop', () => {
|
||||
this.migas.pop();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
36
resources/js/components/pedidos/Pedido.vue
Normal file
36
resources/js/components/pedidos/Pedido.vue
Normal file
|
@ -0,0 +1,36 @@
|
|||
<script >
|
||||
import { defineComponent } from "vue";
|
||||
import { mapActions, mapState } from "vuex";
|
||||
import SubpedidoSelect from "./SubpedidoSelect.vue";
|
||||
import CategoriasContainer from "./CategoriasContainer.vue";
|
||||
import ProductosContainer from "./ProductosContainer.vue";
|
||||
import Chismosa from "./Chismosa.vue";
|
||||
import DevolucionesModal from "./DevolucionesModal.vue";
|
||||
import CartelPedidoAprobado from "./CartelPedidoAprobado.vue";
|
||||
|
||||
export default defineComponent({
|
||||
components: { CartelPedidoAprobado, DevolucionesModal, SubpedidoSelect, CategoriasContainer, ProductosContainer, Chismosa },
|
||||
computed: {
|
||||
...mapState('ui',["show_chismosa","show_devoluciones"])
|
||||
},
|
||||
methods: {
|
||||
...mapActions('productos',["init"]),
|
||||
},
|
||||
async mounted() {
|
||||
await this.init();
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="columns ml-3 mr-3" v-else>
|
||||
<categorias-container :class="show_chismosa ? 'hide-below-1024' : ''"></categorias-container>
|
||||
<productos-container :class="show_chismosa ? 'hide-below-1024' : ''"></productos-container>
|
||||
<chismosa v-show="show_chismosa"></chismosa>
|
||||
<devoluciones-modal v-show="show_devoluciones"></devoluciones-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
26
resources/js/components/pedidos/PedidoSelectSection.vue
Normal file
26
resources/js/components/pedidos/PedidoSelectSection.vue
Normal file
|
@ -0,0 +1,26 @@
|
|||
<script>
|
||||
import { defineComponent } from "vue";
|
||||
import SubpedidoSelect from "./SubpedidoSelect.vue";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default defineComponent({
|
||||
components: { SubpedidoSelect },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="section">
|
||||
<div id="root" class="container">
|
||||
<h1 class="title">
|
||||
Pedidos MPS
|
||||
</h1>
|
||||
<p class="subtitle">
|
||||
Bienvenidx a la aplicación de pedidos del <strong>Mercado Popular de Subsistencia</strong>
|
||||
</p>
|
||||
<subpedido-select></subpedido-select>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
|
@ -7,29 +7,31 @@
|
|||
</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<input id="cantidad" v-model="cantidad" class="input is-small" type="number" style="text-align: center">
|
||||
<input id="cantidad" v-model="cantidadControl" class="input is-small" type="number"
|
||||
style="text-align: center">
|
||||
</div>
|
||||
<div class="control" @click="incrementar();">
|
||||
<button class="button is-small">
|
||||
<i class="fa fa-solid fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
<button :disabled="disableConfirm()" class="button is-small is-success ml-1" @click="confirmar()">
|
||||
<button :disabled="!hayCambios" class="button is-small is-success ml-1" @click="confirmar()">
|
||||
<span class="icon">
|
||||
<i class="fas fa-check"></i>
|
||||
</span>
|
||||
</button>
|
||||
<button :disabled="!puedeBorrar()" class="button is-small is-danger ml-1" @click="borrar()">
|
||||
<button :disabled="!puedeBorrar" class="button is-small is-danger ml-1" @click="borrar()">
|
||||
<span class="icon">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="producto.requiere_notas" v-bind:class="{'has-icons-right': notas_warning_visible}" class="control is-full-width has-icons-left">
|
||||
<div v-if="requiere_notas" :class="{'has-icons-right': notas_warning_visible}"
|
||||
class="control is-full-width has-icons-left">
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-sticky-note"></i>
|
||||
</span>
|
||||
<input v-model="notas" v-bind:class="{'is-danger': notas_warning_visible}" id="notas" class="input" type="text" placeholder="Talle o color" />
|
||||
<input v-model="notasControl" v-bind:class="{'is-danger': notas_warning_visible}" id="notas" class="input" type="text" placeholder="Talle o color"/>
|
||||
<span v-if="notas_warning_visible" class="icon is-small is-right">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
</span>
|
||||
|
@ -43,70 +45,81 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
producto: Object
|
||||
producto_id: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
requiere_notas: {
|
||||
type: Number,
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
cantidad: this.cantidadEnChismosa(),
|
||||
notas: this.notasEnChismosa(),
|
||||
cantidadControl: 0,
|
||||
notasControl: '',
|
||||
notas_warning_visible: false,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
cantidadEnChismosa() {
|
||||
this.actualizar();
|
||||
},
|
||||
notasEnChismosa() {
|
||||
this.actualizar();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('sync-subpedido', (cantidad, productoId, notas) => {
|
||||
if (this.producto.id === productoId)
|
||||
this.sincronizar(cantidad, notas);
|
||||
});
|
||||
this.actualizar();
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('pedido', ["enChismosa", "cantidad", "notas"]),
|
||||
cantidadEnChismosa() {
|
||||
return this.cantidad(this.producto_id);
|
||||
},
|
||||
notasEnChismosa() {
|
||||
return this.notas(this.producto_id);
|
||||
},
|
||||
hayCambios() {
|
||||
return this.cantidadControl !== this.cantidadEnChismosa || this.notasControl !== this.notasEnChismosa;
|
||||
},
|
||||
puedeBorrar() {
|
||||
return this.enChismosa(this.producto_id);
|
||||
},
|
||||
faltaNotas() {
|
||||
return this.requiere_notas && this.cantidadControl > 0 && !this.notasControl;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
notasEnChismosa() {
|
||||
return this.producto.pivot !== undefined ? this.producto.pivot.notas : "";
|
||||
},
|
||||
cantidadEnChismosa() {
|
||||
return this.producto.pivot !== undefined ? this.producto.pivot.cantidad : 0;
|
||||
},
|
||||
...mapActions('pedido', ["modificarChismosa"]),
|
||||
decrementar() {
|
||||
this.cantidad -= 1;
|
||||
this.cantidadControl -= 1;
|
||||
},
|
||||
incrementar() {
|
||||
this.cantidad += 1;
|
||||
this.cantidadControl += 1;
|
||||
},
|
||||
confirmar() {
|
||||
if (this.warningNotas()) {
|
||||
borrar() {
|
||||
this.cantidadControl = 0;
|
||||
this.confirmar();
|
||||
},
|
||||
async confirmar() {
|
||||
if (this.faltaNotas) {
|
||||
this.notas_warning_visible = true;
|
||||
return;
|
||||
}
|
||||
console.log("Emit sync " + this.cantidad + " " + this.notas);
|
||||
Event.$emit('sync-subpedido', this.cantidad, this.producto.id, this.notas);
|
||||
await this.modificarChismosa({
|
||||
producto_id: this.producto_id,
|
||||
cantidad: this.cantidadControl,
|
||||
notas: this.notasControl
|
||||
});
|
||||
},
|
||||
borrar() {
|
||||
this.cantidad = 0;
|
||||
this.confirmar();
|
||||
},
|
||||
sincronizar(cantidad, notas) {
|
||||
this.notas_warning_visible = false;
|
||||
this.notas = notas;
|
||||
this.cantidad = cantidad;
|
||||
if (this.producto.pivot !== undefined) {
|
||||
this.producto.pivot.cantidad = cantidad;
|
||||
this.producto.pivot.notas = notas;
|
||||
}
|
||||
},
|
||||
hayCambios() {
|
||||
if (this.cantidad != this.cantidadEnChismosa()) return true;
|
||||
|
||||
return this.cantidad > 0 && this.notas != this.notasEnChismosa();
|
||||
},
|
||||
puedeBorrar() {
|
||||
return this.cantidadEnChismosa() > 0;
|
||||
},
|
||||
warningNotas() {
|
||||
return this.producto.requiere_notas && this.cantidad > 0 && !this.notas;
|
||||
},
|
||||
disableConfirm() {
|
||||
return !this.hayCambios();
|
||||
actualizar() {
|
||||
this.cantidadControl = this.cantidadEnChismosa;
|
||||
this.notasControl = this.notasEnChismosa;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +146,7 @@
|
|||
.is-danger {
|
||||
background-color: #fca697;
|
||||
}
|
||||
|
||||
.is-danger::placeholder {
|
||||
color: #fff;
|
||||
opacity: 1; /* Firefox */
|
||||
|
|
|
@ -1,53 +1,25 @@
|
|||
<script>
|
||||
import ProductoCantidad from "./ProductoCantidad.vue";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
name: "ProductoCard",
|
||||
components: { ProductoCantidad },
|
||||
props: {
|
||||
producto: Object
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
cantidad: this.producto.cantidad,
|
||||
enChismosa: this.producto.cantidad,
|
||||
notas: this.producto.notas,
|
||||
producto: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Event.$on('sync-subpedido', (cantidad, productoId, notas) => {
|
||||
if (this.producto.id === productoId)
|
||||
this.sincronizar(cantidad, notas);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
decrementar() {
|
||||
this.cantidad -= 1;
|
||||
},
|
||||
incrementar() {
|
||||
this.cantidad += 1;
|
||||
},
|
||||
confirmar() {
|
||||
Event.$emit('sync-subpedido', this.cantidad, this.producto.id, this.notas);
|
||||
},
|
||||
borrar() {
|
||||
this.cantidad = 0;
|
||||
this.confirmar();
|
||||
},
|
||||
sincronizar(cantidad, notas) {
|
||||
this.cantidad = cantidad;
|
||||
this.producto.cantidad = cantidad;
|
||||
this.enChismosa = cantidad;
|
||||
this.notas = notas;
|
||||
this.producto.notas = notas;
|
||||
},
|
||||
hayCambios() {
|
||||
return this.cantidad !== this.enChismosa || this.notas !== this.producto.notas;
|
||||
},
|
||||
puedeBorrar() {
|
||||
return this.enChismosa > 0;
|
||||
computed: {
|
||||
...mapGetters('pedido',["enChismosa", "cantidad"]),
|
||||
fuePedido() {
|
||||
return this.enChismosa(this.producto.id);
|
||||
},
|
||||
cantidadEnChismosa() {
|
||||
return this.cantidad(this.producto.id);
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -59,7 +31,7 @@ export default {
|
|||
<p class="title is-6">
|
||||
{{ producto.nombre }}
|
||||
</p>
|
||||
<span class="subtitle is-7 hidden-from-tablet" v-if="enChismosa">{{ enChismosa }} en chismosa</span>
|
||||
<span class="subtitle is-7 hidden-from-tablet" v-if="fuePedido">{{ cantidadEnChismosa }}</span>
|
||||
</div>
|
||||
<div class="column is-one-quarter has-text-right">
|
||||
<p class="has-text-weight-bold has-text-primary">
|
||||
|
@ -73,13 +45,16 @@ export default {
|
|||
</div>
|
||||
<footer class="columns">
|
||||
<div class="column is-three-quarters">
|
||||
<producto-cantidad :producto="producto"></producto-cantidad>
|
||||
<producto-cantidad
|
||||
:producto_id="producto.id"
|
||||
:requiere_notas="producto.requiere_notas">
|
||||
</producto-cantidad>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p class="subtitle is-7 is-hidden-mobile" v-if="enChismosa > 0">{{ enChismosa }} en chismosa</p>
|
||||
<p class="subtitle is-7 is-hidden-mobile" v-if="fuePedido">{{ cantidadEnChismosa }} en chismosa</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div><!-- END BOX -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -2,18 +2,25 @@
|
|||
<tr>
|
||||
<td>{{ this.producto.nombre }}</td>
|
||||
<td class="has-text-right">
|
||||
<producto-cantidad :producto="producto"></producto-cantidad>
|
||||
<producto-cantidad
|
||||
:producto_id="producto.id"
|
||||
:requiere_notas="producto.requiere_notas">
|
||||
</producto-cantidad>
|
||||
</td>
|
||||
<td class="has-text-right">{{ this.producto.pivot.total }}</td>
|
||||
<td class="has-text-right">{{ cantidad(producto.id) }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
<script>
|
||||
import ProductoCantidad from "./ProductoCantidad.vue";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
components: { ProductoCantidad },
|
||||
props: {
|
||||
producto: Object
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('pedido',["cantidad"]),
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<template>
|
||||
<div v-show="visible" class="column">
|
||||
<div class="columns is-multiline is-mobile">
|
||||
<producto-card v-for="(producto,i) in this.productos" :key="i" :producto="producto">
|
||||
</producto-card><!-- END BLOCK COLUMN -->
|
||||
</div><!-- END COLUMNS -->
|
||||
</div><!-- END CONTAINER -->
|
||||
<producto-card
|
||||
v-for="(producto,i) in this.productos"
|
||||
:key="i"
|
||||
:producto="producto">
|
||||
</producto-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -20,8 +23,8 @@ export default {
|
|||
},
|
||||
miga: function () {
|
||||
return {
|
||||
nombre: this.valor,
|
||||
href: "#" + this.valor
|
||||
nombre: this.filtro.valor,
|
||||
href: "#" + this.filtro.valor
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
v-text="subpedidoExistente.nombre"></p>
|
||||
</div>
|
||||
<div class="buttons column is-half-mobile is-one-third-desktop is-one-third-tablet">
|
||||
<button class="button is-danger" @click="elegirSubpedido(subpedidoExistente)">Continuar pedido
|
||||
<button class="button is-danger" @click="elegirPedido({ pedido: subpedidoExistente })">Continuar pedido
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -37,6 +37,7 @@
|
|||
import { mapActions, mapMutations, mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
name: 'SubpedidoSelect',
|
||||
async mounted() {
|
||||
await this.getGrupoDeCompra();
|
||||
},
|
||||
|
@ -55,33 +56,18 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
...mapActions('barrio',["getGrupoDeCompra","getPedidos"]),
|
||||
...mapActions('pedido',["crearPedido"]),
|
||||
...mapActions('pedido',["crearPedido","elegirPedido"]),
|
||||
...mapMutations('barrio',["setPedidos"]),
|
||||
onType() {
|
||||
if (!this.searchString) {
|
||||
this.setPedidos([]);
|
||||
return;
|
||||
}
|
||||
|
||||
this.getPedidos(this.searchString);
|
||||
},
|
||||
async submit() {
|
||||
await this.crearPedido({ nombre: this.searchString, grupo_de_compra_id: this.grupo_de_compra_id });
|
||||
this.guardarSubpedidoEnSesion({ id: this.pedido_id, nombre: this.nombre });
|
||||
},
|
||||
elegirSubpedido(subpedido) {
|
||||
//lo guardamos en sesion
|
||||
this.guardarSubpedidoEnSesion(subpedido);
|
||||
},
|
||||
guardarSubpedidoEnSesion(subpedido) {
|
||||
axios.post("/subpedidos/guardar_sesion", {
|
||||
subpedido: subpedido,
|
||||
grupo_de_compra_id: this.grupo_de_compra_id
|
||||
}).then(_ => {
|
||||
Event.$emit('obtener-sesion')
|
||||
window.location.href = 'productos';
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
2
resources/js/store/index.js
vendored
2
resources/js/store/index.js
vendored
|
@ -5,6 +5,7 @@ import login from "./modules/login";
|
|||
import pedido from "./modules/pedido";
|
||||
import barrio from "./modules/barrio";
|
||||
import productos from "./modules/productos";
|
||||
import ui from "./modules/ui";
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
|
@ -15,5 +16,6 @@ export default new Vuex.Store({
|
|||
pedido,
|
||||
barrio,
|
||||
productos,
|
||||
ui,
|
||||
},
|
||||
});
|
||||
|
|
5
resources/js/store/modules/admin.js
vendored
5
resources/js/store/modules/admin.js
vendored
|
@ -38,9 +38,12 @@ const actions = {
|
|||
const response = await axios.get('/user/grupo_de_compra');
|
||||
commit('setState', response.data);
|
||||
},
|
||||
async setAprobacionPedido({ commit }, { pedido_id, aprobacion }){
|
||||
async setAprobacionPedido({ commit, dispatch }, { pedido_id, aprobacion }){
|
||||
await axios.post("/api/admin/subpedidos/" + pedido_id + "/aprobacion", { aprobacion: aprobacion });
|
||||
await actions.getGrupoDeCompra({ commit });
|
||||
dispatch("ui/toast",
|
||||
{ mensaje: `Pedido ${aprobacion ? '' : 'des' }aprobado con éxito.` },
|
||||
{ root: true });
|
||||
},
|
||||
async toggleCaracteristica({ commit }, { caracteristica_id }) {
|
||||
await axios.post(`/api/grupos-de-compra/${state.grupo_de_compra_id}/${caracteristica_id}`);
|
||||
|
|
14
resources/js/store/modules/login.js
vendored
14
resources/js/store/modules/login.js
vendored
|
@ -5,6 +5,7 @@ const state = {
|
|||
grupos_de_compra: null,
|
||||
region_elegida: null,
|
||||
grupo_de_compra_elegido: null,
|
||||
rol: null,
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
|
@ -18,6 +19,9 @@ const mutations = {
|
|||
selectGrupoDeCompra(state, { grupo_de_compra }) {
|
||||
state.grupo_de_compra_elegido = grupo_de_compra;
|
||||
},
|
||||
setRol(state, { rol }) {
|
||||
state.rol = rol;
|
||||
},
|
||||
};
|
||||
|
||||
const actions = {
|
||||
|
@ -28,17 +32,21 @@ const actions = {
|
|||
async selectRegion({ commit }, { region }) {
|
||||
const response = await axios.get("/api/grupos-de-compra");
|
||||
commit('setRegionYBarrios', { region: region, grupos_de_compra: response.data[region] });
|
||||
},
|
||||
async getRol({ commit }) {
|
||||
const response = await axios.get("/user/rol");
|
||||
commit('setRol', { rol: response.data.rol });
|
||||
}
|
||||
};
|
||||
|
||||
const getters = {
|
||||
admin() {
|
||||
adminUrl() {
|
||||
return window.location.pathname.startsWith('/admin');
|
||||
},
|
||||
mensajes() {
|
||||
return {
|
||||
mensaje: `Contraseña de ${getters.admin() ? 'administración ' : ''}del barrio`,
|
||||
ayuda: `Si no la sabés, consultá a ${getters.admin() ? 'la comisión informática ' : 'tus compañerxs'}.`
|
||||
mensaje: `Contraseña de ${getters.adminUrl() ? 'administración ' : ''}del barrio`,
|
||||
ayuda: `Si no la sabés, consultá a ${getters.adminUrl() ? 'la comisión informática ' : 'tus compañerxs'}.`
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
46
resources/js/store/modules/pedido.js
vendored
46
resources/js/store/modules/pedido.js
vendored
|
@ -1,3 +1,5 @@
|
|||
import axios from "axios";
|
||||
|
||||
const state = {
|
||||
lastFetch: null,
|
||||
pedido_id: null,
|
||||
|
@ -34,20 +36,52 @@ const actions = {
|
|||
nombre: nombre,
|
||||
grupo_de_compra_id: grupo_de_compra_id
|
||||
});
|
||||
commit('setState', response.data);
|
||||
},
|
||||
async getPedido({ commit }, pedido_id) {
|
||||
const response = await axios.get(`/api/subpedidos/${pedido_id}`);
|
||||
commit('setState', response.data.data);
|
||||
},
|
||||
async modificarChismosa({ commit }, producto_id, cantidad, notas) {},
|
||||
async modificarDevoluciones({ commit }, monto, notas) {}
|
||||
async elegirPedido({ commit }, { pedido }) {
|
||||
const response = await axios.get(`/api/subpedidos/${pedido.id}`);
|
||||
commit('setState', response.data.data);
|
||||
},
|
||||
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
||||
try {
|
||||
const response = await axios.post("/api/subpedidos/" + state.pedido_id + "/sync", {
|
||||
cantidad: cantidad,
|
||||
producto_id: producto_id,
|
||||
notas: notas,
|
||||
});
|
||||
commit('setState', response.data.data);
|
||||
dispatch("ui/toast", { mensaje: 'Pedido modificado con éxito' }, { root: true });
|
||||
} catch (error) {
|
||||
dispatch("ui/error", { error: error }, { root: true });
|
||||
}
|
||||
},
|
||||
async modificarDevoluciones({ commit, dispatch }, { monto, notas }) {
|
||||
try {
|
||||
const response = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", {
|
||||
total: monto,
|
||||
notas: notas,
|
||||
});
|
||||
commit('setState', response.data.data);
|
||||
dispatch("ui/toast", { mensaje: 'Devoluciones modificadas con éxito' }, { root: true });
|
||||
} catch (error) {
|
||||
dispatch("ui/error", { error: error }, { root: true });
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const getters = {
|
||||
pedidoDefinido() {
|
||||
return state.lastFetch !== null;
|
||||
},
|
||||
enChismosa() {
|
||||
return ((producto_id) => state.productos.some(p => p.id === producto_id));
|
||||
},
|
||||
cantidad() {
|
||||
return ((producto_id) => state.productos.find(p => p.id === producto_id)?.pivot.cantidad ?? 0);
|
||||
},
|
||||
notas() {
|
||||
return ((producto_id) => state.productos.find(p => p.id === producto_id)?.pivot.notas ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
48
resources/js/store/modules/ui.js
vendored
Normal file
48
resources/js/store/modules/ui.js
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { dropWhile } from "lodash/array";
|
||||
|
||||
const state = {
|
||||
show_chismosa: false,
|
||||
show_devoluciones: false,
|
||||
miga_inicial: { nombre: 'Categorias', action: 'productos/getProductos' },
|
||||
migas: [{ nombre: 'Categorias', action: 'productos/getProductos' }],
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
toggleChismosa(state) {
|
||||
state.show_chismosa = !state.show_chismosa;
|
||||
},
|
||||
toggleDevoluciones(state) {
|
||||
state.show_devoluciones = !state.show_devoluciones;
|
||||
},
|
||||
addMiga(state, miga) {
|
||||
state.migas.push(miga);
|
||||
},
|
||||
};
|
||||
|
||||
const actions = {
|
||||
clickMiga({ dispatch }, { miga }) {
|
||||
dispatch(miga.action, null, { root: true });
|
||||
state.migas = dropWhile(state.migas.reverse(),(m => m.nombre !== miga.nombre)).reverse();
|
||||
},
|
||||
toast(_, { mensaje }) {
|
||||
return window.bulmaToast.toast({
|
||||
message: mensaje,
|
||||
duration: 2000,
|
||||
type: 'is-danger',
|
||||
position: 'bottom-center',
|
||||
});
|
||||
},
|
||||
error({ dispatch }, { error }) {
|
||||
const errorMsg = error.response && error.response.data && error.response.data.message
|
||||
? error.response.data.message
|
||||
: error.message;
|
||||
dispatch("toast", { mensaje: errorMsg });
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
};
|
|
@ -7,7 +7,7 @@
|
|||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<title>{{ session("subpedido_nombre") ? "Pedido de " . session("subpedido_nombre") . " - " . config('app.name', 'Pedidos del MPS') : config('app.name', 'Pedidos del MPS')}}</title>
|
||||
<title>{{ config('app.name', 'Pedidos del MPS') }}</title>
|
||||
<link rel="icon" type="image/x-icon" href="/assets/favicon.png">
|
||||
|
||||
<!-- Fonts -->
|
||||
|
@ -26,7 +26,6 @@
|
|||
</comunes-nav-bar>
|
||||
<pedidos-nav-migas></pedidos-nav-migas>
|
||||
<main id="main" class="py-4 has-top-padding">
|
||||
<pedidos-cartel-pedido-aprobado></pedidos-cartel-pedido-aprobado>
|
||||
@yield('content')
|
||||
</main>
|
||||
</div>
|
||||
|
|
8
resources/views/main.blade.php
Normal file
8
resources/views/main.blade.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<app-main></app-main>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
@endsection
|
|
@ -1,17 +1,7 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<section class="section">
|
||||
<div id="root" class="container">
|
||||
<h1 class="title">
|
||||
Pedidos MPS
|
||||
</h1>
|
||||
<p class="subtitle">
|
||||
Bienvenidx a la aplicación de pedidos del <strong>Mercado Popular de Subsistencia</strong>
|
||||
</p>
|
||||
<pedidos-subpedido-select></pedidos-subpedido-select>
|
||||
</div>
|
||||
</section>
|
||||
<app-main></app-main>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
|
|
|
@ -25,10 +25,13 @@ Auth::routes(['register' => false]);
|
|||
Route::get('/', 'RouteController@home')->name('home');
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/user/rol', 'UserController@rol')->name('user.rol');
|
||||
Route::get('/user/grupo_de_compra', 'UserController@grupoDeCompra');
|
||||
});
|
||||
|
||||
Route::middleware(['auth', 'role:barrio'])->group(function() {
|
||||
Route::get('/pedido', 'RouteController@main')->name('pedido');
|
||||
|
||||
Route::get('/productos', 'ProductoController@index')->name('productos.index');
|
||||
|
||||
Route::name('subpedidos.')->prefix("subpedidos")->group(function() {
|
||||
|
@ -69,7 +72,7 @@ Route::middleware(['auth', 'role:barrio'])->group( function() {
|
|||
Route::get('/admin/login', 'AdminController@show')->name('admin.login');
|
||||
|
||||
Route::middleware(['auth', 'role:admin_barrio'])->group(function () {
|
||||
Route::get('/admin', 'AdminController@index')->name('admin.pedidos');
|
||||
Route::get('/admin', 'RouteController@main')->name('admin');
|
||||
|
||||
Route::get('/admin/exportar-planillas-a-pdf/{gdc}', 'AdminController@exportarPedidosAPdf');
|
||||
|
||||
|
@ -81,7 +84,7 @@ Route::middleware(['auth', 'role:admin_barrio'])->group( function () {
|
|||
Route::get('/compras/login', 'ComprasController@show')->name('compras.login');
|
||||
|
||||
Route::middleware(['auth', 'role:comision'])->group( function() {
|
||||
Route::get('/compras', 'ComprasController@indexPedidos')->name('compras.pedidos');
|
||||
Route::get('/compras', 'RouteController@main')->name('compras');
|
||||
Route::get('/compras/pedidos/descargar', 'ComprasController@descargarPedidos')->name('compras.pedidos.descargar');
|
||||
Route::get('/compras/pedidos/notas', 'ComprasController@descargarNotas')->name('compras.pedidos.descargar');
|
||||
Route::get('/compras/pedidos/pdf', 'ComprasController@pdf')->name('compras.pedidos.pdf');
|
||||
|
|
Loading…
Add table
Reference in a new issue