@jswork/antd-components 1.0.147 → 1.0.149
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 +5 -4
- package/dist/main.d.ts +5 -4
- package/dist/main.esm.js +1 -1
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/table-extras.tsx +7 -21
- package/src/lib/table.tsx +5 -5
- package/src/lib/use-table-command.ts +4 -3
package/package.json
CHANGED
package/src/lib/table-extras.tsx
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* @Author: aric 1290657123@qq.com
|
|
3
3
|
* @Date: 2025-10-24 20:40:55
|
|
4
4
|
* @LastEditors: aric 1290657123@qq.com
|
|
5
|
-
* @LastEditTime: 2025-10-
|
|
5
|
+
* @LastEditTime: 2025-10-26 14:48:21
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { Space, SpaceProps } from 'antd';
|
|
8
8
|
import React, { FC } from 'react';
|
|
9
|
-
import { PlusOutlined, ReloadOutlined } from '@ant-design/icons';
|
|
10
9
|
import nx from '@jswork/next';
|
|
10
|
+
import { BtnBack, BtnCreate, BtnRefresh } from './button';
|
|
11
11
|
|
|
12
12
|
declare global {
|
|
13
13
|
interface NxStatic {
|
|
@@ -23,17 +23,6 @@ export type AcTableExtrasProps = SpaceProps & {
|
|
|
23
23
|
actions?: string []
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const locales = {
|
|
27
|
-
'zh-CN': {
|
|
28
|
-
reset: '刷新',
|
|
29
|
-
add: '添加',
|
|
30
|
-
},
|
|
31
|
-
'en-US': {
|
|
32
|
-
reset: 'Refresh',
|
|
33
|
-
add: 'Create',
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
26
|
const defaultExtras = {
|
|
38
27
|
lang: 'zh-CN',
|
|
39
28
|
actions: ['reset', 'add'],
|
|
@@ -41,17 +30,14 @@ const defaultExtras = {
|
|
|
41
30
|
|
|
42
31
|
export const AcTableExtras: FC<AcTableExtrasProps> = (props) => {
|
|
43
32
|
const { name, lang, as, asProps, actions } = { ...defaultExtras, ...props };
|
|
44
|
-
const t = (key: string) => locales[lang][key];
|
|
45
33
|
const handleRefresh = () => nx.$event?.emit?.(`${name}:reset`);
|
|
46
34
|
const handleAdd = () => nx.$event?.emit?.(`${name}:add`);
|
|
35
|
+
const handleBack = () => history.back();
|
|
47
36
|
const AsComponent = as || Space;
|
|
48
37
|
const items = {
|
|
49
|
-
reset: <
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
add: <Button key="add" size="small" icon={<PlusOutlined />} onClick={handleAdd}>
|
|
53
|
-
{t('add')}
|
|
54
|
-
</Button>,
|
|
38
|
+
reset: <BtnRefresh lang={lang} onClick={handleRefresh} />,
|
|
39
|
+
add: <BtnCreate lang={lang} onClick={handleAdd} />,
|
|
40
|
+
back: <BtnBack lang={lang} onClick={handleBack} />,
|
|
55
41
|
};
|
|
56
42
|
|
|
57
43
|
return (
|
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-
|
|
5
|
+
* @LastEditTime: 2025-10-26 08:56:31
|
|
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', 'draft'];
|
|
104
104
|
static defaultProps = {
|
|
105
105
|
name: '@',
|
|
106
106
|
module: 'admin',
|
|
@@ -202,15 +202,15 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
|
|
|
202
202
|
);
|
|
203
203
|
};
|
|
204
204
|
|
|
205
|
-
public
|
|
205
|
+
public draft = async (payload: Record<string, any>) => {
|
|
206
206
|
const { rowKey } = this.props;
|
|
207
|
-
const id =
|
|
207
|
+
const id = payload[rowKey as string];
|
|
208
208
|
const dataSource = this.state.dataSource!.slice();
|
|
209
209
|
const index = dataSource.findIndex((item) => item[rowKey as string] === id);
|
|
210
210
|
if (index !== -1) {
|
|
211
211
|
dataSource[index] = {
|
|
212
212
|
...dataSource[index],
|
|
213
|
-
...
|
|
213
|
+
...payload,
|
|
214
214
|
};
|
|
215
215
|
this.setState({ dataSource });
|
|
216
216
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AcTable } from './table';
|
|
2
2
|
|
|
3
|
-
type ExecuteFn = (command: string,
|
|
3
|
+
type ExecuteFn = (command: string, data?: any) => void;
|
|
4
4
|
type ListenFn = (command: string, callback: any) => void;
|
|
5
|
+
type Payload = Record<string, any>;
|
|
5
6
|
|
|
6
7
|
const useCommand = (inName?: string) => {
|
|
7
8
|
const name = inName || '@';
|
|
@@ -14,7 +15,7 @@ const useCommand = (inName?: string) => {
|
|
|
14
15
|
const add = () => execute('add');
|
|
15
16
|
const edit = () => execute('edit');
|
|
16
17
|
const destroy = () => execute('destroy');
|
|
17
|
-
const
|
|
18
|
+
const draft = (payload: Payload) => execute('draft', payload);
|
|
18
19
|
|
|
19
20
|
return {
|
|
20
21
|
listen,
|
|
@@ -24,7 +25,7 @@ const useCommand = (inName?: string) => {
|
|
|
24
25
|
add,
|
|
25
26
|
edit,
|
|
26
27
|
destroy,
|
|
27
|
-
|
|
28
|
+
draft,
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
|