11<template >
22 <div >
3- <breadcrumb v-if =" device !== 'desktop'" style = " margin-left : -16 px ; margin-right : -16 px ; margin-top : -16 px " />
3+ <breadcrumb v-if =" device !== 'desktop'" class = " mobile-breadcrumb " />
44 <a-row >
55 <a-col :span =" 17" >
66 <a-tooltip placement =" bottom" v-for =" (action, actionIndex) in actions" :key =" actionIndex" v-if =" (!dataView && (action.listView || action.groupAction && selectedRowKeys.length > 0)) || (dataView && action.dataView)" >
7575 <a-input-search
7676 size =" default"
7777 placeholder =" Search"
78- @search = " onSearch "
78+ v-model = " searchQuery "
7979 v-if =" !dataView"
80+ @search =" onSearch"
8081 >
8182 <a-icon slot =" prefix" type =" search" />
8283 </a-input-search >
170171 <component :is =" $route.meta.viewComponent" :resource =" resource" v-if =" $route.meta.viewComponent" /></component >
171172 <data-view :resource =" resource" v-else />
172173 </div >
173- <div style = " margin-top : 12 px " v-else >
174+ <div class = " row-element " v-else >
174175 <list-view
175176 :loading =" loading"
176177 :columns =" columns"
180181 :items =" items"
181182 :loading =" loading"
182183 v-show =" !tableView" />
184+ <a-pagination
185+ class =" row-element"
186+ size =" small"
187+ :current =" page"
188+ :pageSize =" pageSize"
189+ :total =" itemCount"
190+ :showTotal =" total => `Total ${total} items`"
191+ :pageSizeOptions =" ['20', '40', '80', '100']"
192+ @change =" changePage"
193+ @showSizeChange =" changePageSize"
194+ showSizeChanger />
183195 </div >
184-
185196 </div >
186197</template >
187198
@@ -214,6 +225,10 @@ export default {
214225 autoRefresh: false ,
215226 columns: [],
216227 items: [],
228+ itemCount: 0 ,
229+ page: 1 ,
230+ pageSize: 20 ,
231+ searchQuery: ' ' ,
217232 resource: {},
218233 selectedRowKeys: [],
219234 currentAction: {},
@@ -234,6 +249,7 @@ export default {
234249 watch: {
235250 ' $route' (to, from) {
236251 if (to .fullPath !== from .fullPath && ! to .fullPath .includes (' action/' )) {
252+ this .page = 1
237253 this .fetchData ()
238254 }
239255 },
@@ -247,7 +263,7 @@ export default {
247263 this .form = this .$form .createForm (this )
248264 },
249265 methods: {
250- fetchData (search = ' ' ) {
266+ fetchData () {
251267 this .routeName = this .$route .name
252268 if (! this .routeName ) {
253269 this .routeName = this .$route .matched [this .$route .matched .length - 1 ].parent .name
@@ -263,8 +279,8 @@ export default {
263279 Object .assign (params, this .$route .meta .params )
264280 }
265281
266- if (search !== ' ' ) {
267- params[' keyword' ] = search
282+ if (this . searchQuery !== ' ' ) {
283+ params[' keyword' ] = this . searchQuery
268284 }
269285
270286 if (this .$route && this .$route .params && this .$route .params .id ) {
@@ -316,6 +332,8 @@ export default {
316332 if (this .$route .params && this .$route .params .id ) {
317333 params[' id' ] = this .$route .params .id
318334 }
335+ params[' page' ] = this .page
336+ params[' pagesize' ] = this .pageSize
319337 api (this .apiName , params).then (json => {
320338 this .loading = false
321339 var responseName
@@ -327,7 +345,10 @@ export default {
327345 }
328346 }
329347 for (const key in json[responseName]) {
330- if (key === ' count' ) continue
348+ if (key === ' count' ) {
349+ this .itemCount = json[responseName][' count' ]
350+ continue
351+ }
331352 objectName = key
332353 break
333354 }
@@ -346,7 +367,8 @@ export default {
346367 })
347368 },
348369 onSearch (value ) {
349- this .fetchData (value)
370+ this .searchQuery = value
371+ this .fetchData ()
350372 },
351373 toggleAutoRefresh () {
352374 this .autoRefresh = ! this .autoRefresh
@@ -506,6 +528,16 @@ export default {
506528 }
507529 })
508530 },
531+ changePage (page , pageSize ) {
532+ this .page = page
533+ this .pageSize = pageSize
534+ this .fetchData ()
535+ },
536+ changePageSize (currentPage , pageSize ) {
537+ this .page = currentPage
538+ this .pageSize = pageSize
539+ this .fetchData ()
540+ },
509541 start () {
510542 this .loading = true
511543 this .fetchData ()
@@ -518,18 +550,25 @@ export default {
518550}
519551 </script >
520552
521- <style >
522- .info-card {
523- margin-top : 12px ;
553+ <style scoped>
554+
555+ .mobile-breadcrumb {
556+ margin-left : -16px ;
557+ margin-right : -16px ;
558+ margin-top : -16px ;
559+ padding-bottom : 16px ;
560+ }
561+
562+ .row-element {
563+ margin-top : 10px ;
564+ margin-bottom : 10px ;
524565}
525566
526567.ant-breadcrumb {
527568 vertical-align : text-bottom ;
528- margin-bottom : 8px ;
529569}
530570
531571.ant-breadcrumb .anticon {
532572 margin-left : 8px ;
533573}
534-
535574 </style >
0 commit comments