zy-react-library 1.1.2 → 1.1.4

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 (72) hide show
  1. package/components/Cascader/Area/index.js +1 -20
  2. package/components/Cascader/Basic/index.js +1 -57
  3. package/components/Cascader/Dictionary/index.js +1 -42
  4. package/components/Cascader/Industry/index.js +1 -21
  5. package/components/Editor/index.js +1 -82
  6. package/components/FormBuilder/FormBuilder.js +1 -97
  7. package/components/FormBuilder/FormItemsRenderer.js +1 -589
  8. package/components/FormBuilder/index.js +1 -5
  9. package/components/HeaderBack/index.js +1 -44
  10. package/components/HiddenInfo/gwj/index.js +1 -586
  11. package/components/Icon/AddIcon/index.js +1 -9
  12. package/components/Icon/BackIcon/index.js +1 -9
  13. package/components/Icon/DeleteIcon/index.js +1 -9
  14. package/components/Icon/DownloadIcon/index.js +1 -9
  15. package/components/Icon/EditIcon/index.js +1 -9
  16. package/components/Icon/ExportIcon/index.js +1 -9
  17. package/components/Icon/ImportIcon/index.js +1 -9
  18. package/components/Icon/LocationIcon/index.js +1 -9
  19. package/components/Icon/PrintIcon/index.js +1 -9
  20. package/components/Icon/ResetIcon/index.js +1 -9
  21. package/components/Icon/SearchIcon/index.js +1 -9
  22. package/components/Icon/VideoIcon/index.js +1 -9
  23. package/components/Icon/ViewIcon/index.js +1 -9
  24. package/components/ImportFile/index.js +1 -94
  25. package/components/LeftTree/Area/index.js +1 -15
  26. package/components/LeftTree/Basic/index.js +1 -160
  27. package/components/LeftTree/Department/Gwj/index.js +1 -29
  28. package/components/LeftTree/Dictionary/index.js +1 -42
  29. package/components/Map/MapSelector.js +1 -280
  30. package/components/Map/index.js +1 -90
  31. package/components/Page/index.js +1 -59
  32. package/components/Pdf/index.js +1 -136
  33. package/components/PreviewImg/index.js +1 -26
  34. package/components/PreviewPdf/index.js +1 -78
  35. package/components/Search/index.js +1 -147
  36. package/components/Select/Basic/index.js +1 -70
  37. package/components/Select/Dictionary/index.js +1 -42
  38. package/components/Select/Personnel/Gwj/index.js +1 -45
  39. package/components/SelectCreate/index.js +1 -48
  40. package/components/SelectTree/Area/index.js +1 -20
  41. package/components/SelectTree/Basic/index.js +1 -105
  42. package/components/SelectTree/Department/Gwj/index.js +1 -40
  43. package/components/SelectTree/Dictionary/index.js +1 -42
  44. package/components/SelectTree/HiddenLevel/Gwj/index.js +1 -70
  45. package/components/SelectTree/HiddenPart/Gwj/index.js +1 -36
  46. package/components/SelectTree/Industry/index.js +1 -21
  47. package/components/Signature/index.js +1 -100
  48. package/components/Table/index.js +1 -77
  49. package/components/TooltipPreviewImg/index.js +1 -28
  50. package/components/Upload/index.js +1 -229
  51. package/components/Video/AliPlayer.js +1 -182
  52. package/components/Video/index.js +1 -71
  53. package/enum/dictionary/index.js +1 -9
  54. package/enum/formItemRender/index.js +1 -39
  55. package/enum/hidden/gwj/index.js +1 -70
  56. package/enum/uploadFile/gwj/index.js +1 -258
  57. package/hooks/useDeleteFile/index.js +1 -95
  58. package/hooks/useDictionary/index.js +1 -64
  59. package/hooks/useDownloadBlob/index.js +1 -80
  60. package/hooks/useDownloadFile/index.js +1 -78
  61. package/hooks/useGetFile/index.js +1 -74
  62. package/hooks/useGetUrlQuery/index.js +1 -15
  63. package/hooks/useGetUserInfo/index.js +1 -42
  64. package/hooks/useIdle/index.js +1 -65
  65. package/hooks/useImportFile/index.js +1 -61
  66. package/hooks/useIsExistenceDuplicateSelection/index.js +1 -27
  67. package/hooks/useTable/index.js +1 -124
  68. package/hooks/useUploadFile/index.js +1 -144
  69. package/hooks/useUrlQueryCriteria/index.js +1 -84
  70. package/package.json +5 -1
  71. package/regular/index.js +1 -56
  72. package/utils/index.js +1 -591
