From b7fa1fea175f80b4a8fc6ef70e00273902188bee Mon Sep 17 00:00:00 2001 From: xianfuxing Date: Sun, 19 Aug 2018 21:54:19 +0800 Subject: [PATCH] # add pagination in device page --- src/styles/index.scss | 1 + src/styles/pagination.scss | 60 +++++++++++++++++++++++++++++++++++ src/views/counter/device.vue | 24 ++++++++++++-- src/views/counter/logs.vue | 61 +----------------------------------- 4 files changed, 83 insertions(+), 63 deletions(-) create mode 100644 src/styles/pagination.scss diff --git a/src/styles/index.scss b/src/styles/index.scss index b6fd924..d504fef 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -4,6 +4,7 @@ @import './element-ui.scss'; @import './sidebar.scss'; @import './btn.scss'; +@import './pagination.scss'; body { height: 100%; diff --git a/src/styles/pagination.scss b/src/styles/pagination.scss new file mode 100644 index 0000000..1b1d0dc --- /dev/null +++ b/src/styles/pagination.scss @@ -0,0 +1,60 @@ +.pagination { + float: right; + font-weight: normal; + padding: 2rem 0 1rem 0; + .btn-prev { + border: 1px solid #d1dbe5; + border-right: 0; + border-radius: 0 !important; + background: #fff !important; + margin: 0 !important; + } + .btn-next { + border: 1px solid #d1dbe5; + // border-left: 0; + background: #fff !important; + border-radius: 0!important; + margin: 0 !important; + } + .el-pager li { + border: 1px solid #d1dbe5; + box-sizing: border-box; + background: #fff !important; + border-radius: 0!important; + border-right: 0; + padding: 0; + margin: 0 !important; + } + .el-pager li:not(.disabled).active { + background: #409EFF !important; + border-color: #409EFF; + } + .el-pagination__jump { + margin-left: .8rem; + } + .el-pagination__editor.el-input { + width: 2.5rem; + } +} +// mobile +@media screen and (max-width: 375px) { + .pagination { + display: flex !important; + justify-content: center; + float: none; + padding: 1rem 0 1rem 0; + .el-pager li { + // height: 1.5rem; + // line-height: 1.5rem; + font-size: .5rem !important; + // min-width: 1.5rem !important; + } + .el-pagination__total { + // margin-right: 2rem; + display: none !important; + } + .el-pagination__jump { + display: none !important; + } + } +} \ No newline at end of file diff --git a/src/views/counter/device.vue b/src/views/counter/device.vue index e9a0861..8d77538 100644 --- a/src/views/counter/device.vue +++ b/src/views/counter/device.vue @@ -70,6 +70,14 @@ + + @@ -84,7 +92,8 @@ export default { DeviceSearchForm: { device_id: null, status: null - } + }, + total: 0 } }, methods: { @@ -92,6 +101,7 @@ export default { fetchDeviceList(params).then(response => { this.deviceList = response.data.results console.log(this.deviceList) + this.total = response.data.count this.listLoading = false }) }, @@ -102,6 +112,15 @@ export default { resetSearch() { this.DeviceSearchForm.device_id = '' this.getDevices() + }, + handleCurrentChange(page) { + // console.log(page) + this.listLoading = true + this.getDevices({ page }) + }, + handleSizeChange(page) { + this.listLoading = true + this.getDevices({ page }) } }, created() { @@ -114,6 +133,5 @@ export default { diff --git a/src/views/counter/logs.vue b/src/views/counter/logs.vue index 7450159..fff20f6 100644 --- a/src/views/counter/logs.vue +++ b/src/views/counter/logs.vue @@ -99,64 +99,5 @@ export default {