From d7ae290513cd15a4b643f9e051cdc2f665d9570a Mon Sep 17 00:00:00 2001 From: lhzzforever Date: Tue, 9 Apr 2024 10:41:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E7=BB=84=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E2=80=94>=E4=BA=BA=E5=91=98=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=88=97=E8=A1=A8=E6=90=9C=E7=B4=A2=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E4=B8=8B=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=AB=AF=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../group-member-template-detail-table.vue | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/frontend/src/views/group/components/group-member-template-detail-table.vue b/frontend/src/views/group/components/group-member-template-detail-table.vue index cded688a8..58f8959ef 100644 --- a/frontend/src/views/group/components/group-member-template-detail-table.vue +++ b/frontend/src/views/group/components/group-member-template-detail-table.vue @@ -92,6 +92,7 @@ tableLoading: false, tableKeyWord: '', groupTableList: [], + searchTableData: [], pagination: { current: 1, limit: 10, @@ -110,6 +111,21 @@ this.fetchTemplateGroupList(); }, methods: { + getDataByPage (page) { + if (!page) { + this.pagination.current = page = 1; + } + let startIndex = (page - 1) * this.pagination.limit; + let endIndex = page * this.pagination.limit; + if (startIndex < 0) { + startIndex = 0; + } + if (endIndex > this.searchTableData.length) { + endIndex = this.searchTableData.length; + } + return this.searchTableData.slice(startIndex, endIndex); + }, + async fetchTemplateGroupList () { this.tableLoading = true; try { @@ -118,15 +134,27 @@ const params = { id, template_id, - page: current, - page_size: limit, + limit, + offset: limit * (current - 1), keyword: this.tableKeyWord }; const { code, data } = await this.$store.dispatch('memberTemplate/getGroupSubjectTemplateMembers', params); const { count, results } = data; this.pagination.count = count || 0; this.groupTableList = results || []; - this.emptyTableData = formatCodeData(code, this.emptyTableData, this.groupTableList.length === 0); + if (!data.hasOwnProperty('count')) { + this.pagination.count = results.length || 0; + this.searchTableData = [...results || []]; + this.groupTableList = this.getDataByPage(this.pagination.current); + } else { + this.pagination.count = count || 0; + this.groupTableList = results || []; + } + this.emptyTableData = formatCodeData( + code, + Object.assign(this.emptyTableData, { tipType: this.tableKeyWord.length > 0 ? 'search' : '' }), + this.groupTableList.length === 0 + ); } catch (e) { this.groupTableList = []; this.emptyTableData = formatCodeData(e.code, this.emptyTableData); @@ -139,6 +167,7 @@ handleSearchGroup (payload) { this.tableKeyWord = payload; this.emptyTableData.tipType = 'search'; + this.resetPagination(); this.fetchTemplateGroupList(); }, @@ -151,12 +180,17 @@ async handlePageChange (current) { this.pagination = Object.assign(this.pagination, { current }); - await this.fetchTemplateGroupList(); + if (this.emptyTableData.tipType === 'search') { + const list = this.getDataByPage(current); + this.groupTableList.splice(0, this.groupTableList.length, ...list); + } else { + await this.fetchTemplateGroupList(); + } }, - async handleLimitChange (limit) { + handleLimitChange (limit) { this.pagination = Object.assign(this.pagination, { current: 1, limit }); - await this.fetchTemplateGroupList(); + this.handlePageChange(this.pagination.current); }, handleEmptyClear () {