@cqsjjb/jjb-react-admin-component 3.0.28 → 3.0.30
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 +1 -1
- package/FormilyDescriptions/index.js +203 -112
- package/FormilyDescriptions/index.mjs +244 -153
- package/package.json +1 -1
|
@@ -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,8 +63,7 @@ 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 {
|
|
@@ -72,85 +73,50 @@ export function ItemRender(props) {
|
|
|
72
73
|
imagePreview,
|
|
73
74
|
extraFileLink
|
|
74
75
|
} = props;
|
|
75
|
-
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", {
|
|
76
87
|
style: {
|
|
77
88
|
width: '100%'
|
|
78
89
|
}
|
|
79
|
-
}, /*#__PURE__*/React.createElement(
|
|
80
|
-
columns: data.
|
|
90
|
+
}, /*#__PURE__*/React.createElement(RenderTable, {
|
|
91
|
+
columns: data.tableColumns,
|
|
81
92
|
dataSource: data.value,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
display: 'inline-block',
|
|
90
|
-
marginRight: 4,
|
|
91
|
-
marginBottom: 4
|
|
92
|
-
}
|
|
93
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
94
|
-
src: next.url,
|
|
95
|
-
width: imageWidth || 64,
|
|
96
|
-
height: imageHeight || 64,
|
|
97
|
-
preview: extraFileLink ? {
|
|
98
|
-
visible: false,
|
|
99
|
-
onVisibleChange: e => {
|
|
100
|
-
window.open(next.url);
|
|
101
|
-
}
|
|
102
|
-
} : imagePreview
|
|
103
|
-
}));
|
|
104
|
-
} else {
|
|
105
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
106
|
-
title: next.url
|
|
107
|
-
}, /\.pdf$/.test(next.url) ? /*#__PURE__*/React.createElement("a", {
|
|
108
|
-
key: nextIndex,
|
|
109
|
-
style: {
|
|
110
|
-
gap: 4,
|
|
111
|
-
display: 'flex',
|
|
112
|
-
alignItems: 'center'
|
|
113
|
-
},
|
|
114
|
-
onClick: () => {
|
|
115
|
-
if (extraFileLink) {
|
|
116
|
-
window.open(next.url);
|
|
117
|
-
} else {
|
|
118
|
-
setType('pdf');
|
|
119
|
-
setOpen(true);
|
|
120
|
-
setPreviewUrl(next.url);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}, /*#__PURE__*/React.createElement(FilePdfOutlined, null), "\u70B9\u51FB\u67E5\u770B") : /\.(mp4|ogg|mkv|webm)$/.test(next.url) ? /*#__PURE__*/React.createElement("a", {
|
|
124
|
-
key: nextIndex,
|
|
125
|
-
style: {
|
|
126
|
-
gap: 4,
|
|
127
|
-
display: 'flex',
|
|
128
|
-
alignItems: 'center'
|
|
129
|
-
},
|
|
130
|
-
onClick: () => {
|
|
131
|
-
if (props.extraFileLink) {
|
|
132
|
-
window.open(next.url);
|
|
133
|
-
} else {
|
|
134
|
-
setType('video');
|
|
135
|
-
setOpen(true);
|
|
136
|
-
setPreviewUrl(next.url);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}, /*#__PURE__*/React.createElement(PlayCircleOutlined, null), "\u70B9\u51FB\u67E5\u770B") : /*#__PURE__*/React.createElement("a", {
|
|
140
|
-
key: nextIndex,
|
|
141
|
-
href: next.url,
|
|
142
|
-
style: {
|
|
143
|
-
gap: 4,
|
|
144
|
-
display: 'flex',
|
|
145
|
-
alignItems: 'center'
|
|
146
|
-
},
|
|
147
|
-
target: "_blank"
|
|
148
|
-
}, /*#__PURE__*/React.createElement(LinkOutlined, null), "\u70B9\u51FB\u4E0B\u8F7D"));
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
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);
|
|
152
100
|
}
|
|
153
|
-
}))
|
|
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, {
|
|
154
120
|
name: data.name,
|
|
155
121
|
value: data.value,
|
|
156
122
|
renderItemText: props.renderItemText
|
|
@@ -161,38 +127,23 @@ export function ItemRender(props) {
|
|
|
161
127
|
width: 1100,
|
|
162
128
|
footer: false,
|
|
163
129
|
onCancel: () => setOpen(false)
|
|
164
|
-
},
|
|
130
|
+
}, IS_PDF_REG.test(previewUrl) && /*#__PURE__*/React.createElement("embed", {
|
|
165
131
|
src: previewUrl,
|
|
166
132
|
width: "100%",
|
|
167
133
|
height: 600
|
|
168
|
-
}),
|
|
134
|
+
}), IS_VIDEO_REG.test(previewUrl) && /*#__PURE__*/React.createElement("video", {
|
|
169
135
|
controls: true,
|
|
170
136
|
src: previewUrl,
|
|
171
137
|
width: "100%",
|
|
172
138
|
height: "350"
|
|
173
139
|
})));
|
|
174
140
|
}
|
|
175
|
-
|
|
176
|
-
const result = [];
|
|
177
|
-
data.forEach(item => {
|
|
178
|
-
// 当前节点的完整 name
|
|
179
|
-
const currentName = prefix.concat(item.title);
|
|
180
|
-
result.push({
|
|
181
|
-
name: currentName,
|
|
182
|
-
key: item.key
|
|
183
|
-
});
|
|
184
|
-
if (item.children && item.children.length > 0) {
|
|
185
|
-
// 递归处理子节点
|
|
186
|
-
result.push(...generateValue(item.children, currentName));
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
return result;
|
|
190
|
-
}
|
|
191
|
-
export function RenderText(props) {
|
|
141
|
+
function RenderText(props) {
|
|
192
142
|
const {
|
|
193
143
|
value
|
|
194
144
|
} = props;
|
|
195
145
|
const [text, setText] = React.useState();
|
|
146
|
+
const [options, setOptions] = React.useState([]);
|
|
196
147
|
const [loading, setLoading] = React.useState(false);
|
|
197
148
|
React.useEffect(() => {
|
|
198
149
|
if (value) {
|
|
@@ -200,10 +151,8 @@ export function RenderText(props) {
|
|
|
200
151
|
setLoading(true);
|
|
201
152
|
value.load().then(res => res.json()).then(res => {
|
|
202
153
|
if (res.success) {
|
|
203
|
-
|
|
204
|
-
setText(value
|
|
205
|
-
return data.find(i => i.key === item.key)?.name?.join('/');
|
|
206
|
-
})?.filter(i => i));
|
|
154
|
+
setOptions(res.data);
|
|
155
|
+
setText(value?.selected?.map?.(i => `${i.key}&${i.label}`));
|
|
207
156
|
}
|
|
208
157
|
setLoading(false);
|
|
209
158
|
});
|
|
@@ -212,23 +161,165 @@ export function RenderText(props) {
|
|
|
212
161
|
}
|
|
213
162
|
}
|
|
214
163
|
}, [props.value]);
|
|
215
|
-
return Array.isArray(text) ? /*#__PURE__*/React.createElement(
|
|
216
|
-
spinning: loading
|
|
217
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
164
|
+
return Array.isArray(text) ? /*#__PURE__*/React.createElement("div", {
|
|
218
165
|
style: {
|
|
219
166
|
gap: 6,
|
|
167
|
+
width: '100%',
|
|
220
168
|
display: 'flex',
|
|
221
169
|
minHeight: 22,
|
|
222
170
|
flexDirection: 'column'
|
|
223
171
|
}
|
|
224
|
-
},
|
|
172
|
+
}, /*#__PURE__*/React.createElement(Spin, {
|
|
173
|
+
spinning: loading
|
|
174
|
+
}, /*#__PURE__*/React.createElement(TreeSelect, {
|
|
175
|
+
treeCheckable: true,
|
|
176
|
+
treeDefaultExpandAll: true,
|
|
225
177
|
style: {
|
|
226
|
-
|
|
178
|
+
width: '100%'
|
|
227
179
|
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
180
|
+
value: text,
|
|
181
|
+
variant: "borderless",
|
|
182
|
+
treeData: options,
|
|
183
|
+
showSearch: false,
|
|
184
|
+
maxTagCount: 1
|
|
185
|
+
}))) : props.renderItemText ? props.renderItemText({
|
|
231
186
|
text,
|
|
232
187
|
name: props.name
|
|
233
|
-
}) : 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
|
+
});
|
|
234
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
|
|
|
@@ -90,121 +92,56 @@ export function ItemRender(props) {
|
|
|
90
92
|
|
|
91
93
|
return (
|
|
92
94
|
<React.Fragment>
|
|
95
|
+
{/*如果数据是集合*/}
|
|
93
96
|
{tools.isArray(data.value)
|
|
97
|
+
// 如果数据是字符串集合 或 数字集合
|
|
94
98
|
? (tools.isStringArray(data.value) || tools.isNumberArray(data.value))
|
|
99
|
+
// 直接字符串拼接
|
|
95
100
|
? data.value.join('、')
|
|
101
|
+
// 如果是对象集合
|
|
96
102
|
: tools.isObjectArray(data.value)
|
|
103
|
+
// 如果数据表单类型是 数据表格
|
|
97
104
|
? data.formType === 'Table'
|
|
105
|
+
// 处理数据表格
|
|
98
106
|
? (
|
|
99
107
|
<div style={{ width: '100%' }}>
|
|
100
|
-
<
|
|
101
|
-
columns={data.
|
|
108
|
+
<RenderTable
|
|
109
|
+
columns={data.tableColumns}
|
|
102
110
|
dataSource={data.value}
|
|
103
|
-
|
|
111
|
+
imageWidth={imageWidth}
|
|
112
|
+
imageHeight={imageHeight}
|
|
113
|
+
imagePreview={imagePreview}
|
|
114
|
+
extraFileLink={extraFileLink}
|
|
115
|
+
onPreview={url => {
|
|
116
|
+
setOpen(true);
|
|
117
|
+
setPreviewUrl(url);
|
|
118
|
+
}}
|
|
104
119
|
/>
|
|
105
120
|
</div>
|
|
106
121
|
)
|
|
122
|
+
// 否则就是文件数据
|
|
107
123
|
: (
|
|
108
124
|
<div>
|
|
109
|
-
{data.value.map((
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
preview={extraFileLink ? {
|
|
126
|
-
visible: false,
|
|
127
|
-
onVisibleChange: e => {
|
|
128
|
-
window.open(next.url);
|
|
129
|
-
}
|
|
130
|
-
} : imagePreview}
|
|
131
|
-
/>
|
|
132
|
-
</span>
|
|
133
|
-
);
|
|
134
|
-
} else {
|
|
135
|
-
return (
|
|
136
|
-
<Tooltip title={next.url}>
|
|
137
|
-
{/\.pdf$/.test(next.url)
|
|
138
|
-
? (
|
|
139
|
-
<a
|
|
140
|
-
key={nextIndex}
|
|
141
|
-
style={{
|
|
142
|
-
gap: 4,
|
|
143
|
-
display: 'flex',
|
|
144
|
-
alignItems: 'center'
|
|
145
|
-
}}
|
|
146
|
-
onClick={() => {
|
|
147
|
-
if (extraFileLink) {
|
|
148
|
-
window.open(next.url);
|
|
149
|
-
} else {
|
|
150
|
-
setType('pdf');
|
|
151
|
-
setOpen(true);
|
|
152
|
-
setPreviewUrl(next.url);
|
|
153
|
-
}
|
|
154
|
-
}}
|
|
155
|
-
>
|
|
156
|
-
<FilePdfOutlined />
|
|
157
|
-
点击查看
|
|
158
|
-
</a>
|
|
159
|
-
)
|
|
160
|
-
: /\.(mp4|ogg|mkv|webm)$/.test(next.url)
|
|
161
|
-
? (
|
|
162
|
-
<a
|
|
163
|
-
key={nextIndex}
|
|
164
|
-
style={{
|
|
165
|
-
gap: 4,
|
|
166
|
-
display: 'flex',
|
|
167
|
-
alignItems: 'center'
|
|
168
|
-
}}
|
|
169
|
-
onClick={() => {
|
|
170
|
-
if (props.extraFileLink) {
|
|
171
|
-
window.open(next.url);
|
|
172
|
-
} else {
|
|
173
|
-
setType('video');
|
|
174
|
-
setOpen(true);
|
|
175
|
-
setPreviewUrl(next.url);
|
|
176
|
-
}
|
|
177
|
-
}}
|
|
178
|
-
>
|
|
179
|
-
<PlayCircleOutlined />
|
|
180
|
-
点击查看
|
|
181
|
-
</a>
|
|
182
|
-
)
|
|
183
|
-
: (
|
|
184
|
-
<a
|
|
185
|
-
key={nextIndex}
|
|
186
|
-
href={next.url}
|
|
187
|
-
style={{
|
|
188
|
-
gap: 4,
|
|
189
|
-
display: 'flex',
|
|
190
|
-
alignItems: 'center'
|
|
191
|
-
}}
|
|
192
|
-
target="_blank"
|
|
193
|
-
>
|
|
194
|
-
<LinkOutlined />
|
|
195
|
-
点击下载
|
|
196
|
-
</a>
|
|
197
|
-
)}
|
|
198
|
-
</Tooltip>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
} else {
|
|
202
|
-
return tools.textPlaceholder(next.name);
|
|
203
|
-
}
|
|
204
|
-
})}
|
|
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
|
+
))}
|
|
205
141
|
</div>
|
|
206
142
|
)
|
|
207
143
|
: tools.textPlaceholder()
|
|
144
|
+
// 处理文本数据
|
|
208
145
|
: (
|
|
209
146
|
<RenderText
|
|
210
147
|
name={data.name}
|
|
@@ -220,14 +157,14 @@ export function ItemRender(props) {
|
|
|
220
157
|
footer={false}
|
|
221
158
|
onCancel={() => setOpen(false)}
|
|
222
159
|
>
|
|
223
|
-
{
|
|
160
|
+
{IS_PDF_REG.test(previewUrl) && (
|
|
224
161
|
<embed
|
|
225
162
|
src={previewUrl}
|
|
226
163
|
width="100%"
|
|
227
164
|
height={600}
|
|
228
165
|
/>
|
|
229
166
|
)}
|
|
230
|
-
{
|
|
167
|
+
{IS_VIDEO_REG.test(previewUrl) && (
|
|
231
168
|
<video
|
|
232
169
|
controls
|
|
233
170
|
src={previewUrl}
|
|
@@ -240,29 +177,10 @@ export function ItemRender(props) {
|
|
|
240
177
|
);
|
|
241
178
|
}
|
|
242
179
|
|
|
243
|
-
|
|
244
|
-
const result = [];
|
|
245
|
-
|
|
246
|
-
data.forEach(item => {
|
|
247
|
-
// 当前节点的完整 name
|
|
248
|
-
const currentName = prefix.concat(item.title);
|
|
249
|
-
result.push({
|
|
250
|
-
name: currentName,
|
|
251
|
-
key: item.key
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
if (item.children && item.children.length > 0) {
|
|
255
|
-
// 递归处理子节点
|
|
256
|
-
result.push(...generateValue(item.children, currentName));
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
return result;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export function RenderText(props) {
|
|
180
|
+
function RenderText(props) {
|
|
264
181
|
const { value } = props;
|
|
265
182
|
const [ text, setText ] = React.useState();
|
|
183
|
+
const [ options, setOptions ] = React.useState([]);
|
|
266
184
|
const [ loading, setLoading ] = React.useState(false);
|
|
267
185
|
|
|
268
186
|
React.useEffect(() => {
|
|
@@ -271,10 +189,8 @@ export function RenderText(props) {
|
|
|
271
189
|
setLoading(true);
|
|
272
190
|
value.load().then(res => res.json()).then(res => {
|
|
273
191
|
if (res.success) {
|
|
274
|
-
|
|
275
|
-
setText(value
|
|
276
|
-
return data.find(i => i.key === item.key)?.name?.join('/');
|
|
277
|
-
})?.filter(i => i));
|
|
192
|
+
setOptions(res.data);
|
|
193
|
+
setText(value?.selected?.map?.(i => `${i.key}&${i.label}`));
|
|
278
194
|
}
|
|
279
195
|
setLoading(false);
|
|
280
196
|
});
|
|
@@ -286,31 +202,206 @@ export function RenderText(props) {
|
|
|
286
202
|
|
|
287
203
|
return Array.isArray(text)
|
|
288
204
|
? (
|
|
289
|
-
<
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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>
|
|
309
227
|
)
|
|
310
228
|
: props.renderItemText
|
|
311
229
|
? props.renderItemText({
|
|
312
230
|
text,
|
|
313
231
|
name: props.name
|
|
314
232
|
})
|
|
315
|
-
: 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
|
+
);
|
|
316
407
|
}
|