villianjs-pro 1.0.34 → 1.0.35

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.
Files changed (54) hide show
  1. package/dist/ProTable/components/form-content-container.d.ts +10 -0
  2. package/dist/ProTable/components/form-content-container.js +1 -0
  3. package/dist/ProTable/components/grid-card.d.ts +1 -1
  4. package/dist/ProTable/components/grid-card.js +1 -1
  5. package/dist/ProTable/components/grid-view.d.ts +1 -1
  6. package/dist/ProTable/components/grid-view.js +1 -1
  7. package/dist/ProTable/components/headerTitle.d.ts +4 -0
  8. package/dist/ProTable/components/headerTitle.js +1 -0
  9. package/dist/ProTable/components/list-container.d.ts +3 -0
  10. package/dist/ProTable/components/list-container.js +1 -0
  11. package/dist/ProTable/components/list.d.ts +3 -0
  12. package/dist/ProTable/components/list.js +1 -0
  13. package/dist/ProTable/components/operation-form-wrapper.d.ts +7 -0
  14. package/dist/ProTable/components/operation-form-wrapper.js +1 -0
  15. package/dist/ProTable/components/row-actions.d.ts +1 -1
  16. package/dist/ProTable/components/row-actions.js +1 -1
  17. package/dist/ProTable/components/search.d.ts +2 -2
  18. package/dist/ProTable/components/search.js +1 -1
  19. package/dist/ProTable/{utils.d.ts → components/utils.d.ts} +2 -2
  20. package/dist/ProTable/container.d.ts +3 -0
  21. package/dist/ProTable/container.js +1 -0
  22. package/dist/ProTable/context.d.ts +1 -20
  23. package/dist/ProTable/context.js +1 -1
  24. package/dist/ProTable/hooks/usePagination.js +1 -1
  25. package/dist/ProTable/index.d.ts +2 -3
  26. package/dist/ProTable/index.js +1 -1
  27. package/dist/ProTable/styles.js +1 -1
  28. package/dist/ProTable/table.d.ts +3 -3
  29. package/dist/ProTable/table.js +1 -1
  30. package/dist/ProTable/types.d.ts +333 -160
  31. package/dist/imports/components/import-detail-dialog.js +1 -1
  32. package/dist/imports/components/import-history-dialog.js +1 -1
  33. package/package.json +1 -1
  34. package/dist/ProTable/components/Container.d.ts +0 -27
  35. package/dist/ProTable/components/Container.js +0 -1
  36. package/dist/ProTable/components/form-content.d.ts +0 -34
  37. package/dist/ProTable/components/form-content.js +0 -1
  38. package/dist/ProTable/components/form-footer.d.ts +0 -32
  39. package/dist/ProTable/components/form-footer.js +0 -1
  40. package/dist/ProTable/components/header-buttons-wrapper.d.ts +0 -10
  41. package/dist/ProTable/components/header-buttons-wrapper.js +0 -1
  42. package/dist/ProTable/components/list/index.d.ts +0 -19
  43. package/dist/ProTable/components/list/index.js +0 -1
  44. package/dist/ProTable/components/operation-container.d.ts +0 -39
  45. package/dist/ProTable/components/operation-container.js +0 -1
  46. package/dist/ProTable/components/operation-content-router.d.ts +0 -37
  47. package/dist/ProTable/components/operation-content-router.js +0 -1
  48. package/dist/ProTable/components/operation-content.d.ts +0 -35
  49. package/dist/ProTable/components/operation-content.js +0 -1
  50. package/dist/ProTable/components/row-actions-router.d.ts +0 -8
  51. package/dist/ProTable/components/row-actions-router.js +0 -1
  52. package/dist/ProTable/hooks/useRouterNavigation.d.ts +0 -10
  53. package/dist/ProTable/hooks/useRouterNavigation.js +0 -1
  54. /package/dist/ProTable/{utils.js → components/utils.js} +0 -0
@@ -1,13 +1,11 @@
1
- import * as React from "react";
1
+ import type { FormSchema } from "@ant-design/pro-form/es/components/SchemaForm/typing";
2
+ import type React from "react";
3
+ import { type Key, type RefObject } from "react";
4
+ import { type ProTableProps as AntdProTableProps, type ProColumns, type ActionType } from "@ant-design/pro-components";
2
5
  import type { SizeType } from "antd/es/config-provider/SizeContext";
