Employees-Index: Create new User.

This commit is contained in:
Sockenklaus
2021-11-17 03:35:49 +01:00
parent 8071e8ef91
commit 6f237ff8fa
12 changed files with 408 additions and 347 deletions

View File

@@ -9,7 +9,7 @@ export default defineStore('employees', () => {
const user = useUser()
const state = reactive({
rows: Array<any>(),
rows: Array<Employee>(),
columns: Array<string>(),
meta : {
@@ -91,89 +91,4 @@ export default defineStore('employees', () => {
setPage
}
})
/*
export const useEmployees = defineStore('employees', {
state: () => {
return {
/**
* @type any[]
rows: Array<any>(),
meta: {
current_page: NaN,
first_page: NaN,
last_page: NaN,
per_page: NaN,
total: NaN
},
columns: Array<string>(),
limit: 10,
page: 1,
sort_by: '',
simple_search: ''
}
},
actions: {
/**
* @param: {number} limit - QueryString: limit=20 etc.
* @param: {number} page - QueryString: page=1 etc.
* @param: {string} sortBy - QueryString: sort_by=asc(col1),desc(col2),...
* @param: {string} simpleSearch - QueryString: simple_search=query(col1,col2,...)
**
async fetchFromApi() {
try {
const data : any = (await axios.get(
'/employees',
{
params: {
limit: this.limit,
page: this.page,
sort_by: this.sort_by,
simple_search: this.simple_search
},
headers: user.header
}
)).data
Object.assign(this.meta, data.meta)
this.rows = _cloneDeep(data.data)
this.columns = this.fetchColumns()
}
catch(err) {
console.log(err)
}
},
fetchColumns() : string[] {
if(this.rows[0]){
return Object.keys(this.rows[0])
}
return []
},
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()
}
}
}) */
})