feat(OrganizationList): add pagination support
This commit is contained in:
parent
26af62e9c2
commit
676912e97f
1 changed files with 51 additions and 12 deletions
|
@ -4,6 +4,9 @@
|
||||||
<v-data-table
|
<v-data-table
|
||||||
:headers="headers"
|
:headers="headers"
|
||||||
:items="organizations"
|
:items="organizations"
|
||||||
|
:loading="isLoading"
|
||||||
|
:options.sync="options"
|
||||||
|
:server-items-length="totalCount"
|
||||||
sort-by="validationState"
|
sort-by="validationState"
|
||||||
class="elevation-1"
|
class="elevation-1"
|
||||||
>
|
>
|
||||||
|
@ -447,7 +450,8 @@ export default {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Actions',
|
text: 'Actions',
|
||||||
value: 'actions'
|
value: 'actions',
|
||||||
|
sortable: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
organizations: [],
|
organizations: [],
|
||||||
|
@ -468,7 +472,10 @@ export default {
|
||||||
importFile: null,
|
importFile: null,
|
||||||
importLoading: false,
|
importLoading: false,
|
||||||
diffModal: false,
|
diffModal: false,
|
||||||
diffText: ''
|
diffText: '',
|
||||||
|
options: null,
|
||||||
|
totalCount: 0,
|
||||||
|
isLoading: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -484,26 +491,58 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
dialog (val) {
|
dialog (val) {
|
||||||
val || this.close()
|
val || this.close()
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
handler () {
|
||||||
|
this.fetchData()
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
created () {
|
created () {
|
||||||
this.$store.commit('SET_TITLE', 'Gestion des associations')
|
this.$store.commit('SET_TITLE', 'Gestion des associations')
|
||||||
this.fetchData()
|
|
||||||
|
if (this.$route.query.approval !== undefined) {
|
||||||
|
this.fetchOne(this.$route.query.approval).then((data) => {
|
||||||
|
if (data != null) {
|
||||||
|
this.$router.push({ query: {} })
|
||||||
|
this.openApproveModal(data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
fetchData () {
|
|
||||||
this.$apitator.get('/admin/organizations', { withAuth: true }).then(res => {
|
|
||||||
this.organizations = res.data.data
|
|
||||||
|
|
||||||
if (this.$route.query.approval !== undefined) {
|
fetchOne (id) {
|
||||||
const organizations = this.organizations.filter(o => o._id === this.$route.query.approval)
|
return new Promise(resolve => {
|
||||||
if (organizations.length > 0) {
|
this.$apitator.get('/admin/organizations/' + id, {
|
||||||
this.$router.push({ query: {} })
|
withAuth: true
|
||||||
this.openApproveModal(organizations[0])
|
}).then(res => {
|
||||||
}
|
resolve(res.data.data)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
fetchData () {
|
||||||
|
this.isLoading = true
|
||||||
|
let params = {}
|
||||||
|
if (this.options != null) {
|
||||||
|
params = {
|
||||||
|
page: this.options.page,
|
||||||
|
limit: this.options.itemsPerPage,
|
||||||
|
sortBy: this.options.sortBy[0],
|
||||||
|
sortDesc: this.options.sortDesc[0]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
this.$apitator.get('/admin/organizations', {
|
||||||
|
withAuth: true,
|
||||||
|
axiosConfig: { params }
|
||||||
|
}).then(res => {
|
||||||
|
this.organizations = res.data.data.docs
|
||||||
|
this.totalCount = res.data.data.totalDocs
|
||||||
|
this.isLoading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue