@fe-free/core 3.0.38 → 3.0.39
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/CHANGELOG.md +8 -0
- package/package.json +3 -3
- package/src/crud/crud_delete.tsx +9 -16
- package/src/crud/helper.tsx +45 -0
- package/src/crud/use_operate.tsx +49 -33
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.39",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"antd": "^5.27.1",
|
|
47
47
|
"dayjs": "~1.11.10",
|
|
48
48
|
"react": "^19.2.0",
|
|
49
|
-
"@fe-free/
|
|
50
|
-
"@fe-free/
|
|
49
|
+
"@fe-free/icons": "3.0.39",
|
|
50
|
+
"@fe-free/tool": "3.0.39"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"test": "echo \"Error: no test specified\" && exit 1"
|
package/src/crud/crud_delete.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DeleteOutlined } from '@fe-free/icons';
|
|
2
|
-
import { App
|
|
2
|
+
import { App } from 'antd';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
|
+
import { OperateBtn } from './helper';
|
|
4
5
|
|
|
5
6
|
interface Params {
|
|
6
7
|
name: string;
|
|
@@ -40,22 +41,14 @@ function OperateDelete(props: Params) {
|
|
|
40
41
|
const { name, desc, onDelete, operateText, disabled } = props;
|
|
41
42
|
const { doDelete } = useDelete({ name, desc, onDelete, operateText });
|
|
42
43
|
|
|
43
|
-
if (disabled) {
|
|
44
|
-
return (
|
|
45
|
-
<Tooltip title="删除">
|
|
46
|
-
<span className="cursor-not-allowed text-lg text-03">
|
|
47
|
-
{operateText || <DeleteOutlined />}
|
|
48
|
-
</span>
|
|
49
|
-
</Tooltip>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
44
|
return (
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
<OperateBtn
|
|
46
|
+
title="删除"
|
|
47
|
+
icon={<DeleteOutlined />}
|
|
48
|
+
operateText={operateText}
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
onClick={doDelete}
|
|
51
|
+
/>
|
|
59
52
|
);
|
|
60
53
|
}
|
|
61
54
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Tooltip } from 'antd';
|
|
2
|
+
|
|
3
|
+
function OperateBtn({
|
|
4
|
+
title,
|
|
5
|
+
icon,
|
|
6
|
+
operateText,
|
|
7
|
+
disabled,
|
|
8
|
+
onClick,
|
|
9
|
+
}: {
|
|
10
|
+
title: string;
|
|
11
|
+
icon: React.ReactNode;
|
|
12
|
+
operateText?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
onClick?: () => void;
|
|
15
|
+
}) {
|
|
16
|
+
if (disabled) {
|
|
17
|
+
if (operateText) {
|
|
18
|
+
return <span className="cursor-not-allowed text-lg text-03">{operateText || icon}</span>;
|
|
19
|
+
} else {
|
|
20
|
+
return (
|
|
21
|
+
<Tooltip title={title}>
|
|
22
|
+
<span className="cursor-not-allowed text-lg text-03">{icon}</span>
|
|
23
|
+
</Tooltip>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (operateText) {
|
|
29
|
+
return (
|
|
30
|
+
<span className="cursor-pointer text-lg text-primary" onClick={onClick}>
|
|
31
|
+
{operateText}
|
|
32
|
+
</span>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Tooltip title={title}>
|
|
38
|
+
<span className="cursor-pointer text-lg text-primary" onClick={onClick}>
|
|
39
|
+
{operateText || icon}
|
|
40
|
+
</span>
|
|
41
|
+
</Tooltip>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { OperateBtn };
|
package/src/crud/use_operate.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { EditOutlined, EyeOutlined } from '@fe-free/icons';
|
|
2
|
-
import {
|
|
2
|
+
import { App } from 'antd';
|
|
3
3
|
import { isString } from 'lodash-es';
|
|
4
4
|
import { useCallback, useMemo } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { routeTool } from '../route';
|
|
6
6
|
import { OperateDelete } from './crud_delete';
|
|
7
7
|
import { CRUDDetail } from './crud_detail';
|
|
8
|
+
import { OperateBtn } from './helper';
|
|
8
9
|
import type { TableProps } from './table';
|
|
9
10
|
|
|
10
11
|
function useOperate(props, detailProps, actionRef) {
|
|
@@ -18,6 +19,7 @@ function useOperate(props, detailProps, actionRef) {
|
|
|
18
19
|
detailIdIndex,
|
|
19
20
|
requestDeleteByRecord,
|
|
20
21
|
} = props;
|
|
22
|
+
const { message } = App.useApp();
|
|
21
23
|
|
|
22
24
|
const idField = tableProps.rowKey || 'id';
|
|
23
25
|
|
|
@@ -56,13 +58,15 @@ function useOperate(props, detailProps, actionRef) {
|
|
|
56
58
|
|
|
57
59
|
if (!hidden) {
|
|
58
60
|
const disabled = readProps?.operateIsDisabled?.(record) || false;
|
|
61
|
+
|
|
59
62
|
if (disabled) {
|
|
60
63
|
return (
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
<OperateBtn
|
|
65
|
+
title="查看"
|
|
66
|
+
icon={<EyeOutlined />}
|
|
67
|
+
operateText={readProps?.operateText}
|
|
68
|
+
disabled
|
|
69
|
+
/>
|
|
66
70
|
);
|
|
67
71
|
} else {
|
|
68
72
|
return (
|
|
@@ -72,9 +76,11 @@ function useOperate(props, detailProps, actionRef) {
|
|
|
72
76
|
record={record}
|
|
73
77
|
onSuccess={handleReload}
|
|
74
78
|
trigger={
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
<OperateBtn
|
|
80
|
+
title="查看"
|
|
81
|
+
icon={<EyeOutlined />}
|
|
82
|
+
operateText={readProps?.operateText}
|
|
83
|
+
/>
|
|
78
84
|
}
|
|
79
85
|
action="read"
|
|
80
86
|
{...detailProps}
|
|
@@ -94,24 +100,31 @@ function useOperate(props, detailProps, actionRef) {
|
|
|
94
100
|
const disabled = readProps?.operateIsDisabled?.(record) || false;
|
|
95
101
|
if (disabled) {
|
|
96
102
|
return (
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
<OperateBtn
|
|
104
|
+
title="查看"
|
|
105
|
+
icon={<EyeOutlined />}
|
|
106
|
+
operateText={readProps?.operateText}
|
|
107
|
+
disabled
|
|
108
|
+
/>
|
|
102
109
|
);
|
|
103
110
|
} else {
|
|
104
111
|
return (
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
<OperateBtn
|
|
113
|
+
title="查看"
|
|
114
|
+
icon={<EyeOutlined />}
|
|
115
|
+
operateText={readProps?.operateText}
|
|
116
|
+
onClick={() => {
|
|
117
|
+
if (readProps?.target === '_blank') {
|
|
118
|
+
const url = `${window.location.pathname}/detail/${record[detailIdIndex || 'id']}`;
|
|
119
|
+
window.open(url, readProps?.target);
|
|
120
|
+
} else {
|
|
121
|
+
routeTool.navigateTo({
|
|
122
|
+
path: './detail/:id',
|
|
123
|
+
params: { id: record[detailIdIndex || 'id'] },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
115
128
|
);
|
|
116
129
|
}
|
|
117
130
|
}
|
|
@@ -128,11 +141,12 @@ function useOperate(props, detailProps, actionRef) {
|
|
|
128
141
|
|
|
129
142
|
if (disabled) {
|
|
130
143
|
return (
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
<OperateBtn
|
|
145
|
+
title="编辑"
|
|
146
|
+
icon={<EditOutlined />}
|
|
147
|
+
operateText={updateProps?.operateText}
|
|
148
|
+
disabled
|
|
149
|
+
/>
|
|
136
150
|
);
|
|
137
151
|
} else {
|
|
138
152
|
return (
|
|
@@ -142,9 +156,11 @@ function useOperate(props, detailProps, actionRef) {
|
|
|
142
156
|
record={record}
|
|
143
157
|
onSuccess={handleReload}
|
|
144
158
|
trigger={
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
159
|
+
<OperateBtn
|
|
160
|
+
title="编辑"
|
|
161
|
+
icon={<EditOutlined />}
|
|
162
|
+
operateText={updateProps?.operateText}
|
|
163
|
+
/>
|
|
148
164
|
}
|
|
149
165
|
action="update"
|
|
150
166
|
{...detailProps}
|