DataTableComponent.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <v-col
  3. cols="12"
  4. sm="12"
  5. >
  6. <v-data-table
  7. :headers="headers"
  8. :items="entries"
  9. :options.sync="options"
  10. :server-items-length="totalEntries"
  11. :loading="loading"
  12. class="elevation-1"
  13. ></v-data-table>
  14. </v-col>
  15. </template>
  16. <script lang="ts">
  17. import {defineComponent, ref} from '@vue/composition-api'
  18. import {Repository} from "@vuex-orm/core";
  19. import personActivitiesData from '@/data/personActivitiesData'
  20. export default defineComponent({
  21. props: {
  22. repository:{
  23. type: Object as () => Repository,
  24. required: true
  25. },
  26. uri:{
  27. type: String,
  28. required: true
  29. },
  30. headers:{
  31. type: Array,
  32. required: true
  33. }
  34. },
  35. setup() {
  36. const totalEntries = ref(0)
  37. const entries = ref([])
  38. const loading = ref(true)
  39. const options = ref({})
  40. return {
  41. entries,
  42. totalEntries,
  43. loading,
  44. options
  45. }
  46. },
  47. async fetch() {
  48. // const entries = await this.$http.$get(`https://local.new.api.opentalent.fr/api/${this.uri}`)
  49. const entries = await personActivitiesData()
  50. this.repository.insert(entries['hydra:member']);
  51. this.entries = this.repository.all()
  52. this.totalEntries = entries['hydra:totalItems']
  53. this.loading = false
  54. }
  55. })
  56. </script>