Usando sesion para recordar el pedido
This commit is contained in:
parent
5b9908e0b5
commit
7140796ccd
4 changed files with 23 additions and 10 deletions
|
@ -5,7 +5,6 @@ namespace App\Http\Controllers;
|
||||||
use App\Subpedido;
|
use App\Subpedido;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class SessionController extends Controller
|
class SessionController extends Controller
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters } from "vuex";
|
import { mapActions, mapGetters } from "vuex";
|
||||||
import PedidoSelectSection from "./PedidoSelectSection.vue";
|
import PedidoSelectSection from "./PedidoSelectSection.vue";
|
||||||
import Pedido from "./Pedido.vue";
|
import Pedido from "./Pedido.vue";
|
||||||
import CartelPedidoAprobado from "./CartelPedidoAprobado.vue";
|
import CartelPedidoAprobado from "./CartelPedidoAprobado.vue";
|
||||||
|
@ -17,5 +17,13 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('pedido',["pedidoDefinido"]),
|
...mapGetters('pedido',["pedidoDefinido"]),
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions('productos',["init"]),
|
||||||
|
...mapActions('pedido',["getSesion"]),
|
||||||
|
},
|
||||||
|
async mounted() {
|
||||||
|
await this.init();
|
||||||
|
await this.getSesion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -13,12 +13,6 @@ export default defineComponent({
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('ui',["show_chismosa","show_devoluciones"])
|
...mapState('ui',["show_chismosa","show_devoluciones"])
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
...mapActions('productos',["init"]),
|
|
||||||
},
|
|
||||||
async mounted() {
|
|
||||||
await this.init();
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
16
resources/js/store/modules/pedido.js
vendored
16
resources/js/store/modules/pedido.js
vendored
|
@ -31,15 +31,27 @@ const mutations = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
async crearPedido({ commit }, { nombre, grupo_de_compra_id }) {
|
async guardarSesion(_, { pedido_id }) {
|
||||||
|
await axios.post("/subpedidos/sesion", { id: pedido_id });
|
||||||
|
},
|
||||||
|
async getSesion({ commit }) {
|
||||||
|
const sesion = await axios.get("/subpedidos/sesion");
|
||||||
|
if (sesion.data) {
|
||||||
|
const response = await axios.get(`/api/subpedidos/${sesion.data}`);
|
||||||
|
commit('setState', response.data.data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async crearPedido({ commit, dispatch }, { nombre, grupo_de_compra_id }) {
|
||||||
const response = await axios.post("/api/subpedidos", {
|
const response = await axios.post("/api/subpedidos", {
|
||||||
nombre: nombre,
|
nombre: nombre,
|
||||||
grupo_de_compra_id: grupo_de_compra_id
|
grupo_de_compra_id: grupo_de_compra_id
|
||||||
});
|
});
|
||||||
|
dispatch("guardarSesion", { pedido_id: response.data.data.id});
|
||||||
commit('setState', response.data.data);
|
commit('setState', response.data.data);
|
||||||
},
|
},
|
||||||
async elegirPedido({ commit }, { pedido }) {
|
async elegirPedido({ commit, dispatch }, { pedido }) {
|
||||||
const response = await axios.get(`/api/subpedidos/${pedido.id}`);
|
const response = await axios.get(`/api/subpedidos/${pedido.id}`);
|
||||||
|
dispatch("guardarSesion", { pedido_id: response.data.data.id})
|
||||||
commit('setState', response.data.data);
|
commit('setState', response.data.data);
|
||||||
},
|
},
|
||||||
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue