Usando store para pedidos
This commit is contained in:
parent
191f01a398
commit
248b346f78
1 changed files with 8 additions and 14 deletions
|
@ -34,7 +34,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from "vuex";
|
||||
import { mapActions, mapMutations, mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
async mounted() {
|
||||
|
@ -42,32 +42,26 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
searchString: null,
|
||||
pedidos: []
|
||||
searchString: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState('barrio',["grupo_de_compra_id"]),
|
||||
...mapState('barrio',["grupo_de_compra_id","pedidos"]),
|
||||
deshabilitado: function () {
|
||||
return !this.searchString?.trim()
|
||||
|| this.pedidos.some(p => p.nombre.toLowerCase() === this.searchString.toLowerCase())
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('barrio',["getGrupoDeCompra"]),
|
||||
...mapActions('barrio',["getGrupoDeCompra","getPedidos"]),
|
||||
...mapMutations('barrio',["setPedidos"]),
|
||||
onType() {
|
||||
if (!this.searchString) {
|
||||
this.pedidos = [];
|
||||
this.setPedidos([]);
|
||||
return;
|
||||
}
|
||||
axios.get("/api/subpedidos", {
|
||||
params: {
|
||||
nombre: this.searchString,
|
||||
grupo_de_compra: this.grupo_de_compra_id
|
||||
}
|
||||
}).then(response => {
|
||||
this.pedidos = response.data
|
||||
});
|
||||
|
||||
this.getPedidos(this.searchString);
|
||||
},
|
||||
submit() {
|
||||
axios.post("/api/subpedidos", {
|
||||
|
|
Loading…
Add table
Reference in a new issue