Fix pagination: all pages default to 10 per page, add total counts, fix tasks pagination position and use client-side slicing

This commit is contained in:
Yuzhiran Dev
2026-05-18 22:59:03 +08:00
parent 894e53caef
commit 7b4e52743b
3 changed files with 30 additions and 19 deletions
+7 -5
View File
@@ -37,6 +37,7 @@
<div v-if="activeTab === 'cases'">
<div class="toolbar">
<el-button type="primary" size="small" @click="showCaseDialog()">新增案例</el-button>
<span style="font-size:13px;color:#909399;margin-left:8px;">共 {{ cases.length }} 个</span>
</div>
<div v-if="casesLoading" class="card-loading">加载中...</div>
<template v-else-if="cases.length === 0">
@@ -272,6 +273,7 @@
<div class="toolbar">
<el-button type="primary" size="small" @click="showCategoryDialog()">新增类别</el-button>
<el-button size="small" @click="loadCategories">刷新</el-button>
<span style="font-size:13px;color:#909399;margin-left:8px;">共 {{ categories.length }} 个</span>
</div>
<div v-if="categoriesLoading" class="card-loading">加载中...</div>
<template v-else-if="categories.length === 0">
@@ -649,7 +651,7 @@
catch (e) { if (e !== 'cancel') ElMessage.error('删除失败: ' + e.message); }
};
const casePage = ref(1);
const casePageSize = 20;
const casePageSize = 10;
const paginatedCases = computed(() => { const s = (casePage.value - 1) * casePageSize; return cases.value.slice(s, s + casePageSize); });
const taskLogs = ref([]);
@@ -751,7 +753,7 @@
catch (e) { if (e !== 'cancel') ElMessage.error('删除失败: ' + e.message); }
};
const orgPage = ref(1);
const orgPageSize = 20;
const orgPageSize = 10;
const paginatedOrgs = computed(() => { const s = (orgPage.value - 1) * orgPageSize; return orgs.value.slice(s, s + orgPageSize); });
const users = ref([]);
@@ -760,7 +762,7 @@
const userSubmitting = ref(false);
const userForm = reactive({ username: '', password: '', role: 'editor' });
const userPage = ref(1);
const userPageSize = 20;
const userPageSize = 10;
const paginatedUsers = computed(() => {
const start = (userPage.value - 1) * userPageSize;
return users.value.slice(start, start + userPageSize);
@@ -861,7 +863,7 @@
catch (e) { if (e !== 'cancel') ElMessage.error('删除失败: ' + e.message); }
};
const categoryPage = ref(1);
const categoryPageSize = 20;
const categoryPageSize = 10;
const paginatedCategories = computed(() => { const s = (categoryPage.value - 1) * categoryPageSize; return categories.value.slice(s, s + categoryPageSize); });
const loadSources = async () => {
@@ -886,7 +888,7 @@
catch (e) { if (e !== 'cancel') ElMessage.error('删除失败: ' + e.message); }
};
const sourcePage = ref(1);
const sourcePageSize = 20;
const sourcePageSize = 10;
const paginatedSources = computed(() => { const s = (sourcePage.value - 1) * sourcePageSize; return sources.value.slice(s, s + sourcePageSize); });
const formatDate = (dateStr) => { if (!dateStr) return '-'; return new Date(dateStr.replace(' ', 'T')).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }); };