3
- import { type ProTableProps as AntdProTableProps, type ProColumns } from "@ant-design/pro-components";
4
- import type { Key } from "react";
5
- import type { ButtonGroupItem } from "../ButtonGroup";
6
6
  import type { DrawerProps } from "antd";
7
- import type { FormSchema } from "@ant-design/pro-form/es/components/SchemaForm/typing";
8
- import type { ProFormColumnsType } from "../Form/types";
9
- import type { ModalProps } from "../Modal/components/antd";
10
- import type { ProTableContextType } from "./context";
7
+ import type { ProFormColumnsType, ProFormProps } from "../Form";
8
+ import type { ButtonGroupItem } from "../ButtonGroup";
11
9
  /**
12
10
  * 表格操作模式
13
11
  */
@@ -20,6 +18,57 @@ export type OperationType = "list" | "create" | "update" | "view";
20
18
  * 视图显示模式
21
19
  */
22
20
  export type ViewMode = "table" | "grid";
21
+ /**
22
+ * 搜索表单类型
23
+ */
24
+ export type SearchType = Extract<FormSchema["layoutType"], "QueryFilter" | "Form">;
25
+ /**
26
+ * 上下文
27
+ */
28
+ export type TableColumnType = "text" | "number" | "date" | "boolean" | "select" | "radio" | "checkbox" | "textarea" | "html" | "custom";
29
+ /**
30
+ * ProTable 上下文类型
31
+ */
32
+ export type ProTableContextType = {
33
+ resetContextValue: () => void;
34
+ selectedRowKeys: Key[];
35
+ setSelectedRowKeys: (keys: Key[]) => void;
36
+ selectedRows: Record<string, any>[];
37
+ setSelectedRows: (rows: Record<string, any>[]) => void;
38
+ operationType: OperationType;
39
+ setOperationType: (type: OperationType) => void;
40
+ currentRecord: Record<string, any> | null;
41
+ setCurrentRecord: (record: Record<string, any> | null) => void;
42
+ currentIndex: number;
43
+ setCurrentIndex: (index: number) => void;
44
+ viewMode: ViewMode;
45
+ setViewMode: (mode: ViewMode) => void;
46
+ dataSource: Record<string, any>[];
47
+ setDataSource: (data: Record<string, any>[]) => void;
48
+ loading: boolean;
49
+ setLoading: (loading: boolean) => void;
50
+ searchFormValues: Record<string, any>;
51
+ setSearchFormValues: (values: Record<string, any>) => void;
52
+ actionRef: RefObject<ActionType | null>;
53
+ operationVisible: boolean;
54
+ setOperationVisible: (visible: boolean) => void;
55
+ formRef: RefObject<any>;
56
+ };
57
+ export type ProTableInterface = {
58
+ selectedRowKeys: Key[];
59
+ selectedRows: Record<string, any>[];
60
+ operationType: OperationType;
61
+ currentRecord: Record<string, any> | null;
62
+ currentIndex: number;
63
+ viewMode: ViewMode;
64
+ dataSource: Record<string, any>[];
65
+ loading: boolean;
66
+ searchFormValues: Record<string, any>;
67
+ actionRef: RefObject<ActionType | null>;
68
+ };
69
+ export type ProTableRef = {
70
+ getContext: () => ProTableInterface;
71
+ };
23
72
  /**
24
73
  * 网格卡片渲染函数的参数
25
74
  */
@@ -45,10 +94,6 @@ export type GridCardRender<T = any> = (params: GridCardRenderParams<T>) => React
45
94
  * 提取 FormSchema 的 submitter 类型
46
95
  */
47
96
  type FormSchemaSubmitter<T, ValueType extends string = 'text'> = FormSchema<T, ValueType>['submitter'];
48
- /**
49
- * 搜索表单类型
50
- */
51
- export type SearchType = Extract<FormSchema["layoutType"], "QueryFilter" | "Form">;
52
97
  /**
53
98
  * ProTableSearch 组件属性
54
99
  * 继承 FormSchema 的所有属性,并扩展自定义属性
@@ -116,6 +161,27 @@ export type SearchConfig<T = Record<string, any>, ValueType = "text"> = {
116
161
  */
