zy-react-library 1.1.0 → 1.1.2

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.
Files changed (76) hide show
  1. package/README.md +5 -1
  2. package/components/Cascader/Area/index.js +11 -11
  3. package/components/Cascader/Basic/index.js +23 -30
  4. package/components/Cascader/Dictionary/index.js +42 -42
  5. package/components/Cascader/Industry/index.js +12 -11
  6. package/components/Editor/index.js +43 -63
  7. package/components/FormBuilder/FormBuilder.js +97 -87
  8. package/components/FormBuilder/FormItemsRenderer.js +579 -581
  9. package/components/FormBuilder/index.js +5 -3
  10. package/components/HeaderBack/index.js +39 -32
  11. package/components/HiddenInfo/gwj/index.js +507 -439
  12. package/components/Icon/AddIcon/index.js +6 -6
  13. package/components/Icon/BackIcon/index.js +6 -6
  14. package/components/Icon/DeleteIcon/index.js +6 -6
  15. package/components/Icon/DownloadIcon/index.js +6 -6
  16. package/components/Icon/EditIcon/index.js +6 -6
  17. package/components/Icon/ExportIcon/index.js +6 -6
  18. package/components/Icon/ImportIcon/index.js +6 -6
  19. package/components/Icon/LocationIcon/index.js +6 -6
  20. package/components/Icon/PrintIcon/index.js +6 -6
  21. package/components/Icon/ResetIcon/index.js +6 -6
  22. package/components/Icon/SearchIcon/index.js +6 -6
  23. package/components/Icon/VideoIcon/index.js +6 -6
  24. package/components/Icon/ViewIcon/index.js +6 -6
  25. package/components/ImportFile/index.js +94 -91
  26. package/components/LeftTree/Area/index.js +15 -15
  27. package/components/LeftTree/Basic/index.js +54 -65
  28. package/components/LeftTree/Department/Gwj/index.js +29 -32
  29. package/components/LeftTree/Dictionary/index.js +42 -42
  30. package/components/Map/MapSelector.js +280 -254
  31. package/components/Map/index.js +90 -77
  32. package/components/Page/index.d.ts +2 -0
  33. package/components/Page/index.js +44 -34
  34. package/components/Pdf/index.js +92 -90
  35. package/components/PreviewImg/index.js +26 -32
  36. package/components/PreviewPdf/index.js +78 -86
  37. package/components/Search/index.js +147 -141
  38. package/components/Select/Basic/index.js +70 -76
  39. package/components/Select/Dictionary/index.js +42 -42
  40. package/components/Select/Personnel/Gwj/index.js +45 -49
  41. package/components/SelectCreate/index.js +33 -40
  42. package/components/SelectTree/Area/index.js +11 -17
  43. package/components/SelectTree/Basic/index.js +105 -102
  44. package/components/SelectTree/Department/Gwj/index.js +40 -46
  45. package/components/SelectTree/Dictionary/index.js +42 -42
  46. package/components/SelectTree/HiddenLevel/Gwj/index.js +33 -35
  47. package/components/SelectTree/HiddenPart/Gwj/index.js +16 -19
  48. package/components/SelectTree/Industry/index.js +12 -18
  49. package/components/Signature/index.js +68 -62
  50. package/components/Table/index.js +77 -73
  51. package/components/Table/index.less +7 -1
  52. package/components/TooltipPreviewImg/index.js +28 -27
  53. package/components/Upload/index.js +229 -275
  54. package/components/Video/AliPlayer.js +182 -160
  55. package/components/Video/index.js +71 -90
  56. package/css/common.less +4 -0
  57. package/enum/dictionary/index.js +5 -3
  58. package/enum/formItemRender/index.js +37 -35
  59. package/enum/hidden/gwj/index.js +65 -26
  60. package/enum/uploadFile/gwj/index.js +166 -84
  61. package/hooks/useDeleteFile/index.js +24 -30
  62. package/hooks/useDictionary/index.js +28 -30
  63. package/hooks/useDownloadBlob/index.js +78 -77
  64. package/hooks/useDownloadFile/index.js +76 -79
  65. package/hooks/useGetFile/index.js +32 -32
  66. package/hooks/useGetUrlQuery/index.js +1 -2
  67. package/hooks/useGetUserInfo/index.js +19 -26
  68. package/hooks/useIdle/index.js +9 -11
  69. package/hooks/useImportFile/index.js +30 -28
  70. package/hooks/useIsExistenceDuplicateSelection/index.js +25 -18
  71. package/hooks/useTable/index.js +49 -38
  72. package/hooks/useUploadFile/index.js +142 -147
  73. package/hooks/useUrlQueryCriteria/index.js +20 -13
  74. package/package.json +14 -1
  75. package/regular/index.js +34 -39
  76. package/utils/index.js +515 -511
