@jswork/antd-components 1.0.149 → 1.0.151

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.149",
3
+ "version": "1.0.151",
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 1290657123@qq.com
5
- * @LastEditTime: 2025-10-26 08:56:31
5
+ * @LastEditTime: 2025-10-26 19:11:01
6
6
  *
7
7
  *
8
8
  * 路由风格: /{module}/{name} eg: /admin/staff-roles
@@ -44,6 +44,16 @@ export type AcTableProps = TableProps & {
44
44
  * The extra params when query data.
45
45
  */
46
46
  params?: Record<string, any>;
47
+ /**
48
+ * The extra params when redirect to add page.
49
+ * `paramsAdd` will merge with `params` when redirect to add page.
50
+ */
51
+ paramsAdd?: Record<string, any>;
52
+ /**
53
+ * The extra params when redirect to edit page.
54
+ * `paramsEdit` will merge with `paramsAdd` when redirect to edit page.
55
+ */
56
+ paramsEdit?: Record<string, any>;
47
57
  /**
48
58
  * Custom get standard data.
49
59
  * @param params { current: number; pageSize: number }
@@ -60,10 +70,10 @@ export type AcTableProps = TableProps & {
60
70
  */
61
71
  onPageChange?: (page: number, size: number) => void;
62
72
  /**
63
- * When destroy success.
73
+ * When destroy complete.
64
74
  * @param model
65
75
  */
66
- onDestroySuccess?: (model: any) => void;
76
+ onDestroyComplete?: (model: any) => void;
67
77
  /**
68
78
  * Default page.
69
79
  */
@@ -143,6 +153,10 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
143
153
  this.defaultFetcher = fetcher || nx.createFetcher(resourceId, { dataPath, totalPath });
144
154
  }
145
155
 
156
+ private toQueryString(params?: Record<string, any>) {
157
+ return params ? `?${new URLSearchParams(params).toString()}` : '';
158
+ }
159
+
146
160
  async componentDidMount() {
147
161
  const { current, pageSize } = this.state;
148
162
  this.harmonyEvents = ReactHarmonyEvents.create(this);
@@ -217,24 +231,26 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
217
231
  };
218
232
 
219
233
  public destroy = (item) => {
220
- const { name, onDestroySuccess } = this.props;
234
+ const { name, onDestroyComplete } = this.props;
221
235
  this.setState({ isLoading: true });
222
236
  nx.$api[`${name}_destroy`](item)
223
237
  .then(this.refetch)
224
238
  .finally(() => {
225
- onDestroySuccess?.(item);
239
+ onDestroyComplete?.(item);
226
240
  this.setState({ isLoading: false });
227
241
  });
228
242
  };
229
243
 
230
244
  public add = () => {
231
- const { module } = this.props;
232
- nx.$nav?.(`/${module}/${this.routerKey}/add`);
245
+ const { module, paramsAdd } = this.props;
246
+ const qs = this.toQueryString(paramsAdd);
247
+ nx.$nav?.(`/${module}/${this.routerKey}/add${qs}`);
233
248
  };
234
249
 
235
250
  public edit = (item: any) => {
236
- const { module, rowKey } = this.props;
237
- nx.$nav?.(`/${module}/${this.routerKey}/${item[rowKey as string]}/edit`);
251
+ const { module, rowKey, paramsEdit } = this.props;
252
+ const qs = this.toQueryString(paramsEdit);
253
+ nx.$nav?.(`/${module}/${this.routerKey}/${item[rowKey as string]}/edit${qs}`);
238
254
  };
239
255
 
240
256
  /* ----- public eventBus methods end ----- */
@@ -252,8 +268,20 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
252
268
  };
253
269
 
254
270
  render() {
255
- const { className, pagination, onPageChange, params, fetcher, dataPath, totalPath, ...rest } = this.props;
271
+ const {
272
+ className,
273
+ pagination,
274
+ onPageChange,
275
+ params,
276
+ paramsAdd,
277
+ paramsEdit,
278
+ fetcher,
279
+ dataPath,
280
+ totalPath,
281
+ ...rest
282
+ } = this.props;
256
283
  const { dataSource, isLoading, current, pageSize, total } = this.state;
284
+
257
285
  return (
258
286
  <Table
259
287
  className={cx(className, CLASS_NAME)}