feat(web): 列表自适应布局并将分页固定页脚

数据源与查询列表整页不滚、仅表体内滚;名称筛选去掉「模糊」占位后缀。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
unknownandCursor committed 2026-11-18 18:48:50 +08:00
1 parent c1da6d7c3a
commit be63e2fe5d
11 files changed
+74 -31

No files matched your search

+5 -4
View File
@@ -16,10 +16,11 @@
除非用户对本页另有说明,控制台业务列表一律满足: 除非用户对本页另有说明,控制台业务列表一律满足:
1. **筛选条件**:表格上方工具条左侧提供常用查询条件(至少含名称类模糊搜索;有归属/类型/状态列时一并提供下拉)。「新建」等页面按钮靠右。筛选为草稿态:点「查询」才请求后端,「重置」清空条件并重新请求;禁止输入即筛。无匹配与真正空列表文案区分。 1. **筛选条件**:表格上方工具条左侧提供常用查询条件(至少含名称;有归属/类型/状态列时一并提供下拉)。「新建」等页面按钮靠右。筛选为草稿态:点「查询」才请求后端,「重置」清空条件并重新请求;禁止输入即筛。无匹配与真正空列表文案区分。
2. **表头排序与分页**:数据列 `sortable="custom"`,排序与分页一律走后端 SQL(`sort_by`/`sort_order`/`page`/`page_size`);操作列不排序。禁止只对当前页做前端排序。分页用 `ElPagination`(`total, sizes, prev, pager, next` + `background`)。 2. **自适应布局**:列表页整页不纵向滚动。工具条置顶、分页固定在页脚(`border-t`,右对齐),中间表格区 `flex-1` 且 `ElTable` 设 `height="100%"`,只在表体内滚动。空状态/报错占满中间区,可不显示分页脚。
3. **操作列宽度**:按行内 link 按钮数量取固定 `width`(`align="right"`),用 `actionsColumnWidth(n)`(`src/tableLayout.ts`):1→72,2→120,3→168,4→216(约 48px/钮 + 24 边距)。禁止用过大 `min-width` 把操作列撑宽。 3. **表头排序与分页**:数据列 `sortable="custom"`,排序与分页一律走后端 SQL(`sort_by`/`sort_order`/`page`/`page_size`);操作列不排序。禁止只对当前页做前端排序。分页用 `ElPagination`(`total, sizes, prev, pager, next` + `background`),放在页脚而非表格下方随内容移动。
4. **行内操作**:只放本模块明确需要的行操作;删除、版本切换等若需求未授权则不做。 4. **操作列宽度**:按行内 link 按钮数量取固定 `width`(`align="right"`),用 `actionsColumnWidth(n)`(`src/tableLayout.ts`):1→72,2→120,3→168,4→216(约 48px/钮 + 24 边距)。禁止用过大 `min-width` 把操作列撑宽。
5. **行内操作**:只放本模块明确需要的行操作;删除、版本切换等若需求未授权则不做。
## 数据源(D23) ## 数据源(D23)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 36 KiB

