@jswork/antd-components 1.0.189 → 1.0.191

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jswork/antd-components",
3
- "version": "1.0.189",
3
+ "version": "1.0.191",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.esm.js",
6
6
  "types": "dist/main.d.ts",
package/src/lib/table.tsx CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: aric 1290657123@qq.com
3
3
  * @Date: 2025-10-03 07:11:26
4
4
  * @LastEditors: aric.zheng 1290657123@qq.com
5
- * @LastEditTime: 2025-10-29 15:31:38
5
+ * @LastEditTime: 2025-10-29 15:42:04
6
6
  *
7
7
  *
8
8
  * 路由风格: /{module}/{name} eg: /admin/staff-roles
@@ -83,6 +83,14 @@ export type AcTableProps = TableProps & {
83
83
  * @param model
84
84
  */
85
85
  onDestroyComplete?: (model: any) => void;
86
+ /**
87
+ * When refetch called.
88
+ */
89
+ onRefetch?: () => void;
90
+ /**
91
+ * When reset called.
92
+ */
93
+ onReset?: () => void;
86
94
  /**
87
95
  * Default page.
88
96
  */
@@ -103,7 +111,6 @@ export type AcTableProps = TableProps & {
103
111
  * The response total key.
104
112
  */
105
113
  totalPath?: string;
106
-
107
114
  /**
108
115
  * Column fields for table.
109
116
  */
@@ -228,11 +235,13 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
228
235
  // 2. 合并所有过滤/搜索参数:
229
236
  // 优先级:overrideParams > propsParams > currentUrlParams
230
237
  // 注意:这里不包含 page 和 size,它们将作为独立参数处理
231
- const filterParams = overrideParams === null ? propsParams : {
232
- ...currentUrlParams, // URL 读取的现有参数
233
- ...propsParams, // 组件 props 中定义的固定参数
234
- ...overrideParams, // 动态传入的覆盖参数(例如搜索关键字)
235
- };
238
+ const filterParams = nx.compactObject(
239
+ overrideParams === null ? propsParams : {
240
+ ...currentUrlParams, // URL 读取的现有参数
241
+ ...propsParams, // 组件 props 中定义的固定参数
242
+ ...overrideParams, // 动态传入的覆盖参数(例如搜索关键字)
243
+ },
244
+ );
236
245
 
237
246
  // 3. 确保 page 和 size 是明确的,并从 filterParams 中移除它们,
238
247
  // 以便传递给 fetcher 的 params 字段时不会重复
@@ -297,15 +306,17 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
297
306
  * Refresh data use current state.
298
307
  */
299
308
  public refetch = async () => {
309
+ const { onRefetch } = this.props;
300
310
  const { current, pageSize } = this.state;
301
311
  await this.fetchData(current, pageSize);
312
+ onRefetch?.();
302
313
  };
303
314
 
304
315
  /**
305
316
  * Reset to default state, and fetch data.
306
317
  */
307
318
  public reset = async () => {
308
- const { defaultCurrent, defaultPageSize } = this.props;
319
+ const { defaultCurrent, defaultPageSize, onReset } = this.props;
309
320
  this.setState(
310
321
  {
311
322
  current: defaultCurrent,
@@ -315,6 +326,7 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
315
326
  },
316
327
  () => {
317
328
  void this.fetchData(defaultCurrent!, defaultPageSize!, null);
329
+ onReset?.();
318
330
  },
319
331
  );
320
332
  };
@@ -387,6 +399,8 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
387
399
  className,
388
400
  pagination,
389
401
  onPageChange,
402
+ onRefetch,
403
+ onReset,
390
404
  params,
391
405
  paramsAdd,
392
406
  paramsEdit,