@cqsjjb/jjb-react-admin-component 3.0.26 → 3.0.28
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.
|
@@ -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
|
+
}
|
|
@@ -56,6 +56,10 @@ interface FormilyDescriptionsProps extends ComponentProps {
|
|
|
56
56
|
* @see https://ant.design/components/descriptions-cn#descriptions
|
|
57
57
|
*/
|
|
58
58
|
contentStyle?: React.CSSProperties;
|
|
59
|
+
/**
|
|
60
|
+
* @description 是否外部预览?
|
|
61
|
+
*/
|
|
62
|
+
extraFileLink: boolean;
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
interface FormilyDescriptionsFc extends React.FC<FormilyDescriptionsProps> {
|
|
@@ -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('');
|
|
@@ -64,7 +69,8 @@ function ItemRender(props) {
|
|
|
64
69
|
data,
|
|
65
70
|
imageWidth,
|
|
66
71
|
imageHeight,
|
|
67
|
-
imagePreview
|
|
72
|
+
imagePreview,
|
|
73
|
+
extraFileLink
|
|
68
74
|
} = props;
|
|
69
75
|
return /*#__PURE__*/React.createElement(React.Fragment, null, tools.isArray(data.value) ? tools.isStringArray(data.value) || tools.isNumberArray(data.value) ? data.value.join('、') : tools.isObjectArray(data.value) ? data.formType === 'Table' ? /*#__PURE__*/React.createElement("div", {
|
|
70
76
|
style: {
|
|
@@ -88,7 +94,12 @@ function ItemRender(props) {
|
|
|
88
94
|
src: next.url,
|
|
89
95
|
width: imageWidth || 64,
|
|
90
96
|
height: imageHeight || 64,
|
|
91
|
-
preview:
|
|
97
|
+
preview: extraFileLink ? {
|
|
98
|
+
visible: false,
|
|
99
|
+
onVisibleChange: e => {
|
|
100
|
+
window.open(next.url);
|
|
101
|
+
}
|
|
102
|
+
} : imagePreview
|
|
92
103
|
}));
|
|
93
104
|
} else {
|
|
94
105
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
@@ -101,9 +112,13 @@ function ItemRender(props) {
|
|
|
101
112
|
alignItems: 'center'
|
|
102
113
|
},
|
|
103
114
|
onClick: () => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
if (extraFileLink) {
|
|
116
|
+
window.open(next.url);
|
|
117
|
+
} else {
|
|
118
|
+
setType('pdf');
|
|
119
|
+
setOpen(true);
|
|
120
|
+
setPreviewUrl(next.url);
|
|
121
|
+
}
|
|
107
122
|
}
|
|
108
123
|
}, /*#__PURE__*/React.createElement(FilePdfOutlined, null), "\u70B9\u51FB\u67E5\u770B") : /\.(mp4|ogg|mkv|webm)$/.test(next.url) ? /*#__PURE__*/React.createElement("a", {
|
|
109
124
|
key: nextIndex,
|
|
@@ -113,9 +128,13 @@ function ItemRender(props) {
|
|
|
113
128
|
alignItems: 'center'
|
|
114
129
|
},
|
|
115
130
|
onClick: () => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
131
|
+
if (props.extraFileLink) {
|
|
132
|
+
window.open(next.url);
|
|
133
|
+
} else {
|
|
134
|
+
setType('video');
|
|
135
|
+
setOpen(true);
|
|
136
|
+
setPreviewUrl(next.url);
|
|
137
|
+
}
|
|
119
138
|
}
|
|
120
139
|
}, /*#__PURE__*/React.createElement(PlayCircleOutlined, null), "\u70B9\u51FB\u67E5\u770B") : /*#__PURE__*/React.createElement("a", {
|
|
121
140
|
key: nextIndex,
|
|
@@ -153,7 +172,7 @@ function ItemRender(props) {
|
|
|
153
172
|
height: "350"
|
|
154
173
|
})));
|
|
155
174
|
}
|
|
156
|
-
function generateValue(data, prefix = []) {
|
|
175
|
+
export function generateValue(data, prefix = []) {
|
|
157
176
|
const result = [];
|
|
158
177
|
data.forEach(item => {
|
|
159
178
|
// 当前节点的完整 name
|
|
@@ -169,7 +188,7 @@ function generateValue(data, prefix = []) {
|
|
|
169
188
|
});
|
|
170
189
|
return result;
|
|
171
190
|
}
|
|
172
|
-
function RenderText(props) {
|
|
191
|
+
export function RenderText(props) {
|
|
173
192
|
const {
|
|
174
193
|
value
|
|
175
194
|
} = 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('');
|
|
@@ -82,7 +84,8 @@ function ItemRender(props) {
|
|
|
82
84
|
data,
|
|
83
85
|
imageWidth,
|
|
84
86
|
imageHeight,
|
|
85
|
-
imagePreview
|
|
87
|
+
imagePreview,
|
|
88
|
+
extraFileLink
|
|
86
89
|
} = props;
|
|
87
90
|
|
|
88
91
|
return (
|
|
@@ -119,7 +122,12 @@ function ItemRender(props) {
|
|
|
119
122
|
src={next.url}
|
|
120
123
|
width={imageWidth || 64}
|
|
121
124
|
height={imageHeight || 64}
|
|
122
|
-
preview={
|
|
125
|
+
preview={extraFileLink ? {
|
|
126
|
+
visible: false,
|
|
127
|
+
onVisibleChange: e => {
|
|
128
|
+
window.open(next.url);
|
|
129
|
+
}
|
|
130
|
+
} : imagePreview}
|
|
123
131
|
/>
|
|
124
132
|
</span>
|
|
125
133
|
);
|
|
@@ -136,9 +144,13 @@ function ItemRender(props) {
|
|
|
136
144
|
alignItems: 'center'
|
|
137
145
|
}}
|
|
138
146
|
onClick={() => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
if (extraFileLink) {
|
|
148
|
+
window.open(next.url);
|
|
149
|
+
} else {
|
|
150
|
+
setType('pdf');
|
|
151
|
+
setOpen(true);
|
|
152
|
+
setPreviewUrl(next.url);
|
|
153
|
+
}
|
|
142
154
|
}}
|
|
143
155
|
>
|
|
144
156
|
<FilePdfOutlined />
|
|
@@ -155,9 +167,13 @@ function ItemRender(props) {
|
|
|
155
167
|
alignItems: 'center'
|
|
156
168
|
}}
|
|
157
169
|
onClick={() => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
170
|
+
if (props.extraFileLink) {
|
|
171
|
+
window.open(next.url);
|
|
172
|
+
} else {
|
|
173
|
+
setType('video');
|
|
174
|
+
setOpen(true);
|
|
175
|
+
setPreviewUrl(next.url);
|
|
176
|
+
}
|
|
161
177
|
}}
|
|
162
178
|
>
|
|
163
179
|
<PlayCircleOutlined />
|
|
@@ -224,7 +240,7 @@ function ItemRender(props) {
|
|
|
224
240
|
);
|
|
225
241
|
}
|
|
226
242
|
|
|
227
|
-
function generateValue(data, prefix = []) {
|
|
243
|
+
export function generateValue(data, prefix = []) {
|
|
228
244
|
const result = [];
|
|
229
245
|
|
|
230
246
|
data.forEach(item => {
|
|
@@ -244,7 +260,7 @@ function generateValue(data, prefix = []) {
|
|
|
244
260
|
return result;
|
|
245
261
|
}
|
|
246
262
|
|
|
247
|
-
function RenderText(props) {
|
|
263
|
+
export function RenderText(props) {
|
|
248
264
|
const { value } = props;
|
|
249
265
|
const [ text, setText ] = React.useState();
|
|
250
266
|
const [ loading, setLoading ] = React.useState(false);
|