@jswork/antd-components 1.0.186 → 1.0.189
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/dist/main.cjs.js +1 -1
- package/dist/main.d.mts +3 -7
- package/dist/main.d.ts +3 -7
- package/dist/main.esm.js +1 -1
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/table-toggle-switcher.tsx +3 -3
- package/src/lib/table.tsx +8 -13
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: aric.zheng 1290657123@qq.com
|
|
3
3
|
* @Date: 2025-10-29 14:09:01
|
|
4
4
|
* @LastEditors: aric.zheng 1290657123@qq.com
|
|
5
|
-
* @LastEditTime: 2025-10-29 15:
|
|
5
|
+
* @LastEditTime: 2025-10-29 15:14:28
|
|
6
6
|
*/
|
|
7
7
|
import React, { FC } from 'react';
|
|
8
8
|
import nx from '@jswork/next';
|
|
@@ -44,9 +44,8 @@ export const AcTableToggleSwitcher: FC<AcTableToggleSwitcherProps> = (props) =>
|
|
|
44
44
|
const _apiPath = updateApi || `${name}_update`;
|
|
45
45
|
const _onSuccess = onSuccess || (() => nx.$event.emit(`${name}:refetch`));
|
|
46
46
|
const _currentValue = nx.get(model, updateKey);
|
|
47
|
-
const handleStatusChange = (
|
|
47
|
+
const handleStatusChange = (value) => {
|
|
48
48
|
const id = nx.get(model, idKey!);
|
|
49
|
-
const { value } = e.target;
|
|
50
49
|
const payload = { id, [updateKey]: value, ...params };
|
|
51
50
|
nx.$event.emit(`${name}:draft`, { ...model, ...payload });
|
|
52
51
|
nx.$api[_apiPath](payload).then(_onSuccess);
|
|
@@ -54,6 +53,7 @@ export const AcTableToggleSwitcher: FC<AcTableToggleSwitcherProps> = (props) =>
|
|
|
54
53
|
|
|
55
54
|
return (
|
|
56
55
|
<Switch
|
|
56
|
+
size="small"
|
|
57
57
|
defaultChecked={_currentValue}
|
|
58
58
|
onChange={handleStatusChange}
|
|
59
59
|
{...rest}
|
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
|
|
5
|
+
* @LastEditTime: 2025-10-29 15:31:38
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* 路由风格: /{module}/{name} eg: /admin/staff-roles
|
|
@@ -63,11 +63,6 @@ export type AcTableProps = TableProps & {
|
|
|
63
63
|
*/
|
|
64
64
|
paramsEdit?: Record<string, any>;
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
* The extra params when reset.
|
|
68
|
-
* `paramsReset` will merge with `params` when reset.
|
|
69
|
-
*/
|
|
70
|
-
paramsReset?: Record<string, any>;
|
|
71
66
|
/**
|
|
72
67
|
* Custom get standard data.
|
|
73
68
|
* @param params { current: number; pageSize: number }
|
|
@@ -152,6 +147,7 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
152
147
|
dataPath: 'rows',
|
|
153
148
|
totalPath: 'total',
|
|
154
149
|
columnsFields: [],
|
|
150
|
+
params: {},
|
|
155
151
|
};
|
|
156
152
|
|
|
157
153
|
public eventBus: EventMittNamespace.EventMitt = AcTable.event;
|
|
@@ -222,7 +218,7 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
222
218
|
this.sync.cancel();
|
|
223
219
|
}
|
|
224
220
|
|
|
225
|
-
fetchData = async (page: number, size: number, overrideParams?: Record<string, any>) => {
|
|
221
|
+
fetchData = async (page: number, size: number, overrideParams?: Record<string, any> | null) => {
|
|
226
222
|
const abortController = new AbortController();
|
|
227
223
|
const { params: propsParams } = this.props; // 将 props.params 重命名以避免与局部变量冲突
|
|
228
224
|
|
|
@@ -232,17 +228,17 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
232
228
|
// 2. 合并所有过滤/搜索参数:
|
|
233
229
|
// 优先级:overrideParams > propsParams > currentUrlParams
|
|
234
230
|
// 注意:这里不包含 page 和 size,它们将作为独立参数处理
|
|
235
|
-
const filterParams =
|
|
231
|
+
const filterParams = overrideParams === null ? propsParams : {
|
|
236
232
|
...currentUrlParams, // 从 URL 读取的现有参数
|
|
237
233
|
...propsParams, // 组件 props 中定义的固定参数
|
|
238
234
|
...overrideParams, // 动态传入的覆盖参数(例如搜索关键字)
|
|
239
|
-
}
|
|
235
|
+
};
|
|
240
236
|
|
|
241
237
|
// 3. 确保 page 和 size 是明确的,并从 filterParams 中移除它们,
|
|
242
238
|
// 以便传递给 fetcher 的 params 字段时不会重复
|
|
243
239
|
const finalPage = page;
|
|
244
240
|
const finalSize = size;
|
|
245
|
-
const { page: _, size: __, ...fetcherFilterParams } = filterParams
|
|
241
|
+
const { page: _, size: __, ...fetcherFilterParams } = filterParams as Record<string, any>;
|
|
246
242
|
|
|
247
243
|
|
|
248
244
|
// 4. 更新组件状态:加载中、当前页和每页大小
|
|
@@ -309,7 +305,7 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
309
305
|
* Reset to default state, and fetch data.
|
|
310
306
|
*/
|
|
311
307
|
public reset = async () => {
|
|
312
|
-
const { defaultCurrent, defaultPageSize
|
|
308
|
+
const { defaultCurrent, defaultPageSize } = this.props;
|
|
313
309
|
this.setState(
|
|
314
310
|
{
|
|
315
311
|
current: defaultCurrent,
|
|
@@ -318,7 +314,7 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
318
314
|
dataSource: [],
|
|
319
315
|
},
|
|
320
316
|
() => {
|
|
321
|
-
void this.fetchData(defaultCurrent!, defaultPageSize!,
|
|
317
|
+
void this.fetchData(defaultCurrent!, defaultPageSize!, null);
|
|
322
318
|
},
|
|
323
319
|
);
|
|
324
320
|
};
|
|
@@ -394,7 +390,6 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
394
390
|
params,
|
|
395
391
|
paramsAdd,
|
|
396
392
|
paramsEdit,
|
|
397
|
-
paramsReset,
|
|
398
393
|
fetcher,
|
|
399
394
|
dataPath,
|
|
400
395
|
totalPath,
|