@cqsjjb/jjb-react-admin-component 3.0.26 → 3.0.27
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/ErrorBoundary/index.d.ts +12 -0
- package/ErrorBoundary/index.js +41 -0
- package/ErrorBoundary/index.mjs +58 -0
- package/FormilyDescriptions/index.js +11 -6
- package/FormilyDescriptions/index.mjs +48 -46
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ComponentProps } from '../types';
|
|
4
|
+
|
|
5
|
+
interface ErrorBoundaryProps extends ComponentProps {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ErrorBoundaryFc extends React.FC<ErrorBoundaryProps> {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const ErrorBoundary: ErrorBoundaryFc;
|
|
12
|
+
export default ErrorBoundary;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Result, Tooltip, Button } from 'antd';
|
|
3
|
+
export default class ErrorBoundary extends React.Component {
|
|
4
|
+
state = {
|
|
5
|
+
hasError: false,
|
|
6
|
+
errorInfo: '',
|
|
7
|
+
errorStack: undefined
|
|
8
|
+
};
|
|
9
|
+
componentDidCatch(error, info) {
|
|
10
|
+
this.setState({
|
|
11
|
+
hasError: true,
|
|
12
|
+
errorInfo: error.message,
|
|
13
|
+
errorStack: info.componentStack
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
render() {
|
|
17
|
+
if (this.state.hasError) {
|
|
18
|
+
return /*#__PURE__*/React.createElement(Result, {
|
|
19
|
+
status: "error",
|
|
20
|
+
title: "\u5E94\u7528\u8FD0\u884C\u5F02\u5E38",
|
|
21
|
+
subTitle: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, this.state.errorInfo), /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
style: {
|
|
23
|
+
width: 700,
|
|
24
|
+
display: 'inline-block',
|
|
25
|
+
overflow: 'auto',
|
|
26
|
+
maxHeight: 400,
|
|
27
|
+
textAlign: 'left',
|
|
28
|
+
whiteSpace: 'pre-line'
|
|
29
|
+
}
|
|
30
|
+
}, this.state.errorStack)),
|
|
31
|
+
extra: /*#__PURE__*/React.createElement(Tooltip, {
|
|
32
|
+
title: "\u82E5\u5237\u65B0\u4EFB\u7136\u65E0\u6CD5\u89E3\u51B3\uFF0C\u8BF7\u8054\u7CFB\u6280\u672F\u4EBA\u5458\u89E3\u51B3"
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
34
|
+
type: "primary",
|
|
35
|
+
onClick: () => window.location.reload()
|
|
36
|
+
}, "\u5237\u65B0\u91CD\u8BD5"))
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return this.props.children;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Result, Tooltip, Button } from 'antd';
|
|
3
|
+
|
|
4
|
+
export default class ErrorBoundary extends React.Component {
|
|
5
|
+
state = {
|
|
6
|
+
hasError: false,
|
|
7
|
+
errorInfo: '',
|
|
8
|
+
errorStack: undefined
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
componentDidCatch(error, info) {
|
|
12
|
+
this.setState({
|
|
13
|
+
hasError: true,
|
|
14
|
+
errorInfo: error.message,
|
|
15
|
+
errorStack: info.componentStack
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
render() {
|
|
20
|
+
if (this.state.hasError) {
|
|
21
|
+
return (
|
|
22
|
+
<Result
|
|
23
|
+
status="error"
|
|
24
|
+
title="应用运行异常"
|
|
25
|
+
subTitle={(
|
|
26
|
+
<React.Fragment>
|
|
27
|
+
<div>{this.state.errorInfo}</div>
|
|
28
|
+
<div
|
|
29
|
+
style={{
|
|
30
|
+
width: 700,
|
|
31
|
+
display: 'inline-block',
|
|
32
|
+
overflow: 'auto',
|
|
33
|
+
maxHeight: 400,
|
|
34
|
+
textAlign: 'left',
|
|
35
|
+
whiteSpace: 'pre-line'
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
{this.state.errorStack}
|
|
39
|
+
</div>
|
|
40
|
+
</React.Fragment>
|
|
41
|
+
)}
|
|
42
|
+
extra={(
|
|
43
|
+
<Tooltip title="若刷新任然无法解决,请联系技术人员解决">
|
|
44
|
+
<Button
|
|
45
|
+
type="primary"
|
|
46
|
+
onClick={() => window.location.reload()}
|
|
47
|
+
>
|
|
48
|
+
刷新重试
|
|
49
|
+
</Button>
|
|
50
|
+
</Tooltip>
|
|
51
|
+
)}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return this.props.children;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -22,8 +22,13 @@ export default function FormilyDescriptions(props) {
|
|
|
22
22
|
});
|
|
23
23
|
return dataSource.length === 0 ? /*#__PURE__*/React.createElement(Empty, {
|
|
24
24
|
image: Empty.PRESENTED_IMAGE_SIMPLE
|
|
25
|
-
}) : /*#__PURE__*/React.createElement(
|
|
26
|
-
|
|
25
|
+
}) : /*#__PURE__*/React.createElement(DescriptionsRender, _extends({
|
|
26
|
+
dataSource: dataSource
|
|
27
|
+
}, props));
|
|
28
|
+
}
|
|
29
|
+
export function DescriptionsRender(props) {
|
|
30
|
+
return props.dataSource.map((item, index) => {
|
|
31
|
+
const isLast = index === props.dataSource.length - 1;
|
|
27
32
|
return /*#__PURE__*/React.createElement(Descriptions, {
|
|
28
33
|
key: index,
|
|
29
34
|
size: props.size,
|
|
@@ -54,9 +59,9 @@ export default function FormilyDescriptions(props) {
|
|
|
54
59
|
labelStyle: props.labelStyle,
|
|
55
60
|
contentStyle: props.contentStyle
|
|
56
61
|
});
|
|
57
|
-
})
|
|
62
|
+
});
|
|
58
63
|
}
|
|
59
|
-
function ItemRender(props) {
|
|
64
|
+
export function ItemRender(props) {
|
|
60
65
|
const [type, setType] = React.useState(undefined);
|
|
61
66
|
const [open, setOpen] = React.useState(false);
|
|
62
67
|
const [previewUrl, setPreviewUrl] = React.useState('');
|
|
@@ -153,7 +158,7 @@ function ItemRender(props) {
|
|
|
153
158
|
height: "350"
|
|
154
159
|
})));
|
|
155
160
|
}
|
|
156
|
-
function generateValue(data, prefix = []) {
|
|
161
|
+
export function generateValue(data, prefix = []) {
|
|
157
162
|
const result = [];
|
|
158
163
|
data.forEach(item => {
|
|
159
164
|
// 当前节点的完整 name
|
|
@@ -169,7 +174,7 @@ function generateValue(data, prefix = []) {
|
|
|
169
174
|
});
|
|
170
175
|
return result;
|
|
171
176
|
}
|
|
172
|
-
function RenderText(props) {
|
|
177
|
+
export function RenderText(props) {
|
|
173
178
|
const {
|
|
174
179
|
value
|
|
175
180
|
} = props;
|
|
@@ -26,54 +26,56 @@ export default function FormilyDescriptions(props) {
|
|
|
26
26
|
return dataSource.length === 0
|
|
27
27
|
? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
|
28
28
|
: (
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
<DescriptionsRender dataSource={dataSource} {...props} />
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function DescriptionsRender(props) {
|
|
34
|
+
return props.dataSource.map((item, index) => {
|
|
35
|
+
const isLast = index === props.dataSource.length - 1;
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
);
|
|
71
|
-
})}
|
|
72
|
-
</React.Fragment>
|
|
37
|
+
return (
|
|
38
|
+
<Descriptions
|
|
39
|
+
key={index}
|
|
40
|
+
size={props.size}
|
|
41
|
+
style={{
|
|
42
|
+
marginBottom: isLast
|
|
43
|
+
? 0
|
|
44
|
+
: formilyItemMargin.get(props.size || 'default')
|
|
45
|
+
}}
|
|
46
|
+
items={item.fromComponentEnum === 'GRID_FORM'
|
|
47
|
+
? item.children.map((child, childIndex) => {
|
|
48
|
+
return {
|
|
49
|
+
key: childIndex,
|
|
50
|
+
label: child.name,
|
|
51
|
+
span: child.formType === 'Table'
|
|
52
|
+
? props.column
|
|
53
|
+
: 1,
|
|
54
|
+
children: (
|
|
55
|
+
<ItemRender data={child} {...props} />
|
|
56
|
+
)
|
|
57
|
+
};
|
|
58
|
+
})
|
|
59
|
+
: [
|
|
60
|
+
{
|
|
61
|
+
key: 1,
|
|
62
|
+
label: item.name,
|
|
63
|
+
children: <ItemRender data={item} {...props} />
|
|
64
|
+
}
|
|
65
|
+
]}
|
|
66
|
+
colon={props.colon}
|
|
67
|
+
title={props.title}
|
|
68
|
+
extra={props.extra}
|
|
69
|
+
layout={props.layout || 'vertical'}
|
|
70
|
+
column={props.column}
|
|
71
|
+
labelStyle={props.labelStyle}
|
|
72
|
+
contentStyle={props.contentStyle}
|
|
73
|
+
/>
|
|
73
74
|
);
|
|
75
|
+
});
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
function ItemRender(props) {
|
|
78
|
+
export function ItemRender(props) {
|
|
77
79
|
const [ type, setType ] = React.useState(undefined);
|
|
78
80
|
const [ open, setOpen ] = React.useState(false);
|
|
79
81
|
const [ previewUrl, setPreviewUrl ] = React.useState('');
|
|
@@ -224,7 +226,7 @@ function ItemRender(props) {
|
|
|
224
226
|
);
|
|
225
227
|
}
|
|
226
228
|
|
|
227
|
-
function generateValue(data, prefix = []) {
|
|
229
|
+
export function generateValue(data, prefix = []) {
|
|
228
230
|
const result = [];
|
|
229
231
|
|
|
230
232
|
data.forEach(item => {
|
|
@@ -244,7 +246,7 @@ function generateValue(data, prefix = []) {
|
|
|
244
246
|
return result;
|
|
245
247
|
}
|
|
246
248
|
|
|
247
|
-
function RenderText(props) {
|
|
249
|
+
export function RenderText(props) {
|
|
248
250
|
const { value } = props;
|
|
249
251
|
const [ text, setText ] = React.useState();
|
|
250
252
|
const [ loading, setLoading ] = React.useState(false);
|