From 264180600f23914c220581cb70a0437fb10cc885 Mon Sep 17 00:00:00 2001 From: ruibaby Date: Sun, 24 Nov 2019 21:02:55 +0800 Subject: [PATCH] fix: all pagination error. --- .../FooterToolbar/FooterToolBar.vue | 2 +- src/views/attachment/AttachmentList.vue | 17 +++++----- .../components/AttachmentDrawer.vue | 17 +++++----- .../components/AttachmentSelectDrawer.vue | 27 ++++++++++------ src/views/comment/components/CommentTab.vue | 26 +++++++-------- .../components/TargetCommentDrawer.vue | 3 +- src/views/dashboard/Dashboard.vue | 26 +++++++-------- src/views/post/PostList.vue | 32 +++++++++---------- src/views/sheet/SheetList.vue | 17 +++++----- src/views/sheet/internal/JournalList.vue | 25 ++++++++------- src/views/sheet/internal/PhotoList.vue | 19 +++++------ 11 files changed, 110 insertions(+), 101 deletions(-) diff --git a/src/components/FooterToolbar/FooterToolBar.vue b/src/components/FooterToolbar/FooterToolBar.vue index a2ff79fe..5f565e65 100644 --- a/src/components/FooterToolbar/FooterToolBar.vue +++ b/src/components/FooterToolbar/FooterToolBar.vue @@ -23,4 +23,4 @@ export default { } } } - \ No newline at end of file + diff --git a/src/views/attachment/AttachmentList.vue b/src/views/attachment/AttachmentList.vue index 4efe705d..1d78741e 100644 --- a/src/views/attachment/AttachmentList.vue +++ b/src/views/attachment/AttachmentList.vue @@ -32,7 +32,7 @@ 查询 重置 @@ -124,6 +124,7 @@
@@ -50,8 +50,9 @@
@@ -122,7 +123,7 @@ export default { }, queryParam: { page: 0, - size: 18, + size: 12, sort: null, keyword: null }, @@ -162,18 +163,18 @@ export default { this.$log.debug('Show detail of', attachment) this.detailVisible = true }, - loadAttachments(isSearch) { + loadAttachments() { this.queryParam.page = this.pagination.page - 1 this.queryParam.size = this.pagination.size this.queryParam.sort = this.pagination.sort - if (isSearch) { - this.queryParam.page = 0 - } attachmentApi.query(this.queryParam).then(response => { this.attachments = response.data.data.content this.pagination.total = response.data.data.total }) }, + handleQuery() { + this.handlePaginationChange(1, this.pagination.size) + }, handlePaginationChange(page, pageSize) { this.pagination.page = page this.pagination.size = pageSize @@ -182,7 +183,7 @@ export default { onUploadClose() { this.$refs.upload.handleClearFileList() this.loadSkeleton() - this.loadAttachments() + this.handlePaginationChange(1, this.pagination.size) }, handleDelete() { this.loadAttachments() diff --git a/src/views/attachment/components/AttachmentSelectDrawer.vue b/src/views/attachment/components/AttachmentSelectDrawer.vue index fb83a8de..9ffcac15 100644 --- a/src/views/attachment/components/AttachmentSelectDrawer.vue +++ b/src/views/attachment/components/AttachmentSelectDrawer.vue @@ -14,6 +14,8 @@ > @@ -48,8 +50,9 @@
@@ -125,6 +128,12 @@ export default { size: 12, sort: '' }, + queryParam: { + page: 0, + size: 12, + sort: null, + keyword: null + }, attachments: [], uploadHandler: attachmentApi.upload } @@ -148,13 +157,17 @@ export default { this.uploadVisible = true }, loadAttachments() { - const pagination = Object.assign({}, this.pagination) - pagination.page-- - attachmentApi.query(pagination).then(response => { + this.queryParam.page = this.pagination.page - 1 + this.queryParam.size = this.pagination.size + this.queryParam.sort = this.pagination.sort + attachmentApi.query(this.queryParam).then(response => { this.attachments = response.data.data.content this.pagination.total = response.data.data.total }) }, + handleQuery() { + this.handlePaginationChange(1, this.pagination.size) + }, handleSelectAttachment(item) { this.$emit('listenToSelect', item) }, @@ -166,14 +179,10 @@ export default { this.pagination.size = pageSize this.loadAttachments() }, - handleAttachmentUploadSuccess() { - this.$message.success('上传成功!') - this.loadAttachments() - }, onUploadClose() { this.$refs.upload.handleClearFileList() this.loadSkeleton() - this.loadAttachments() + this.handlePaginationChange(1, this.pagination.size) }, handleJudgeMediaType(attachment) { var mediaType = attachment.mediaType diff --git a/src/views/comment/components/CommentTab.vue b/src/views/comment/components/CommentTab.vue index 33ac7b6b..ad028e46 100644 --- a/src/views/comment/components/CommentTab.vue +++ b/src/views/comment/components/CommentTab.vue @@ -23,7 +23,7 @@ 查询 重置 @@ -377,7 +377,9 @@
{ this.comments = response.data.data.content @@ -569,9 +571,7 @@ export default { }) }, handleQuery() { - this.queryParam.page = 0 - this.pagination.current = 1 - this.loadComments() + this.handlePaginationChange(1, this.pagination.size) }, handleEditStatusClick(commentId, status) { commentApi.updateStatus(this.type, commentId, status).then(response => { @@ -617,14 +617,14 @@ export default { }, handlePaginationChange(page, pageSize) { this.$log.debug(`Current: ${page}, PageSize: ${pageSize}`) - this.pagination.current = page - this.pagination.pageSize = pageSize + this.pagination.page = page + this.pagination.size = pageSize this.loadComments() }, handleResetParam() { this.queryParam.keyword = null this.queryParam.status = null - this.loadComments() + this.handlePaginationChange(1, this.pagination.size) }, handlePublishMore() { if (this.selectedRowKeys.length <= 0) { diff --git a/src/views/comment/components/TargetCommentDrawer.vue b/src/views/comment/components/TargetCommentDrawer.vue index 105bbdb1..53fe3f82 100644 --- a/src/views/comment/components/TargetCommentDrawer.vue +++ b/src/views/comment/components/TargetCommentDrawer.vue @@ -36,8 +36,9 @@
diff --git a/src/views/dashboard/Dashboard.vue b/src/views/dashboard/Dashboard.vue index e9d50a03..819cb846 100644 --- a/src/views/dashboard/Dashboard.vue +++ b/src/views/dashboard/Dashboard.vue @@ -300,12 +300,13 @@
@@ -365,17 +366,14 @@ export default { }, logs: [], logPagination: { - current: 1, - pageSize: 50, + page: 1, + size: 50, sort: null }, logQueryParam: { page: 0, size: 50, - sort: null, - keyword: null, - categoryId: null, - status: null + sort: null }, interval: null } @@ -475,8 +473,8 @@ export default { setTimeout(() => { this.logsLoading = false }, 500) - this.logQueryParam.page = this.logPagination.current - 1 - this.logQueryParam.size = this.logPagination.pageSize + this.logQueryParam.page = this.logPagination.page - 1 + this.logQueryParam.size = this.logPagination.size this.logQueryParam.sort = this.logPagination.sort logApi.pageBy(this.logQueryParam).then(response => { this.logs = response.data.data.content @@ -495,10 +493,10 @@ export default { window.open(response.data, '_blank') }) }, - onPaginationChange(page, pageSize) { + handlePaginationChange(page, pageSize) { this.$log.debug(`Current: ${page}, PageSize: ${pageSize}`) - this.logPagination.current = page - this.logPagination.pageSize = pageSize + this.logPagination.page = page + this.logPagination.size = pageSize this.loadLogs() } } diff --git a/src/views/post/PostList.vue b/src/views/post/PostList.vue index 4afe8c91..7d9b7267 100644 --- a/src/views/post/PostList.vue +++ b/src/views/post/PostList.vue @@ -23,7 +23,7 @@ 查询 重置 @@ -478,7 +478,9 @@
{ this.posts = response.data.data.content @@ -672,20 +672,18 @@ export default { }, handlePaginationChange(page, pageSize) { this.$log.debug(`Current: ${page}, PageSize: ${pageSize}`) - this.pagination.current = page - this.pagination.pageSize = pageSize + this.pagination.page = page + this.pagination.size = pageSize this.loadPosts() }, handleResetParam() { this.queryParam.keyword = null this.queryParam.categoryId = null this.queryParam.status = null - this.loadPosts() + this.handlePaginationChange(1, this.pagination.size) }, handleQuery() { - this.queryParam.page = 0 - this.pagination.current = 1 - this.loadPosts() + this.handlePaginationChange(1, this.pagination.size) }, handleEditStatusClick(postId, status) { postApi.updateStatus(postId, status).then(response => { diff --git a/src/views/sheet/SheetList.vue b/src/views/sheet/SheetList.vue index ecde91b6..1186bd16 100644 --- a/src/views/sheet/SheetList.vue +++ b/src/views/sheet/SheetList.vue @@ -465,7 +465,9 @@
{ this.sheets = response.data.data.content @@ -676,8 +677,8 @@ export default { }, handlePaginationChange(page, pageSize) { this.$log.debug(`Current: ${page}, PageSize: ${pageSize}`) - this.pagination.current = page - this.pagination.pageSize = pageSize + this.pagination.page = page + this.pagination.size = pageSize this.loadSheets() }, onSheetSettingsClose() { diff --git a/src/views/sheet/internal/JournalList.vue b/src/views/sheet/internal/JournalList.vue index 616f1e2f..c5e1ea3a 100644 --- a/src/views/sheet/internal/JournalList.vue +++ b/src/views/sheet/internal/JournalList.vue @@ -25,7 +25,7 @@ 查询 重置 @@ -133,12 +133,13 @@
@@ -262,20 +263,20 @@ export default { ...mapGetters(['user']) }, methods: { - loadJournals(isSearch) { + loadJournals() { + this.listLoading = true this.queryParam.page = this.pagination.page - 1 this.queryParam.size = this.pagination.size this.queryParam.sort = this.pagination.sort - if (isSearch) { - this.queryParam.page = 0 - } - this.listLoading = true journalApi.query(this.queryParam).then(response => { this.journals = response.data.data.content this.pagination.total = response.data.data.total this.listLoading = false }) }, + handleQuery() { + this.handlePaginationChange(1, this.pagination.size) + }, handleNew() { this.title = '新建' this.visible = true @@ -344,7 +345,7 @@ export default { } this.visible = false }, - onPaginationChange(page, pageSize) { + handlePaginationChange(page, pageSize) { this.$log.debug(`Current: ${page}, PageSize: ${pageSize}`) this.pagination.page = page this.pagination.size = pageSize @@ -357,7 +358,7 @@ export default { resetParam() { this.queryParam.keyword = null this.queryParam.type = null - this.loadJournals() + this.handlePaginationChange(1, this.pagination.size) } } } diff --git a/src/views/sheet/internal/PhotoList.vue b/src/views/sheet/internal/PhotoList.vue index 4432f9d0..1d828d66 100644 --- a/src/views/sheet/internal/PhotoList.vue +++ b/src/views/sheet/internal/PhotoList.vue @@ -31,7 +31,7 @@ 查询 重置 @@ -101,6 +101,7 @@
{ this.photos = response.data.data.content this.pagination.total = response.data.data.total this.listLoading = false }) }, + handleQuery() { + this.handlePaginationChange(1, this.pagination.size) + }, loadTeams() { photoApi.listTeams().then(response => { this.teams = response.data.data @@ -396,7 +397,7 @@ export default { resetParam() { this.queryParam.keyword = null this.queryParam.team = null - this.loadPhotos() + this.handlePaginationChange(1, this.pagination.size) this.loadTeams() }, onDrawerClose() {