外观
KvSearchTablePage
搜索表格整页组件,在 KvSearchTable 基础上内置 usePagedTable 状态机、列显隐和满高布局,页面只需传入配置与请求函数。
间距可通过组件或祖先上的 CSS 变量调整,详见 KvSearchTable 间距配置。
实时预览
完整搜索表格页面
示例使用本地异步数据,支持查询、分页、刷新和请求加载状态。
Props
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
title | string | — | 否 | 可选工具栏标题;未传、空字符串或纯空白时不显示 |
rowKey | string | ((row: T) => string | number) | — | 是 | 行唯一键 |
searchItems | SearchFormItem[] | — | 是 | 搜索项配置 |
columns | ColumnOption<T>[] | — | 是 | 完整列配置,组件内部生成显隐状态 |
request | (params: PagedTableRequest<Q>) => Promise<PagedTableResponse<T>> | — | 是 | 分页请求函数 |
initialQuery | Q | {} | 否 | 初始查询条件和重置目标 |
initialPageSize | number | 10 | 否 | 初始每页条数 |
immediate | boolean | true | 否 | 挂载后是否立即请求 |
paginationOptions | KvTablePaginationOptions | { align: 'right' } | 否 | 分页选项 |
toolbarOptions | Partial<KvTableToolbarOptions> | {} | 否 | 工具栏按钮显隐;默认只显示刷新和全屏 |
messages | Partial<KevairyComponentMessages> | {} | 否 | 组件文案覆盖 |
ariaLabel | string | 有标题时为 ${title}搜索表格,否则为 搜索表格 | 否 | 页面区域的无障碍名称 |
v-model
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
showSearchBar | boolean | true | 是否显示搜索栏 |
fullscreen | boolean | false | 是否全屏 |
appearance | TableAppearance | 默认外观 | 表格外观 |
Slots
toolbar-left / toolbar-right 中插入的按钮统一使用 8px 间距,与内置工具按钮一致;直接插入按钮即可,不要叠加外边距或间距容器。详见 插槽按钮间距规范。
| 插槽 | 说明 |
|---|---|
toolbar-left | 数量统计之后的左侧扩展 |
toolbar-right | 工具栏右侧扩展 |
bulk-actions | 批量操作,插槽参数提供 { selectedRows, selectedCount } |
[column.prop] | 单元格插槽,列配置 useSlot: true 时生效 |
[column.prop]-header | 表头插槽,列配置 useHeaderSlot: true 时生效 |
Expose
| 名称 | 说明 |
|---|---|
query / data / loading / error / pagination | 只读响应式状态 |
selectedRows / selectedCount | 当前选中行及数量 |
load / search / reset / refresh / cancel | 命令式请求控制 |
示例代码
vue
<script setup>
import { KvSearchTablePage } from '@kevairy/components'
const searchItems = [{ key: 'keyword', label: '关键词', type: 'input' }]
const columns = [
{ prop: 'id', label: 'ID' },
{ prop: 'name', label: '名称' }
]
const request = async ({ query, current, size, signal }) => {
const response = await api.list({ ...query, current, size }, { signal })
return { records: response.items, total: response.totalCount }
}
</script>
<template>
<KvSearchTablePage
title="列表"
row-key="id"
:search-items="searchItems"
:columns="columns"
:request="request"
/>
</template>组件根节点使用模板布局的 --art-full-height 作为可用高度,脱离模板布局时回退为父容器的 100% 高度。