@@ -1,27 +1,28 @@
1
- import { Tag, Tooltip } from "antd";
2
- import PreviewImg from "../PreviewImg";
3
-
4
- /**
5
- * 在表格组件中图片查看组件
6
- */
7
- const TooltipPreviewImg = (props) => {
8
- const { files = [], fileUrlKey = "filePath" } = props;
9
-
10
- const renderContent = () => {
11
- return (
12
- files.length > 0
13
- ? <PreviewImg files={files} fileUrlKey={fileUrlKey} />
14
- : <span>暂无图片</span>
15
- );
16
- };
17
-
18
- return (
19
- <Tooltip placement="top" title={renderContent()}>
20
- <Tag>预览</Tag>
21
- </Tooltip>
22
- );
23
- };
24
-
25
- TooltipPreviewImg.displayName = "TooltipPreviewImg";
26
-
27
- export default TooltipPreviewImg;
1
+ import { Tooltip, Tag } from 'antd';
2
+ import PreviewImg from '../PreviewImg/index.js';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ const TooltipPreviewImg = props => {
6
+ const {
7
+ files = [],
8
+ fileUrlKey = "filePath"
9
+ } = props;
10
+ const renderContent = () => {
11
+ return files.length > 0 ? /*#__PURE__*/jsx(PreviewImg, {
12
+ files: files,
13
+ fileUrlKey: fileUrlKey
14
+ }) : /*#__PURE__*/jsx("span", {
15
+ children: "\u6682\u65E0\u56FE\u7247"
16
+ });
17
+ };
18
+ return /*#__PURE__*/jsx(Tooltip, {
19
+ placement: "top",
20
+ title: renderContent(),
21
+ children: /*#__PURE__*/jsx(Tag, {
22
+ children: "\u9884\u89C8"
23
+ })
24
+ });
25
+ };
26
+ TooltipPreviewImg.displayName = "TooltipPreviewImg";
27
+
28
+ export { TooltipPreviewImg as default };
@@ -1,275 +1,229 @@
1
- import { PlusOutlined, UploadOutlined, VideoCameraAddOutlined } from "@ant-design/icons";
2
- import { Upload as AntUpload, Button, message, Modal } from "antd";
3
- import { useState } from "react";
4
-
5
- /**
6
- * 文件上传组件
7
- */
8
- const Upload = (props) => {
9
- const {
10
- value = [],
11
- onChange,
12
- onPreview,
13
- onRemove,
14
- onGetRemoveFile,
15
- beforeUpload,
16
- maxCount: externalMaxCount,
17
- listType: externalListType,
18
- accept: externalAccept,
19
- ratio = "",
20
- showTip = true,
21
- multiple = true,
22
- size: externalSize,
23
- tipContent,
24
- uploadButtonText: externalUploadButtonText,
25
- fileType: externalFileType,
26
- ...restProps
27
- } = props;
28
-
29
- const [previewVisible, setPreviewVisible] = useState(false);
30
- const [previewImage, setPreviewImage] = useState("");
31
-
32
- // 预设的文件格式
33
- const imageAccept = ".jpg,.jpeg,.png";
34
- const documentAccept = ".pdf,.doc,.docx";
35
- const videoAccept = ".mp4";
36
-
37
- // 根据accept自动判断文件类型
38
- const getAutoFileType = () => {
39
- if (externalAccept) {
40
- if (externalAccept === "*")
41
- return "document";
42
- const acceptList = externalAccept.split(",");
43
- if (acceptList.some(format => videoAccept.split(",").includes(format)))
44
- return "video";
45
- if (acceptList.some(format => documentAccept.split(",").includes(format)))
46
- return "document";
47
- if (acceptList.some(format => imageAccept.split(",").includes(format)))
48
- return "image";
49
- return "document";
50
- }
51
- return "image";
52
- };
53
- const fileType = externalFileType || getAutoFileType();
54
-
55
- // 文件类型判断
56
- const isImageType = fileType === "image";
57
- const isVideoType = fileType === "video";
58
- const isDocumentType = fileType === "document";
59
-
60
- // 获取listType
61
- const getListType = () => {
62
- if (externalListType)
63
- return externalListType;
64
- if (externalAccept === "*")
65
- return "text";
66
- if (fileType === "image")
67
- return "picture-card";
68
- return "text";
69
- };
70
- const listType = getListType();
71
-
72
- // 获取文件格式
73
- const getAccept = () => {
74
- if (externalAccept)
75
- return externalAccept === "*" ? "" : externalAccept;
76
- if (isImageType)
77
- return imageAccept;
78
- if (isVideoType)
79
- return videoAccept;
80
- if (isDocumentType)
81
- return documentAccept;
82
- return imageAccept;
83
- };
84
- const accept = getAccept();
85
-
86
- // 获取默认上传数量
87
- const getMaxCount = () => {
88
- if (externalMaxCount)
89
- return externalMaxCount;
90
- if (isVideoType)
91
- return 1;
92
- if (isImageType)
93
- return 4;
94
- if (isDocumentType)
95
- return 4;
96
- return 1;
97
- };
98
- const maxCount = getMaxCount();
99
-
100
- // 获取默认文件大小
101
- const getSize = () => {
102
- if (externalSize)
103
- return externalSize;
104
- if (isVideoType)
105
- return 100;
106
- return 0;
107
- };
108
- const size = getSize();
109
-
110
- // 上传按钮文字
111
- const uploadButtonText = externalUploadButtonText || (isVideoType ? "上传视频" : "上传附件");
112
-
113
- // 文件格式提示
114
- const acceptTip = accept.replace(/\./g, "").split(",").join("、");
115
-
116
- // 生成提示信息
117
- const getTipText = () => {
118
- if (tipContent)
119
- return tipContent;
120
-
121
- const tips = [
122
- `最多上传${maxCount}个文件`,
123
- accept
124
- ? `并且只能上传${acceptTip}格式的文件`
125
- : "可以上传任意格式的文件",
126
- size ? `文件大小不能超过${size}M` : "",
127
- ratio ? `只能上传${ratio}分辨率的图片` : "",
128
- ].filter(Boolean);
129
-
130
- return `${tips.join("")}。`;
131
- };
132
-
133
- const handleBeforeUpload = (file, fileList) => {
134
- if (beforeUpload)
135
- return beforeUpload(file, fileList);
136
- return false;
137
- };
138
-
139
- // 文件状态改变
140
- const handleChange = ({ file, fileList }) => {
141
- const acceptList = accept ? accept.split(",") : [];
142
- const ratioArr = ratio ? ratio.split("*") : [];
143
- const suffix = file.name.substring(
144
- file.name.lastIndexOf("."),
145
- file.name.length,
146
- );
147
- const maxSize = size * 1024 * 1024;
148
-
149
- // 验证文件格式
150
- if (acceptList.length > 0 && !acceptList.includes(suffix)) {
151
- message.warning(`只能上传${acceptTip}格式的文件`);
152
- return;
153
- }
154
-
155
- // 验证文件大小
156
- if (maxSize && file.size > maxSize) {
157
- message.warning(`文件大小不能超过${size}M`);
158
- return;
159
- }
160
-
161
- // 验证图片分辨率
162
- if (ratioArr.length === 2 && file.type?.startsWith("image/")) {
163
- const validateImageResolution = (imageUrl) => {
164
- const img = new Image();
165
- img.onload = () => {
166
- if (img.width !== +ratioArr[0] || img.height !== +ratioArr[1]) {
167
- message.warning(`只能上传${ratio}分辨率的图片`);
168
- const filtered = fileList.filter(item => item.uid !== file.uid);
169
- onChange?.(filtered);
170
- return;
171
- }
172
- onChange?.(fileList);
173
- };
174
- img.src = imageUrl;
175
- };
176
-
177
- // 如果有现成的URL则直接使用,否则使用FileReader读取本地文件
178
- if (file.url) {
179
- validateImageResolution(file.url);
180
- }
181
- else {
182
- const reader = new FileReader();
183
- reader.onload = (e) => {
184
- validateImageResolution(e.target.result);
185
- };
186
- reader.readAsDataURL(file);
187
- }
188
- }
189
- else {
190
- onChange?.(fileList);
191
- }
192
- };
193
-
194
- // 删除文件
195
- const handleRemove = (file) => {
196
- if (!file.originFileObj)
197
- onGetRemoveFile?.(file);
198
- return onRemove?.(file);
199
- };
200
-
201
- // 预览文件
202
- const handlePreview = (file) => {
203
- if (isImageType) {
204
- setPreviewImage(file.url || file.thumbUrl);
205
- setPreviewVisible(true);
206
- }
207
- onPreview?.(file);
208
- };
209
-
210
- // 关闭预览
211
- const handleCancel = () => {
212
- setPreviewVisible(false);
213
- };
214
-
215
- // 上传按钮
216
- const uploadButton
217
- = isImageType
218
- ? (
219
- <div>
220
- <PlusOutlined style={{ fontSize: 32 }} />
221
- </div>
222
- )
223
- : (
224
- <Button
225
- type="primary"
226
- icon={isVideoType ? <VideoCameraAddOutlined /> : <UploadOutlined />}
227
- >
228
- {uploadButtonText}
229
- </Button>
230
- );
231
-
232
- return (
233
- <>
234
- <AntUpload
235
- fileList={value}
236
- multiple={multiple}
237
- maxCount={maxCount}
238
- listType={listType}
239
- accept={accept}
240
- onChange={handleChange}
241
- onPreview={handlePreview}
242
- onRemove={handleRemove}
243
- beforeUpload={handleBeforeUpload}
244
- {...restProps}
245
- >
246
- {value.length >= maxCount ? null : uploadButton}
247
- </AntUpload>
248
- {
249
- showTip
250
- ? (getTipText()) && (
251
- <div style={{ marginTop: 10, color: "#ff4d4f" }}>
252
- {getTipText()}
253
- </div>
254
- )
255
- : null
256
- }
257
- <Modal
258
- open={previewVisible}
259
- title="查看图片"
260
- footer={null}
261
- onCancel={handleCancel}
262
- >
263
- <img
264
- alt="preview"
265
- style={{ width: "100%", objectFit: "scale-down" }}
266
- src={previewImage}
267
- />
268
- </Modal>
269
- </>
270
- );
271
- };
272
-
273
- Upload.displayName = "Upload";
274
-
275
- export default Upload;
1
+ import { PlusOutlined, VideoCameraAddOutlined, UploadOutlined } from '@ant-design/icons';
2
+ import { Upload as Upload$1, Modal, Button, message } from 'antd';
3
+ import { useState } from 'react';
4
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
5
+
6
+ const Upload = props => {
7
+ const {
8
+ value = [],
9
+ onChange,
10
+ onPreview,
11
+ onRemove,
12
+ onGetRemoveFile,
13
+ beforeUpload,
14
+ maxCount: externalMaxCount,
15
+ listType: externalListType,
16
+ accept: externalAccept,
17
+ ratio = "",
18
+ showTip = true,
19
+ multiple = true,
20
+ size: externalSize,
21
+ tipContent,
22
+ uploadButtonText: externalUploadButtonText,
23
+ fileType: externalFileType,
24
+ ...restProps
25
+ } = props;
26
+ const [previewVisible, setPreviewVisible] = useState(false);
27
+ const [previewImage, setPreviewImage] = useState("");
28
+
29
+ // 预设的文件格式
30
+ const imageAccept = ".jpg,.jpeg,.png";
31
+ const documentAccept = ".pdf,.doc,.docx";
32
+ const videoAccept = ".mp4";
33
+
34
+ // 根据accept自动判断文件类型
35
+ const getAutoFileType = () => {
36
+ if (externalAccept) {
37
+ if (externalAccept === "*") return "document";
38
+ const acceptList = externalAccept.split(",");
39
+ if (acceptList.some(format => videoAccept.split(",").includes(format))) return "video";
40
+ if (acceptList.some(format => documentAccept.split(",").includes(format))) return "document";
41
+ if (acceptList.some(format => imageAccept.split(",").includes(format))) return "image";
42
+ return "document";
43
+ }
44
+ return "image";
45
+ };
46
+ const fileType = externalFileType || getAutoFileType();
47
+
48
+ // 文件类型判断
49
+ const isImageType = fileType === "image";
50
+ const isVideoType = fileType === "video";
51
+ const isDocumentType = fileType === "document";
52
+
53
+ // 获取listType
54
+ const getListType = () => {
55
+ if (externalListType) return externalListType;
56
+ if (externalAccept === "*") return "text";
57
+ if (fileType === "image") return "picture-card";
58
+ return "text";
59
+ };
60
+ const listType = getListType();
61
+
62
+ // 获取文件格式
63
+ const getAccept = () => {
64
+ if (externalAccept) return externalAccept === "*" ? "" : externalAccept;
65
+ if (isImageType) return imageAccept;
66
+ if (isVideoType) return videoAccept;
67
+ if (isDocumentType) return documentAccept;
68
+ return imageAccept;
69
+ };
70
+ const accept = getAccept();
71
+
72
+ // 获取默认上传数量
73
+ const getMaxCount = () => {
74
+ if (externalMaxCount) return externalMaxCount;
75
+ if (isVideoType) return 1;
76
+ if (isImageType) return 4;
77
+ if (isDocumentType) return 4;
78
+ return 1;
79
+ };
80
+ const maxCount = getMaxCount();
81
+
82
+ // 获取默认文件大小
83
+ const getSize = () => {
84
+ if (externalSize) return externalSize;
85
+ if (isVideoType) return 100;
86
+ return 0;
87
+ };
88
+ const size = getSize();
89
+
90
+ // 上传按钮文字
91
+ const uploadButtonText = externalUploadButtonText || (isVideoType ? "上传视频" : "上传附件");
92
+
93
+ // 文件格式提示
94
+ const acceptTip = accept.replace(/\./g, "").split(",").join("、");
95
+
96
+ // 生成提示信息
97
+ const getTipText = () => {
98
+ if (tipContent) return tipContent;
99
+ const tips = [`最多上传${maxCount}个文件`, accept ? `并且只能上传${acceptTip}格式的文件` : "可以上传任意格式的文件", size ? `文件大小不能超过${size}M` : "", ratio ? `只能上传${ratio}分辨率的图片` : ""].filter(Boolean);
100
+ return `${tips.join(",")}。`;
101
+ };
102
+ const handleBeforeUpload = (file, fileList) => {
103
+ if (beforeUpload) return beforeUpload(file, fileList);
104
+ return false;
105
+ };
106
+
107
+ // 文件状态改变
108
+ const handleChange = ({
109
+ file,
110
+ fileList
111
+ }) => {
112
+ const acceptList = accept ? accept.split(",") : [];
113
+ const ratioArr = ratio ? ratio.split("*") : [];
114
+ const suffix = file.name.substring(file.name.lastIndexOf("."), file.name.length);
115
+ const maxSize = size * 1024 * 1024;
116
+
117
+ // 验证文件格式
118
+ if (acceptList.length > 0 && !acceptList.includes(suffix)) {
119
+ message.warning(`只能上传${acceptTip}格式的文件`);
120
+ return;
121
+ }
122
+
123
+ // 验证文件大小
124
+ if (maxSize && file.size > maxSize) {
125
+ message.warning(`文件大小不能超过${size}M`);
126
+ return;
127
+ }
128
+
129
+ // 验证图片分辨率
130
+ if (ratioArr.length === 2 && file.type?.startsWith("image/")) {
131
+ const validateImageResolution = imageUrl => {
132
+ const img = new Image();
133
+ img.onload = () => {
134
+ if (img.width !== +ratioArr[0] || img.height !== +ratioArr[1]) {
135
+ message.warning(`只能上传${ratio}分辨率的图片`);
136
+ const filtered = fileList.filter(item => item.uid !== file.uid);
137
+ onChange?.(filtered);
138
+ return;
139
+ }
140
+ onChange?.(fileList);
141
+ };
142
+ img.src = imageUrl;
143
+ };
144
+
145
+ // 如果有现成的URL则直接使用,否则使用FileReader读取本地文件
146
+ if (file.url) {
147
+ validateImageResolution(file.url);
148
+ } else {
149
+ const reader = new FileReader();
150
+ reader.onload = e => {
151
+ validateImageResolution(e.target.result);
152
+ };
153
+ reader.readAsDataURL(file);
154
+ }
155
+ } else {
156
+ onChange?.(fileList);
157
+ }
158
+ };
159
+
160
+ // 删除文件
161
+ const handleRemove = file => {
162
+ if (!file.originFileObj) onGetRemoveFile?.(file);
163
+ return onRemove?.(file);
164
+ };
165
+
166
+ // 预览文件
167
+ const handlePreview = file => {
168
+ if (isImageType) {
169
+ setPreviewImage(file.url || file.thumbUrl);
170
+ setPreviewVisible(true);
171
+ }
172
+ onPreview?.(file);
173
+ };
174
+
175
+ // 关闭预览
176
+ const handleCancel = () => {
177
+ setPreviewVisible(false);
178
+ };
179
+
180
+ // 上传按钮
181
+ const uploadButton = isImageType ? /*#__PURE__*/jsx("div", {
182
+ children: /*#__PURE__*/jsx(PlusOutlined, {
183
+ style: {
184
+ fontSize: 32
185
+ }
186
+ })
187
+ }) : /*#__PURE__*/jsx(Button, {
188
+ type: "primary",
189
+ icon: isVideoType ? /*#__PURE__*/jsx(VideoCameraAddOutlined, {}) : /*#__PURE__*/jsx(UploadOutlined, {}),
190
+ children: uploadButtonText
191
+ });
192
+ return /*#__PURE__*/jsxs(Fragment, {
193
+ children: [/*#__PURE__*/jsx(Upload$1, {
194
+ fileList: value,
195
+ multiple: multiple,
196
+ maxCount: maxCount,
197
+ listType: listType,
198
+ accept: accept,
199
+ onChange: handleChange,
200
+ onPreview: handlePreview,
201
+ onRemove: handleRemove,
202
+ beforeUpload: handleBeforeUpload,
203
+ ...restProps,
204
+ children: value.length >= maxCount ? null : uploadButton
205
+ }), showTip ? getTipText() && /*#__PURE__*/jsx("div", {
206
+ style: {
207
+ marginTop: 10,
208
+ color: "#ff4d4f"
209
+ },
210
+ children: getTipText()
211
+ }) : null, /*#__PURE__*/jsx(Modal, {
212
+ open: previewVisible,
213
+ title: "\u67E5\u770B\u56FE\u7247",
214
+ footer: null,
215
+ onCancel: handleCancel,
216
+ children: /*#__PURE__*/jsx("img", {
217
+ alt: "preview",
218
+ style: {
219
+ width: "100%",
220
+ objectFit: "scale-down"
221
+ },
222
+ src: previewImage
223
+ })
224
+ })]
225
+ });
226
+ };
227
+ Upload.displayName = "Upload";
228
+
229
+ export { Upload as default };