+10 -3
View File
@@ -313,14 +313,21 @@ test.describe("datasources console", () => {
await expect(page.getByTestId("datasource-filter-search")).toBeVisible(); await expect(page.getByTestId("datasource-filter-search")).toBeVisible();
await expect(page.getByTestId("datasource-filter-reset")).toBeVisible(); await expect(page.getByTestId("datasource-filter-reset")).toBeVisible();
// 新建 sits above the table, right aligned. // 新建 sits above the table, right aligned; pagination is a page footer below the table.
const create = await page.getByTestId("datasource-create").boundingBox(); const create = await page.getByTestId("datasource-create").boundingBox();
const table = await page.getByTestId("datasource-table").boundingBox(); const table = await page.getByTestId("datasource-table").boundingBox();
const pager = await page.getByTestId("datasource-pagination").boundingBox();
const viewport = page.viewportSize(); const viewport = page.viewportSize();
expect(create && table && viewport).toBeTruthy(); expect(create && table && pager && viewport).toBeTruthy();
expect(create!.y + create!.height).toBeLessThanOrEqual(table!.y); expect(create!.y + create!.height).toBeLessThanOrEqual(table!.y);
expect(create!.x + create!.width).toBeGreaterThan(table!.x + table!.width - 40); expect(create!.x + create!.width).toBeGreaterThan(table!.x + table!.width - 40);
// No page footer on the list. expect(pager!.y).toBeGreaterThanOrEqual(table!.y + table!.height - 2);
// The list page itself does not scroll; only the table body does.
const listScrolls = await page
.getByTestId("datasource-list")
.evaluate((el) => el.scrollHeight > el.clientHeight + 1);
expect(listScrolls).toBe(false);
// Detail-style action footer is not used on the list.
await expect(page.getByTestId("datasource-footer")).toHaveCount(0); await expect(page.getByTestId("datasource-footer")).toHaveCount(0);
// Disabled row: visible, 测试 disabled, no 停用, no "停用后不能测试" copy. // Disabled row: visible, 测试 disabled, no 停用, no "停用后不能测试" copy.
+6
View File
@@ -516,8 +516,14 @@ test.describe("queries console", () => {
const create = (await page.getByTestId("query-create").boundingBox())!; const create = (await page.getByTestId("query-create").boundingBox())!;
const box = (await table.boundingBox())!; const box = (await table.boundingBox())!;
const pager = (await page.getByTestId("query-pagination").boundingBox())!;
expect(create.y + create.height).toBeLessThanOrEqual(box.y); expect(create.y + create.height).toBeLessThanOrEqual(box.y);
expect(create.x + create.width).toBeGreaterThan(box.x + box.width - 40); expect(create.x + create.width).toBeGreaterThan(box.x + box.width - 40);
expect(pager.y).toBeGreaterThanOrEqual(box.y + box.height - 2);
const listScrolls = await page
.getByTestId("query-list")
.evaluate((el) => el.scrollHeight > el.clientHeight + 1);
expect(listScrolls).toBe(false);
await expect(page.getByTestId("query-footer")).toHaveCount(0); await expect(page.getByTestId("query-footer")).toHaveCount(0);
await expect(page.getByTestId("query-list-toolbar")).toBeVisible(); await expect(page.getByTestId("query-list-toolbar")).toBeVisible();
+2 -2
View File
@@ -48,7 +48,7 @@
"loadFailed": "Failed to load data sources", "loadFailed": "Failed to load data sources",
"empty": "No data sources yet", "empty": "No data sources yet",
"emptyHint": "An administrator can create the first data source.", "emptyHint": "An administrator can create the first data source.",
"filterName": "Name (contains)", "filterName": "Name",
"filterEngine": "Engine", "filterEngine": "Engine",
"filterStatus": "Status", "filterStatus": "Status",
"filterSearch": "Search", "filterSearch": "Search",
@@ -183,7 +183,7 @@
"loadFailed": "Failed to load queries", "loadFailed": "Failed to load queries",
"empty": "No queries yet", "empty": "No queries yet",
"emptyHint": "An administrator can create the first query: pick a data source, write a parameterized SQL template, and declare its parameters and output contract.", "emptyHint": "An administrator can create the first query: pick a data source, write a parameterized SQL template, and declare its parameters and output contract.",
"filterName": "Name (contains)", "filterName": "Name",
"filterDatasource": "Data source", "filterDatasource": "Data source",
"filterStatus": "Status", "filterStatus": "Status",
"filterSearch": "Search", "filterSearch": "Search",
+2 -2
View File
@@ -48,7 +48,7 @@
"loadFailed": "โหลดแหล่งข้อมูลไม่สำเร็จ", "loadFailed": "โหลดแหล่งข้อมูลไม่สำเร็จ",
"empty": "ยังไม่มีแหล่งข้อมูล", "empty": "ยังไม่มีแหล่งข้อมูล",
"emptyHint": "ผู้ดูแลสามารถสร้างแหล่งข้อมูลแรกได้", "emptyHint": "ผู้ดูแลสามารถสร้างแหล่งข้อมูลแรกได้",
"filterName": "ชื่อ (ค้นหาบางส่วน)", "filterName": "ชื่อ",
"filterEngine": "เอนจิน", "filterEngine": "เอนจิน",
"filterStatus": "สถานะ", "filterStatus": "สถานะ",
"filterSearch": "ค้นหา", "filterSearch": "ค้นหา",
@@ -183,7 +183,7 @@
"loadFailed": "โหลดคิวรีไม่สำเร็จ", "loadFailed": "โหลดคิวรีไม่สำเร็จ",
"empty": "ยังไม่มีคิวรี", "empty": "ยังไม่มีคิวรี",
"emptyHint": "ผู้ดูแลสามารถสร้างคิวรีแรกได้ โดยเลือกแหล่งข้อมูล เขียนเทมเพลต SQL แบบมีพารามิเตอร์ และประกาศพารามิเตอร์กับสัญญาเอาต์พุต", "emptyHint": "ผู้ดูแลสามารถสร้างคิวรีแรกได้ โดยเลือกแหล่งข้อมูล เขียนเทมเพลต SQL แบบมีพารามิเตอร์ และประกาศพารามิเตอร์กับสัญญาเอาต์พุต",
"filterName": "ชื่อ (ค้นหาบางส่วน)", "filterName": "ชื่อ",
"filterDatasource": "แหล่งข้อมูล", "filterDatasource": "แหล่งข้อมูล",
"filterStatus": "สถานะ", "filterStatus": "สถานะ",
"filterSearch": "ค้นหา", "filterSearch": "ค้นหา",
+2 -2
View File
@@ -49,7 +49,7 @@
"loadFailed": "数据源加载失败", "loadFailed": "数据源加载失败",
"empty": "还没有数据源", "empty": "还没有数据源",
"emptyHint": "管理者可以新建第一个数据源。", "emptyHint": "管理者可以新建第一个数据源。",
"filterName": "名称(模糊)", "filterName": "名称",
"filterEngine": "引擎", "filterEngine": "引擎",
"filterStatus": "状态", "filterStatus": "状态",
"filterSearch": "查询", "filterSearch": "查询",
@@ -184,7 +184,7 @@
"loadFailed": "查询加载失败", "loadFailed": "查询加载失败",
"empty": "还没有查询", "empty": "还没有查询",
"emptyHint": "管理者可以新建第一个查询定义:选择数据源,写参数化 SQL,声明参数与输出契约。", "emptyHint": "管理者可以新建第一个查询定义:选择数据源,写参数化 SQL,声明参数与输出契约。",
"filterName": "名称(模糊)", "filterName": "名称",
"filterDatasource": "数据源", "filterDatasource": "数据源",
"filterStatus": "状态", "filterStatus": "状态",
"filterSearch": "查询", "filterSearch": "查询",
+2 -2
View File
@@ -48,7 +48,7 @@
"loadFailed": "資料來源載入失敗", "loadFailed": "資料來源載入失敗",
"empty": "還沒有資料來源", "empty": "還沒有資料來源",
"emptyHint": "管理者可以新增第一個資料來源。", "emptyHint": "管理者可以新增第一個資料來源。",
"filterName": "名稱(模糊)", "filterName": "名稱",
"filterEngine": "引擎", "filterEngine": "引擎",
"filterStatus": "狀態", "filterStatus": "狀態",
"filterSearch": "查詢", "filterSearch": "查詢",
@@ -183,7 +183,7 @@
"loadFailed": "查詢載入失敗", "loadFailed": "查詢載入失敗",
"empty": "還沒有查詢", "empty": "還沒有查詢",
"emptyHint": "管理者可以新建第一個查詢定義:選擇資料來源,撰寫參數化 SQL,宣告參數與輸出契約。", "emptyHint": "管理者可以新建第一個查詢定義:選擇資料來源,撰寫參數化 SQL,宣告參數與輸出契約。",
"filterName": "名稱(模糊)", "filterName": "名稱",
"filterDatasource": "資料來源", "filterDatasource": "資料來源",
"filterStatus": "狀態", "filterStatus": "狀態",
"filterSearch": "查詢", "filterSearch": "查詢",
@@ -218,8 +218,12 @@ onMounted(load);
</script> </script>
<template> <template>
<div class="h-full overflow-auto p-5" data-testid="datasource-list"> <!-- Page itself does not scroll: toolbar + table body + pagination footer. -->
<div class="mb-3 flex flex-wrap items-center gap-2" data-testid="datasource-list-toolbar"> <div class="flex h-full min-h-0 flex-col overflow-hidden" data-testid="datasource-list">
<div
class="flex shrink-0 flex-wrap items-center gap-2 px-5 pb-3 pt-5"
data-testid="datasource-list-toolbar"
>
<div class="w-[200px]" data-testid="datasource-filter-name"> <div class="w-[200px]" data-testid="datasource-filter-name">
<ElInput v-model="draft.name" clearable :placeholder="t('datasource.list.filterName')" /> <ElInput v-model="draft.name" clearable :placeholder="t('datasource.list.filterName')" />
</div> </div>
@@ -259,6 +263,7 @@ onMounted(load);
</div> </div>
</div> </div>
<div class="flex min-h-0 flex-1 flex-col px-5">
<ElAlert <ElAlert
v-if="loadError" v-if="loadError"
type="error" type="error"
@@ -270,22 +275,27 @@ onMounted(load);
<div <div
v-else-if="!loading && total === 0 && !hasAppliedFilters" v-else-if="!loading && total === 0 && !hasAppliedFilters"
data-testid="datasource-empty" data-testid="datasource-empty"
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center" class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
> >
<div>
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.empty") }}</h3> <h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.empty") }}</h3>
<p class="text-[var(--text-secondary)]">{{ t("datasource.list.emptyHint") }}</p> <p class="text-[var(--text-secondary)]">{{ t("datasource.list.emptyHint") }}</p>
</div> </div>
</div>
<div <div
v-else-if="!loading && total === 0 && hasAppliedFilters" v-else-if="!loading && total === 0 && hasAppliedFilters"
data-testid="datasource-filter-empty" data-testid="datasource-filter-empty"
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center" class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
> >
<div>
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.filterEmpty") }}</h3> <h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.filterEmpty") }}</h3>
<p class="text-[var(--text-secondary)]">{{ t("datasource.list.filterEmptyHint") }}</p> <p class="text-[var(--text-secondary)]">{{ t("datasource.list.filterEmptyHint") }}</p>
</div> </div>
<template v-else> </div>
<div v-else class="min-h-0 flex-1" data-testid="datasource-table-wrap">
<ElTable <ElTable
v-loading="loading" v-loading="loading"
height="100%"
:data="items" :data="items"
row-key="id" row-key="id"
data-testid="datasource-table" data-testid="datasource-table"
@@ -385,7 +395,14 @@ onMounted(load);
</template> </template>
</ElTableColumn> </ElTableColumn>
</ElTable> </ElTable>
<div class="mt-3 flex justify-end" data-testid="datasource-pagination"> </div>
</div>
<footer
v-if="!loadError && (loading || total > 0)"
data-testid="datasource-pagination"
class="flex shrink-0 items-center justify-end border-t border-[var(--border-subtle)] bg-white px-5 py-3"
>
<ElPagination <ElPagination
background background
layout="total, sizes, prev, pager, next" layout="total, sizes, prev, pager, next"
@@ -396,8 +413,7 @@ onMounted(load);
@current-change="onPageChange" @current-change="onPageChange"
@size-change="onSizeChange" @size-change="onSizeChange"
/> />
</div> </footer>
</template>
</div> </div>
</template> </template>
+21 -8
View File
@@ -202,8 +202,9 @@ onMounted(async () => {
</script> </script>
<template> <template>
<div class="h-full overflow-auto p-5" data-testid="query-list"> <!-- Page itself does not scroll: toolbar + table body + pagination footer. -->
<div class="mb-3 flex flex-wrap items-center gap-2" data-testid="query-list-toolbar"> <div class="flex h-full min-h-0 flex-col overflow-hidden" data-testid="query-list">
<div class="flex shrink-0 flex-wrap items-center gap-2 px-5 pb-3 pt-5" data-testid="query-list-toolbar">
<div class="w-[200px]" data-testid="query-filter-name"> <div class="w-[200px]" data-testid="query-filter-name">
<ElInput v-model="draft.name" clearable :placeholder="t('query.list.filterName')" /> <ElInput v-model="draft.name" clearable :placeholder="t('query.list.filterName')" />
</div> </div>
@@ -246,6 +247,7 @@ onMounted(async () => {
</div> </div>
</div> </div>
<div class="flex min-h-0 flex-1 flex-col px-5">
<ElAlert <ElAlert
v-if="loadError" v-if="loadError"
type="error" type="error"
@@ -257,22 +259,27 @@ onMounted(async () => {
<div <div
v-else-if="!loading && total === 0 && !hasAppliedFilters" v-else-if="!loading && total === 0 && !hasAppliedFilters"
data-testid="query-empty" data-testid="query-empty"
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center" class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
> >
<div>
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.empty") }}</h3> <h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.empty") }}</h3>
<p class="text-[var(--text-secondary)]">{{ t("query.list.emptyHint") }}</p> <p class="text-[var(--text-secondary)]">{{ t("query.list.emptyHint") }}</p>
</div> </div>
</div>
<div <div
v-else-if="!loading && total === 0 && hasAppliedFilters" v-else-if="!loading && total === 0 && hasAppliedFilters"
data-testid="query-filter-empty" data-testid="query-filter-empty"
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center" class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
> >
<div>
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.filterEmpty") }}</h3> <h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.filterEmpty") }}</h3>
<p class="text-[var(--text-secondary)]">{{ t("query.list.filterEmptyHint") }}</p> <p class="text-[var(--text-secondary)]">{{ t("query.list.filterEmptyHint") }}</p>
</div> </div>
<template v-else> </div>
<div v-else class="min-h-0 flex-1" data-testid="query-table-wrap">
<ElTable <ElTable
v-loading="loading" v-loading="loading"
height="100%"
:data="items" :data="items"
row-key="id" row-key="id"
data-testid="query-table" data-testid="query-table"
@@ -350,7 +357,14 @@ onMounted(async () => {
</template> </template>
</ElTableColumn> </ElTableColumn>
</ElTable> </ElTable>
<div class="mt-3 flex justify-end" data-testid="query-pagination"> </div>
</div>
<footer
v-if="!loadError && (loading || total > 0)"
data-testid="query-pagination"
class="flex shrink-0 items-center justify-end border-t border-[var(--border-subtle)] bg-white px-5 py-3"
>
<ElPagination <ElPagination
background background
layout="total, sizes, prev, pager, next" layout="total, sizes, prev, pager, next"
@@ -361,8 +375,7 @@ onMounted(async () => {
@current-change="onPageChange" @current-change="onPageChange"
@size-change="onSizeChange" @size-change="onSizeChange"
/> />
</div> </footer>
</template>
<ElDialog <ElDialog
v-model="switchOpen" v-model="switchOpen"