117
162
  searchProps?: Omit<ProTableSearchProps<T, ValueType extends string ? ValueType : "text">, "columns" | "layoutType" | "layout">;
118
163
  };
164
+ /**
165
+ * 操作行按钮配置
166
+ */
167
+ export interface RowButtonItem<T = any> extends Omit<ButtonGroupItem, 'key' | 'onClick' | 'disabled'> {
168
+ /**
169
+ * @description 按钮 key
170
+ */
171
+ key?: string;
172
+ /**
173
+ * @description 按钮是否可见
174
+ */
175
+ visible?: boolean | ((record: T, index: number) => boolean);
176
+ /**
177
+ * @description 按钮是否禁用
178
+ */
179
+ disabled?: boolean | ((record: T, index: number) => boolean);
180
+ /**
181
+ * @description 点击回调
182
+ */
183
+ onClick?: (record: T, index: number) => void | Promise<void>;
184
+ }
119
185
  /**
120
186
  * 操作按钮配置
121
187
  */
@@ -138,167 +204,191 @@ export interface HeaderButtonItem extends Omit<ButtonGroupItem, 'key' | 'onClick
138
204
  onClick?: (selectKeys: Key[]) => void | Promise<void>;
139
205
  }
140
206
  /**
141
- * 操作行按钮配置
207
+ * 重置按钮配置(取消按钮)
142
208
  */
