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>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapActions, mapState } from "vuex";
|
import { mapActions, mapMutations, mapState } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
@ -42,32 +42,26 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
searchString: null,
|
searchString: null
|
||||||
pedidos: []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('barrio',["grupo_de_compra_id"]),
|
...mapState('barrio',["grupo_de_compra_id","pedidos"]),
|
||||||
deshabilitado: function () {
|
deshabilitado: function () {
|
||||||
return !this.searchString?.trim()
|
return !this.searchString?.trim()
|
||||||
|| this.pedidos.some(p => p.nombre.toLowerCase() === this.searchString.toLowerCase())
|
|| this.pedidos.some(p => p.nombre.toLowerCase() === this.searchString.toLowerCase())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('barrio',["getGrupoDeCompra"]),
|
...mapActions('barrio',["getGrupoDeCompra","getPedidos"]),
|
||||||
|
...mapMutations('barrio',["setPedidos"]),
|
||||||
onType() {
|
onType() {
|
||||||
if (!this.searchString) {
|
if (!this.searchString) {
|
||||||
this.pedidos = [];
|
this.setPedidos([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
axios.get("/api/subpedidos", {
|
|
||||||
params: {
|
this.getPedidos(this.searchString);
|
||||||
nombre: this.searchString,
|
|
||||||
grupo_de_compra: this.grupo_de_compra_id
|
|
||||||
}
|
|
||||||
}).then(response => {
|
|
||||||
this.pedidos = response.data
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
axios.post("/api/subpedidos", {
|
axios.post("/api/subpedidos", {
|
||||||
|
|
Loading…
Add table
Reference in a new issue