feat(web): 列表自适应布局并将分页固定页脚
数据源与查询列表整页不滚、仅表体内滚;名称筛选去掉「模糊」占位后缀。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c1da6d7c3a
commit
be63e2fe5d
11 files changed
+314
-271
No files matched your search
@@ -202,8 +202,9 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full overflow-auto p-5" data-testid="query-list">
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2" data-testid="query-list-toolbar">
|
||||
<!-- Page itself does not scroll: toolbar + table body + pagination footer. -->
|
||||
<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">
|
||||
<ElInput v-model="draft.name" clearable :placeholder="t('query.list.filterName')" />
|
||||
</div>
|
||||
@@ -246,123 +247,135 @@ onMounted(async () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
data-testid="query-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && !hasAppliedFilters"
|
||||
data-testid="query-empty"
|
||||
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<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>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="query-filter-empty"
|
||||
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<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>
|
||||
</div>
|
||||
<template v-else>
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="query-table"
|
||||
:default-sort="{ prop: 'updated_at', order: 'descending' }"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
<div class="flex min-h-0 flex-1 flex-col px-5">
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
data-testid="query-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && !hasAppliedFilters"
|
||||
data-testid="query-empty"
|
||||
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"
|
||||
>
|
||||
<ElTableColumn
|
||||
prop="name"
|
||||
:label="t('query.columns.name')"
|
||||
min-width="180"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn
|
||||
prop="datasource"
|
||||
:label="t('query.columns.datasource')"
|
||||
min-width="160"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ sourceName(row) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="status"
|
||||
:label="t('query.columns.status')"
|
||||
min-width="110"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="row.enabled ? 'success' : 'info'" effect="light" data-testid="row-status">
|
||||
{{ row.enabled ? t("query.status.enabled") : t("query.status.disabled") }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="currentVersion"
|
||||
:label="t('query.columns.currentVersion')"
|
||||
min-width="120"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ currentVersion(row) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="updated_at"
|
||||
:label="t('query.columns.updatedAt')"
|
||||
min-width="150"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ formatDateTime(row.updated_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
:label="t('query.columns.actions')"
|
||||
:width="actionsWidth"
|
||||
align="right"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap" :data-testid="`query-row-${row.id}`">
|
||||
<ElButton link type="primary" data-testid="row-open" @click="openDetail(row)">
|
||||
{{ t("query.actions.open") }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" data-testid="row-switch-version" @click="openSwitch(row)">
|
||||
{{ t("query.actions.switchVersion") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="row-preview"
|
||||
:disabled="!row.enabled"
|
||||
:title="row.enabled ? undefined : t('query.actions.previewDisabledWhy')"
|
||||
@click="openPreview(row)"
|
||||
>
|
||||
{{ t("query.actions.preview") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
<div class="mt-3 flex justify-end" data-testid="query-pagination">
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
<div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="query-filter-empty"
|
||||
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>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("query.list.filterEmptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1" data-testid="query-table-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
height="100%"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="query-table"
|
||||
:default-sort="{ prop: 'updated_at', order: 'descending' }"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<ElTableColumn
|
||||
prop="name"
|
||||
:label="t('query.columns.name')"
|
||||
min-width="180"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn
|
||||
prop="datasource"
|
||||
:label="t('query.columns.datasource')"
|
||||
min-width="160"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ sourceName(row) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="status"
|
||||
:label="t('query.columns.status')"
|
||||
min-width="110"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="row.enabled ? 'success' : 'info'" effect="light" data-testid="row-status">
|
||||
{{ row.enabled ? t("query.status.enabled") : t("query.status.disabled") }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="currentVersion"
|
||||
:label="t('query.columns.currentVersion')"
|
||||
min-width="120"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ currentVersion(row) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="updated_at"
|
||||
:label="t('query.columns.updatedAt')"
|
||||
min-width="150"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ formatDateTime(row.updated_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
:label="t('query.columns.actions')"
|
||||
:width="actionsWidth"
|
||||
align="right"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap" :data-testid="`query-row-${row.id}`">
|
||||
<ElButton link type="primary" data-testid="row-open" @click="openDetail(row)">
|
||||
{{ t("query.actions.open") }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" data-testid="row-switch-version" @click="openSwitch(row)">
|
||||
{{ t("query.actions.switchVersion") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="row-preview"
|
||||
:disabled="!row.enabled"
|
||||
:title="row.enabled ? undefined : t('query.actions.previewDisabledWhy')"
|
||||
@click="openPreview(row)"
|
||||
>
|
||||
{{ t("query.actions.preview") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</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
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</footer>
|
||||
|
||||
<ElDialog
|
||||
v-model="switchOpen"
|
||||
|
||||
Reference in new issue
Block a user