143
- export interface RowButtonItem<T = any> extends Omit<ButtonGroupItem, 'key' | 'onClick' | 'disabled'> {
209
+ export interface ResetButtonConfig extends Omit<ButtonGroupItem, 'key' | 'onClick' | 'label' | 'order' | 'disabled'> {
144
210
  /**
145
- * @description 按钮 key
211
+ * @description 按钮文本
212
+ * @default '取消'
146
213
  */
147
- key?: string;
214
+ text?: string;
148
215
  /**
149
- * @description 按钮是否可见
216
+ * @description 按钮排序(数字越小越靠前)
217
+ * @default 1
150
218
  */
151
- visible?: boolean | ((record: T, index: number) => boolean);
219
+ order?: number;
152
220
  /**
153
- * @description 按钮是否禁用
221
+ * @description 按钮是否可见(支持函数形式,根据 operationType 和 currentRecord 动态判断)
154
222
  */
155
- disabled?: boolean | ((record: T, index: number) => boolean);
223
+ visible?: boolean | ((operationType: OperationType, currentRecord: Record<string, any> | null) => boolean);
156
224
  /**
157
- * @description 点击回调
225
+ * @description 按钮是否禁用(支持函数形式,根据 operationType 和 currentRecord 动态判断)
158
226
  */
159
- onClick?: (record: T, index: number) => void | Promise<void>;
227
+ disabled?: boolean | ((operationType: OperationType, currentRecord: Record<string, any> | null) => boolean);
228
+ /**
229
+ * @description 点击回调(可选,默认行为是关闭表单)
230
+ * @param formRef 表单实例 ref
231
+ * @param operationType 当前操作类型
232
+ * @param currentRecord 当前记录
233
+ */
234
+ onClick?: (formRef: RefObject<any>, operationType: OperationType, currentRecord: Record<string, any> | null) => void | Promise<void>;
160
235
  }
161
236
  /**
162
- * 操作内容渲染函数
163
- */
164
- export type OperationContentRender<T = any> = (params: {
165
- type: OperationType;
166
- record?: T;
167
- onClose: () => void;
168
- onSuccess?: () => void;
169
- }) => React.ReactNode;
170
- /**
171
- * 表单底部渲染函数
237
+ * 提交按钮配置
172
238
  */
173
- export type FormFooterRender<T = any> = (params: {
239
+ export interface SubmitButtonConfig extends Omit<ButtonGroupItem, 'key' | 'onClick' | 'label' | 'order' | 'type' | 'disabled'> {
174
240
  /**
175
- * @description 操作类型
241
+ * @description 按钮文本
242
+ * @default '提交'
176
243
  */
177
- type: OperationType;
244
+ text?: string;
178
245
  /**
179
- * @description 当前记录
246
+ * @description 按钮排序(数字越小越靠前)
247
+ * @default 2
180
248
  */
181
- record?: T;
249
+ order?: number;
182
250
  /**
183
- * @description 表单实例
251
+ * @description 按钮类型
252
+ * @default 'primary'
184
253
  */
185
- form: any;
254
+ type?: ButtonGroupItem['type'];
186
255
  /**
187
- * @description 提交处理
256
+ * @description 按钮是否可见(支持函数形式,根据 operationType 和 currentRecord 动态判断)
188
257
  */
189
- onSubmit: () => void;
258
+ visible?: boolean | ((operationType: OperationType, currentRecord: Record<string, any> | null) => boolean);
190
259
  /**
191
- * @description 取消处理
260
+ * @description 按钮是否禁用(支持函数形式,根据 operationType 和 currentRecord 动态判断)
192
261
  */
193
- onCancel: () => void;
262
+ disabled?: boolean | ((operationType: OperationType, currentRecord: Record<string, any> | null) => boolean);
194
263
  /**
195
- * @description 提交中状态
264
+ * @description 点击回调(可选,默认行为是提交表单并关闭)
265
+ * @param formRef 表单实例 ref
266
+ * @param operationType 当前操作类型
267
+ * @param currentRecord 当前记录
196
268
  */
197
- loading?: boolean;
198
- }) => React.ReactNode;
199
- /**
200
- * 表单提交回调
201
- * @returns 返回 false 时不关闭弹窗和刷新数据;返回 void 或 true 时正常关闭和刷新
202
- */
203
- export type FormSubmitCallback<T = any> = (values: T, type: OperationType, record?: T) => Promise<void | false> | void | false;
269
+ onClick?: (formRef: RefObject<any>, operationType: OperationType, currentRecord: Record<string, any> | null) => void | Promise<void>;
270
+ }
204
271
  /**
205
- * 内置表单配置
272
+ * 操作表单按钮配置
206
273
  */
207
- export interface FormConfig<T = any, ValueType extends string = 'text'> {
274
+ export interface OperationFormButtonItem extends Omit<ButtonGroupItem, 'key' | 'onClick' | 'disabled'> {
208
275
  /**
209
- * @description 是否启用内置表单(设置为 false 时使用 operationContent 自定义)
210
- * @default true
276
+ * @description 按钮 key
211
277
  */
212
- enabled?: boolean;
278
+ key?: string;
213
279
  /**
214
- * @description 表单列配置(不传则从表格 columns 自动生成)
280
+ * @description 按钮排序(数字越小越靠前,重置按钮默认 1,提交按钮默认 2)
215
281
  */
216
- columns?: ProFormColumnsType<T, ValueType>[];
282
+ order?: number;
217
283
  /**
218
- * @description 表单属性(透传给 Form 组件)
284
+ * @description 按钮是否可见(支持函数形式,根据 operationType 和 currentRecord 动态判断)
219
285
  */
220
- formProps?: Omit<FormSchema<T, ValueType>, 'columns' | 'onFinish' | 'submitter'>;
286
+ visible?: boolean | ((operationType: OperationType, currentRecord: Record<string, any> | null) => boolean);
221
287
  /**
222
- * @description 自定义表单底部渲染(返回 false 则隐藏底部)
288
+ * @description 按钮是否禁用(支持函数形式,根据 operationType 和 currentRecord 动态判断)
223
289
  */
224
- footerRender?: false | FormFooterRender<T>;
290
+ disabled?: boolean | ((operationType: OperationType, currentRecord: Record<string, any> | null) => boolean);
225
291
  /**
226
- * @description 表单提交回调
292
+ * @description 点击回调
293
+ * @param formRef 表单实例 ref
294
+ * @param operationType 当前操作类型
295
+ * @param currentRecord 当前记录
227
296
  */
228
- onSubmit?: FormSubmitCallback<T>;
297
+ onClick?: (formRef: RefObject<any>, operationType: OperationType, currentRecord: Record<string, any> | null) => void | Promise<void>;
298
+ }
299
+ /**
300
+ * 表格属性
301
+ */
302
+ export type ProTableProps<DataSource extends Record<string, any> = Record<string, any>, ParamsType extends Record<string, any> = Record<string, any>, ValueType = "text"> = {
303
+ className?: string;
304
+ style?: React.CSSProperties;
229
305
  /**
230
- * @description 新增时的提交按钮文本
306
+ * @description 默认视图模式
307
+ * @default table
231
308
  */
232
- createSubmitText?: string;
309
+ defaultViewMode?: ViewMode;
310
+ size?: SizeType;
311
+ tableKey?: string;
233
312
  /**
234
- * @description 编辑时的提交按钮文本
313
+ * @description 搜索表单类型(已废弃,请使用 search.layoutType)
314
+ * @default QueryFilter
315
+ * @deprecated 请使用 search.layoutType
235
316
  */
236
- updateSubmitText?: string;
317
+ searchType?: SearchType;
318
+ /**
319
+ * @description 搜索表单配置
320
+ */
321
+ search?: false | SearchConfig<DataSource, ValueType>;
322
+ /**
323
+ * @description 操作模式
324
+ * @default modal
325
+ */
326
+ mode?: VlianTableMode;
327
+ /**
328
+ * @description 网格卡片渲染函数(网格模式下必需)
329
+ */
330
+ gridCardRender?: GridCardRender<DataSource>;
237
331
  /**
238
- * @description 取消按钮文本
332
+ * @description 网格列数配置
333
+ * @default { xs: 1, sm: 2, md: 3, lg: 4, xl: 4, xxl: 6 }
239
334
  */
240
- cancelText?: string;
335
+ gridColumns?: {
336
+ xs?: number;
337
+ sm?: number;
338
+ md?: number;
339
+ lg?: number;
340
+ xl?: number;
341
+ xxl?: number;
342
+ };
241
343
  /**
242
- * @description 表单布局
243
- * @default horizontal
344
+ * @description 网格卡片中每行显示的字段数量
345
+ * @default 3
244
346
  */
245
- layout?: "horizontal" | "vertical" | "inline";
347
+ gridCardFieldsPerRow?: number;
246
348
  /**
247
- * @description 标签宽度
349
+ * @description 路由基础路径(router 模式下使用)
248
350
  */
249
- labelCol?: any;
351
+ routerBasePath?: string;
250
352
  /**
251
- * @description 控件宽度
353
+ * 列表的类名
252
354
  */
253
- wrapperCol?: any;
355
+ listClassName?: string;
254
356
  /**
255
- * @description 是否显示消息提醒(成功/失败提示)
256
- * @default false
357
+ * 列表的样式
358
+ * @default {}
257
359
  */
258
- showMessage?: boolean;
259
- }
260
- /**
261
- * ProTable 上下文值(排除 setter 方法)
262
- */
263
- export type ProTableContextValue = Omit<ProTableContextType, "setSelectedRowKeys" | "setSelectedRows" | "setOperationType" | "setCurrentRecord" | "setCurrentIndex" | "setViewMode" | "setDataSource" | "setLoading">;
264
- /**
265
- * ProTable 实例暴露的 ref
266
- */
267
- export type ProTableRef<DataSource extends Record<string, any> = Record<string, any>, ParamsType extends Record<string, any> = Record<string, any>, ValueType = "text"> = {
360
+ listStyle?: React.CSSProperties;
268
361
  /**
269
- * @description Table action 的引用,便于自定义触发
362
+ * 列表的布局
363
+ * @default 'vertical'
270
364
  */
271
- actionRef: React.MutableRefObject<any>;
365
+ listGap?: number;
366
+ /**
367
+ * @description 表单列配置(支持 ProColumns 和 ProFormColumnsType)
368
+ * @default []
369
+ */
370
+ columns?: ProColumns<DataSource, ValueType extends string ? ValueType : "text">[] | ProFormColumnsType<DataSource, ValueType extends string ? ValueType : "text">[];
272
371
  /**
273
- * @description 获取最新的上下文值
274
- * @returns 返回当前的上下文值(排除 setter 方法)
372
+ * @description ProTable 组件属性
275
373
  */
276
- getContext: () => ProTableContextValue;
277
- };
278
- /**
279
- * 公共属性
280
- */
281
- export type ProTableProps<DataSource extends Record<string, any> = Record<string, any>, ParamsType extends Record<string, any> = Record<string, any>, ValueType = "text"> = AntdProTableProps<DataSource, ParamsType, ValueType> & {
282
- prefixCls?: string;
283
- className?: string;
284
- style?: React.CSSProperties;
285
- tableRef?: React.ForwardedRef<ProTableRef<DataSource, ParamsType, ValueType>>;
286
- size?: SizeType;
287
- tableKey?: string;
374
+ tableProps?: Omit<AntdProTableProps<DataSource, ParamsType, ValueType extends string ? ValueType : "text">, 'columns' | 'search'>;
288
375
  /**
289
- * @description Table action 的引用,便于自定义触发
376
+ * @description ProTable 组件 ref
290
377
  */
291
- actionRef?: AntdProTableProps<DataSource, ParamsType, ValueType>['actionRef'];
378
+ tableRef?: React.RefObject<ProTableRef | null>;
292
379
  /**
293
- * @description 搜索表单类型(已废弃,请使用 search.layoutType)
294
- * @default QueryFilter
295
- * @deprecated 请使用 search.layoutType
380
+ * @description 自定义操作按钮列表
296
381
  */
297
- searchType?: SearchType;
382
+ headerButtonItems?: HeaderButtonItem[];
298
383
  /**
299
- * @description 搜索表单配置
384
+ * @description ButtonGroup 最大显示按钮数量
385
+ * @default 3
300
386
  */
301
- search?: false | SearchConfig<DataSource, ValueType>;
387
+ headerButtonMaxCount?: number;
388
+ /**
389
+ * @description 自定义操作按钮渲染
390
+ */
391
+ headerButtonRender?: (dom: React.ReactNode) => React.ReactNode;
302
392
  /**
303
393
  * @description 是否显示新增按钮
304
394
  * @default true
@@ -311,7 +401,7 @@ export type ProTableProps<DataSource extends Record<string, any> = Record<string
311
401
  /**
312
402
  * @description 新增按钮点击回调
313
403
  */
314
- onCreate?: (selectKeys: Key[]) => void | Promise<void>;
404
+ onCreate?: (selectKeys: Key[], selectedRows?: Record<string, any>[]) => (void | false | true) | Promise<void | false | true>;
315
405
  /**
316
406
  * @description 是否显示批量删除按钮
317
407
  * @default true
@@ -327,29 +417,26 @@ export type ProTableProps<DataSource extends Record<string, any> = Record<string
327
417
  */
328
418
  onBatchRemove?: (selectKeys: Key[]) => void | false | Promise<void | false>;
329
419
  /**
330
- * @description 自定义操作按钮列表
420
+ * @description 批量删除 API 方法(优先于 onBatchRemove 使用)
421
+ * @param selectKeys 选中的 key 数组
422
+ * @returns 返回 false 或 reject 时不刷新数据;返回其他值时刷新数据
331
423
  */
332
- headerButtonItems?: HeaderButtonItem[];
424
+ batchRemoveApi?: (selectKeys: Key[]) => any | false | Promise<any | false>;
333
425
  /**
334
- * @description ButtonGroup 最大显示按钮数量
335
- * @default 3
426
+ * @description 默认页面大小
427
+ * @default 10
336
428
  */
337
- headerButtonMaxCount?: number;
429
+ defaultPageSize?: number;
338
430
  /**
339
431
  * @description 是否开启页面大小缓存
340
432
  * @default false
341
433
  */
342
434
  openPageSizeCache?: boolean;
343
435
  /**
344
- * @description 默认页面大小
345
- * @default 10
346
- */
347
- defaultPageSize?: number;
348
- /**
349
- * @description 操作模式
350
- * @default modal
436
+ * 是否展示操作列
437
+ * @default true
351
438
  */
352
- mode?: VlianTableMode;
439
+ showOperateColumn?: boolean;
353
440
  /**
354
441
  * @description 是否显示查看按钮
355
442
  * @default true
@@ -377,6 +464,11 @@ export type ProTableProps<DataSource extends Record<string, any> = Record<string
377
464
  * @description 删除按钮配置
378
465
  */
379
466
  removeBtnProps?: RowButtonItem<DataSource> | false;
467
+ /**
468
+ * @description 删除回调
469
+ * @returns 返回 false 时不刷新数据;返回 void 或 true 时正常刷新
470
+ */
471
+ onRemove?: (record: DataSource, index: number) => void | false | Promise<void | false>;
380
472
  /**
381
473
  * @description 自定义行操作按钮列表
382
474
  */
@@ -387,59 +479,140 @@ export type ProTableProps<DataSource extends Record<string, any> = Record<string
387
479
  */
388
480
  rowButtonMaxCount?: number;
389
481
  /**
390
- * @description Modal 配置
482
+ * @description 获取详情数据(用于编辑和查看)
391
483
  */
392
- modalProps?: Omit<ModalProps, 'open' | 'onCancel' | 'children'>;
484
+ onGetDetail?: (record: DataSource, index: number) => (Promise<DataSource>);
393
485
  /**
394
- * @description Drawer 配置
486
+ * @description ProForm 组件属性(用于表单容器配置,会自动去掉 submitter)
395
487
  */
396
- drawerProps?: Omit<DrawerProps, 'open' | 'onClose' | 'children'>;
488
+ formProps?: Omit<ProFormProps<DataSource, ValueType extends string ? ValueType : "text">, 'submitter' | 'columns'>;
397
489
  /**
398
- * @description 路由基础路径(router 模式下使用)
490
+ * @description 表单列配置(用于 create、update、view 操作的表单字段)
491
+ * 如果未提供自定义渲染函数,则使用此配置渲染表单
399
492
  */
400
- routerBasePath?: string;
493
+ formColumns?: ProFormColumnsType<DataSource, ValueType extends string ? ValueType : "text">[];
401
494
  /**
402
- * @description 操作内容渲染函数
495
+ * @description 自定义查看渲染函数
496
+ * 如果提供此函数,则使用自定义渲染替代默认的表单渲染
497
+ * @param record 当前查看的记录数据
498
+ * @param index 记录索引
403
499
  */
404
- operationContent?: OperationContentRender<DataSource>;
500
+ viewRender?: (record: DataSource | null, index: number) => React.ReactNode;
405
501
  /**
406
- * @description 获取详情数据(用于编辑和查看)
502
+ * @description 自定义创建渲染函数
503
+ * 如果提供此函数,则使用自定义渲染替代默认的表单渲染
407
504
  */
408
- onGetDetail?: (record: DataSource, index: number) => Promise<DataSource>;
505
+ createRender?: () => React.ReactNode;
409
506
  /**
410
- * @description 删除回调
411
- * @returns 返回 false 时不刷新数据;返回 void 或 true 时正常刷新
507
+ * @description 自定义更新渲染函数
508
+ * 如果提供此函数,则使用自定义渲染替代默认的表单渲染
509
+ * @param record 当前编辑的记录数据
510
+ * @param index 记录索引
412
511
  */
413
- onRemove?: (record: DataSource, index: number) => void | false | Promise<void | false>;
512
+ updateRender?: (record: DataSource | null, index: number) => React.ReactNode;
414
513
  /**
415
- * @description 内置表单配置
514
+ * @description 表单前面的温馨提示渲染函数或组件
515
+ * 用于在表单内容的前面显示温馨提示信息
516
+ * @param operationType 当前操作类型
517
+ * @param currentRecord 当前操作的记录数据
518
+ * @param currentIndex 当前记录的索引
416
519
  */
417
- formConfig?: FormConfig<DataSource, ValueType extends string ? ValueType : 'text'>;
520
+ formTipBeforeRender?: React.ReactNode | ((operationType: OperationType, currentRecord: DataSource | null, currentIndex: number) => React.ReactNode);
418
521
  /**
419
- * @description 默认视图模式
420
- * @default table
522
+ * @description 表单后面的温馨提示渲染函数或组件
523
+ * 用于在表单内容的后面显示温馨提示信息
524
+ * @param operationType 当前操作类型
525
+ * @param currentRecord 当前操作的记录数据
526
+ * @param currentIndex 当前记录的索引
421
527
  */
422
- defaultViewMode?: ViewMode;
528
+ formTipAfterRender?: React.ReactNode | ((operationType: OperationType, currentRecord: DataSource | null, currentIndex: number) => React.ReactNode);
423
529
  /**
424
- * @description 网格卡片渲染函数(网格模式下必需)
530
+ * @description 操作表单标题(配合 OperationType 使用,如:create 时显示为"新增{operationTitle}")
425
531
  */
426
- gridCardRender?: GridCardRender<DataSource>;
532
+ operationTitle?: string;
427
533
  /**
428
- * @description 网格列数配置
429
- * @default { xs: 1, sm: 2, md: 3, lg: 4, xl: 4, xxl: 6 }
534
+ * @description Modal.CustomModal 组件属性(排除 open、onCancel、title,这些由组件内部管理)
535
+ * 注意:由于类型限制,这里使用 any,实际使用时请参考 villianjs-pro Modal.CustomModal 类型定义
430
536
  */
431
- gridColumns?: {
432
- xs?: number;
433
- sm?: number;
434
- md?: number;
435
- lg?: number;
436
- xl?: number;
437
- xxl?: number;
438
- };
537
+ modalProps?: Omit<any, 'open' | 'onCancel' | 'title' | 'onOk'>;
439
538
  /**
440
- * @description 网格卡片中每行显示的字段数量
441
- * @default 3
539
+ * @description Drawer 组件属性(排除 open、onClose、title,这些由组件内部管理)
442
540
  */
443
- gridCardFieldsPerRow?: number;
541
+ drawerProps?: Omit<DrawerProps, 'open' | 'onClose' | 'title' | 'onOk'>;
542
+ /**
543
+ * @description 操作表单底部按钮对齐方式
544
+ * @default modal 模式下为 'right',drawer 模式下为 'right',router 模式下为 'center'
545
+ */
546
+ footerAlign?: 'left' | 'center' | 'right';
547
+ /**
548
+ * @description 是否显示提交按钮
549
+ * @default true(view 模式下为 false)
550
+ * @deprecated 请使用 submitBtnProps.visible
551
+ */
552
+ showSubmitBtn?: boolean;
553
+ /**
554
+ * @description 是否显示重置按钮
555
+ * @default true(view 模式下为 false)
556
+ * @deprecated 请使用 resetBtnProps.visible
557
+ */
558
+ showResetBtn?: boolean;
559
+ /**
560
+ * @description 提交按钮文本
561
+ * @default '提交'
562
+ * @deprecated 请使用 submitBtnProps.text
563
+ */
564
+ submitText?: string;
565
+ /**
566
+ * @description 重置按钮文本(取消按钮)
567
+ * @default '取消'
568
+ * @deprecated 请使用 resetBtnProps.text
569
+ */
570
+ resetText?: string;
571
+ /**
572
+ * @description 重置按钮配置
573
+ */
574
+ resetBtnProps?: ResetButtonConfig | false;
575
+ /**
576
+ * @description 提交按钮配置
577
+ */
578
+ submitBtnProps?: SubmitButtonConfig | false;
579
+ /**
580
+ * @description 自定义操作表单按钮列表(支持排序)
581
+ */
582
+ operationFormButtons?: OperationFormButtonItem[];
583
+ /**
584
+ * @description 提交之前的钩子函数
585
+ * @param values 表单值
586
+ * @param operationType 操作类型
587
+ * @param currentRecord 当前记录
588
+ * @returns 返回 false 或 Promise<false> 时阻止提交
589
+ */
590
+ beforeSubmit?: (values: DataSource, operationType: OperationType, currentRecord: DataSource | null) => boolean | Promise<boolean>;
591
+ /**
592
+ * @description 数据转换方法
593
+ * @param values 表单值
594
+ * @param operationType 操作类型
595
+ * @param currentRecord 当前记录
596
+ * @returns 转换后的数据
597
+ */
598
+ transform?: (values: DataSource, operationType: OperationType, currentRecord: DataSource | null) => DataSource | Promise<DataSource>;
599
+ /**
600
+ * @description 提交方法
601
+ * @param values 转换后的表单值
602
+ * @param operationType 操作类型
603
+ * @param currentRecord 当前记录
604
+ * @returns 返回 false 或 Promise<false> 时阻止后续操作(不执行 afterSubmit 和关闭表单),否则返回的值会传递给 afterSubmit
605
+ */
606
+ onSubmit?: (values: DataSource, operationType: OperationType, currentRecord: DataSource | null) => any | false | Promise<any | false>;
607
+ /**
608
+ * @description 提交后的钩子函数
609
+ * @param values 转换后的表单值
610
+ * @param operationType 操作类型
611
+ * @param currentRecord 当前记录
612
+ * @param result onSubmit 返回的值(当 onSubmit 返回 false 时不会执行此方法)
613
+ */
614
+ afterSubmit?: (values: DataSource, operationType: OperationType, currentRecord: DataSource | null, result: {
615
+ result: any;
616
+ }) => void | Promise<void>;
444
617
  };
445
618
  export {};