@@ -1,36 +1 @@
1
- import { request } from '@cqsjjb/jjb-common-lib/http';
2
- import { useState, useEffect } from 'react';
3
- import BasicSelectTree from '../../Basic/index.js';
4
- import { jsx } from 'react/jsx-runtime';
5
-
6
- function HiddenPartSelectTree(props) {
7
- const {
8
- params = {},
9
- isNeedCorpInfoId = false,
10
- ...restProps
11
- } = props;
12
- const [treeData, setTreeData] = useState([]);
13
- const getData = async () => {
14
- setTreeData([]);
15
-
16
- // 根据参数决定是否发送请求
17
- if (isNeedCorpInfoId && !params.eqCorpinfoId) return;
18
- const {
19
- data
20
- } = await request("/hidden/hiddenRegion/listByTree", "post", params);
21
- setTreeData(data);
22
- };
23
- useEffect(() => {
24
- getData();
25
- }, [JSON.stringify(params), isNeedCorpInfoId]);
26
- return /*#__PURE__*/jsx(BasicSelectTree, {
27
- treeData: treeData,
28
- placeholder: "\u9690\u60A3\u90E8\u4F4D",
29
- nameKey: "hiddenregion",
30
- idKey: "hiddenregionId",
31
- ...restProps
32
- });
33
- }
34
- HiddenPartSelectTree.displayName = "HiddenPartSelectTree";
35
-
36
- export { HiddenPartSelectTree as default };
1
+ import{request as e}from"@cqsjjb/jjb-common-lib/http";import{useState as r,useEffect as i}from"react";import t from"../../Basic/index.js";import{jsx as o}from"react/jsx-runtime";function n(n){const{params:d={},isNeedCorpInfoId:a=!1,...m}=n,[s,p]=r([]);return i(()=>{(async()=>{if(p([]),a&&!d.eqCorpinfoId)return;const{data:r}=await e("/hidden/hiddenRegion/listByTree","post",d);p(r)})()},[JSON.stringify(d),a]),o(t,{treeData:s,placeholder:"隐患部位",nameKey:"hiddenregion",idKey:"hiddenregionId",...m})}n.displayName="HiddenPartSelectTree";export{n as default};
@@ -1,21 +1 @@
1
- import Industry from '../../../json/industry.json';
2
- import BasicSelectTree from '../Basic/index.js';
3
- import { jsx } from 'react/jsx-runtime';
4
-
5
- function IndustrySelectTree(props) {
6
- const {
7
- placeholder = "行业类型",
8
- ...restProps
9
- } = props;
10
- return /*#__PURE__*/jsx(BasicSelectTree, {
11
- treeData: Industry,
12
- placeholder: placeholder,
13
- nameKey: "dict_label",
14
- idKey: "dict_value",
15
- childrenKey: "childrenList",
16
- ...restProps
17
- });
18
- }
19
- IndustrySelectTree.displayName = "IndustrySelectTree";
20
-
21
- export { IndustrySelectTree as default };
1
+ import e from"../../../json/industry.json";import r from"../Basic/index.js";import{jsx as t}from"react/jsx-runtime";function i(i){const{placeholder:a="行业类型",...n}=i;return t(r,{treeData:e,placeholder:a,nameKey:"dict_label",idKey:"dict_value",childrenKey:"childrenList",...n})}i.displayName="IndustrySelectTree";export{i as default};
@@ -1,100 +1 @@
1
- import { Button, Image, Modal, message } from 'antd';
2
- import dayjs from 'dayjs';
3
- import { useState, useRef, useEffect } from 'react';
4
- import SignatureCanvas from 'react-signature-canvas';
5
- import { base642File } from '../../utils/index.js';
6
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
-
8
- function Signature(props) {
9
- const {
10
- onConfirm,
11
- width = 752,
12
- height = 300,
13
- url = "",
14
- ...restProps
15
- } = props;
16
- const [signatureModalOpen, setSignatureModalOpen] = useState(false);
17
- const signatureCanvas = useRef(null);
18
- const [base64, setBase64] = useState("");
19
- useEffect(() => {
20
- setBase64(url);
21
- }, [url]);
22
- const onOk = () => {
23
- if (signatureCanvas.current.isEmpty()) {
24
- message.warning("请签名");
25
- return;
26
- }
27
- const base64 = signatureCanvas.current.toDataURL();
28
- setBase64(base64);
29
- onConfirm({
30
- time: dayjs().format("YYYY-MM-DD HH:mm:ss"),
31
- base64,
32
- file: base642File(base64)
33
- });
34
- signatureCanvas.current.clear();
35
- setSignatureModalOpen(false);
36
- };
37
- return /*#__PURE__*/jsxs(Fragment, {
38
- children: [/*#__PURE__*/jsx("div", {
39
- children: /*#__PURE__*/jsx(Button, {
40
- type: "primary",
41
- onClick: () => {
42
- setSignatureModalOpen(true);
43
- },
44
- children: base64 ? "重新签字" : "手写签字"
45
- })
46
- }), base64 && /*#__PURE__*/jsx("div", {
47
- style: {
48
- border: "1px dashed #d9d9d9",
49
- width,
50
- height,
51
- marginTop: 16
52
- },
53
- children: /*#__PURE__*/jsx(Image, {
54
- src: base64,
55
- style: {
56
- width,
57
- height,
58
- objectFit: "contain"
59
- }
60
- })
61
- }), /*#__PURE__*/jsx(Modal, {
62
- title: "\u7B7E\u5B57",
63
- width: 800,
64
- open: signatureModalOpen,
65
- maskClosable: false,
66
- onCancel: () => setSignatureModalOpen(false),
67
- footer: [/*#__PURE__*/jsx(Button, {
68
- onClick: () => signatureCanvas.current.clear(),
69
- children: "\u91CD\u7B7E"
70
- }, "clear"), /*#__PURE__*/jsx(Button, {
71
- onClick: () => {
72
- setSignatureModalOpen(false);
73
- signatureCanvas.current.clear();
74
- },
75
- children: "\u53D6\u6D88"
76
- }, "cancel"), /*#__PURE__*/jsx(Button, {
77
- type: "primary",
78
- onClick: onOk,
79
- children: "\u786E\u5B9A"
80
- }, "ok")],
81
- children: /*#__PURE__*/jsx("div", {
82
- style: {
83
- border: "1px dashed #d9d9d9"
84
- },
85
- children: /*#__PURE__*/jsx(SignatureCanvas, {
86
- ref: signatureCanvas,
87
- penColor: "black",
88
- canvasProps: {
89
- width,
90
- height
91
- },
92
- ...restProps
93
- })
94
- })
95
- })]
96
- });
97
- }
98
- Signature.displayName = "Signature";
99
-
100
- export { Signature as default };
1
+ import{Button as r,Image as e,Modal as i,message as t}from"antd";import n from"dayjs";import{useState as o,useRef as c,useEffect as a}from"react";import d from"react-signature-canvas";import{base642File as l}from"../../utils/index.js";import{jsxs as h,Fragment as m,jsx as s}from"react/jsx-runtime";function p(p){const{onConfirm:u,width:f=752,height:y=300,url:g="",...C}=p,[k,b]=o(!1),v=c(null),[w,x]=o("");return a(()=>{x(g)},[g]),h(m,{children:[s("div",{children:s(r,{type:"primary",onClick:()=>{b(!0)},children:w?"重新签字":"手写签字"})}),w&&s("div",{style:{border:"1px dashed #d9d9d9",width:f,height:y,marginTop:16},children:s(e,{src:w,style:{width:f,height:y,objectFit:"contain"}})}),s(i,{title:"签字",width:800,open:k,maskClosable:!1,onCancel:()=>b(!1),footer:[s(r,{onClick:()=>v.current.clear(),children:"重签"},"clear"),s(r,{onClick:()=>{b(!1),v.current.clear()},children:"取消"},"cancel"),s(r,{type:"primary",onClick:()=>{if(v.current.isEmpty())return void t.warning("请签名");const r=v.current.toDataURL();x(r),u({time:n().format("YYYY-MM-DD HH:mm:ss"),base64:r,file:l(r)}),v.current.clear(),b(!1)},children:"确定"},"ok")],children:s("div",{style:{border:"1px dashed #d9d9d9"},children:s(d,{ref:v,penColor:"black",canvasProps:{width:f,height:y},...C})})})]})}p.displayName="Signature";export{p as default};
@@ -1,77 +1 @@
1
- import TablePro from '@cqsjjb/jjb-react-admin-component/Table';
2
- import { getIndexColumn } from '../../utils/index.js';
3
- import dayjs from 'dayjs';
4
- import './index.less';
5
- import { jsx } from 'react/jsx-runtime';
6
-
7
- const CLEANUP_INTERVAL_DAYS = 10; // 清理间隔天数
8
- const LAST_CLEANUP_KEY = 'tableLocalStorageLastCleanup'; // 最后清理时间存储key
9
-
10
- // 清理本地存储中特定后缀的key
11
- function cleanupTableLocalStorage() {
12
- const now = dayjs();
13
- const lastCleanupStr = localStorage.getItem(LAST_CLEANUP_KEY);
14
- const lastCleanup = lastCleanupStr ? dayjs(lastCleanupStr) : null;
15
-
16
- // 如果没有上次清理时间或距离上次清理已超过10天
17
- if (!lastCleanup || now.diff(lastCleanup, 'day') >= CLEANUP_INTERVAL_DAYS) {
18
- // 查找并清理符合条件的key
19
- const keysToRemove = [];
20
- for (let i = 0; i < localStorage.length; i++) {
21
- const key = localStorage.key(i);
22
- if (key && (key.endsWith('#columnState') || key.endsWith('#size') || key.endsWith('#resizable'))) {
23
- keysToRemove.push(key);
24
- }
25
- }
26
-
27
- // 删除匹配的key
28
- keysToRemove.forEach(key => {
29
- localStorage.removeItem(key);
30
- });
31
-
32
- // 更新最后清理时间
33
- localStorage.setItem(LAST_CLEANUP_KEY, now.toISOString());
34
- }
35
- }
36
- function Table(props) {
37
- const {
38
- columns = [],
39
- showIndexColumn = true,
40
- ellipsis = true,
41
- align = "center",
42
- indexColumnFixed = "left",
43
- rowKey = "id",
44
- ...restProps
45
- } = props;
46
-
47
- // 组件初始化时执行清理
48
- cleanupTableLocalStorage();
49
- function settingColumns() {
50
- showIndexColumn && columns.unshift({
51
- ...getIndexColumn(props.pagination),
52
- fixed: indexColumnFixed
53
- });
54
- const setAlign = column => ({
55
- align,
56
- ellipsis,
57
- ...column,
58
- ...(column.children ? {
59
- children: column.children.map(setAlign)
60
- } : {})
61
- });
62
- return columns.map(setAlign);
63
- }
64
- return /*#__PURE__*/jsx("div", {
65
- className: "table-layout card-layout",
66
- children: /*#__PURE__*/jsx(TablePro, {
67
- rowKey: rowKey,
68
- columns: settingColumns(),
69
- bordered: true,
70
- size: "small",
71
- ...restProps
72
- })
73
- });
74
- }
75
- Table.displayName = "Table";
76
-
77
- export { Table as default };
1
+ import e from"@cqsjjb/jjb-react-admin-component/Table";import{getIndexColumn as t}from"../../utils/index.js";import o from"dayjs";import"./index.less";import{jsx as l}from"react/jsx-runtime";const n="tableLocalStorageLastCleanup";function a(a){const{columns:i=[],showIndexColumn:r=!0,ellipsis:s=!0,align:c="center",indexColumnFixed:m="left",rowKey:d="id",...u}=a;return function(){const e=o(),t=localStorage.getItem(n),l=t?o(t):null;if(!l||e.diff(l,"day")>=10){const t=[];for(let e=0;e<localStorage.length;e++){const o=localStorage.key(e);o&&(o.endsWith("#columnState")||o.endsWith("#size")||o.endsWith("#resizable"))&&t.push(o)}t.forEach(e=>{localStorage.removeItem(e)}),localStorage.setItem(n,e.toISOString())}}(),l("div",{className:"table-layout card-layout",children:l(e,{rowKey:d,columns:function(){r&&i.unshift({...t(a.pagination),fixed:m});const e=t=>({align:c,ellipsis:s,...t,...t.children?{children:t.children.map(e)}:{}});return i.map(e)}(),bordered:!0,size:"small",...u})})}a.displayName="Table";export{a as default};
@@ -1,28 +1 @@
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
+ import{Tooltip as e,Tag as i}from"antd";import r from"../PreviewImg/index.js";import{jsx as t}from"react/jsx-runtime";const l=l=>{const{files:n=[],fileUrlKey:o="filePath"}=l;return t(e,{placement:"top",title:n.length>0?t(r,{files:n,fileUrlKey:o}):t("span",{children:"暂无图片"}),children:t(i,{children:"预览"})})};l.displayName="TooltipPreviewImg";export{l as default};
@@ -1,229 +1 @@
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 };
1
+ import{PlusOutlined as e,VideoCameraAddOutlined as t,UploadOutlined as i}from"@ant-design/icons";import{Upload as n,Modal as o,Button as l,message as r}from"antd";import{useState as s}from"react";import{jsxs as a,Fragment as d,jsx as c}from"react/jsx-runtime";const p=p=>{const{value:m=[],onChange:u,onPreview:f,onRemove:g,onGetRemoveFile:h,beforeUpload:v,maxCount:w,listType:y,accept:x,ratio:$="",showTip:j=!0,multiple:b=!0,size:C,tipContent:T,uploadButtonText:U,fileType:R,...F}=p,[z,L]=s(!1),[B,I]=s(""),M=".jpg,.jpeg,.png",O=".pdf,.doc,.docx",P=".mp4",A=R||(()=>{if(x){if("*"===x)return"document";const e=x.split(",");return e.some(e=>P.split(",").includes(e))?"video":e.some(e=>O.split(",").includes(e))?"document":e.some(e=>M.split(",").includes(e))?"image":"document"}return"image"})(),D="image"===A,G="video"===A,N="document"===A,S=y||("*"===x?"text":"image"===A?"picture-card":"text"),W=x?"*"===x?"":x:D?M:G?P:N?O:M,k=w||(G?1:D||N?4:1),q=C||(G?100:0),E=U||(G?"上传视频":"上传附件"),H=W.replace(/\./g,"").split(",").join("、"),J=()=>T||`${[`最多上传${k}个文件`,W?`并且只能上传${H}格式的文件`:"可以上传任意格式的文件",q?`文件大小不能超过${q}M`:"",$?`只能上传${$}分辨率的图片`:""].filter(Boolean).join(",")}。`,K=D?c("div",{children:c(e,{style:{fontSize:32}})}):c(l,{type:"primary",icon:c(G?t:i,{}),children:E});return a(d,{children:[c(n,{fileList:m,multiple:b,maxCount:k,listType:S,accept:W,onChange:({file:e,fileList:t})=>{const i=W?W.split(","):[],n=$?$.split("*"):[],o=e.name.substring(e.name.lastIndexOf("."),e.name.length),l=1024*q*1024;if(i.length>0&&!i.includes(o))r.warning(`只能上传${H}格式的文件`);else if(l&&e.size>l)r.warning(`文件大小不能超过${q}M`);else if(2===n.length&&e.type?.startsWith("image/")){const i=i=>{const o=new Image;o.onload=()=>{if(o.width!==+n[0]||o.height!==+n[1]){r.warning(`只能上传${$}分辨率的图片`);const i=t.filter(t=>t.uid!==e.uid);return void u?.(i)}u?.(t)},o.src=i};if(e.url)i(e.url);else{const t=new FileReader;t.onload=e=>{i(e.target.result)},t.readAsDataURL(e)}}else u?.(t)},onPreview:e=>{D&&(I(e.url||e.thumbUrl),L(!0)),f?.(e)},onRemove:e=>(e.originFileObj||h?.(e),g?.(e)),beforeUpload:(e,t)=>!!v&&v(e,t),...F,children:m.length>=k?null:K}),j?J()&&c("div",{style:{marginTop:10,color:"#ff4d4f"},children:J()}):null,c(o,{open:z,title:"查看图片",footer:null,onCancel:()=>{L(!1)},children:c("img",{alt:"preview",style:{width:"100%",objectFit:"scale-down"},src:B})})]})};p.displayName="Upload";export{p as default};