@aspire-ui/element-component-pro 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -7
- package/dist/ProTable/ProTable.vue.d.ts +421 -0
- package/dist/ProTable/TableAction.vue.d.ts +43 -0
- package/dist/ProTable/index.d.ts +8 -0
- package/dist/ProTable/types/index.d.ts +252 -0
- package/dist/ProTable/useProTable.d.ts +12 -0
- package/dist/element-component-pro.es.js +740 -295
- package/dist/element-component-pro.es.js.map +1 -1
- package/dist/element-component-pro.umd.js +2 -2
- package/dist/element-component-pro.umd.js.map +1 -1
- package/dist/index.d.ts +1325 -0
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +0 -49
- package/dist/useComponentSetting.d.ts +12 -0
- package/package.json +7 -5
- package/src/ProForm/ProForm.vue +3 -1
- package/src/ProForm/useForm.ts +0 -1
- package/src/ProTable/ProTable.vue +773 -0
- package/src/ProTable/TableAction.vue +193 -0
- package/src/ProTable/index.ts +20 -0
- package/src/ProTable/types/index.ts +236 -0
- package/src/ProTable/useProTable.ts +79 -0
- package/src/index.ts +13 -10
- package/src/types/index.ts +0 -44
- package/src/useComponentSetting.ts +35 -0
package/README.md
CHANGED
|
@@ -54,12 +54,10 @@ import { ProTable, ProForm } from 'element-component-pro'
|
|
|
54
54
|
```vue
|
|
55
55
|
<template>
|
|
56
56
|
<ProTable
|
|
57
|
-
ref="tableRef"
|
|
58
57
|
:columns="columns"
|
|
59
|
-
:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
show-pagination
|
|
58
|
+
:api="fetchTableData"
|
|
59
|
+
row-key="id"
|
|
60
|
+
:pagination="{ pageSize: 10 }"
|
|
63
61
|
/>
|
|
64
62
|
</template>
|
|
65
63
|
|
|
@@ -81,11 +79,145 @@ const columns: ProColumn[] = [
|
|
|
81
79
|
|
|
82
80
|
const fetchTableData = async (params) => {
|
|
83
81
|
const res = await api.getList(params)
|
|
84
|
-
|
|
82
|
+
// ProTable 约定返回 { list, total },与 VbenAdmin 一致
|
|
83
|
+
return { list: res.list, total: res.total }
|
|
85
84
|
}
|
|
86
85
|
</script>
|
|
87
86
|
```
|
|
88
87
|
|
|
88
|
+
### ProTable + useProTable(tableAction)
|
|
89
|
+
|
|
90
|
+
参考 VbenAdmin 的 `useTable`,ProTable 提供 `useProTable` Hook,对外暴露 `tableAction` 方法。**可选传入 props**:`useProTable(props)` 支持传入 `ProTableProps` 或 `Ref<ProTableProps>`,会在表格 `@register` 时通过 `setProps` 应用,且 props 为响应式时变更会自动同步到表格(类型 `UseProTablePropsReactive`)。
|
|
91
|
+
|
|
92
|
+
```vue
|
|
93
|
+
<template>
|
|
94
|
+
<ProTable
|
|
95
|
+
@register="registerTable"
|
|
96
|
+
title="用户列表"
|
|
97
|
+
:columns="columns"
|
|
98
|
+
:api="fetchTableData"
|
|
99
|
+
row-key="id"
|
|
100
|
+
:row-selection="{ type: 'checkbox' }"
|
|
101
|
+
/>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<script setup lang="ts">
|
|
105
|
+
import { ProTable, useProTable } from 'element-component-pro'
|
|
106
|
+
import type { ProColumn, TableActionType } from 'element-component-pro'
|
|
107
|
+
|
|
108
|
+
const columns: ProColumn[] = [
|
|
109
|
+
{ title: 'ID', dataIndex: 'id', width: 80 },
|
|
110
|
+
{ title: '姓名', dataIndex: 'name', width: 120 },
|
|
111
|
+
{ title: '年龄', dataIndex: 'age', width: 80 },
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
const [registerTable, tableAction] = useProTable()
|
|
115
|
+
|
|
116
|
+
const reload = () => {
|
|
117
|
+
// 支持传入 page / pageSize / searchInfo,与 VbenAdmin 对齐
|
|
118
|
+
tableAction.reload({ page: 1 })
|
|
119
|
+
}
|
|
120
|
+
</script>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**TableActionType 常用方法(与 VbenAdmin BasicTable 对齐):**
|
|
124
|
+
|
|
125
|
+
| 方法 | 说明 |
|
|
126
|
+
|------|------|
|
|
127
|
+
| `setProps` | 动态更新 ProTable Props,例如列配置、分页配置等 |
|
|
128
|
+
| `reload(opt?: FetchParams)` | 重新请求数据,支持指定页码、每页条数、搜索参数 |
|
|
129
|
+
| `setLoading(loading: boolean)` | 手动切换表格 loading 状态 |
|
|
130
|
+
| `getDataSource()` / `setTableData(data)` | 获取 / 设置当前表格数据 |
|
|
131
|
+
| `getRawDataSource()` | 获取接口原始返回数据(未经过 afterFetch) |
|
|
132
|
+
| `getColumns()` / `setColumns(cols)` | 获取 / 设置列配置,支持传 `ProColumn[]` 或列 key 数组 |
|
|
133
|
+
| `setPagination(info)` | 设置分页信息(page、pageSize、total) |
|
|
134
|
+
| `getSelectRowKeys()` / `getSelectRows()` | 获取当前选中行的 keys / 行数据 |
|
|
135
|
+
| `getRowSelection()` | 获取当前行选择配置(rowSelection) |
|
|
136
|
+
| `setSelectedRowKeys(keys)` / `clearSelectedRowKeys()` | 设置 / 清空选中行 |
|
|
137
|
+
| `deleteSelectRowByKey(key)` | 取消勾选指定 key 的行 |
|
|
138
|
+
| `updateTableDataRecord(rowKey, record)` | 按 rowKey 更新某一行(局部刷新,不重新请求接口) |
|
|
139
|
+
| `deleteTableDataRecord(rowKey)` | 按 rowKey 删除行(支持单个或数组) |
|
|
140
|
+
| `insertTableDataRecord(record, index?)` | 在指定位置插入一行数据 |
|
|
141
|
+
| `getPaginationRef()` | 获取当前分页信息 `{ page, pageSize, total }` |
|
|
142
|
+
| `getShowPagination()` / `setShowPagination(show)` | 获取 / 设置是否显示分页 |
|
|
143
|
+
| `expandAll()` / `collapseAll()` | 展开 / 折叠树形表格所有行 |
|
|
144
|
+
|
|
145
|
+
### ProTable 操作列 + TableAction 组件
|
|
146
|
+
|
|
147
|
+
参考 VbenAdmin 的 `TableAction`,ProTable 提供了独立的 `TableAction` 组件,用于快速渲染「编辑 / 删除 / 更多」等操作按钮。
|
|
148
|
+
|
|
149
|
+
```vue
|
|
150
|
+
<template>
|
|
151
|
+
<ProTable
|
|
152
|
+
title="操作列示例"
|
|
153
|
+
:columns="columns"
|
|
154
|
+
:data-source="data"
|
|
155
|
+
:action-column="{ title: 'Action', dataIndex: 'action', width: 220, fixed: 'right' }"
|
|
156
|
+
>
|
|
157
|
+
<template #bodyCell="{ column, record }">
|
|
158
|
+
<!-- 只处理 action 列,其它列仍按默认方式渲染(与 Vben bodyCell 行为一致) -->
|
|
159
|
+
<template v-if="column.dataIndex === 'action'">
|
|
160
|
+
<TableAction
|
|
161
|
+
:actions="[
|
|
162
|
+
{
|
|
163
|
+
label: '编辑',
|
|
164
|
+
onClick: () => handleEdit(record),
|
|
165
|
+
},
|
|
166
|
+
]"
|
|
167
|
+
:drop-down-actions="[
|
|
168
|
+
{
|
|
169
|
+
label: '删除',
|
|
170
|
+
color: 'error',
|
|
171
|
+
popConfirm: {
|
|
172
|
+
title: '确认删除该行?',
|
|
173
|
+
confirm: () => handleDelete(record),
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
]"
|
|
177
|
+
/>
|
|
178
|
+
</template>
|
|
179
|
+
</template>
|
|
180
|
+
</ProTable>
|
|
181
|
+
</template>
|
|
182
|
+
|
|
183
|
+
<script setup lang="ts">
|
|
184
|
+
import { ProTable, TableAction } from 'element-component-pro'
|
|
185
|
+
import type { ProColumn } from 'element-component-pro'
|
|
186
|
+
|
|
187
|
+
const columns: ProColumn[] = [
|
|
188
|
+
{ title: '姓名', dataIndex: 'name', width: 120 },
|
|
189
|
+
{ title: '年龄', dataIndex: 'age', width: 80 },
|
|
190
|
+
{ title: '地址', dataIndex: 'address', minWidth: 200 },
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
const data = [
|
|
194
|
+
{ id: 1, name: '张三', age: 28, address: '北京市朝阳区' },
|
|
195
|
+
{ id: 2, name: '李四', age: 32, address: '上海市浦东新区' },
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
const handleEdit = (record: Record<string, unknown>) => {
|
|
199
|
+
console.log('编辑', record)
|
|
200
|
+
}
|
|
201
|
+
const handleDelete = (record: Record<string, unknown>) => {
|
|
202
|
+
console.log('删除', record)
|
|
203
|
+
}
|
|
204
|
+
</script>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**TableActionItem 支持的字段(与 VbenAdmin ActionItem 对齐):**
|
|
208
|
+
|
|
209
|
+
- **label**:按钮文本
|
|
210
|
+
- **icon**:图标 class(可传 Element UI 图标或自定义 iconfont)
|
|
211
|
+
- **color**:`success / error / warning`,内部映射为对应按钮类型
|
|
212
|
+
- **type**:直接透传给 `el-button` 的 `type`
|
|
213
|
+
- **props**:额外的按钮 props
|
|
214
|
+
- **disabled**:是否禁用
|
|
215
|
+
- **divider**:是否在该操作后显示分隔线
|
|
216
|
+
- **ifShow**:是否显示当前操作项(支持函数)
|
|
217
|
+
- **tooltip**:字符串或 Tooltip 配置对象
|
|
218
|
+
- **popConfirm**:气泡确认配置 `{ title, okText, cancelText, confirm, cancel }`
|
|
219
|
+
- **onClick**:点击回调
|
|
220
|
+
|
|
89
221
|
## ProForm
|
|
90
222
|
|
|
91
223
|
参考 [Vben Admin Form](https://doc.vvbin.cn/components/form.html),支持 Schema 驱动、useForm、render/slot、动态显示等。
|
|
@@ -182,8 +314,10 @@ const handleSubmit = (values) => {
|
|
|
182
314
|
|
|
183
315
|
## 示例与文档
|
|
184
316
|
|
|
185
|
-
- **示例**:运行 `npm run dev` 后访问开发预览,包含 ProForm
|
|
317
|
+
- **示例**:运行 `npm run dev` 后访问开发预览,包含 ProTable、ProForm、componentSettings 测试等示例
|
|
318
|
+
- **ProTable 文档**:[docs/ProTable.md](./docs/ProTable.md)
|
|
186
319
|
- **ProForm 文档**:[docs/ProForm.md](./docs/ProForm.md)
|
|
320
|
+
- **组件默认配置**:[docs/ComponentSetting.md](./docs/ComponentSetting.md)(`useComponentSetting`)
|
|
187
321
|
|
|
188
322
|
## 开发
|
|
189
323
|
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { ProColumn, ProTableProps, TableActionType, FetchSetting, FetchParams } from './types';
|
|
2
|
+
|
|
3
|
+
declare function __VLS_template(): Partial<Record<`header-${string}`, (_: {
|
|
4
|
+
column: {
|
|
5
|
+
key?: string | undefined;
|
|
6
|
+
title: string;
|
|
7
|
+
dataIndex: string;
|
|
8
|
+
width?: number | string | undefined;
|
|
9
|
+
minWidth?: number | string | undefined;
|
|
10
|
+
maxWidth?: number | string | undefined;
|
|
11
|
+
fixed?: "left" | "right" | undefined;
|
|
12
|
+
sortable?: boolean | undefined;
|
|
13
|
+
align?: "left" | "center" | "right" | undefined;
|
|
14
|
+
resizable?: boolean | undefined;
|
|
15
|
+
ellipsis?: boolean | undefined;
|
|
16
|
+
hideInTable?: boolean | undefined;
|
|
17
|
+
defaultHidden?: boolean | undefined;
|
|
18
|
+
helpMessage?: string | string[] | undefined;
|
|
19
|
+
valueType?: "text" | "date" | "dateTime" | "option" | "select" | "index" | undefined;
|
|
20
|
+
valueEnum?: Record<string | number, {
|
|
21
|
+
text: string;
|
|
22
|
+
status?: string;
|
|
23
|
+
}> | undefined;
|
|
24
|
+
customRender?: ((params: {
|
|
25
|
+
text: unknown;
|
|
26
|
+
record: Record<string, unknown>;
|
|
27
|
+
index: number;
|
|
28
|
+
}) => import('vue').VNode | string) | undefined;
|
|
29
|
+
formatter?: ((row: Record<string, unknown>, column: unknown, cellValue: unknown) => string) | undefined;
|
|
30
|
+
ifShow?: boolean | ((params: {
|
|
31
|
+
column: ProColumn;
|
|
32
|
+
}) => boolean) | undefined;
|
|
33
|
+
fieldProps?: Record<string, unknown> | undefined;
|
|
34
|
+
placeholder?: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
}) => any>> & Partial<Record<string, (_: {
|
|
37
|
+
row: any;
|
|
38
|
+
column: {
|
|
39
|
+
key?: string | undefined;
|
|
40
|
+
title: string;
|
|
41
|
+
dataIndex: string;
|
|
42
|
+
width?: number | string | undefined;
|
|
43
|
+
minWidth?: number | string | undefined;
|
|
44
|
+
maxWidth?: number | string | undefined;
|
|
45
|
+
fixed?: "left" | "right" | undefined;
|
|
46
|
+
sortable?: boolean | undefined;
|
|
47
|
+
align?: "left" | "center" | "right" | undefined;
|
|
48
|
+
resizable?: boolean | undefined;
|
|
49
|
+
ellipsis?: boolean | undefined;
|
|
50
|
+
hideInTable?: boolean | undefined;
|
|
51
|
+
defaultHidden?: boolean | undefined;
|
|
52
|
+
helpMessage?: string | string[] | undefined;
|
|
53
|
+
valueType?: "text" | "date" | "dateTime" | "option" | "select" | "index" | undefined;
|
|
54
|
+
valueEnum?: Record<string | number, {
|
|
55
|
+
text: string;
|
|
56
|
+
status?: string;
|
|
57
|
+
}> | undefined;
|
|
58
|
+
customRender?: ((params: {
|
|
59
|
+
text: unknown;
|
|
60
|
+
record: Record<string, unknown>;
|
|
61
|
+
index: number;
|
|
62
|
+
}) => import('vue').VNode | string) | undefined;
|
|
63
|
+
formatter?: ((row: Record<string, unknown>, column: unknown, cellValue: unknown) => string) | undefined;
|
|
64
|
+
ifShow?: boolean | ((params: {
|
|
65
|
+
column: ProColumn;
|
|
66
|
+
}) => boolean) | undefined;
|
|
67
|
+
fieldProps?: Record<string, unknown> | undefined;
|
|
68
|
+
placeholder?: string | undefined;
|
|
69
|
+
};
|
|
70
|
+
index: any;
|
|
71
|
+
value: any;
|
|
72
|
+
}) => any>> & {
|
|
73
|
+
tableTitle?(_: {}): any;
|
|
74
|
+
toolbar?(_: {}): any;
|
|
75
|
+
"toolbar-right"?(_: {}): any;
|
|
76
|
+
headerCell?(_: {
|
|
77
|
+
column: {
|
|
78
|
+
key?: string | undefined;
|
|
79
|
+
title: string;
|
|
80
|
+
dataIndex: string;
|
|
81
|
+
width?: number | string | undefined;
|
|
82
|
+
minWidth?: number | string | undefined;
|
|
83
|
+
maxWidth?: number | string | undefined;
|
|
84
|
+
fixed?: "left" | "right" | undefined;
|
|
85
|
+
sortable?: boolean | undefined;
|
|
86
|
+
align?: "left" | "center" | "right" | undefined;
|
|
87
|
+
resizable?: boolean | undefined;
|
|
88
|
+
ellipsis?: boolean | undefined;
|
|
89
|
+
hideInTable?: boolean | undefined;
|
|
90
|
+
defaultHidden?: boolean | undefined;
|
|
91
|
+
helpMessage?: string | string[] | undefined;
|
|
92
|
+
valueType?: "text" | "date" | "dateTime" | "option" | "select" | "index" | undefined;
|
|
93
|
+
valueEnum?: Record<string | number, {
|
|
94
|
+
text: string;
|
|
95
|
+
status?: string;
|
|
96
|
+
}> | undefined;
|
|
97
|
+
customRender?: ((params: {
|
|
98
|
+
text: unknown;
|
|
99
|
+
record: Record<string, unknown>;
|
|
100
|
+
index: number;
|
|
101
|
+
}) => import('vue').VNode | string) | undefined;
|
|
102
|
+
formatter?: ((row: Record<string, unknown>, column: unknown, cellValue: unknown) => string) | undefined;
|
|
103
|
+
ifShow?: boolean | ((params: {
|
|
104
|
+
column: ProColumn;
|
|
105
|
+
}) => boolean) | undefined;
|
|
106
|
+
fieldProps?: Record<string, unknown> | undefined;
|
|
107
|
+
placeholder?: string | undefined;
|
|
108
|
+
};
|
|
109
|
+
}): any;
|
|
110
|
+
action?(_: {
|
|
111
|
+
record: any;
|
|
112
|
+
column: Partial<ProColumn>;
|
|
113
|
+
index: any;
|
|
114
|
+
}): any;
|
|
115
|
+
};
|
|
116
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
117
|
+
columns?: ProColumn[];
|
|
118
|
+
dataSource?: Record<string, unknown>[];
|
|
119
|
+
api?: (params: Record<string, unknown>) => Promise<{
|
|
120
|
+
list?: unknown[];
|
|
121
|
+
items?: unknown[];
|
|
122
|
+
total?: number;
|
|
123
|
+
}>;
|
|
124
|
+
rowKey?: string;
|
|
125
|
+
title?: string;
|
|
126
|
+
titleHelpMessage?: string | string[];
|
|
127
|
+
bordered?: boolean;
|
|
128
|
+
striped?: boolean;
|
|
129
|
+
size?: "medium" | "small" | "large";
|
|
130
|
+
loading?: boolean;
|
|
131
|
+
maxHeight?: number | string;
|
|
132
|
+
height?: number | string;
|
|
133
|
+
ellipsis?: boolean;
|
|
134
|
+
showIndexColumn?: boolean;
|
|
135
|
+
indexColumnProps?: Partial<ProColumn>;
|
|
136
|
+
actionColumn?: Partial<ProColumn>;
|
|
137
|
+
rowSelection?: {
|
|
138
|
+
type?: "checkbox" | "radio";
|
|
139
|
+
width?: number;
|
|
140
|
+
fixed?: "left" | "right";
|
|
141
|
+
getCheckboxProps?: (r: Record<string, unknown>) => {
|
|
142
|
+
disabled?: boolean;
|
|
143
|
+
};
|
|
144
|
+
getRadioProps?: (r: Record<string, unknown>) => {
|
|
145
|
+
disabled?: boolean;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
clearSelectOnPageChange?: boolean;
|
|
149
|
+
pagination?: false | {
|
|
150
|
+
pageSize?: number;
|
|
151
|
+
pageSizes?: number[];
|
|
152
|
+
layout?: string;
|
|
153
|
+
props?: Record<string, unknown>;
|
|
154
|
+
} | Record<string, unknown>;
|
|
155
|
+
tableSetting?: {
|
|
156
|
+
redo?: boolean;
|
|
157
|
+
size?: boolean;
|
|
158
|
+
setting?: boolean;
|
|
159
|
+
fullScreen?: boolean;
|
|
160
|
+
};
|
|
161
|
+
fetchSetting?: FetchSetting;
|
|
162
|
+
beforeFetch?: (params: Record<string, unknown>) => Record<string, unknown>;
|
|
163
|
+
afterFetch?: (data: unknown) => unknown;
|
|
164
|
+
immediate?: boolean;
|
|
165
|
+
searchInfo?: Record<string, unknown>;
|
|
166
|
+
defaultSort?: {
|
|
167
|
+
prop: string;
|
|
168
|
+
order: "ascending" | "descending";
|
|
169
|
+
};
|
|
170
|
+
tableProps?: Record<string, unknown>;
|
|
171
|
+
rowClassName?: string | ((params: {
|
|
172
|
+
row: Record<string, unknown>;
|
|
173
|
+
rowIndex: number;
|
|
174
|
+
}) => string);
|
|
175
|
+
spanMethod?: (params: {
|
|
176
|
+
row: Record<string, unknown>;
|
|
177
|
+
column: Record<string, unknown>;
|
|
178
|
+
rowIndex: number;
|
|
179
|
+
columnIndex: number;
|
|
180
|
+
}) => [number, number] | {
|
|
181
|
+
rowspan: number;
|
|
182
|
+
colspan: number;
|
|
183
|
+
};
|
|
184
|
+
treeProps?: {
|
|
185
|
+
hasChildren?: string;
|
|
186
|
+
children?: string;
|
|
187
|
+
};
|
|
188
|
+
defaultExpandAll?: boolean;
|
|
189
|
+
expandRowKeys?: (string | number)[];
|
|
190
|
+
lazy?: boolean;
|
|
191
|
+
load?: (row: Record<string, unknown>, treeNode: {
|
|
192
|
+
level: number;
|
|
193
|
+
expanded: boolean;
|
|
194
|
+
loaded: boolean;
|
|
195
|
+
}, resolve: (data: Record<string, unknown>[]) => void) => void;
|
|
196
|
+
}>, {
|
|
197
|
+
rowKey: string;
|
|
198
|
+
clearSelectOnPageChange: boolean;
|
|
199
|
+
bordered: boolean;
|
|
200
|
+
striped: boolean;
|
|
201
|
+
size: string;
|
|
202
|
+
loading: boolean;
|
|
203
|
+
ellipsis: boolean;
|
|
204
|
+
showIndexColumn: boolean;
|
|
205
|
+
pagination: () => {
|
|
206
|
+
pageSize: number;
|
|
207
|
+
pageSizes: number[];
|
|
208
|
+
};
|
|
209
|
+
tableSetting: () => {
|
|
210
|
+
redo: boolean;
|
|
211
|
+
};
|
|
212
|
+
fetchSetting: () => {
|
|
213
|
+
pageField: string;
|
|
214
|
+
sizeField: string;
|
|
215
|
+
listField: string;
|
|
216
|
+
totalField: string;
|
|
217
|
+
};
|
|
218
|
+
immediate: boolean;
|
|
219
|
+
}>, {
|
|
220
|
+
setProps: (props: Partial<ProTableProps>) => void;
|
|
221
|
+
reload: (opt?: FetchParams) => Promise<void>;
|
|
222
|
+
redoHeight: () => void;
|
|
223
|
+
setLoading: (loading: boolean) => void;
|
|
224
|
+
getDataSource: () => Record<string, unknown>[];
|
|
225
|
+
getRawDataSource: () => Record<string, unknown>;
|
|
226
|
+
setTableData: (data: Record<string, unknown>[]) => void;
|
|
227
|
+
getColumns: () => ProColumn[];
|
|
228
|
+
setColumns: (columns: ProColumn[] | string[]) => void;
|
|
229
|
+
setPagination: (info: Partial<{
|
|
230
|
+
page: number;
|
|
231
|
+
pageSize: number;
|
|
232
|
+
total: number;
|
|
233
|
+
}>) => void;
|
|
234
|
+
getSelectRowKeys: () => (string | number)[];
|
|
235
|
+
getSelectRows: () => Record<string, unknown>[];
|
|
236
|
+
clearSelectedRowKeys: () => void;
|
|
237
|
+
setSelectedRowKeys: (keys: (string | number)[]) => void;
|
|
238
|
+
deleteSelectRowByKey: (key: string | number) => void;
|
|
239
|
+
updateTableData: (index: number, key: string, value: unknown) => void;
|
|
240
|
+
updateTableDataRecord: (rowKey: string | number, record: Record<string, unknown>) => Record<string, unknown> | void;
|
|
241
|
+
deleteTableDataRecord: (rowKey: string | number | (string | number)[]) => void;
|
|
242
|
+
insertTableDataRecord: (record: Record<string, unknown>, index?: number) => Record<string, unknown> | void;
|
|
243
|
+
getPaginationRef: () => {
|
|
244
|
+
page: number;
|
|
245
|
+
pageSize: number;
|
|
246
|
+
total: number;
|
|
247
|
+
} | false;
|
|
248
|
+
getShowPagination: () => boolean;
|
|
249
|
+
setShowPagination: (show: boolean) => void | Promise<void>;
|
|
250
|
+
getRowSelection: () => import('./types').TableRowSelection;
|
|
251
|
+
expandAll?: () => void;
|
|
252
|
+
collapseAll?: () => void;
|
|
253
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
254
|
+
register: (action: TableActionType) => void;
|
|
255
|
+
"fetch-success": (data: {
|
|
256
|
+
items: unknown[];
|
|
257
|
+
total: number;
|
|
258
|
+
}) => void;
|
|
259
|
+
"fetch-error": (error: unknown) => void;
|
|
260
|
+
"selection-change": (data: {
|
|
261
|
+
keys: (string | number)[];
|
|
262
|
+
rows: Record<string, unknown>[];
|
|
263
|
+
}) => void;
|
|
264
|
+
"row-click": (record: Record<string, unknown>, event: Event) => void;
|
|
265
|
+
"row-dblclick": (record: Record<string, unknown>, event: Event) => void;
|
|
266
|
+
"sort-change": (sortInfo: {
|
|
267
|
+
prop: string;
|
|
268
|
+
order: string;
|
|
269
|
+
}) => void;
|
|
270
|
+
"expand-change": (row: Record<string, unknown>, expanded: boolean | Record<string, unknown>[]) => void;
|
|
271
|
+
}, string, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
272
|
+
columns?: ProColumn[];
|
|
273
|
+
dataSource?: Record<string, unknown>[];
|
|
274
|
+
api?: (params: Record<string, unknown>) => Promise<{
|
|
275
|
+
list?: unknown[];
|
|
276
|
+
items?: unknown[];
|
|
277
|
+
total?: number;
|
|
278
|
+
}>;
|
|
279
|
+
rowKey?: string;
|
|
280
|
+
title?: string;
|
|
281
|
+
titleHelpMessage?: string | string[];
|
|
282
|
+
bordered?: boolean;
|
|
283
|
+
striped?: boolean;
|
|
284
|
+
size?: "medium" | "small" | "large";
|
|
285
|
+
loading?: boolean;
|
|
286
|
+
maxHeight?: number | string;
|
|
287
|
+
height?: number | string;
|
|
288
|
+
ellipsis?: boolean;
|
|
289
|
+
showIndexColumn?: boolean;
|
|
290
|
+
indexColumnProps?: Partial<ProColumn>;
|
|
291
|
+
actionColumn?: Partial<ProColumn>;
|
|
292
|
+
rowSelection?: {
|
|
293
|
+
type?: "checkbox" | "radio";
|
|
294
|
+
width?: number;
|
|
295
|
+
fixed?: "left" | "right";
|
|
296
|
+
getCheckboxProps?: (r: Record<string, unknown>) => {
|
|
297
|
+
disabled?: boolean;
|
|
298
|
+
};
|
|
299
|
+
getRadioProps?: (r: Record<string, unknown>) => {
|
|
300
|
+
disabled?: boolean;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
clearSelectOnPageChange?: boolean;
|
|
304
|
+
pagination?: false | {
|
|
305
|
+
pageSize?: number;
|
|
306
|
+
pageSizes?: number[];
|
|
307
|
+
layout?: string;
|
|
308
|
+
props?: Record<string, unknown>;
|
|
309
|
+
} | Record<string, unknown>;
|
|
310
|
+
tableSetting?: {
|
|
311
|
+
redo?: boolean;
|
|
312
|
+
size?: boolean;
|
|
313
|
+
setting?: boolean;
|
|
314
|
+
fullScreen?: boolean;
|
|
315
|
+
};
|
|
316
|
+
fetchSetting?: FetchSetting;
|
|
317
|
+
beforeFetch?: (params: Record<string, unknown>) => Record<string, unknown>;
|
|
318
|
+
afterFetch?: (data: unknown) => unknown;
|
|
319
|
+
immediate?: boolean;
|
|
320
|
+
searchInfo?: Record<string, unknown>;
|
|
321
|
+
defaultSort?: {
|
|
322
|
+
prop: string;
|
|
323
|
+
order: "ascending" | "descending";
|
|
324
|
+
};
|
|
325
|
+
tableProps?: Record<string, unknown>;
|
|
326
|
+
rowClassName?: string | ((params: {
|
|
327
|
+
row: Record<string, unknown>;
|
|
328
|
+
rowIndex: number;
|
|
329
|
+
}) => string);
|
|
330
|
+
spanMethod?: (params: {
|
|
331
|
+
row: Record<string, unknown>;
|
|
332
|
+
column: Record<string, unknown>;
|
|
333
|
+
rowIndex: number;
|
|
334
|
+
columnIndex: number;
|
|
335
|
+
}) => [number, number] | {
|
|
336
|
+
rowspan: number;
|
|
337
|
+
colspan: number;
|
|
338
|
+
};
|
|
339
|
+
treeProps?: {
|
|
340
|
+
hasChildren?: string;
|
|
341
|
+
children?: string;
|
|
342
|
+
};
|
|
343
|
+
defaultExpandAll?: boolean;
|
|
344
|
+
expandRowKeys?: (string | number)[];
|
|
345
|
+
lazy?: boolean;
|
|
346
|
+
load?: (row: Record<string, unknown>, treeNode: {
|
|
347
|
+
level: number;
|
|
348
|
+
expanded: boolean;
|
|
349
|
+
loaded: boolean;
|
|
350
|
+
}, resolve: (data: Record<string, unknown>[]) => void) => void;
|
|
351
|
+
}>, {
|
|
352
|
+
rowKey: string;
|
|
353
|
+
clearSelectOnPageChange: boolean;
|
|
354
|
+
bordered: boolean;
|
|
355
|
+
striped: boolean;
|
|
356
|
+
size: string;
|
|
357
|
+
loading: boolean;
|
|
358
|
+
ellipsis: boolean;
|
|
359
|
+
showIndexColumn: boolean;
|
|
360
|
+
pagination: () => {
|
|
361
|
+
pageSize: number;
|
|
362
|
+
pageSizes: number[];
|
|
363
|
+
};
|
|
364
|
+
tableSetting: () => {
|
|
365
|
+
redo: boolean;
|
|
366
|
+
};
|
|
367
|
+
fetchSetting: () => {
|
|
368
|
+
pageField: string;
|
|
369
|
+
sizeField: string;
|
|
370
|
+
listField: string;
|
|
371
|
+
totalField: string;
|
|
372
|
+
};
|
|
373
|
+
immediate: boolean;
|
|
374
|
+
}>>>, {
|
|
375
|
+
size: "medium" | "small" | "large";
|
|
376
|
+
rowKey: string;
|
|
377
|
+
bordered: boolean;
|
|
378
|
+
striped: boolean;
|
|
379
|
+
loading: boolean;
|
|
380
|
+
ellipsis: boolean;
|
|
381
|
+
showIndexColumn: boolean;
|
|
382
|
+
clearSelectOnPageChange: boolean;
|
|
383
|
+
pagination: false | {
|
|
384
|
+
pageSize?: number;
|
|
385
|
+
pageSizes?: number[];
|
|
386
|
+
layout?: string;
|
|
387
|
+
props?: Record<string, unknown>;
|
|
388
|
+
} | Record<string, unknown>;
|
|
389
|
+
tableSetting: {
|
|
390
|
+
redo?: boolean;
|
|
391
|
+
size?: boolean;
|
|
392
|
+
setting?: boolean;
|
|
393
|
+
fullScreen?: boolean;
|
|
394
|
+
};
|
|
395
|
+
fetchSetting: FetchSetting;
|
|
396
|
+
immediate: boolean;
|
|
397
|
+
}>;
|
|
398
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
399
|
+
export default _default;
|
|
400
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
401
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
402
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
403
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
404
|
+
} : {
|
|
405
|
+
type: import('vue').PropType<T[K]>;
|
|
406
|
+
required: true;
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
type __VLS_WithDefaults<P, D> = {
|
|
410
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
411
|
+
default: D[K];
|
|
412
|
+
}> : P[K];
|
|
413
|
+
};
|
|
414
|
+
type __VLS_Prettify<T> = {
|
|
415
|
+
[K in keyof T]: T[K];
|
|
416
|
+
} & {};
|
|
417
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
418
|
+
new (): {
|
|
419
|
+
$scopedSlots: S;
|
|
420
|
+
};
|
|
421
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TableActionItem } from './types';
|
|
2
|
+
|
|
3
|
+
declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
actions?: TableActionItem[];
|
|
5
|
+
dropDownActions?: TableActionItem[];
|
|
6
|
+
/** 是否阻止按钮 click 冒泡,参考 VbenAdmin stopButtonPropagation */
|
|
7
|
+
stopButtonPropagation?: boolean;
|
|
8
|
+
}>, {
|
|
9
|
+
actions: () => never[];
|
|
10
|
+
dropDownActions: () => never[];
|
|
11
|
+
stopButtonPropagation: boolean;
|
|
12
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
13
|
+
actions?: TableActionItem[];
|
|
14
|
+
dropDownActions?: TableActionItem[];
|
|
15
|
+
/** 是否阻止按钮 click 冒泡,参考 VbenAdmin stopButtonPropagation */
|
|
16
|
+
stopButtonPropagation?: boolean;
|
|
17
|
+
}>, {
|
|
18
|
+
actions: () => never[];
|
|
19
|
+
dropDownActions: () => never[];
|
|
20
|
+
stopButtonPropagation: boolean;
|
|
21
|
+
}>>>, {
|
|
22
|
+
actions: TableActionItem[];
|
|
23
|
+
dropDownActions: TableActionItem[];
|
|
24
|
+
stopButtonPropagation: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
export default _default;
|
|
27
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
28
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
29
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
30
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
31
|
+
} : {
|
|
32
|
+
type: import('vue').PropType<T[K]>;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
type __VLS_WithDefaults<P, D> = {
|
|
37
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
38
|
+
default: D[K];
|
|
39
|
+
}> : P[K];
|
|
40
|
+
};
|
|
41
|
+
type __VLS_Prettify<T> = {
|
|
42
|
+
[K in keyof T]: T[K];
|
|
43
|
+
} & {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as ProTable } from './ProTable.vue';
|
|
2
|
+
import { default as TableAction } from './TableAction.vue';
|
|
3
|
+
import { useProTable } from './useProTable';
|
|
4
|
+
|
|
5
|
+
export { ProTable, useProTable, TableAction };
|
|
6
|
+
export type { UseProTableReturn } from './useProTable';
|
|
7
|
+
export type { ProColumn, ProTableProps, TableActionType, FetchSetting, FetchParams, ProTableToolBarConfig, SpanMethodParams, SpanMethodResult, TreeProps, TableActionItem, TableActionProps, } from './types';
|
|
8
|
+
export default ProTable;
|