@jswork/antd-components 1.0.145 → 1.0.147
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 +2 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.esm.js +1 -1
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/table.tsx +16 -2
- package/src/lib/use-table-command.ts +2 -0
package/package.json
CHANGED
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-25
|
|
5
|
+
* @LastEditTime: 2025-10-25 23:54:58
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
8
|
* 路由风格: /{module}/{name} eg: /admin/staff-roles
|
|
@@ -100,7 +100,7 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
100
100
|
static formSchema = CLASS_NAME;
|
|
101
101
|
private harmonyEvents: ReactHarmonyEvents | null = null;
|
|
102
102
|
static event: EventMittNamespace.EventMitt;
|
|
103
|
-
static events = ['refetch', 'reset', 'add', 'edit', 'destroy'];
|
|
103
|
+
static events = ['refetch', 'reset', 'add', 'edit', 'destroy', 'optimisticUpdate'];
|
|
104
104
|
static defaultProps = {
|
|
105
105
|
name: '@',
|
|
106
106
|
module: 'admin',
|
|
@@ -202,6 +202,20 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
202
202
|
);
|
|
203
203
|
};
|
|
204
204
|
|
|
205
|
+
public optimisticUpdate = async (inData: Record<string, any>) => {
|
|
206
|
+
const { rowKey } = this.props;
|
|
207
|
+
const id = inData[rowKey as string];
|
|
208
|
+
const dataSource = this.state.dataSource!.slice();
|
|
209
|
+
const index = dataSource.findIndex((item) => item[rowKey as string] === id);
|
|
210
|
+
if (index !== -1) {
|
|
211
|
+
dataSource[index] = {
|
|
212
|
+
...dataSource[index],
|
|
213
|
+
...inData,
|
|
214
|
+
};
|
|
215
|
+
this.setState({ dataSource });
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
205
219
|
public destroy = (item) => {
|
|
206
220
|
const { name, onDestroySuccess } = this.props;
|
|
207
221
|
this.setState({ isLoading: true });
|
|
@@ -14,6 +14,7 @@ const useCommand = (inName?: string) => {
|
|
|
14
14
|
const add = () => execute('add');
|
|
15
15
|
const edit = () => execute('edit');
|
|
16
16
|
const destroy = () => execute('destroy');
|
|
17
|
+
const optimisticUpdate = (inData: Record<string, any>) => execute('optimisticUpdate', inData);
|
|
17
18
|
|
|
18
19
|
return {
|
|
19
20
|
listen,
|
|
@@ -23,6 +24,7 @@ const useCommand = (inName?: string) => {
|
|
|
23
24
|
add,
|
|
24
25
|
edit,
|
|
25
26
|
destroy,
|
|
27
|
+
optimisticUpdate,
|
|
26
28
|
};
|
|
27
29
|
};
|
|
28
30
|
|