@cqsjjb/jjb-react-admin-component 3.0.27 → 3.0.29
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/FormilyDescriptions/index.d.ts +4 -0
- package/FormilyDescriptions/index.js +205 -100
- package/FormilyDescriptions/index.mjs +246 -141
- package/package.json +1 -1
|
@@ -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> {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { tools } from '@cqsjjb/jjb-common-lib';
|
|
4
|
-
import {
|
|
5
|
-
import { Modal, Descriptions, Empty, Image, Tooltip,
|
|
4
|
+
import { FileOutlined, LinkOutlined } from '@ant-design/icons';
|
|
5
|
+
import { Modal, Descriptions, Empty, Image, Tooltip, Spin, Table, Space, TreeSelect } from 'antd';
|
|
6
6
|
const formilyItemMargin = new Map([['small', 8], ['middle', 12], ['default', 16]]);
|
|
7
|
+
const IS_PDF_REG = /\.pdf$/;
|
|
8
|
+
const IS_VIDEO_REG = /\.(mp4|ogg|mkv|webm)$/;
|
|
7
9
|
export default function FormilyDescriptions(props) {
|
|
8
10
|
const [regions, setRegions] = React.useState([]);
|
|
9
11
|
React.useEffect(() => {
|
|
@@ -26,7 +28,7 @@ export default function FormilyDescriptions(props) {
|
|
|
26
28
|
dataSource: dataSource
|
|
27
29
|
}, props));
|
|
28
30
|
}
|
|
29
|
-
|
|
31
|
+
function DescriptionsRender(props) {
|
|
30
32
|
return props.dataSource.map((item, index) => {
|
|
31
33
|
const isLast = index === props.dataSource.length - 1;
|
|
32
34
|
return /*#__PURE__*/React.createElement(Descriptions, {
|
|
@@ -38,8 +40,8 @@ export function DescriptionsRender(props) {
|
|
|
38
40
|
items: item.fromComponentEnum === 'GRID_FORM' ? item.children.map((child, childIndex) => {
|
|
39
41
|
return {
|
|
40
42
|
key: childIndex,
|
|
41
|
-
label: child.name,
|
|
42
43
|
span: child.formType === 'Table' ? props.column : 1,
|
|
44
|
+
label: child.name,
|
|
43
45
|
children: /*#__PURE__*/React.createElement(ItemRender, _extends({
|
|
44
46
|
data: child
|
|
45
47
|
}, props))
|
|
@@ -61,82 +63,60 @@ export function DescriptionsRender(props) {
|
|
|
61
63
|
});
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
|
-
|
|
65
|
-
const [type, setType] = React.useState(undefined);
|
|
66
|
+
function ItemRender(props) {
|
|
66
67
|
const [open, setOpen] = React.useState(false);
|
|
67
68
|
const [previewUrl, setPreviewUrl] = React.useState('');
|
|
68
69
|
const {
|
|
69
70
|
data,
|
|
70
71
|
imageWidth,
|
|
71
72
|
imageHeight,
|
|
72
|
-
imagePreview
|
|
73
|
+
imagePreview,
|
|
74
|
+
extraFileLink
|
|
73
75
|
} = props;
|
|
74
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, tools.isArray(data.value)
|
|
76
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, tools.isArray(data.value)
|
|
77
|
+
// 如果数据是字符串集合 或 数字集合
|
|
78
|
+
? tools.isStringArray(data.value) || tools.isNumberArray(data.value)
|
|
79
|
+
// 直接字符串拼接
|
|
80
|
+
? data.value.join('、')
|
|
81
|
+
// 如果是对象集合
|
|
82
|
+
: tools.isObjectArray(data.value)
|
|
83
|
+
// 如果数据表单类型是 数据表格
|
|
84
|
+
? data.formType === 'Table'
|
|
85
|
+
// 处理数据表格
|
|
86
|
+
? /*#__PURE__*/React.createElement("div", {
|
|
75
87
|
style: {
|
|
76
88
|
width: '100%'
|
|
77
89
|
}
|
|
78
|
-
}, /*#__PURE__*/React.createElement(
|
|
79
|
-
columns: data.
|
|
90
|
+
}, /*#__PURE__*/React.createElement(RenderTable, {
|
|
91
|
+
columns: data.tableColumns,
|
|
80
92
|
dataSource: data.value,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
display: 'inline-block',
|
|
89
|
-
marginRight: 4,
|
|
90
|
-
marginBottom: 4
|
|
91
|
-
}
|
|
92
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
93
|
-
src: next.url,
|
|
94
|
-
width: imageWidth || 64,
|
|
95
|
-
height: imageHeight || 64,
|
|
96
|
-
preview: imagePreview
|
|
97
|
-
}));
|
|
98
|
-
} else {
|
|
99
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
100
|
-
title: next.url
|
|
101
|
-
}, /\.pdf$/.test(next.url) ? /*#__PURE__*/React.createElement("a", {
|
|
102
|
-
key: nextIndex,
|
|
103
|
-
style: {
|
|
104
|
-
gap: 4,
|
|
105
|
-
display: 'flex',
|
|
106
|
-
alignItems: 'center'
|
|
107
|
-
},
|
|
108
|
-
onClick: () => {
|
|
109
|
-
setType('pdf');
|
|
110
|
-
setOpen(true);
|
|
111
|
-
setPreviewUrl(next.url);
|
|
112
|
-
}
|
|
113
|
-
}, /*#__PURE__*/React.createElement(FilePdfOutlined, null), "\u70B9\u51FB\u67E5\u770B") : /\.(mp4|ogg|mkv|webm)$/.test(next.url) ? /*#__PURE__*/React.createElement("a", {
|
|
114
|
-
key: nextIndex,
|
|
115
|
-
style: {
|
|
116
|
-
gap: 4,
|
|
117
|
-
display: 'flex',
|
|
118
|
-
alignItems: 'center'
|
|
119
|
-
},
|
|
120
|
-
onClick: () => {
|
|
121
|
-
setType('video');
|
|
122
|
-
setOpen(true);
|
|
123
|
-
setPreviewUrl(next.url);
|
|
124
|
-
}
|
|
125
|
-
}, /*#__PURE__*/React.createElement(PlayCircleOutlined, null), "\u70B9\u51FB\u67E5\u770B") : /*#__PURE__*/React.createElement("a", {
|
|
126
|
-
key: nextIndex,
|
|
127
|
-
href: next.url,
|
|
128
|
-
style: {
|
|
129
|
-
gap: 4,
|
|
130
|
-
display: 'flex',
|
|
131
|
-
alignItems: 'center'
|
|
132
|
-
},
|
|
133
|
-
target: "_blank"
|
|
134
|
-
}, /*#__PURE__*/React.createElement(LinkOutlined, null), "\u70B9\u51FB\u4E0B\u8F7D"));
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
return tools.textPlaceholder(next.name);
|
|
93
|
+
imageWidth: imageWidth,
|
|
94
|
+
imageHeight: imageHeight,
|
|
95
|
+
imagePreview: imagePreview,
|
|
96
|
+
extraFileLink: extraFileLink,
|
|
97
|
+
onPreview: url => {
|
|
98
|
+
setOpen(true);
|
|
99
|
+
setPreviewUrl(url);
|
|
138
100
|
}
|
|
139
|
-
}))
|
|
101
|
+
}))
|
|
102
|
+
|
|
103
|
+
// 否则就是文件数据
|
|
104
|
+
: /*#__PURE__*/React.createElement("div", null, data.value.map((file, index) => /*#__PURE__*/React.createElement(RenderFileItem, {
|
|
105
|
+
key: index,
|
|
106
|
+
url: file.url,
|
|
107
|
+
name: file.name,
|
|
108
|
+
isImage: file.isImage,
|
|
109
|
+
imageWidth: imageWidth,
|
|
110
|
+
imageHeight: imageHeight,
|
|
111
|
+
imagePreview: imagePreview,
|
|
112
|
+
extraFileLink: extraFileLink,
|
|
113
|
+
onPreview: () => {
|
|
114
|
+
setOpen(true);
|
|
115
|
+
setPreviewUrl(file.url);
|
|
116
|
+
}
|
|
117
|
+
}))) : tools.textPlaceholder()
|
|
118
|
+
// 处理文本数据
|
|
119
|
+
: /*#__PURE__*/React.createElement(RenderText, {
|
|
140
120
|
name: data.name,
|
|
141
121
|
value: data.value,
|
|
142
122
|
renderItemText: props.renderItemText
|
|
@@ -147,38 +127,23 @@ export function ItemRender(props) {
|
|
|
147
127
|
width: 1100,
|
|
148
128
|
footer: false,
|
|
149
129
|
onCancel: () => setOpen(false)
|
|
150
|
-
},
|
|
130
|
+
}, IS_PDF_REG.test(previewUrl) && /*#__PURE__*/React.createElement("embed", {
|
|
151
131
|
src: previewUrl,
|
|
152
132
|
width: "100%",
|
|
153
133
|
height: 600
|
|
154
|
-
}),
|
|
134
|
+
}), IS_VIDEO_REG.test(previewUrl) && /*#__PURE__*/React.createElement("video", {
|
|
155
135
|
controls: true,
|
|
156
136
|
src: previewUrl,
|
|
157
137
|
width: "100%",
|
|
158
138
|
height: "350"
|
|
159
139
|
})));
|
|
160
140
|
}
|
|
161
|
-
|
|
162
|
-
const result = [];
|
|
163
|
-
data.forEach(item => {
|
|
164
|
-
// 当前节点的完整 name
|
|
165
|
-
const currentName = prefix.concat(item.title);
|
|
166
|
-
result.push({
|
|
167
|
-
name: currentName,
|
|
168
|
-
key: item.key
|
|
169
|
-
});
|
|
170
|
-
if (item.children && item.children.length > 0) {
|
|
171
|
-
// 递归处理子节点
|
|
172
|
-
result.push(...generateValue(item.children, currentName));
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
export function RenderText(props) {
|
|
141
|
+
function RenderText(props) {
|
|
178
142
|
const {
|
|
179
143
|
value
|
|
180
144
|
} = props;
|
|
181
145
|
const [text, setText] = React.useState();
|
|
146
|
+
const [options, setOptions] = React.useState([]);
|
|
182
147
|
const [loading, setLoading] = React.useState(false);
|
|
183
148
|
React.useEffect(() => {
|
|
184
149
|
if (value) {
|
|
@@ -186,10 +151,8 @@ export function RenderText(props) {
|
|
|
186
151
|
setLoading(true);
|
|
187
152
|
value.load().then(res => res.json()).then(res => {
|
|
188
153
|
if (res.success) {
|
|
189
|
-
|
|
190
|
-
setText(value.selected
|
|
191
|
-
return data.find(i => i.key === item.key)?.name?.join('/');
|
|
192
|
-
})?.filter(i => i));
|
|
154
|
+
setOptions(res.data);
|
|
155
|
+
setText(value.selected.map(i => `${i.key}&${i.label}`));
|
|
193
156
|
}
|
|
194
157
|
setLoading(false);
|
|
195
158
|
});
|
|
@@ -198,23 +161,165 @@ export function RenderText(props) {
|
|
|
198
161
|
}
|
|
199
162
|
}
|
|
200
163
|
}, [props.value]);
|
|
201
|
-
return Array.isArray(text) ? /*#__PURE__*/React.createElement(
|
|
202
|
-
spinning: loading
|
|
203
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
164
|
+
return Array.isArray(text) ? /*#__PURE__*/React.createElement("div", {
|
|
204
165
|
style: {
|
|
205
166
|
gap: 6,
|
|
167
|
+
width: '100%',
|
|
206
168
|
display: 'flex',
|
|
207
169
|
minHeight: 22,
|
|
208
170
|
flexDirection: 'column'
|
|
209
171
|
}
|
|
210
|
-
},
|
|
172
|
+
}, /*#__PURE__*/React.createElement(Spin, {
|
|
173
|
+
spinning: loading
|
|
174
|
+
}, /*#__PURE__*/React.createElement(TreeSelect, {
|
|
175
|
+
treeCheckable: true,
|
|
176
|
+
treeDefaultExpandAll: true,
|
|
211
177
|
style: {
|
|
212
|
-
|
|
178
|
+
width: '100%'
|
|
213
179
|
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
180
|
+
value: text,
|
|
181
|
+
variant: "borderless",
|
|
182
|
+
treeData: options,
|
|
183
|
+
showSearch: false,
|
|
184
|
+
maxTagCount: 1
|
|
185
|
+
}))) : props.renderItemText ? props.renderItemText({
|
|
217
186
|
text,
|
|
218
187
|
name: props.name
|
|
219
|
-
}) : text;
|
|
188
|
+
}) : tools.textPlaceholder(text);
|
|
189
|
+
}
|
|
190
|
+
function RenderFileItem({
|
|
191
|
+
url,
|
|
192
|
+
name,
|
|
193
|
+
isImage,
|
|
194
|
+
imageWidth,
|
|
195
|
+
imageHeight,
|
|
196
|
+
imagePreview,
|
|
197
|
+
extraFileLink,
|
|
198
|
+
onPreview
|
|
199
|
+
}) {
|
|
200
|
+
if (isImage) {
|
|
201
|
+
return /*#__PURE__*/React.createElement(RenderImage, {
|
|
202
|
+
url: url,
|
|
203
|
+
imageWidth: imageWidth,
|
|
204
|
+
imageHeight: imageHeight,
|
|
205
|
+
imagePreview: imagePreview,
|
|
206
|
+
extraFileLink: extraFileLink
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
210
|
+
title: url
|
|
211
|
+
}, IS_PDF_REG.test(url) || IS_VIDEO_REG.test(url) ? /*#__PURE__*/React.createElement(RenderValidFile, {
|
|
212
|
+
url: url,
|
|
213
|
+
name: name,
|
|
214
|
+
onPreview: onPreview
|
|
215
|
+
}) : /*#__PURE__*/React.createElement(RenderInvalidFile, {
|
|
216
|
+
url: url,
|
|
217
|
+
name: name
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function RenderImage({
|
|
222
|
+
url,
|
|
223
|
+
imageWidth,
|
|
224
|
+
imageHeight,
|
|
225
|
+
imagePreview,
|
|
226
|
+
extraFileLink
|
|
227
|
+
}) {
|
|
228
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
229
|
+
style: {
|
|
230
|
+
display: 'inline-block',
|
|
231
|
+
marginRight: 4,
|
|
232
|
+
marginBottom: 4
|
|
233
|
+
}
|
|
234
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
235
|
+
src: url,
|
|
236
|
+
width: imageWidth || 64,
|
|
237
|
+
height: imageHeight || 64,
|
|
238
|
+
preview: extraFileLink ? {
|
|
239
|
+
visible: false,
|
|
240
|
+
onVisibleChange: () => {
|
|
241
|
+
window.open(url);
|
|
242
|
+
}
|
|
243
|
+
} : imagePreview
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
function RenderValidFile({
|
|
247
|
+
url,
|
|
248
|
+
name,
|
|
249
|
+
extraFileLink,
|
|
250
|
+
onPreview
|
|
251
|
+
}) {
|
|
252
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
253
|
+
style: {
|
|
254
|
+
gap: 4,
|
|
255
|
+
display: 'flex',
|
|
256
|
+
alignItems: 'center'
|
|
257
|
+
},
|
|
258
|
+
onClick: () => {
|
|
259
|
+
if (extraFileLink) {
|
|
260
|
+
window.open(url);
|
|
261
|
+
} else {
|
|
262
|
+
onPreview();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}, /*#__PURE__*/React.createElement(FileOutlined, null), name);
|
|
266
|
+
}
|
|
267
|
+
function RenderInvalidFile({
|
|
268
|
+
url,
|
|
269
|
+
name
|
|
270
|
+
}) {
|
|
271
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
272
|
+
href: url,
|
|
273
|
+
style: {
|
|
274
|
+
gap: 4,
|
|
275
|
+
display: 'flex',
|
|
276
|
+
alignItems: 'center'
|
|
277
|
+
},
|
|
278
|
+
target: "_blank"
|
|
279
|
+
}, /*#__PURE__*/React.createElement(LinkOutlined, null), name);
|
|
280
|
+
}
|
|
281
|
+
function RenderTable({
|
|
282
|
+
columns,
|
|
283
|
+
dataSource,
|
|
284
|
+
imageWidth,
|
|
285
|
+
imageHeight,
|
|
286
|
+
imagePreview,
|
|
287
|
+
extraFileLink,
|
|
288
|
+
onPreview
|
|
289
|
+
}) {
|
|
290
|
+
return /*#__PURE__*/React.createElement(Table, {
|
|
291
|
+
rowKey: (record, index) => index,
|
|
292
|
+
columns: columns.map(item => {
|
|
293
|
+
item.render = row => {
|
|
294
|
+
if (tools.isNumberArray(row) || tools.isStringArray(row)) {
|
|
295
|
+
return row?.join(',');
|
|
296
|
+
}
|
|
297
|
+
if (tools.isUploadFileListArray(row)) {
|
|
298
|
+
return /*#__PURE__*/React.createElement(Space, {
|
|
299
|
+
direction: "vertical"
|
|
300
|
+
}, tools.getDynamicUploadFileList(row).map((file, index) => {
|
|
301
|
+
return /*#__PURE__*/React.createElement(RenderFileItem, {
|
|
302
|
+
key: index,
|
|
303
|
+
url: file.url,
|
|
304
|
+
name: file.name,
|
|
305
|
+
isImage: file.isImage,
|
|
306
|
+
imageWidth: imageWidth,
|
|
307
|
+
imageHeight: imageHeight,
|
|
308
|
+
imagePreview: imagePreview,
|
|
309
|
+
extraFileLink: extraFileLink,
|
|
310
|
+
onPreview: () => {
|
|
311
|
+
onPreview(file.url);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}));
|
|
315
|
+
}
|
|
316
|
+
if (tools.isObject(row)) {
|
|
317
|
+
return '数据错误';
|
|
318
|
+
}
|
|
319
|
+
return row;
|
|
320
|
+
};
|
|
321
|
+
return item;
|
|
322
|
+
}),
|
|
323
|
+
dataSource: dataSource
|
|
324
|
+
});
|
|
220
325
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { tools } from '@cqsjjb/jjb-common-lib';
|
|
4
|
-
import {
|
|
5
|
-
import { Modal, Descriptions, Empty, Image, Tooltip,
|
|
4
|
+
import { FileOutlined, LinkOutlined } from '@ant-design/icons';
|
|
5
|
+
import { Modal, Descriptions, Empty, Image, Tooltip, Spin, Table, Space, TreeSelect } from 'antd';
|
|
6
6
|
|
|
7
7
|
const formilyItemMargin = new Map([
|
|
8
8
|
[ 'small', 8 ],
|
|
@@ -10,6 +10,9 @@ const formilyItemMargin = new Map([
|
|
|
10
10
|
[ 'default', 16 ]
|
|
11
11
|
]);
|
|
12
12
|
|
|
13
|
+
const IS_PDF_REG = /\.pdf$/;
|
|
14
|
+
const IS_VIDEO_REG = /\.(mp4|ogg|mkv|webm)$/;
|
|
15
|
+
|
|
13
16
|
export default function FormilyDescriptions(props) {
|
|
14
17
|
const [ regions, setRegions ] = React.useState([]);
|
|
15
18
|
|
|
@@ -30,7 +33,7 @@ export default function FormilyDescriptions(props) {
|
|
|
30
33
|
);
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
function DescriptionsRender(props) {
|
|
34
37
|
return props.dataSource.map((item, index) => {
|
|
35
38
|
const isLast = index === props.dataSource.length - 1;
|
|
36
39
|
|
|
@@ -47,10 +50,10 @@ export function DescriptionsRender(props) {
|
|
|
47
50
|
? item.children.map((child, childIndex) => {
|
|
48
51
|
return {
|
|
49
52
|
key: childIndex,
|
|
50
|
-
label: child.name,
|
|
51
53
|
span: child.formType === 'Table'
|
|
52
54
|
? props.column
|
|
53
55
|
: 1,
|
|
56
|
+
label: child.name,
|
|
54
57
|
children: (
|
|
55
58
|
<ItemRender data={child} {...props} />
|
|
56
59
|
)
|
|
@@ -75,8 +78,7 @@ export function DescriptionsRender(props) {
|
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
|
|
79
|
-
const [ type, setType ] = React.useState(undefined);
|
|
81
|
+
function ItemRender(props) {
|
|
80
82
|
const [ open, setOpen ] = React.useState(false);
|
|
81
83
|
const [ previewUrl, setPreviewUrl ] = React.useState('');
|
|
82
84
|
|
|
@@ -84,113 +86,62 @@ export function ItemRender(props) {
|
|
|
84
86
|
data,
|
|
85
87
|
imageWidth,
|
|
86
88
|
imageHeight,
|
|
87
|
-
imagePreview
|
|
89
|
+
imagePreview,
|
|
90
|
+
extraFileLink
|
|
88
91
|
} = props;
|
|
89
92
|
|
|
90
93
|
return (
|
|
91
94
|
<React.Fragment>
|
|
95
|
+
{/*如果数据是集合*/}
|
|
92
96
|
{tools.isArray(data.value)
|
|
97
|
+
// 如果数据是字符串集合 或 数字集合
|
|
93
98
|
? (tools.isStringArray(data.value) || tools.isNumberArray(data.value))
|
|
99
|
+
// 直接字符串拼接
|
|
94
100
|
? data.value.join('、')
|
|
101
|
+
// 如果是对象集合
|
|
95
102
|
: tools.isObjectArray(data.value)
|
|
103
|
+
// 如果数据表单类型是 数据表格
|
|
96
104
|
? data.formType === 'Table'
|
|
105
|
+
// 处理数据表格
|
|
97
106
|
? (
|
|
98
107
|
<div style={{ width: '100%' }}>
|
|
99
|
-
<
|
|
100
|
-
columns={data.
|
|
108
|
+
<RenderTable
|
|
109
|
+
columns={data.tableColumns}
|
|
101
110
|
dataSource={data.value}
|
|
102
|
-
|
|
111
|
+
imageWidth={imageWidth}
|
|
112
|
+
imageHeight={imageHeight}
|
|
113
|
+
imagePreview={imagePreview}
|
|
114
|
+
extraFileLink={extraFileLink}
|
|
115
|
+
onPreview={url => {
|
|
116
|
+
setOpen(true);
|
|
117
|
+
setPreviewUrl(url);
|
|
118
|
+
}}
|
|
103
119
|
/>
|
|
104
120
|
</div>
|
|
105
121
|
)
|
|
122
|
+
// 否则就是文件数据
|
|
106
123
|
: (
|
|
107
124
|
<div>
|
|
108
|
-
{data.value.map((
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
preview={imagePreview}
|
|
125
|
-
/>
|
|
126
|
-
</span>
|
|
127
|
-
);
|
|
128
|
-
} else {
|
|
129
|
-
return (
|
|
130
|
-
<Tooltip title={next.url}>
|
|
131
|
-
{/\.pdf$/.test(next.url)
|
|
132
|
-
? (
|
|
133
|
-
<a
|
|
134
|
-
key={nextIndex}
|
|
135
|
-
style={{
|
|
136
|
-
gap: 4,
|
|
137
|
-
display: 'flex',
|
|
138
|
-
alignItems: 'center'
|
|
139
|
-
}}
|
|
140
|
-
onClick={() => {
|
|
141
|
-
setType('pdf');
|
|
142
|
-
setOpen(true);
|
|
143
|
-
setPreviewUrl(next.url);
|
|
144
|
-
}}
|
|
145
|
-
>
|
|
146
|
-
<FilePdfOutlined />
|
|
147
|
-
点击查看
|
|
148
|
-
</a>
|
|
149
|
-
)
|
|
150
|
-
: /\.(mp4|ogg|mkv|webm)$/.test(next.url)
|
|
151
|
-
? (
|
|
152
|
-
<a
|
|
153
|
-
key={nextIndex}
|
|
154
|
-
style={{
|
|
155
|
-
gap: 4,
|
|
156
|
-
display: 'flex',
|
|
157
|
-
alignItems: 'center'
|
|
158
|
-
}}
|
|
159
|
-
onClick={() => {
|
|
160
|
-
setType('video');
|
|
161
|
-
setOpen(true);
|
|
162
|
-
setPreviewUrl(next.url);
|
|
163
|
-
}}
|
|
164
|
-
>
|
|
165
|
-
<PlayCircleOutlined />
|
|
166
|
-
点击查看
|
|
167
|
-
</a>
|
|
168
|
-
)
|
|
169
|
-
: (
|
|
170
|
-
<a
|
|
171
|
-
key={nextIndex}
|
|
172
|
-
href={next.url}
|
|
173
|
-
style={{
|
|
174
|
-
gap: 4,
|
|
175
|
-
display: 'flex',
|
|
176
|
-
alignItems: 'center'
|
|
177
|
-
}}
|
|
178
|
-
target="_blank"
|
|
179
|
-
>
|
|
180
|
-
<LinkOutlined />
|
|
181
|
-
点击下载
|
|
182
|
-
</a>
|
|
183
|
-
)}
|
|
184
|
-
</Tooltip>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
} else {
|
|
188
|
-
return tools.textPlaceholder(next.name);
|
|
189
|
-
}
|
|
190
|
-
})}
|
|
125
|
+
{data.value.map((file, index) => (
|
|
126
|
+
<RenderFileItem
|
|
127
|
+
key={index}
|
|
128
|
+
url={file.url}
|
|
129
|
+
name={file.name}
|
|
130
|
+
isImage={file.isImage}
|
|
131
|
+
imageWidth={imageWidth}
|
|
132
|
+
imageHeight={imageHeight}
|
|
133
|
+
imagePreview={imagePreview}
|
|
134
|
+
extraFileLink={extraFileLink}
|
|
135
|
+
onPreview={() => {
|
|
136
|
+
setOpen(true);
|
|
137
|
+
setPreviewUrl(file.url);
|
|
138
|
+
}}
|
|
139
|
+
/>
|
|
140
|
+
))}
|
|
191
141
|
</div>
|
|
192
142
|
)
|
|
193
143
|
: tools.textPlaceholder()
|
|
144
|
+
// 处理文本数据
|
|
194
145
|
: (
|
|
195
146
|
<RenderText
|
|
196
147
|
name={data.name}
|
|
@@ -206,14 +157,14 @@ export function ItemRender(props) {
|
|
|
206
157
|
footer={false}
|
|
207
158
|
onCancel={() => setOpen(false)}
|
|
208
159
|
>
|
|
209
|
-
{
|
|
160
|
+
{IS_PDF_REG.test(previewUrl) && (
|
|
210
161
|
<embed
|
|
211
162
|
src={previewUrl}
|
|
212
163
|
width="100%"
|
|
213
164
|
height={600}
|
|
214
165
|
/>
|
|
215
166
|
)}
|
|
216
|
-
{
|
|
167
|
+
{IS_VIDEO_REG.test(previewUrl) && (
|
|
217
168
|
<video
|
|
218
169
|
controls
|
|
219
170
|
src={previewUrl}
|
|
@@ -226,29 +177,10 @@ export function ItemRender(props) {
|
|
|
226
177
|
);
|
|
227
178
|
}
|
|
228
179
|
|
|
229
|
-
|
|
230
|
-
const result = [];
|
|
231
|
-
|
|
232
|
-
data.forEach(item => {
|
|
233
|
-
// 当前节点的完整 name
|
|
234
|
-
const currentName = prefix.concat(item.title);
|
|
235
|
-
result.push({
|
|
236
|
-
name: currentName,
|
|
237
|
-
key: item.key
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
if (item.children && item.children.length > 0) {
|
|
241
|
-
// 递归处理子节点
|
|
242
|
-
result.push(...generateValue(item.children, currentName));
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
return result;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export function RenderText(props) {
|
|
180
|
+
function RenderText(props) {
|
|
250
181
|
const { value } = props;
|
|
251
182
|
const [ text, setText ] = React.useState();
|
|
183
|
+
const [ options, setOptions ] = React.useState([]);
|
|
252
184
|
const [ loading, setLoading ] = React.useState(false);
|
|
253
185
|
|
|
254
186
|
React.useEffect(() => {
|
|
@@ -257,10 +189,8 @@ export function RenderText(props) {
|
|
|
257
189
|
setLoading(true);
|
|
258
190
|
value.load().then(res => res.json()).then(res => {
|
|
259
191
|
if (res.success) {
|
|
260
|
-
|
|
261
|
-
setText(value.selected
|
|
262
|
-
return data.find(i => i.key === item.key)?.name?.join('/');
|
|
263
|
-
})?.filter(i => i));
|
|
192
|
+
setOptions(res.data);
|
|
193
|
+
setText(value.selected.map(i => `${i.key}&${i.label}`));
|
|
264
194
|
}
|
|
265
195
|
setLoading(false);
|
|
266
196
|
});
|
|
@@ -272,31 +202,206 @@ export function RenderText(props) {
|
|
|
272
202
|
|
|
273
203
|
return Array.isArray(text)
|
|
274
204
|
? (
|
|
275
|
-
<
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
205
|
+
<div
|
|
206
|
+
style={{
|
|
207
|
+
gap: 6,
|
|
208
|
+
width: '100%',
|
|
209
|
+
display: 'flex',
|
|
210
|
+
minHeight: 22,
|
|
211
|
+
flexDirection: 'column'
|
|
212
|
+
}}
|
|
213
|
+
>
|
|
214
|
+
<Spin spinning={loading}>
|
|
215
|
+
<TreeSelect
|
|
216
|
+
treeCheckable
|
|
217
|
+
treeDefaultExpandAll
|
|
218
|
+
style={{ width: '100%' }}
|
|
219
|
+
value={text}
|
|
220
|
+
variant="borderless"
|
|
221
|
+
treeData={options}
|
|
222
|
+
showSearch={false}
|
|
223
|
+
maxTagCount={1}
|
|
224
|
+
/>
|
|
225
|
+
</Spin>
|
|
226
|
+
</div>
|
|
295
227
|
)
|
|
296
228
|
: props.renderItemText
|
|
297
229
|
? props.renderItemText({
|
|
298
230
|
text,
|
|
299
231
|
name: props.name
|
|
300
232
|
})
|
|
301
|
-
: text;
|
|
233
|
+
: tools.textPlaceholder(text);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function RenderFileItem({
|
|
237
|
+
url,
|
|
238
|
+
name,
|
|
239
|
+
isImage,
|
|
240
|
+
imageWidth,
|
|
241
|
+
imageHeight,
|
|
242
|
+
imagePreview,
|
|
243
|
+
extraFileLink,
|
|
244
|
+
onPreview
|
|
245
|
+
}) {
|
|
246
|
+
if (isImage) {
|
|
247
|
+
return (
|
|
248
|
+
<RenderImage
|
|
249
|
+
url={url}
|
|
250
|
+
imageWidth={imageWidth}
|
|
251
|
+
imageHeight={imageHeight}
|
|
252
|
+
imagePreview={imagePreview}
|
|
253
|
+
extraFileLink={extraFileLink}
|
|
254
|
+
/>
|
|
255
|
+
);
|
|
256
|
+
} else {
|
|
257
|
+
return (
|
|
258
|
+
<Tooltip title={url}>
|
|
259
|
+
{IS_PDF_REG.test(url) || IS_VIDEO_REG.test(url)
|
|
260
|
+
? (
|
|
261
|
+
<RenderValidFile
|
|
262
|
+
url={url}
|
|
263
|
+
name={name}
|
|
264
|
+
onPreview={onPreview}
|
|
265
|
+
/>
|
|
266
|
+
)
|
|
267
|
+
: (
|
|
268
|
+
<RenderInvalidFile
|
|
269
|
+
url={url}
|
|
270
|
+
name={name}
|
|
271
|
+
/>
|
|
272
|
+
)}
|
|
273
|
+
</Tooltip>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function RenderImage({
|
|
279
|
+
url,
|
|
280
|
+
imageWidth,
|
|
281
|
+
imageHeight,
|
|
282
|
+
imagePreview,
|
|
283
|
+
extraFileLink
|
|
284
|
+
}) {
|
|
285
|
+
return (
|
|
286
|
+
<span
|
|
287
|
+
style={{
|
|
288
|
+
display: 'inline-block',
|
|
289
|
+
marginRight: 4,
|
|
290
|
+
marginBottom: 4
|
|
291
|
+
}}
|
|
292
|
+
>
|
|
293
|
+
<Image
|
|
294
|
+
src={url}
|
|
295
|
+
width={imageWidth || 64}
|
|
296
|
+
height={imageHeight || 64}
|
|
297
|
+
preview={extraFileLink
|
|
298
|
+
? {
|
|
299
|
+
visible: false,
|
|
300
|
+
onVisibleChange: () => {
|
|
301
|
+
window.open(url);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
: imagePreview}
|
|
305
|
+
/>
|
|
306
|
+
</span>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function RenderValidFile({
|
|
311
|
+
url,
|
|
312
|
+
name,
|
|
313
|
+
extraFileLink,
|
|
314
|
+
onPreview
|
|
315
|
+
}) {
|
|
316
|
+
return (
|
|
317
|
+
<a
|
|
318
|
+
style={{
|
|
319
|
+
gap: 4,
|
|
320
|
+
display: 'flex',
|
|
321
|
+
alignItems: 'center'
|
|
322
|
+
}}
|
|
323
|
+
onClick={() => {
|
|
324
|
+
if (extraFileLink) {
|
|
325
|
+
window.open(url);
|
|
326
|
+
} else {
|
|
327
|
+
onPreview();
|
|
328
|
+
}
|
|
329
|
+
}}
|
|
330
|
+
>
|
|
331
|
+
<FileOutlined />
|
|
332
|
+
{name}
|
|
333
|
+
</a>
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function RenderInvalidFile({
|
|
338
|
+
url,
|
|
339
|
+
name
|
|
340
|
+
}) {
|
|
341
|
+
return (
|
|
342
|
+
<a
|
|
343
|
+
href={url}
|
|
344
|
+
style={{
|
|
345
|
+
gap: 4,
|
|
346
|
+
display: 'flex',
|
|
347
|
+
alignItems: 'center'
|
|
348
|
+
}}
|
|
349
|
+
target="_blank"
|
|
350
|
+
>
|
|
351
|
+
<LinkOutlined />
|
|
352
|
+
{name}
|
|
353
|
+
</a>
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function RenderTable({
|
|
358
|
+
columns,
|
|
359
|
+
dataSource,
|
|
360
|
+
imageWidth,
|
|
361
|
+
imageHeight,
|
|
362
|
+
imagePreview,
|
|
363
|
+
extraFileLink,
|
|
364
|
+
onPreview
|
|
365
|
+
}) {
|
|
366
|
+
return (
|
|
367
|
+
<Table
|
|
368
|
+
rowKey={(record, index) => index}
|
|
369
|
+
columns={columns.map(item => {
|
|
370
|
+
item.render = row => {
|
|
371
|
+
if (tools.isNumberArray(row) || tools.isStringArray(row)) {
|
|
372
|
+
return row?.join(',');
|
|
373
|
+
}
|
|
374
|
+
if (tools.isUploadFileListArray(row)) {
|
|
375
|
+
return (
|
|
376
|
+
<Space direction="vertical">
|
|
377
|
+
{tools.getDynamicUploadFileList(row).map((file, index) => {
|
|
378
|
+
return (
|
|
379
|
+
<RenderFileItem
|
|
380
|
+
key={index}
|
|
381
|
+
url={file.url}
|
|
382
|
+
name={file.name}
|
|
383
|
+
isImage={file.isImage}
|
|
384
|
+
imageWidth={imageWidth}
|
|
385
|
+
imageHeight={imageHeight}
|
|
386
|
+
imagePreview={imagePreview}
|
|
387
|
+
extraFileLink={extraFileLink}
|
|
388
|
+
onPreview={() => {
|
|
389
|
+
onPreview(file.url);
|
|
390
|
+
}}
|
|
391
|
+
/>
|
|
392
|
+
);
|
|
393
|
+
})}
|
|
394
|
+
</Space>
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
if (tools.isObject(row)) {
|
|
398
|
+
return '数据错误';
|
|
399
|
+
}
|
|
400
|
+
return row;
|
|
401
|
+
};
|
|
402
|
+
return item;
|
|
403
|
+
})}
|
|
404
|
+
dataSource={dataSource}
|
|
405
|
+
/>
|
|
406
|
+
);
|
|
302
407
|
}
|