Created
July 24, 2019 18:21
-
-
Save pedryvo/1d235fb61385b97dcd99cbac5761f5d9 to your computer and use it in GitHub Desktop.
Vue paginator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ha uma chamada para a API direto na renderizacao do componente. | |
<vpaginator ref="paginator" :options="$defaultPaginatorConfig" resource_url="/atlas/planejamentos" @update="updateResource"></vpaginator> | |
--------------------------- | |
O script esta assim: | |
<script> | |
import AuthService from '@/services/auth' | |
import {mapState} from 'vuex' | |
export default { | |
data() { | |
return { | |
services: [], | |
newPlanningLabel: '', | |
showNewPlanningForm: false, | |
} | |
}, | |
beforeMount() { | |
this.permission = AuthService.permission | |
}, | |
computed: { | |
...mapState('warehouse/', ['selectedWarehouse']) | |
}, | |
methods: { | |
updateResource(data) { | |
this.services = data | |
this.services.forEach(it => { | |
it.qty = it.orders.length | |
}) | |
}, | |
createNewPlanning() { | |
this.$http.post('/atlas/plannings', {label: this.newPlanningLabel}).then(() => { | |
this.$refs.paginator.fetchData() | |
}) | |
}, | |
triggerNewPlanning() { | |
this.showNewPlanningForm = !this.showNewPlanningForm | |
} | |
} | |
} | |
</script> | |
---------------- | |
Eu gostaria de filtrar os services a partir das informacoes do state do Vuex, mas nao consigo entender onde fazer esse filtro, se direto na declaracao ou se desenvolvo um metodo pra isso. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment