@jswork/antd-components 1.0.183 → 1.0.185
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 +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.esm.js +1 -1
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/table-status-switcher.tsx +7 -10
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 14:
|
|
5
|
+
* @LastEditTime: 2025-10-29 14:54:35
|
|
6
6
|
*/
|
|
7
7
|
import ReactAntStatusSwitch from '@jswork/react-ant-status-switch';
|
|
8
8
|
import React, { FC } from 'react';
|
|
@@ -21,14 +21,14 @@ export type AcTableStatusSwitcherProps = ReactAntStatusSwitchProps & {
|
|
|
21
21
|
model: any;
|
|
22
22
|
params?: any;
|
|
23
23
|
statusKey?: string;
|
|
24
|
-
|
|
24
|
+
idKey?: string;
|
|
25
25
|
statusUpdateApi?: string;
|
|
26
26
|
onSuccess?: () => void;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const defaultProps = {
|
|
30
30
|
items: [],
|
|
31
|
-
|
|
31
|
+
idKey: 'id',
|
|
32
32
|
statusKey: 'status',
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -38,24 +38,21 @@ export const AcTableStatusSwitcher: FC<AcTableStatusSwitcherProps> = (props) =>
|
|
|
38
38
|
items,
|
|
39
39
|
model,
|
|
40
40
|
statusKey,
|
|
41
|
-
|
|
41
|
+
idKey,
|
|
42
42
|
statusUpdateApi,
|
|
43
43
|
params,
|
|
44
44
|
onSuccess,
|
|
45
45
|
...rest
|
|
46
46
|
} = { ...defaultProps, ...props };
|
|
47
47
|
const _apiPath = statusUpdateApi || `${name}_update`;
|
|
48
|
+
const _onSuccess = onSuccess || (() => nx.$event.emit(`${name}:refetch`));
|
|
48
49
|
const _currentStatus = nx.get(model, statusKey!);
|
|
49
50
|
const handleStatusChange = (e) => {
|
|
50
|
-
const id = nx.get(model,
|
|
51
|
+
const id = nx.get(model, idKey!);
|
|
51
52
|
const status = e.target.value;
|
|
52
53
|
const payload = { id, [statusKey!]: status, ...params };
|
|
53
54
|
nx.$event.emit(`${name}:draft`, { ...model, ...payload });
|
|
54
|
-
nx.$api[_apiPath](payload)
|
|
55
|
-
.then(() => {
|
|
56
|
-
nx.$event.emit(`${name}:refresh`);
|
|
57
|
-
onSuccess?.();
|
|
58
|
-
});
|
|
55
|
+
nx.$api[_apiPath](payload).then(_onSuccess);
|
|
59
56
|
};
|
|
60
57
|
|
|
61
58
|
return (
|