Working on VPaginator

This commit is contained in:
Sockenklaus
2021-11-08 23:02:42 +01:00
parent 598d29803a
commit a1c86790aa
2 changed files with 85 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
import { defineStore } from 'pinia'
import { useUser } from '@/stores/user'
import axios from '@/axios'
import _cloneDeep from 'lodash/cloneDeep'
const user = useUser()
@@ -22,7 +23,7 @@ export const useEmployees = defineStore('employees', {
columns: Array<string>(),
limit: 10,
limit: 1,
page: 1,
sort_by: '',
simple_search: ''
@@ -53,7 +54,7 @@ export const useEmployees = defineStore('employees', {
)).data
Object.assign(this.meta, data.meta)
this.rows = data.data.map(e => e)
this.rows = _cloneDeep(data.data)
this.columns = this.fetchColumns()
}
@@ -69,8 +70,21 @@ export const useEmployees = defineStore('employees', {
return []
},
watch(){
setLimit(limit : number) {
this.limit = limit
this.fetchFromApi()
},
setSortBy(sortBy : string) {
this.sort_by = sortBy
this.fetchFromApi()
},
setSimpleSearch(simpleSearch : string) {
this.simple_search = simpleSearch
this.fetchFromApi()
},
setPage(page : number) {
this.page = page
this.fetchFromApi()
}
}
})