task-272(验收反馈): 分组/软件版本/类目搜索表补齐分页组件(prev/next 中文由 locale 提供)

This commit is contained in:
2026-09-06 01:46:49 +08:00
parent 5e5658b00d
commit 8add3ceaa4
4 changed files with 91 additions and 8 deletions
@@ -16,6 +16,15 @@ const editingGroup = ref<ShopGroupItem | null>(null)
const summary = computed(() => shopGroupSummary(rows.value))
const isSuperAdmin = computed(() => session.isSuperAdmin)
const currentUserId = computed(() => session.user?.id ?? null)
// 客户端分页:全量拉取后按页切片展示。
const page = ref(1)
const pageSize = 10
const total = computed(() => rows.value.length)
const pagedRows = computed(() => rows.value.slice((page.value - 1) * pageSize, page.value * pageSize))
function changePage(p: number) {
page.value = p
}
function canEditOf(group: ShopGroupItem): boolean {
if (isSuperAdmin.value) return true
@@ -87,7 +96,7 @@ onMounted(loadGroups)
</el-col>
</el-row>
<el-card shadow="never">
<el-table v-loading="loading" :data="rows" stripe>
<el-table v-loading="loading" :data="pagedRows" stripe>
<el-table-column type="index" label="序号" width="80" />
<el-table-column prop="name" label="分组名称" min-width="180" />
<el-table-column prop="leaderUsername" label="组长" width="170" />
@@ -113,6 +122,9 @@ onMounted(loadGroups)
</template>
</el-table-column>
</el-table>
<div class="table-footer">
<el-pagination background layout="prev, pager, next" :total="total" :page-size="pageSize" :current-page="page" @current-change="changePage" />
</div>
</el-card>
<GroupEditorDialog
v-model="editorVisible"
@@ -133,7 +133,8 @@ async function runSearch(page: number): Promise<void> {
searchLoading.value = true
try {
const result = await searchProductCategories(keyword.value, page, PRODUCT_CATEGORY_DEFAULT_PAGE_SIZE)
searchRows.value = page === 1 ? result.items : [...searchRows.value, ...result.items]
// 分页换页模式:每页独立展示当前页结果(对齐列表统一分页交互)。
searchRows.value = result.items
searchTotal.value = result.total
searchPage.value = result.page
searchHasMore.value = result.hasMore
@@ -158,8 +159,8 @@ function reset(): void {
void loadTree()
}
function loadMore(): void {
void runSearch(searchPage.value + 1)
function searchChangePage(p: number): void {
void runSearch(p)
}
function openCreate(parent: ProductCategoryNode | null) {
@@ -350,8 +351,8 @@ onMounted(loadTree)
</template>
</el-table-column>
</el-table>
<div v-if="searchHasMore" class="load-more-row">
<el-button :loading="searchLoading" @click="loadMore">加载更多搜索结果</el-button>
<div class="table-footer">
<el-pagination background layout="prev, pager, next" :total="searchTotal" :page-size="PRODUCT_CATEGORY_DEFAULT_PAGE_SIZE" :current-page="searchPage" @current-change="searchChangePage" />
</div>
</el-card>
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { formatDateTime } from '@/utils/datetime'
/** 软件版本管理页:客户端版本列表 + 上传新版本(成功留驻弹窗含链接,对齐 admin panel-version)。 */
import { onMounted, ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { fetchSoftwareVersions, uploadSoftwareVersion } from './version-api.ts'
import type { SoftwareVersionItem } from './version-dto.ts'
@@ -9,6 +9,15 @@ import { isNonEmptyVersion } from './version-dto.ts'
const loading = ref(false)
const items = ref<SoftwareVersionItem[]>([])
// 客户端分页:全量拉取后按页切片展示。
const page = ref(1)
const pageSize = 10
const total = computed(() => items.value.length)
const pagedItems = computed(() => items.value.slice((page.value - 1) * pageSize, page.value * pageSize))
function changePage(p: number) {
page.value = p
}
const uploadVisible = ref(false)
const uploading = ref(false)
@@ -90,7 +99,7 @@ onMounted(load)
</div>
<el-card shadow="never">
<el-table v-loading="loading" :data="items" stripe border empty-text="暂无版本记录">
<el-table v-loading="loading" :data="pagedItems" stripe border empty-text="暂无版本记录">
<el-table-column prop="version" label="版本号" min-width="180" />
<el-table-column label="下载链接" min-width="240">
<template #default="{ row }">
@@ -108,6 +117,9 @@ onMounted(load)
</template>
</el-table-column>
</el-table>
<div class="table-footer">
<el-pagination background layout="prev, pager, next" :total="total" :page-size="pageSize" :current-page="page" @current-change="changePage" />
</div>
</el-card>
<el-dialog v-model="uploadVisible" title="上传新版本" width="520px">