@jswork/antd-components 1.0.118 → 1.0.120
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 +15 -1
- package/dist/main.d.ts +15 -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.tsx +33 -3
- package/src/lib/use-table-command.ts +6 -0
package/package.json
CHANGED
package/src/lib/table.tsx
CHANGED
|
@@ -2,15 +2,23 @@
|
|
|
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-23
|
|
5
|
+
* @LastEditTime: 2025-10-23 16:23:20
|
|
6
6
|
*/
|
|
7
7
|
import type { EventMittNamespace } from '@jswork/event-mitt';
|
|
8
8
|
import { ReactHarmonyEvents } from '@jswork/harmony-events';
|
|
9
|
-
import '@jswork/next-create-fetcher';
|
|
10
9
|
import UrlSyncFlat from '@jswork/url-sync-flat';
|
|
11
10
|
import { Table, TableProps, message } from 'antd';
|
|
12
11
|
import cx from 'classnames';
|
|
13
12
|
import React from 'react';
|
|
13
|
+
import nx from '@jswork/next';
|
|
14
|
+
import '@jswork/next-create-fetcher';
|
|
15
|
+
|
|
16
|
+
declare global {
|
|
17
|
+
interface NxStatic {
|
|
18
|
+
$nav: any;
|
|
19
|
+
$api: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
14
22
|
|
|
15
23
|
const CLASS_NAME = 'ac-table';
|
|
16
24
|
|
|
@@ -20,6 +28,7 @@ export type AcTableProps = TableProps & {
|
|
|
20
28
|
* @default '@'
|
|
21
29
|
*/
|
|
22
30
|
name?: string;
|
|
31
|
+
module?: string;
|
|
23
32
|
params?: Record<string, any>;
|
|
24
33
|
/**
|
|
25
34
|
* 自定义数据获取函数
|
|
@@ -55,10 +64,11 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
55
64
|
static formSchema = CLASS_NAME;
|
|
56
65
|
private harmonyEvents: ReactHarmonyEvents | null = null;
|
|
57
66
|
static event: EventMittNamespace.EventMitt;
|
|
58
|
-
static events = ['refetch', 'reset'];
|
|
67
|
+
static events = ['refetch', 'reset', 'toAdd', 'toEdit', 'toDestroy'];
|
|
59
68
|
|
|
60
69
|
static defaultProps = {
|
|
61
70
|
name: '@',
|
|
71
|
+
module: 'admin',
|
|
62
72
|
rowKey: 'id',
|
|
63
73
|
defaultCurrent: 1,
|
|
64
74
|
defaultPageSize: 10,
|
|
@@ -143,6 +153,26 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
143
153
|
);
|
|
144
154
|
};
|
|
145
155
|
|
|
156
|
+
public toDestroy = (item) => {
|
|
157
|
+
const { name } = this.props;
|
|
158
|
+
this.setState({ isLoading: true });
|
|
159
|
+
nx.$api[`${name}_destroy`](item)
|
|
160
|
+
.then(this.refetch)
|
|
161
|
+
.finally(() => {
|
|
162
|
+
this.setState({ isLoading: false });
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
public toAdd = () => {
|
|
167
|
+
const { module, name } = this.props;
|
|
168
|
+
nx.$nav?.(`/${module}/${name}/add`);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
public toEdit = (item: any) => {
|
|
172
|
+
const { module, name, rowKey } = this.props;
|
|
173
|
+
nx.$nav?.(`/${module}/${name}/edit/${item[rowKey as string]}`);
|
|
174
|
+
};
|
|
175
|
+
|
|
146
176
|
/* ----- public eventBus methods end ----- */
|
|
147
177
|
|
|
148
178
|
handleOnRow = (record) => {
|
|
@@ -11,12 +11,18 @@ const useCommand = (inName?: string) => {
|
|
|
11
11
|
// the command repository:
|
|
12
12
|
const refetch = () => execute('refetch');
|
|
13
13
|
const reset = () => execute('reset');
|
|
14
|
+
const toAdd = () => execute('toAdd');
|
|
15
|
+
const toEdit = () => execute('toEdit');
|
|
16
|
+
const toDestroy = () => execute('toDestroy');
|
|
14
17
|
|
|
15
18
|
return {
|
|
16
19
|
listen,
|
|
17
20
|
execute,
|
|
18
21
|
refetch,
|
|
19
22
|
reset,
|
|
23
|
+
toAdd,
|
|
24
|
+
toEdit,
|
|
25
|
+
toDestroy,
|
|
20
26
|
};
|
|
21
27
|
};
|
|
22
28
|
|