bw-pro-table 0.0.1
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/LICENSE +21 -0
- package/README.md +341 -0
- package/dist/bw-pro-table.css +2 -0
- package/dist/bw-pro-table.js +6414 -0
- package/dist/bw-pro-table.umd.cjs +62 -0
- package/dist/types/BwProTable.vue.d.ts +61 -0
- package/dist/types/BwProTableAdvancedFilter.vue.d.ts +17 -0
- package/dist/types/BwProTableBatchEditModal.vue.d.ts +23 -0
- package/dist/types/BwProTableColumnSearch.vue.d.ts +14 -0
- package/dist/types/BwProTableColumnSetting.vue.d.ts +14 -0
- package/dist/types/BwProTableContextMenu.vue.d.ts +20 -0
- package/dist/types/BwProTableCore.vue.d.ts +38 -0
- package/dist/types/BwProTableSearch.vue.d.ts +33 -0
- package/dist/types/BwProTableToolbar.vue.d.ts +84 -0
- package/dist/types/composables/index.d.ts +25 -0
- package/dist/types/composables/useBwKeyboard.d.ts +44 -0
- package/dist/types/composables/useBwPermission.d.ts +50 -0
- package/dist/types/composables/useBwRowEdit.d.ts +83 -0
- package/dist/types/composables/useBwRowSelection.d.ts +42 -0
- package/dist/types/composables/useColumnHeaderSearch.d.ts +28 -0
- package/dist/types/composables/useContextMenu.d.ts +54 -0
- package/dist/types/composables/useDragSort.d.ts +36 -0
- package/dist/types/composables/useExportExcel.d.ts +35 -0
- package/dist/types/composables/useImportExcel.d.ts +45 -0
- package/dist/types/composables/useLocale.d.ts +14 -0
- package/dist/types/composables/usePersistence.d.ts +60 -0
- package/dist/types/composables/useQueryParams.d.ts +38 -0
- package/dist/types/composables/useTableView.d.ts +36 -0
- package/dist/types/constants.d.ts +60 -0
- package/dist/types/drag-icon.vue.d.ts +14 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/injection-keys.d.ts +59 -0
- package/dist/types/locales/en-US.d.ts +166 -0
- package/dist/types/locales/zh-CN.d.ts +6 -0
- package/dist/types/renderers/action-renderer.d.ts +6 -0
- package/dist/types/renderers/avatar-renderer.d.ts +6 -0
- package/dist/types/renderers/boolean-renderer.d.ts +6 -0
- package/dist/types/renderers/currency-renderer.d.ts +6 -0
- package/dist/types/renderers/date-renderer.d.ts +6 -0
- package/dist/types/renderers/image-renderer.d.ts +6 -0
- package/dist/types/renderers/index-renderer.d.ts +6 -0
- package/dist/types/renderers/index.d.ts +27 -0
- package/dist/types/renderers/link-renderer.d.ts +6 -0
- package/dist/types/renderers/number-renderer.d.ts +6 -0
- package/dist/types/renderers/progress-renderer.d.ts +6 -0
- package/dist/types/renderers/registry.d.ts +41 -0
- package/dist/types/renderers/tag-enum-renderer.d.ts +6 -0
- package/dist/types/renderers/text-renderer.d.ts +6 -0
- package/dist/types/types.d.ts +567 -0
- package/locales/en-US.ts +177 -0
- package/locales/zh-CN.ts +193 -0
- package/package.json +99 -0
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
import type { VNode } from 'vue';
|
|
2
|
+
import type { TableColumnType, TablePaginationConfig } from 'ant-design-vue';
|
|
3
|
+
import type { TableRowSelection, ExpandableConfig, GetRowKey } from 'ant-design-vue/es/table/interface';
|
|
4
|
+
/** 排序方向 */
|
|
5
|
+
export type SortOrder = 'ascend' | 'descend' | null;
|
|
6
|
+
/** 筛选值类型 */
|
|
7
|
+
export type FilterValue = (string | number)[] | null;
|
|
8
|
+
/** 行 Key 类型 */
|
|
9
|
+
export type Key = string | number;
|
|
10
|
+
import type { CSSProperties } from 'vue';
|
|
11
|
+
/** 支持的 valueType 预设值 */
|
|
12
|
+
export type ValueType = 'text' | 'number' | 'date' | 'tag' | 'image' | 'link' | 'progress' | 'avatar' | 'action' | 'index' | 'currency' | 'boolean';
|
|
13
|
+
/** valueEnum 映射定义 */
|
|
14
|
+
export interface ValueEnumItem {
|
|
15
|
+
text: string;
|
|
16
|
+
status?: 'Success' | 'Processing' | 'Error' | 'Default' | 'Warning';
|
|
17
|
+
color?: string;
|
|
18
|
+
}
|
|
19
|
+
export type ValueEnumMap = Record<string | number, ValueEnumItem | string>;
|
|
20
|
+
/** 列头搜索配置 */
|
|
21
|
+
export interface HeaderSearchConfig {
|
|
22
|
+
/** 是否启用列头搜索(默认 false) */
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
/** 搜索框占位文本 */
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
/** 搜索按钮文本 */
|
|
27
|
+
searchText?: string;
|
|
28
|
+
/** 重置按钮文本 */
|
|
29
|
+
resetText?: string;
|
|
30
|
+
}
|
|
31
|
+
/** ProColumn 类型 — 在 ant-design-vue TableColumnType 基础上扩展 ProTable 特有字段 */
|
|
32
|
+
export interface ProColumnType<RecordType = any> extends Omit<TableColumnType<RecordType>, 'children'> {
|
|
33
|
+
/** 列类型预设值 */
|
|
34
|
+
valueType?: ValueType;
|
|
35
|
+
/** 枚举列的值映射 */
|
|
36
|
+
valueEnum?: ValueEnumMap;
|
|
37
|
+
/** 日期格式(valueType='date' 时生效) */
|
|
38
|
+
dateFormat?: string;
|
|
39
|
+
/** 小数精度(valueType='number'/'currency' 时生效) */
|
|
40
|
+
precision?: number;
|
|
41
|
+
/** 货币前缀符号 */
|
|
42
|
+
currencyPrefix?: string;
|
|
43
|
+
/** 货币后缀符号 */
|
|
44
|
+
currencySuffix?: string;
|
|
45
|
+
/** 空单元格占位符,覆盖全局配置 */
|
|
46
|
+
emptyText?: string;
|
|
47
|
+
/** 溢出策略 */
|
|
48
|
+
overflow?: 'ellipsis' | 'wrap' | 'clip';
|
|
49
|
+
/** 表头说明文字 */
|
|
50
|
+
description?: string;
|
|
51
|
+
/** 操作列按钮配置(valueType='action' 时生效) */
|
|
52
|
+
actions?: ActionItem<RecordType>[];
|
|
53
|
+
/** 图片宽度(valueType='image' 时生效) */
|
|
54
|
+
imageWidth?: number;
|
|
55
|
+
/** 图片高度(valueType='image' 时生效) */
|
|
56
|
+
imageHeight?: number;
|
|
57
|
+
/** 链接列配置(valueType='link' 时生效) */
|
|
58
|
+
linkProps?: {
|
|
59
|
+
href?: string;
|
|
60
|
+
target?: string;
|
|
61
|
+
onClick?: (record: RecordType, event: Event) => void;
|
|
62
|
+
};
|
|
63
|
+
/** 进度列配置(valueType='progress' 时生效) */
|
|
64
|
+
progressProps?: {
|
|
65
|
+
strokeColor?: string;
|
|
66
|
+
};
|
|
67
|
+
/** 头像列配置(valueType='avatar' 时生效) */
|
|
68
|
+
avatarProps?: {
|
|
69
|
+
srcField?: string;
|
|
70
|
+
nameField?: string;
|
|
71
|
+
showName?: boolean;
|
|
72
|
+
size?: number;
|
|
73
|
+
shape?: 'circle' | 'square';
|
|
74
|
+
};
|
|
75
|
+
/** 布尔列使用 Switch 开关 */
|
|
76
|
+
booleanSwitch?: boolean;
|
|
77
|
+
/** 列级表单校验规则 */
|
|
78
|
+
formRules?: FormRule[];
|
|
79
|
+
/** 列级权限标识 */
|
|
80
|
+
authority?: string | string[];
|
|
81
|
+
/** 是否可编辑 */
|
|
82
|
+
editable?: boolean | ((record: RecordType) => boolean);
|
|
83
|
+
/** 编辑态组件类型 */
|
|
84
|
+
editComponent?: string;
|
|
85
|
+
/** 编辑态组件的额外 props */
|
|
86
|
+
editComponentProps?: Record<string, any>;
|
|
87
|
+
/** 子列 */
|
|
88
|
+
children?: ProColumnsType<RecordType>;
|
|
89
|
+
/** 是否隐藏该列 */
|
|
90
|
+
hidden?: boolean;
|
|
91
|
+
/** 列所属分组 */
|
|
92
|
+
columnGroup?: string;
|
|
93
|
+
/** 列头搜索配置(true 或 HeaderSearchConfig 对象启用;仅对 valueType='text' 生效) */
|
|
94
|
+
headerSearch?: boolean | HeaderSearchConfig;
|
|
95
|
+
/** 自定义搜索栏表单渲染器。若提供则优先于 valueType 自动匹配,允许任意表单控件。
|
|
96
|
+
* 示例:
|
|
97
|
+
* ```ts
|
|
98
|
+
* {
|
|
99
|
+
* title: '状态',
|
|
100
|
+
* dataIndex: 'status',
|
|
101
|
+
* valueType: 'customStatus' as any,
|
|
102
|
+
* renderFormItem: ({ model, search }) => {
|
|
103
|
+
* return h(aSelect, {
|
|
104
|
+
* value: model.status,
|
|
105
|
+
* 'onUpdate:value': (v) => { model.status = v; search(); },
|
|
106
|
+
* });
|
|
107
|
+
* },
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
renderFormItem?: (context: {
|
|
112
|
+
/** 当前搜索表单 model(可直接读写) */
|
|
113
|
+
model: Record<string, any>;
|
|
114
|
+
/** 触发搜索 */
|
|
115
|
+
search: () => void;
|
|
116
|
+
/** 清除指定字段值 */
|
|
117
|
+
resetField: (dataIndex: string) => void;
|
|
118
|
+
}) => VNode;
|
|
119
|
+
}
|
|
120
|
+
/** 操作列按钮项 */
|
|
121
|
+
export interface ActionItem<RecordType = any> {
|
|
122
|
+
label: string;
|
|
123
|
+
type?: 'primary' | 'dashed' | 'link' | 'text' | 'default';
|
|
124
|
+
/** 危险操作样式,对应 ant-design-vue Button 的 danger 属性 */
|
|
125
|
+
danger?: boolean;
|
|
126
|
+
icon?: string;
|
|
127
|
+
confirm?: string;
|
|
128
|
+
authority?: string | string[];
|
|
129
|
+
disabled?: boolean | ((record: RecordType) => boolean);
|
|
130
|
+
hidden?: boolean | ((record: RecordType) => boolean);
|
|
131
|
+
onClick?: (record: RecordType, index: number) => void | Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
export type ProColumnsType<RecordType = any> = ProColumnType<RecordType>[];
|
|
134
|
+
export interface FormRule {
|
|
135
|
+
required?: boolean;
|
|
136
|
+
message?: string;
|
|
137
|
+
type?: 'string' | 'number' | 'boolean' | 'email' | 'url';
|
|
138
|
+
min?: number;
|
|
139
|
+
max?: number;
|
|
140
|
+
pattern?: RegExp;
|
|
141
|
+
validator?: (value: any, record: any) => Promise<void> | void;
|
|
142
|
+
}
|
|
143
|
+
export interface EditConfig<RecordType = any> {
|
|
144
|
+
/** 编辑模式 */
|
|
145
|
+
mode?: 'cell' | 'row';
|
|
146
|
+
/** 新增行时的默认值 */
|
|
147
|
+
newRecord?: Partial<RecordType>;
|
|
148
|
+
/** 编辑前回调 */
|
|
149
|
+
onEditStart?: (record: RecordType, field?: string) => Promise<boolean> | boolean;
|
|
150
|
+
/** 保存回调 */
|
|
151
|
+
onSave?: (record: RecordType, isNew: boolean) => Promise<void> | void;
|
|
152
|
+
/** 删除回调 */
|
|
153
|
+
onDelete?: (keys: (string | number)[]) => Promise<void> | void;
|
|
154
|
+
/** 是否允许新增 */
|
|
155
|
+
addable?: boolean;
|
|
156
|
+
/** 是否允许删除 */
|
|
157
|
+
deletable?: boolean;
|
|
158
|
+
}
|
|
159
|
+
/** 撤销/重做 Command */
|
|
160
|
+
export interface EditCommand<RecordType = any> {
|
|
161
|
+
type: 'update' | 'add' | 'delete';
|
|
162
|
+
rowKey: string | number;
|
|
163
|
+
field?: string;
|
|
164
|
+
oldValue?: any;
|
|
165
|
+
newValue?: any;
|
|
166
|
+
record?: RecordType;
|
|
167
|
+
/** 行在 dataSource 中的原始索引(delete/undo 恢复位置用) */
|
|
168
|
+
index?: number;
|
|
169
|
+
}
|
|
170
|
+
export interface ContextMenuItem {
|
|
171
|
+
key: string;
|
|
172
|
+
label: string;
|
|
173
|
+
icon?: string;
|
|
174
|
+
disabled?: boolean;
|
|
175
|
+
danger?: boolean;
|
|
176
|
+
children?: ContextMenuItem[];
|
|
177
|
+
}
|
|
178
|
+
export type ContextMenuType = 'row' | 'cell' | 'header';
|
|
179
|
+
export interface ContextMenuConfig {
|
|
180
|
+
/** 行右键菜单项 */
|
|
181
|
+
row?: ContextMenuItem[];
|
|
182
|
+
/** 单元格右键菜单项 */
|
|
183
|
+
cell?: ContextMenuItem[];
|
|
184
|
+
/** 表头右键菜单项 */
|
|
185
|
+
header?: ContextMenuItem[];
|
|
186
|
+
}
|
|
187
|
+
export interface ViewConfig {
|
|
188
|
+
id?: string;
|
|
189
|
+
name: string;
|
|
190
|
+
tableId: string;
|
|
191
|
+
isDefault: boolean;
|
|
192
|
+
columns: {
|
|
193
|
+
key: string;
|
|
194
|
+
checked: boolean;
|
|
195
|
+
order: number;
|
|
196
|
+
width?: number;
|
|
197
|
+
}[];
|
|
198
|
+
filterState: Record<string, FilterValue | null>;
|
|
199
|
+
sortState: {
|
|
200
|
+
field: string;
|
|
201
|
+
order: SortOrder;
|
|
202
|
+
} | null;
|
|
203
|
+
pageSize: number;
|
|
204
|
+
}
|
|
205
|
+
export interface DragConfig {
|
|
206
|
+
/** 允许行拖拽 */
|
|
207
|
+
rowDraggable?: boolean;
|
|
208
|
+
/** 允许列拖拽 */
|
|
209
|
+
columnDraggable?: boolean;
|
|
210
|
+
/** 拖拽范围约束 */
|
|
211
|
+
dragConstraint?: 'same-table' | 'cross-table';
|
|
212
|
+
/** 拖拽回调 */
|
|
213
|
+
onRowDragEnd?: (fromIndex: number, toIndex: number) => void;
|
|
214
|
+
/** 跨表格拖拽回调 */
|
|
215
|
+
onCrossTableDrop?: (record: any, targetTableId: string) => void;
|
|
216
|
+
}
|
|
217
|
+
export type FilterOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'greaterThan' | 'lessThan' | 'between' | 'in' | 'isEmpty' | 'isNotEmpty';
|
|
218
|
+
export interface AdvancedFilterCondition {
|
|
219
|
+
id: string;
|
|
220
|
+
field: string;
|
|
221
|
+
operator: FilterOperator;
|
|
222
|
+
value: any;
|
|
223
|
+
valueEnd?: any;
|
|
224
|
+
logic?: 'AND' | 'OR';
|
|
225
|
+
}
|
|
226
|
+
export interface AdvancedFilterGroup {
|
|
227
|
+
id: string;
|
|
228
|
+
logic: 'AND' | 'OR';
|
|
229
|
+
conditions: AdvancedFilterCondition[];
|
|
230
|
+
groups?: AdvancedFilterGroup[];
|
|
231
|
+
}
|
|
232
|
+
export interface ExportConfig {
|
|
233
|
+
/** 导出文件名 */
|
|
234
|
+
filename?: string;
|
|
235
|
+
/** 分片大小 */
|
|
236
|
+
chunkSize?: number;
|
|
237
|
+
/** 最大导出行数 */
|
|
238
|
+
maxRows?: number;
|
|
239
|
+
/** 导出选项 */
|
|
240
|
+
type?: 'xlsx' | 'csv';
|
|
241
|
+
/** 自定义列映射 */
|
|
242
|
+
columnMapping?: Record<string, string>;
|
|
243
|
+
/** 导出前回调 */
|
|
244
|
+
beforeExport?: () => Promise<boolean> | boolean;
|
|
245
|
+
}
|
|
246
|
+
export interface ImportConfig {
|
|
247
|
+
/** 列映射 */
|
|
248
|
+
columnMapping?: Record<string, string>;
|
|
249
|
+
/** 校验规则 */
|
|
250
|
+
validateRules?: FormRule[];
|
|
251
|
+
/** 导入前回调 */
|
|
252
|
+
beforeImport?: (data: any[]) => Promise<any[]> | any[];
|
|
253
|
+
/** 导入回调 */
|
|
254
|
+
onImport?: (data: any[]) => Promise<void> | void;
|
|
255
|
+
}
|
|
256
|
+
/** 跨页多选配置 */
|
|
257
|
+
export interface CrossPageSelectionConfig {
|
|
258
|
+
/** 是否启用跨页多选(默认 false) */
|
|
259
|
+
enabled?: boolean;
|
|
260
|
+
/** 选择所有页回调(Request 模式下必需),接收当前搜索/筛选/排序参数,返回所有匹配数据的主键数组 */
|
|
261
|
+
onSelectAllPages?: (searchParams: Record<string, any>) => Promise<(string | number)[]> | (string | number)[];
|
|
262
|
+
/** 最大选择数量上限(0 表示不限制) */
|
|
263
|
+
maxSelectCount?: number;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* BwProTable 语言包接口。
|
|
267
|
+
* 与 locales/zh-CN.ts 结构对齐,外部可通过覆盖任意字段实现国际化。
|
|
268
|
+
*/
|
|
269
|
+
export interface BwProTableLocale {
|
|
270
|
+
search: {
|
|
271
|
+
reset: string;
|
|
272
|
+
search: string;
|
|
273
|
+
expand: string;
|
|
274
|
+
collapse: string;
|
|
275
|
+
placeholder: string;
|
|
276
|
+
selectPlaceholder: string;
|
|
277
|
+
datePlaceholder: string;
|
|
278
|
+
inputPlaceholder: string;
|
|
279
|
+
selectPlaceholderWithTitle: string;
|
|
280
|
+
};
|
|
281
|
+
toolbar: {
|
|
282
|
+
refresh: string;
|
|
283
|
+
density: string;
|
|
284
|
+
densityDefault: string;
|
|
285
|
+
densityMiddle: string;
|
|
286
|
+
densitySmall: string;
|
|
287
|
+
fullscreen: string;
|
|
288
|
+
exitFullscreen: string;
|
|
289
|
+
columnSetting: string;
|
|
290
|
+
export: string;
|
|
291
|
+
clearFilter: string;
|
|
292
|
+
search: string;
|
|
293
|
+
border: string;
|
|
294
|
+
striped: string;
|
|
295
|
+
on: string;
|
|
296
|
+
off: string;
|
|
297
|
+
selected: string;
|
|
298
|
+
clearSelection: string;
|
|
299
|
+
};
|
|
300
|
+
table: {
|
|
301
|
+
total: string;
|
|
302
|
+
emptyText: string;
|
|
303
|
+
triggerAsc: string;
|
|
304
|
+
triggerDesc: string;
|
|
305
|
+
cancelSort: string;
|
|
306
|
+
paginationTotal: string;
|
|
307
|
+
};
|
|
308
|
+
columnSetting: {
|
|
309
|
+
title: string;
|
|
310
|
+
reset: string;
|
|
311
|
+
apply: string;
|
|
312
|
+
cancel: string;
|
|
313
|
+
};
|
|
314
|
+
edit: {
|
|
315
|
+
save: string;
|
|
316
|
+
cancel: string;
|
|
317
|
+
delete: string;
|
|
318
|
+
confirmDelete: string;
|
|
319
|
+
add: string;
|
|
320
|
+
batchEdit: string;
|
|
321
|
+
undo: string;
|
|
322
|
+
redo: string;
|
|
323
|
+
pleaseSelectField: string;
|
|
324
|
+
modifyField: string;
|
|
325
|
+
modifyValue: string;
|
|
326
|
+
selectedData: string;
|
|
327
|
+
placeholder: string;
|
|
328
|
+
selectPlaceholder: string;
|
|
329
|
+
validation: {
|
|
330
|
+
required: (field: string) => string;
|
|
331
|
+
number: (field: string) => string;
|
|
332
|
+
min: (field: string, min: number) => string;
|
|
333
|
+
max: (field: string, max: number) => string;
|
|
334
|
+
pattern: (field: string) => string;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
/** @deprecated 使用 locale.export 代替 */
|
|
338
|
+
export: {
|
|
339
|
+
excel: string;
|
|
340
|
+
csv: string;
|
|
341
|
+
selected: string;
|
|
342
|
+
success: string;
|
|
343
|
+
failed: string;
|
|
344
|
+
noData: string;
|
|
345
|
+
tooLarge: (count: number) => string;
|
|
346
|
+
selectFirst: string;
|
|
347
|
+
};
|
|
348
|
+
import: {
|
|
349
|
+
title: string;
|
|
350
|
+
selectFile: string;
|
|
351
|
+
preview: string;
|
|
352
|
+
columnMapping: string;
|
|
353
|
+
confirm: string;
|
|
354
|
+
cancel: string;
|
|
355
|
+
success: (count: number) => string;
|
|
356
|
+
failed: string;
|
|
357
|
+
template: string;
|
|
358
|
+
parseError: string;
|
|
359
|
+
emptyFile: string;
|
|
360
|
+
emptyValueField: string;
|
|
361
|
+
};
|
|
362
|
+
contextMenu: {
|
|
363
|
+
noActions: string;
|
|
364
|
+
view: string;
|
|
365
|
+
edit: string;
|
|
366
|
+
copy: string;
|
|
367
|
+
clone: string;
|
|
368
|
+
delete: string;
|
|
369
|
+
copyCell: string;
|
|
370
|
+
filterByCell: string;
|
|
371
|
+
sortAsc: string;
|
|
372
|
+
sortDesc: string;
|
|
373
|
+
hideColumn: string;
|
|
374
|
+
pinLeft: string;
|
|
375
|
+
pinRight: string;
|
|
376
|
+
autoSize: string;
|
|
377
|
+
};
|
|
378
|
+
view: {
|
|
379
|
+
save: string;
|
|
380
|
+
load: string;
|
|
381
|
+
delete: string;
|
|
382
|
+
setDefault: string;
|
|
383
|
+
name: string;
|
|
384
|
+
saved: string;
|
|
385
|
+
deleted: string;
|
|
386
|
+
switched: (name: string) => string;
|
|
387
|
+
enterName: string;
|
|
388
|
+
exists: string;
|
|
389
|
+
overWrite: (name: string) => string;
|
|
390
|
+
};
|
|
391
|
+
error: {
|
|
392
|
+
loadFailed: string;
|
|
393
|
+
retry: string;
|
|
394
|
+
required: (field: string) => string;
|
|
395
|
+
formatError: (field: string) => string;
|
|
396
|
+
};
|
|
397
|
+
selection: {
|
|
398
|
+
selectAllPages: string;
|
|
399
|
+
clearAll: string;
|
|
400
|
+
selectCurrentPage: string;
|
|
401
|
+
invertCurrentPage: string;
|
|
402
|
+
selectedCount: (n: number) => string;
|
|
403
|
+
clear: string;
|
|
404
|
+
};
|
|
405
|
+
filter: {
|
|
406
|
+
title: string;
|
|
407
|
+
equals: string;
|
|
408
|
+
notEquals: string;
|
|
409
|
+
contains: string;
|
|
410
|
+
greaterThan: string;
|
|
411
|
+
lessThan: string;
|
|
412
|
+
between: string;
|
|
413
|
+
isEmpty: string;
|
|
414
|
+
isNotEmpty: string;
|
|
415
|
+
field: string;
|
|
416
|
+
condition: string;
|
|
417
|
+
value: string;
|
|
418
|
+
startValue: string;
|
|
419
|
+
endValue: string;
|
|
420
|
+
addCondition: string;
|
|
421
|
+
reset: string;
|
|
422
|
+
apply: string;
|
|
423
|
+
and: string;
|
|
424
|
+
or: string;
|
|
425
|
+
};
|
|
426
|
+
boolean: {
|
|
427
|
+
true: string;
|
|
428
|
+
false: string;
|
|
429
|
+
placeholder: string;
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
export interface BwProTableProps<RecordType = any> {
|
|
433
|
+
/** 表格唯一标识,用于持久化命名空间 */
|
|
434
|
+
tableId?: string;
|
|
435
|
+
/** 列定义 */
|
|
436
|
+
columns: ProColumnsType<RecordType>;
|
|
437
|
+
/** 数据请求函数 */
|
|
438
|
+
request?: (params: {
|
|
439
|
+
current: number;
|
|
440
|
+
pageSize: number;
|
|
441
|
+
[key: string]: any;
|
|
442
|
+
}) => Promise<{
|
|
443
|
+
data: RecordType[];
|
|
444
|
+
total: number;
|
|
445
|
+
success: boolean;
|
|
446
|
+
}>;
|
|
447
|
+
/** 静态数据源(与 request 二选一) */
|
|
448
|
+
dataSource?: RecordType[];
|
|
449
|
+
/** 行 key 属性 */
|
|
450
|
+
rowKey?: string | GetRowKey<RecordType>;
|
|
451
|
+
/** 搜索栏配置 */
|
|
452
|
+
search?: false | {
|
|
453
|
+
labelWidth?: number;
|
|
454
|
+
defaultCollapsed?: boolean;
|
|
455
|
+
resetText?: string;
|
|
456
|
+
searchText?: string;
|
|
457
|
+
collapsedCount?: number;
|
|
458
|
+
};
|
|
459
|
+
/** 列头搜索全局配置(false 禁用所有列的 headerSearch,对象覆写默认值) */
|
|
460
|
+
columnSearch?: false | HeaderSearchConfig;
|
|
461
|
+
/** 工具栏配置 */
|
|
462
|
+
toolbar?: false | {
|
|
463
|
+
refresh?: boolean;
|
|
464
|
+
density?: boolean;
|
|
465
|
+
fullscreen?: boolean;
|
|
466
|
+
columnSetting?: boolean;
|
|
467
|
+
export?: boolean | ExportConfig;
|
|
468
|
+
clearFilter?: boolean;
|
|
469
|
+
import?: boolean | ImportConfig;
|
|
470
|
+
viewManager?: boolean;
|
|
471
|
+
};
|
|
472
|
+
/** 编辑配置 */
|
|
473
|
+
editConfig?: EditConfig<RecordType>;
|
|
474
|
+
/** 右键菜单配置 */
|
|
475
|
+
contextMenu?: ContextMenuConfig;
|
|
476
|
+
/** 拖拽配置 */
|
|
477
|
+
dragConfig?: DragConfig;
|
|
478
|
+
/** 表格标题 */
|
|
479
|
+
title?: string;
|
|
480
|
+
/** 表格边框 */
|
|
481
|
+
bordered?: boolean;
|
|
482
|
+
/** 斑马纹 */
|
|
483
|
+
striped?: boolean;
|
|
484
|
+
/** 表格尺寸 */
|
|
485
|
+
size?: 'small' | 'middle' | 'default';
|
|
486
|
+
/** 空单元格占位符 */
|
|
487
|
+
defaultEmptyText?: string;
|
|
488
|
+
/** 列配置缓存标识 */
|
|
489
|
+
cacheKey?: string;
|
|
490
|
+
/** 持久化配置(false 表示禁用) */
|
|
491
|
+
persistence?: false | PersistenceConfig;
|
|
492
|
+
/** 语言包(覆盖默认中文文案),传入部分字段即可完成局部覆写 */
|
|
493
|
+
locale?: Partial<BwProTableLocale>;
|
|
494
|
+
/** 加载态 */
|
|
495
|
+
loading?: boolean;
|
|
496
|
+
/** 分页配置 */
|
|
497
|
+
pagination?: false | TablePaginationConfig;
|
|
498
|
+
/** 行选择 */
|
|
499
|
+
rowSelection?: TableRowSelection<RecordType>;
|
|
500
|
+
/** 跨页多选配置(false 表示禁用) */
|
|
501
|
+
crossPageSelection?: false | CrossPageSelectionConfig;
|
|
502
|
+
/** 可展开行 */
|
|
503
|
+
expandable?: ExpandableConfig<RecordType>;
|
|
504
|
+
/** 滚动 */
|
|
505
|
+
scroll?: {
|
|
506
|
+
x?: number | string | true;
|
|
507
|
+
y?: number | string;
|
|
508
|
+
};
|
|
509
|
+
/** 固定表头 */
|
|
510
|
+
sticky?: boolean | {
|
|
511
|
+
offsetHeader?: number;
|
|
512
|
+
};
|
|
513
|
+
/** 表格 CSS 类名 */
|
|
514
|
+
class?: string;
|
|
515
|
+
/** 表格样式 */
|
|
516
|
+
style?: CSSProperties;
|
|
517
|
+
}
|
|
518
|
+
export type TableStatus = 'loading' | 'success' | 'error';
|
|
519
|
+
export interface TableState {
|
|
520
|
+
status: TableStatus;
|
|
521
|
+
errorMessage: string;
|
|
522
|
+
errorReload: null | (() => void | Promise<void>);
|
|
523
|
+
}
|
|
524
|
+
export interface PersistedColumnState {
|
|
525
|
+
key: string;
|
|
526
|
+
checked: boolean;
|
|
527
|
+
order: number;
|
|
528
|
+
width?: number;
|
|
529
|
+
}
|
|
530
|
+
/** 当前持久化数据版本(已迁移到 constants.ts,保留向后兼容 re-export) */
|
|
531
|
+
export { PERSISTED_DATA_VERSION } from './constants';
|
|
532
|
+
export interface PersistedTableState {
|
|
533
|
+
/** 数据版本号,用于版本迁移 */
|
|
534
|
+
version: string;
|
|
535
|
+
tableId: string;
|
|
536
|
+
columns: PersistedColumnState[];
|
|
537
|
+
pageSize: number;
|
|
538
|
+
/** 当前页码 */
|
|
539
|
+
current?: number;
|
|
540
|
+
density?: 'small' | 'middle' | 'default';
|
|
541
|
+
/** 筛选状态 */
|
|
542
|
+
filters?: Record<string, FilterValue | null>;
|
|
543
|
+
/** 排序状态 */
|
|
544
|
+
sorter?: {
|
|
545
|
+
field: string;
|
|
546
|
+
order: SortOrder;
|
|
547
|
+
} | null;
|
|
548
|
+
}
|
|
549
|
+
/** 自定义存储适配器接口 */
|
|
550
|
+
export interface StorageAdapter {
|
|
551
|
+
get: (key: string) => PersistedTableState | null;
|
|
552
|
+
set: (key: string, value: PersistedTableState) => void;
|
|
553
|
+
remove: (key: string) => void;
|
|
554
|
+
}
|
|
555
|
+
/** 持久化配置 */
|
|
556
|
+
export interface PersistenceConfig {
|
|
557
|
+
/** 是否启用持久化(默认 true) */
|
|
558
|
+
enabled?: boolean;
|
|
559
|
+
/** 存储方式 */
|
|
560
|
+
storage?: 'localStorage' | 'sessionStorage' | StorageAdapter;
|
|
561
|
+
/** 键名前缀(默认 bw-pro-table) */
|
|
562
|
+
keyPrefix?: string;
|
|
563
|
+
/** 存储失败回调 */
|
|
564
|
+
onError?: (error: Error, operation: 'get' | 'set' | 'remove') => void;
|
|
565
|
+
/** 是否启用调试模式(默认 false),调试模式下输出详细日志 */
|
|
566
|
+
debug?: boolean;
|
|
567
|
+
}
|