@@ -9,7 +9,7 @@ export default {
99 render (h ) {
1010 return (
1111 < div id= " app" >
12- < datasource table- data= {this .information } limits= {this .limits } actions= {this .actions } columns= {this .columns } pagination= {this .pagination } onChange= {this .change }>< / datasource>
12+ < datasource table- data= {this .information } limits= {this .limits } actions= {this .actions } columns= {this .columns } pagination= {this .pagination } onChange= {this .change } onSearching = { this . searching } >< / datasource>
1313 < / div>
1414 )
1515 },
@@ -29,15 +29,15 @@ export default {
2929 key: ' name'
3030 },
3131 {
32- name: ' Year ' ,
33- key: ' year ' ,
32+ name: ' City ' ,
33+ key: ' city ' ,
3434 render : function (value ) {
3535 return ` <strong>${ value} </strong>`
3636 }
3737 },
3838 {
39- name: ' Code color ' ,
40- key: ' pantone_value '
39+ name: ' Company ' ,
40+ key: ' company '
4141 }
4242 ],
4343 actions: [
@@ -95,42 +95,30 @@ export default {
9595 }
9696 ],
9797 limits: [3 , 5 , 10 , 15 , 20 ],
98- current_page: 1 ,
99- per_page: 3 ,
100- total: 0
101- }
102- },
103- computed: {
104- pagination () {
105- return {
106- total: this .total ,
107- per_page: 3 ,
108- current_page: this .current_page ,
109- last_page: 5 ,
110- from: (this .current_page === 1 ) ? 1 : this .per_page ,
111- to: (this .current_page === 1 ) ? this .per_page : this .per_page * this .current_page
112- }
98+ page: 1 ,
99+ perpage: 10 ,
100+ pagination: {},
101+ search: ' '
113102 }
114103 },
115104 methods: {
116- getData () {
117- axios .get (` https ://reqres.in/api/products ?per_page=${ this .pagination . per_page } &page=${ this .pagination . current_page } ` )
105+ async getData () {
106+ await axios .get (` http ://young-falls-97690.herokuapp.com/getusers ?per_page=${ this .perpage } &page=${ this .page } &search= ${ this . search } ` )
118107 .then ((response ) => {
119- this .pagination .per_page = parseInt (response .data .per_page )
120- this .per_page = parseInt (response .data .per_page )
121- this .total = parseInt (response .data .total )
122- this .pagination .current_page = parseInt (response .data .page )
123- this .current_page = parseInt (response .data .page )
124- this .pagination .last_page = parseInt (response .data .total_pages )
108+ this .pagination = response .data .pagination
125109 this .information = response .data .data
126110 })
127111 .catch ((error ) => {
128112 console .error (error)
129113 })
130114 },
131115 change (value ) {
132- this .pagination .per_page = parseInt (value .perpage )
133- this .pagination .current_page = parseInt (value .page )
116+ this .page = value .page
117+ this .perpage = value .perpage
118+ this .getData ()
119+ },
120+ searching (value ) {
121+ this .search = value
134122 this .getData ()
135123 }
136124 }
0 commit comments