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.
- package/components/Cascader/Area/index.js +1 -20
- package/components/Cascader/Basic/index.js +1 -57
- package/components/Cascader/Dictionary/index.js +1 -42
- package/components/Cascader/Industry/index.js +1 -21
- package/components/Editor/index.js +1 -82
- package/components/FormBuilder/FormBuilder.js +1 -97
- package/components/FormBuilder/FormItemsRenderer.js +1 -589
- package/components/FormBuilder/index.js +1 -5
- package/components/HeaderBack/index.js +1 -44
- package/components/HiddenInfo/gwj/index.js +1 -586
- package/components/Icon/AddIcon/index.js +1 -9
- package/components/Icon/BackIcon/index.js +1 -9
- package/components/Icon/DeleteIcon/index.js +1 -9
- package/components/Icon/DownloadIcon/index.js +1 -9
- package/components/Icon/EditIcon/index.js +1 -9
- package/components/Icon/ExportIcon/index.js +1 -9
- package/components/Icon/ImportIcon/index.js +1 -9
- package/components/Icon/LocationIcon/index.js +1 -9
- package/components/Icon/PrintIcon/index.js +1 -9
- package/components/Icon/ResetIcon/index.js +1 -9
- package/components/Icon/SearchIcon/index.js +1 -9
- package/components/Icon/VideoIcon/index.js +1 -9
- package/components/Icon/ViewIcon/index.js +1 -9
- package/components/ImportFile/index.js +1 -94
- package/components/LeftTree/Area/index.js +1 -15
- package/components/LeftTree/Basic/index.js +1 -160
- package/components/LeftTree/Department/Gwj/index.js +1 -29
- package/components/LeftTree/Dictionary/index.js +1 -42
- package/components/Map/MapSelector.js +1 -280
- package/components/Map/index.js +1 -90
- package/components/Page/index.js +1 -59
- package/components/Pdf/index.js +1 -136
- package/components/PreviewImg/index.js +1 -26
- package/components/PreviewPdf/index.js +1 -78
- package/components/Search/index.js +1 -147
- package/components/Select/Basic/index.js +1 -70
- package/components/Select/Dictionary/index.js +1 -42
- package/components/Select/Personnel/Gwj/index.js +1 -45
- package/components/SelectCreate/index.js +1 -48
- package/components/SelectTree/Area/index.js +1 -20
- package/components/SelectTree/Basic/index.js +1 -105
- package/components/SelectTree/Department/Gwj/index.js +1 -40
- package/components/SelectTree/Dictionary/index.js +1 -42
- package/components/SelectTree/HiddenLevel/Gwj/index.js +1 -70
- package/components/SelectTree/HiddenPart/Gwj/index.js +1 -36
- package/components/SelectTree/Industry/index.js +1 -21
- package/components/Signature/index.js +1 -100
- package/components/Table/index.js +1 -77
- package/components/TooltipPreviewImg/index.js +1 -28
- package/components/Upload/index.js +1 -229
- package/components/Video/AliPlayer.js +1 -182
- package/components/Video/index.js +1 -71
- package/enum/dictionary/index.js +1 -9
- package/enum/formItemRender/index.js +1 -39
- package/enum/hidden/gwj/index.js +1 -70
- package/enum/uploadFile/gwj/index.js +1 -258
- package/hooks/useDeleteFile/index.js +1 -95
- package/hooks/useDictionary/index.js +1 -64
- package/hooks/useDownloadBlob/index.js +1 -80
- package/hooks/useDownloadFile/index.js +1 -78
- package/hooks/useGetFile/index.js +1 -74
- package/hooks/useGetUrlQuery/index.js +1 -15
- package/hooks/useGetUserInfo/index.js +1 -42
- package/hooks/useIdle/index.js +1 -65
- package/hooks/useImportFile/index.js +1 -61
- package/hooks/useIsExistenceDuplicateSelection/index.js +1 -27
- package/hooks/useTable/index.js +1 -124
- package/hooks/useUploadFile/index.js +1 -144
- package/hooks/useUrlQueryCriteria/index.js +1 -84
- package/package.json +5 -1
- package/regular/index.js +1 -56
- package/utils/index.js +1 -591
|
@@ -1,280 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRef, useState, useEffect } from 'react';
|
|
3
|
-
import { dynamicLoadJs } from '../../utils/index.js';
|
|
4
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
const MapSelector = props => {
|
|
7
|
-
const {
|
|
8
|
-
visible,
|
|
9
|
-
onClose,
|
|
10
|
-
longitude,
|
|
11
|
-
latitude,
|
|
12
|
-
onConfirm,
|
|
13
|
-
area = "",
|
|
14
|
-
showArea = false,
|
|
15
|
-
disable = false
|
|
16
|
-
} = props;
|
|
17
|
-
const mapContainerRef = useRef(null);
|
|
18
|
-
const mapInstanceRef = useRef(null);
|
|
19
|
-
const local = useRef(null);
|
|
20
|
-
const [loading, setLoading] = useState(false);
|
|
21
|
-
const [currentLongitude, setCurrentLongitude] = useState(longitude || "");
|
|
22
|
-
const [currentLatitude, setCurrentLatitude] = useState(latitude || "");
|
|
23
|
-
const [localSearch, setLocalSearch] = useState("");
|
|
24
|
-
const [currentArea, setCurrentArea] = useState("");
|
|
25
|
-
|
|
26
|
-
// 当外部经纬度变化时,更新内部状态
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
setCurrentLongitude(longitude || "");
|
|
29
|
-
setCurrentLatitude(latitude || "");
|
|
30
|
-
setCurrentArea(area || "");
|
|
31
|
-
}, [longitude, latitude, area]);
|
|
32
|
-
|
|
33
|
-
// 初始化地图
|
|
34
|
-
const initMap = async () => {
|
|
35
|
-
if (!window.BMapGL) {
|
|
36
|
-
if (window?.base?.loadDynamicResource) {
|
|
37
|
-
await window.base.loadDynamicResource({
|
|
38
|
-
url: "https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr&callback=initialize",
|
|
39
|
-
type: "script"
|
|
40
|
-
});
|
|
41
|
-
} else {
|
|
42
|
-
await dynamicLoadJs("https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr&callback=initialize");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
setLoading(true);
|
|
46
|
-
|
|
47
|
-
// 确保DOM已经渲染
|
|
48
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
49
|
-
if (mapContainerRef.current) {
|
|
50
|
-
// 只有在没有地图实例时才创建新地图
|
|
51
|
-
if (!mapInstanceRef.current) {
|
|
52
|
-
const map = new window.BMapGL.Map(mapContainerRef.current);
|
|
53
|
-
mapInstanceRef.current = map;
|
|
54
|
-
map.centerAndZoom(new window.BMapGL.Point(longitude || "119.69457721306945", latitude || "39.940504336846665"), 16);
|
|
55
|
-
map.enableScrollWheelZoom(true);
|
|
56
|
-
|
|
57
|
-
// 如果有初始坐标,添加标记
|
|
58
|
-
if (longitude && latitude) {
|
|
59
|
-
const point = new window.BMapGL.Point(longitude, latitude);
|
|
60
|
-
const marker = new window.BMapGL.Marker(point);
|
|
61
|
-
map.addOverlay(marker);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 添加点击事件
|
|
65
|
-
if (!disable) {
|
|
66
|
-
map.addEventListener("click", event => {
|
|
67
|
-
map.clearOverlays();
|
|
68
|
-
const point = new window.BMapGL.Point(event.latlng.lng, event.latlng.lat);
|
|
69
|
-
const marker = new window.BMapGL.Marker(point);
|
|
70
|
-
map.addOverlay(marker);
|
|
71
|
-
setCurrentLatitude(event.latlng.lat);
|
|
72
|
-
setCurrentLongitude(event.latlng.lng);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
setLoading(false);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// 搜索功能
|
|
81
|
-
const handleLocalSearch = () => {
|
|
82
|
-
if (localSearch && mapInstanceRef.current) {
|
|
83
|
-
local.current = new window.BMapGL.LocalSearch(mapInstanceRef.current, {
|
|
84
|
-
renderOptions: {
|
|
85
|
-
map: mapInstanceRef.current
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
local.current.search(localSearch);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// 清空
|
|
93
|
-
const handleLocalClear = () => {
|
|
94
|
-
setLocalSearch("");
|
|
95
|
-
if (mapInstanceRef.current) {
|
|
96
|
-
local.current.search("");
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// 关闭弹窗
|
|
101
|
-
const handleClose = () => {
|
|
102
|
-
setLocalSearch("");
|
|
103
|
-
if (onClose) onClose();
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// 确认选择
|
|
107
|
-
const handleConfirm = () => {
|
|
108
|
-
if (onConfirm) {
|
|
109
|
-
onConfirm(currentLongitude, currentLatitude, {
|
|
110
|
-
area: currentArea
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
handleClose();
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// 监听visible变化
|
|
117
|
-
useEffect(() => {
|
|
118
|
-
let initTimer;
|
|
119
|
-
if (visible) {
|
|
120
|
-
// 延迟初始化地图,确保DOM完全渲染
|
|
121
|
-
initTimer = setTimeout(() => {
|
|
122
|
-
initMap();
|
|
123
|
-
}, 100);
|
|
124
|
-
}
|
|
125
|
-
return () => {
|
|
126
|
-
if (initTimer) {
|
|
127
|
-
clearTimeout(initTimer);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}, [visible]);
|
|
131
|
-
const handleAfterClose = () => {
|
|
132
|
-
if (mapInstanceRef.current) {
|
|
133
|
-
try {
|
|
134
|
-
mapInstanceRef.current.clearOverlays();
|
|
135
|
-
mapInstanceRef.current.destroy();
|
|
136
|
-
mapInstanceRef.current = null;
|
|
137
|
-
} catch (e) {
|
|
138
|
-
console.warn("Error destroying map on unmount:", e);
|
|
139
|
-
}
|
|
140
|
-
mapInstanceRef.current = null;
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// 组件卸载时清理地图
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
return () => {
|
|
147
|
-
handleAfterClose();
|
|
148
|
-
};
|
|
149
|
-
}, []);
|
|
150
|
-
return /*#__PURE__*/jsxs(Modal, {
|
|
151
|
-
open: visible,
|
|
152
|
-
title: "\u5750\u6807",
|
|
153
|
-
onCancel: handleClose,
|
|
154
|
-
width: 1000,
|
|
155
|
-
destroyOnHidden: false,
|
|
156
|
-
maskClosable: false,
|
|
157
|
-
afterClose: handleAfterClose,
|
|
158
|
-
footer: [/*#__PURE__*/jsx(Button, {
|
|
159
|
-
onClick: handleClose,
|
|
160
|
-
children: "\u53D6\u6D88"
|
|
161
|
-
}, "back"), !disable && /*#__PURE__*/jsx(Button, {
|
|
162
|
-
type: "primary",
|
|
163
|
-
onClick: handleConfirm,
|
|
164
|
-
children: "\u786E\u5B9A"
|
|
165
|
-
}, "submit")],
|
|
166
|
-
children: [/*#__PURE__*/jsxs(Form, {
|
|
167
|
-
labelAlign: "right",
|
|
168
|
-
labelCol: {
|
|
169
|
-
span: 6
|
|
170
|
-
},
|
|
171
|
-
wrapperCol: {
|
|
172
|
-
span: 18
|
|
173
|
-
},
|
|
174
|
-
children: [showArea && /*#__PURE__*/jsx(Row, {
|
|
175
|
-
gutter: 24,
|
|
176
|
-
children: /*#__PURE__*/jsx(Col, {
|
|
177
|
-
span: 12,
|
|
178
|
-
children: /*#__PURE__*/jsx(Form.Item, {
|
|
179
|
-
label: "\u6240\u5C5E\u533A\u57DF",
|
|
180
|
-
children: /*#__PURE__*/jsxs(Select, {
|
|
181
|
-
value: currentArea,
|
|
182
|
-
onChange: e => setCurrentArea(e),
|
|
183
|
-
allowClear: true,
|
|
184
|
-
children: [/*#__PURE__*/jsx(Select.Option, {
|
|
185
|
-
value: "1",
|
|
186
|
-
children: "\u4E1C\u6E2F\u533A"
|
|
187
|
-
}), /*#__PURE__*/jsx(Select.Option, {
|
|
188
|
-
value: "2",
|
|
189
|
-
children: "\u897F\u6E2F\u533A"
|
|
190
|
-
})]
|
|
191
|
-
})
|
|
192
|
-
})
|
|
193
|
-
})
|
|
194
|
-
}), !disable && /*#__PURE__*/jsxs(Row, {
|
|
195
|
-
gutter: 24,
|
|
196
|
-
children: [/*#__PURE__*/jsx(Col, {
|
|
197
|
-
span: 12,
|
|
198
|
-
children: /*#__PURE__*/jsx(Form.Item, {
|
|
199
|
-
label: "\u5173\u952E\u5B57\u641C\u7D22",
|
|
200
|
-
children: /*#__PURE__*/jsx(Input, {
|
|
201
|
-
value: localSearch,
|
|
202
|
-
onChange: e => setLocalSearch(e.target.value),
|
|
203
|
-
allowClear: true
|
|
204
|
-
})
|
|
205
|
-
})
|
|
206
|
-
}), /*#__PURE__*/jsx(Col, {
|
|
207
|
-
span: 12,
|
|
208
|
-
children: /*#__PURE__*/jsxs(Form.Item, {
|
|
209
|
-
label: " ",
|
|
210
|
-
colon: false,
|
|
211
|
-
style: {
|
|
212
|
-
textAlign: "right"
|
|
213
|
-
},
|
|
214
|
-
children: [/*#__PURE__*/jsx(Button, {
|
|
215
|
-
type: "primary",
|
|
216
|
-
onClick: handleLocalSearch,
|
|
217
|
-
children: "\u641C\u7D22"
|
|
218
|
-
}), /*#__PURE__*/jsx(Button, {
|
|
219
|
-
onClick: handleLocalClear,
|
|
220
|
-
style: {
|
|
221
|
-
marginLeft: 8
|
|
222
|
-
},
|
|
223
|
-
children: "\u91CD\u7F6E"
|
|
224
|
-
})]
|
|
225
|
-
})
|
|
226
|
-
})]
|
|
227
|
-
}), /*#__PURE__*/jsxs(Row, {
|
|
228
|
-
gutter: 24,
|
|
229
|
-
children: [/*#__PURE__*/jsx(Col, {
|
|
230
|
-
span: 12,
|
|
231
|
-
children: /*#__PURE__*/jsx(Form.Item, {
|
|
232
|
-
label: "\u7ECF\u5EA6",
|
|
233
|
-
children: /*#__PURE__*/jsx(Input, {
|
|
234
|
-
disabled: true,
|
|
235
|
-
value: currentLongitude
|
|
236
|
-
})
|
|
237
|
-
})
|
|
238
|
-
}), /*#__PURE__*/jsx(Col, {
|
|
239
|
-
span: 12,
|
|
240
|
-
children: /*#__PURE__*/jsx(Form.Item, {
|
|
241
|
-
label: "\u7EAC\u5EA6",
|
|
242
|
-
children: /*#__PURE__*/jsx(Input, {
|
|
243
|
-
disabled: true,
|
|
244
|
-
value: currentLatitude
|
|
245
|
-
})
|
|
246
|
-
})
|
|
247
|
-
})]
|
|
248
|
-
})]
|
|
249
|
-
}), /*#__PURE__*/jsx("div", {
|
|
250
|
-
ref: mapContainerRef,
|
|
251
|
-
style: {
|
|
252
|
-
width: "100%",
|
|
253
|
-
height: "500px",
|
|
254
|
-
position: "relative"
|
|
255
|
-
},
|
|
256
|
-
children: /*#__PURE__*/jsx(Spin, {
|
|
257
|
-
size: "large",
|
|
258
|
-
tip: "\u5730\u56FE\u6B63\u5728\u52A0\u8F7D\u4E2D...",
|
|
259
|
-
spinning: loading,
|
|
260
|
-
children: /*#__PURE__*/jsx("div", {
|
|
261
|
-
style: {
|
|
262
|
-
position: "absolute",
|
|
263
|
-
top: 0,
|
|
264
|
-
left: 0,
|
|
265
|
-
right: 0,
|
|
266
|
-
bottom: 0,
|
|
267
|
-
display: "flex",
|
|
268
|
-
justifyContent: "center",
|
|
269
|
-
alignItems: "center",
|
|
270
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
271
|
-
zIndex: 1000
|
|
272
|
-
}
|
|
273
|
-
})
|
|
274
|
-
})
|
|
275
|
-
})]
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
MapSelector.displayName = "MapSelector";
|
|
279
|
-
|
|
280
|
-
export { MapSelector as default };
|
|
1
|
+
import{Modal as e,Form as n,Row as l,Col as r,Select as t,Input as a,Button as i,Spin as o}from"antd";import{useRef as c,useState as d,useEffect as s}from"react";import{dynamicLoadJs as p}from"../../utils/index.js";import{jsxs as u,jsx as h}from"react/jsx-runtime";const w=w=>{const{visible:m,onClose:b,longitude:g,latitude:y,onConfirm:f,area:C="",showArea:v=!1,disable:k=!1}=w,L=c(null),M=c(null),O=c(null),[B,G]=d(!1),[x,I]=d(g||""),[A,F]=d(y||""),[K,N]=d(""),[z,E]=d("");s(()=>{I(g||""),F(y||""),E(C||"")},[g,y,C]);const P=()=>{N(""),b&&b()};s(()=>{let e;return m&&(e=setTimeout(()=>{(async()=>{if(window.BMapGL||(window?.base?.loadDynamicResource?await window.base.loadDynamicResource({url:"https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr&callback=initialize",type:"script"}):await p("https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr&callback=initialize")),G(!0),await new Promise(e=>setTimeout(e,100)),L.current){if(!M.current){const e=new window.BMapGL.Map(L.current);if(M.current=e,e.centerAndZoom(new window.BMapGL.Point(g||"119.69457721306945",y||"39.940504336846665"),16),e.enableScrollWheelZoom(!0),g&&y){const n=new window.BMapGL.Point(g,y),l=new window.BMapGL.Marker(n);e.addOverlay(l)}k||e.addEventListener("click",n=>{e.clearOverlays();const l=new window.BMapGL.Point(n.latlng.lng,n.latlng.lat),r=new window.BMapGL.Marker(l);e.addOverlay(r),F(n.latlng.lat),I(n.latlng.lng)})}G(!1)}})()},100)),()=>{e&&clearTimeout(e)}},[m]);const j=()=>{if(M.current){try{M.current.clearOverlays(),M.current.destroy(),M.current=null}catch(e){console.warn("Error destroying map on unmount:",e)}M.current=null}};return s(()=>()=>{j()},[]),u(e,{open:m,title:"坐标",onCancel:P,width:1e3,destroyOnHidden:!1,maskClosable:!1,afterClose:j,footer:[h(i,{onClick:P,children:"取消"},"back"),!k&&h(i,{type:"primary",onClick:()=>{f&&f(x,A,{area:z}),P()},children:"确定"},"submit")],children:[u(n,{labelAlign:"right",labelCol:{span:6},wrapperCol:{span:18},children:[v&&h(l,{gutter:24,children:h(r,{span:12,children:h(n.Item,{label:"所属区域",children:u(t,{value:z,onChange:e=>E(e),allowClear:!0,children:[h(t.Option,{value:"1",children:"东港区"}),h(t.Option,{value:"2",children:"西港区"})]})})})}),!k&&u(l,{gutter:24,children:[h(r,{span:12,children:h(n.Item,{label:"关键字搜索",children:h(a,{value:K,onChange:e=>N(e.target.value),allowClear:!0})})}),h(r,{span:12,children:u(n.Item,{label:" ",colon:!1,style:{textAlign:"right"},children:[h(i,{type:"primary",onClick:()=>{K&&M.current&&(O.current=new window.BMapGL.LocalSearch(M.current,{renderOptions:{map:M.current}}),O.current.search(K))},children:"搜索"}),h(i,{onClick:()=>{N(""),M.current&&O.current.search("")},style:{marginLeft:8},children:"重置"})]})})]}),u(l,{gutter:24,children:[h(r,{span:12,children:h(n.Item,{label:"经度",children:h(a,{disabled:!0,value:x})})}),h(r,{span:12,children:h(n.Item,{label:"纬度",children:h(a,{disabled:!0,value:A})})})]})]}),h("div",{ref:L,style:{width:"100%",height:"500px",position:"relative"},children:h(o,{size:"large",tip:"地图正在加载中...",spinning:B,children:h("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e3}})})})]})};w.displayName="MapSelector";export{w as default};
|
package/components/Map/index.js
CHANGED
|
@@ -1,90 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import MapSelector from './MapSelector.js';
|
|
4
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
const Map = props => {
|
|
7
|
-
const {
|
|
8
|
-
longitudeProps = "longitude",
|
|
9
|
-
latitudeProps = "latitude",
|
|
10
|
-
onConfirm,
|
|
11
|
-
required = true,
|
|
12
|
-
area = "",
|
|
13
|
-
showArea = false
|
|
14
|
-
} = props;
|
|
15
|
-
const form = Form.useFormInstance();
|
|
16
|
-
const [mapVisible, setMapVisible] = useState(false);
|
|
17
|
-
const [currentLongitude, setCurrentLongitude] = useState("");
|
|
18
|
-
const [currentLatitude, setCurrentLatitude] = useState("");
|
|
19
|
-
const handleMapConfirm = (longitudeValue, latitudeValue, extra) => {
|
|
20
|
-
setCurrentLongitude(longitudeValue);
|
|
21
|
-
setCurrentLatitude(latitudeValue);
|
|
22
|
-
form.setFieldsValue({
|
|
23
|
-
[longitudeProps]: longitudeValue,
|
|
24
|
-
[latitudeProps]: latitudeValue
|
|
25
|
-
});
|
|
26
|
-
onConfirm?.(longitudeValue, latitudeValue, extra);
|
|
27
|
-
setMapVisible(false);
|
|
28
|
-
};
|
|
29
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
30
|
-
children: [/*#__PURE__*/jsxs(Row, {
|
|
31
|
-
gutter: 24,
|
|
32
|
-
children: [/*#__PURE__*/jsx(Col, {
|
|
33
|
-
span: 12,
|
|
34
|
-
children: /*#__PURE__*/jsx(Form.Item, {
|
|
35
|
-
label: "\u7ECF\u5EA6",
|
|
36
|
-
name: longitudeProps,
|
|
37
|
-
rules: [{
|
|
38
|
-
required,
|
|
39
|
-
message: "请选择经度"
|
|
40
|
-
}],
|
|
41
|
-
children: /*#__PURE__*/jsx(Input, {
|
|
42
|
-
disabled: true
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
}), /*#__PURE__*/jsx(Col, {
|
|
46
|
-
span: 12,
|
|
47
|
-
children: /*#__PURE__*/jsx(Form.Item, {
|
|
48
|
-
label: "\u7EAC\u5EA6",
|
|
49
|
-
required: required,
|
|
50
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
51
|
-
style: {
|
|
52
|
-
display: "flex",
|
|
53
|
-
gap: 10
|
|
54
|
-
},
|
|
55
|
-
children: [/*#__PURE__*/jsx(Form.Item, {
|
|
56
|
-
name: latitudeProps,
|
|
57
|
-
noStyle: true,
|
|
58
|
-
rules: [{
|
|
59
|
-
required,
|
|
60
|
-
message: "请选择纬度"
|
|
61
|
-
}],
|
|
62
|
-
children: /*#__PURE__*/jsx(Input, {
|
|
63
|
-
disabled: true
|
|
64
|
-
})
|
|
65
|
-
}), /*#__PURE__*/jsx(Button, {
|
|
66
|
-
type: "primary",
|
|
67
|
-
onClick: () => {
|
|
68
|
-
setMapVisible(true);
|
|
69
|
-
setCurrentLongitude(form.getFieldValue(longitudeProps));
|
|
70
|
-
setCurrentLatitude(form.getFieldValue(latitudeProps));
|
|
71
|
-
},
|
|
72
|
-
children: "\u5730\u56FE\u5B9A\u4F4D"
|
|
73
|
-
})]
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
})]
|
|
77
|
-
}), /*#__PURE__*/jsx(MapSelector, {
|
|
78
|
-
visible: mapVisible,
|
|
79
|
-
onClose: () => setMapVisible(false),
|
|
80
|
-
longitude: currentLongitude,
|
|
81
|
-
latitude: currentLatitude,
|
|
82
|
-
area: area,
|
|
83
|
-
showArea: showArea,
|
|
84
|
-
onConfirm: handleMapConfirm
|
|
85
|
-
})]
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
Map.displayName = "Map";
|
|
89
|
-
|
|
90
|
-
export { Map as default };
|
|
1
|
+
import{Form as e,Row as r,Col as l,Input as i,Button as a}from"antd";import{useState as t}from"react";import d from"./MapSelector.js";import{jsxs as n,Fragment as o,jsx as s}from"react/jsx-runtime";const m=m=>{const{longitudeProps:u="longitude",latitudeProps:c="latitude",onConfirm:p,required:h=!0,area:g="",showArea:f=!1}=m,y=e.useFormInstance(),[b,q]=t(!1),[C,F]=t(""),[I,x]=t("");return n(o,{children:[n(r,{gutter:24,children:[s(l,{span:12,children:s(e.Item,{label:"经度",name:u,rules:[{required:h,message:"请选择经度"}],children:s(i,{disabled:!0})})}),s(l,{span:12,children:s(e.Item,{label:"纬度",required:h,children:n("div",{style:{display:"flex",gap:10},children:[s(e.Item,{name:c,noStyle:!0,rules:[{required:h,message:"请选择纬度"}],children:s(i,{disabled:!0})}),s(a,{type:"primary",onClick:()=>{q(!0),F(y.getFieldValue(u)),x(y.getFieldValue(c))},children:"地图定位"})]})})})]}),s(d,{visible:b,onClose:()=>q(!1),longitude:C,latitude:I,area:g,showArea:f,onConfirm:(e,r,l)=>{F(e),x(r),y.setFieldsValue({[u]:e,[c]:r}),p?.(e,r,l),q(!1)}})]})};m.displayName="Map";export{m as default};
|
package/components/Page/index.js
CHANGED
|
@@ -1,59 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import HeaderBack from '../HeaderBack/index.js';
|
|
3
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
function Page(props) {
|
|
6
|
-
const {
|
|
7
|
-
headerTitle,
|
|
8
|
-
history,
|
|
9
|
-
isShowHeader = true,
|
|
10
|
-
headerPrevious = true,
|
|
11
|
-
isShowFooter = true,
|
|
12
|
-
isShowAllAction = true,
|
|
13
|
-
backButtonText = "关闭",
|
|
14
|
-
contentPadding = "20px",
|
|
15
|
-
customActionButtons,
|
|
16
|
-
extraActionButtons
|
|
17
|
-
} = props;
|
|
18
|
-
return /*#__PURE__*/jsxs("div", {
|
|
19
|
-
className: "page",
|
|
20
|
-
children: [isShowAllAction && isShowHeader && /*#__PURE__*/jsx(HeaderBack, {
|
|
21
|
-
title: headerTitle,
|
|
22
|
-
history: history,
|
|
23
|
-
previous: headerPrevious
|
|
24
|
-
}), /*#__PURE__*/jsx("div", {
|
|
25
|
-
style: {
|
|
26
|
-
padding: contentPadding
|
|
27
|
-
},
|
|
28
|
-
children: props.children
|
|
29
|
-
}), isShowAllAction && isShowFooter && /*#__PURE__*/jsxs("div", {
|
|
30
|
-
style: {
|
|
31
|
-
transform: 'scale(1)',
|
|
32
|
-
margin: '0px -44px'
|
|
33
|
-
},
|
|
34
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
35
|
-
style: {
|
|
36
|
-
height: "52px"
|
|
37
|
-
}
|
|
38
|
-
}), /*#__PURE__*/jsx("div", {
|
|
39
|
-
style: {
|
|
40
|
-
textAlign: "center",
|
|
41
|
-
backgroundColor: "rgb(241, 241, 242)",
|
|
42
|
-
padding: "10px 0",
|
|
43
|
-
position: "fixed",
|
|
44
|
-
bottom: "0",
|
|
45
|
-
width: "100%"
|
|
46
|
-
},
|
|
47
|
-
children: customActionButtons || /*#__PURE__*/jsxs(Space, {
|
|
48
|
-
children: [extraActionButtons, /*#__PURE__*/jsx(Button, {
|
|
49
|
-
onClick: () => history?.goBack?.() || window.history.back(),
|
|
50
|
-
children: backButtonText
|
|
51
|
-
})]
|
|
52
|
-
})
|
|
53
|
-
})]
|
|
54
|
-
})]
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
Page.displayName = "Page";
|
|
58
|
-
|
|
59
|
-
export { Page as default };
|
|
1
|
+
import{Space as e,Button as t}from"antd";import{useState as i,useEffect as o}from"react";import r from"../HeaderBack/index.js";import{jsxs as n,jsx as d,Fragment as s}from"react/jsx-runtime";function a(a){const{headerTitle:c,history:l,isShowHeader:h=!0,headerPrevious:m=!0,isShowFooter:p=!0,isShowAllAction:u=!0,backButtonText:g="关闭",contentPadding:w="20px",customActionButtons:x,extraActionButtons:f}=a,[v,y]=i(window.innerWidth),k=()=>{const e=document.querySelector("#page");e&&y(e.offsetWidth)};return o(()=>{const e=setTimeout(()=>{k()},0);return u&&p&&window.addEventListener("resize",k),()=>{u&&p&&window.removeEventListener("resize",k),clearTimeout(e)}},[u,p]),n("div",{className:"page",id:"page",children:[u&&h&&d(r,{title:c,history:l,previous:m}),n("div",{style:{padding:w},children:[a.children,u&&p&&n(s,{children:[d("div",{style:{height:"52px"}}),d("div",{style:{textAlign:"center",backgroundColor:"rgb(241, 241, 242)",padding:"10px 0",position:"fixed",bottom:"0",width:v,margin:"0px -20px"},children:x||n(e,{children:[f,d(t,{onClick:()=>l?.goBack?.()||window.history.back(),children:g})]})})]})]})]})}a.displayName="Page";export{a as default};
|
package/components/Pdf/index.js
CHANGED
|
@@ -1,136 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Modal, Button, Spin, message } from 'antd';
|
|
3
|
-
import { useState, useRef } from 'react';
|
|
4
|
-
import { pdfjs, Document, Page } from 'react-pdf';
|
|
5
|
-
import useDownloadFile from '../../hooks/useDownloadFile/index.js';
|
|
6
|
-
import { getFileUrl } from '../../utils/index.js';
|
|
7
|
-
import 'react-pdf/dist/Page/AnnotationLayer.css';
|
|
8
|
-
import 'react-pdf/dist/Page/TextLayer.css';
|
|
9
|
-
import './index.less';
|
|
10
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
11
|
-
|
|
12
|
-
function Pdf(props) {
|
|
13
|
-
const {
|
|
14
|
-
visible = false,
|
|
15
|
-
onCancel,
|
|
16
|
-
file,
|
|
17
|
-
name,
|
|
18
|
-
inline = false,
|
|
19
|
-
style = {}
|
|
20
|
-
} = props;
|
|
21
|
-
const fileUrl = getFileUrl();
|
|
22
|
-
const [numPages, setNumPages] = useState(0);
|
|
23
|
-
const [pdfWidth, setPdfWidth] = useState(600);
|
|
24
|
-
const [loading, setLoading] = useState(true);
|
|
25
|
-
const fullscreenRef = useRef(null);
|
|
26
|
-
const [isFullscreen, {
|
|
27
|
-
enterFullscreen,
|
|
28
|
-
exitFullscreen
|
|
29
|
-
}] = useFullscreen(fullscreenRef);
|
|
30
|
-
const {
|
|
31
|
-
downloadFile
|
|
32
|
-
} = useDownloadFile();
|
|
33
|
-
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
|
|
34
|
-
const onDocumentLoadSuccess = ({
|
|
35
|
-
numPages
|
|
36
|
-
}) => {
|
|
37
|
-
setNumPages(numPages);
|
|
38
|
-
setLoading(false);
|
|
39
|
-
};
|
|
40
|
-
const onDocumentLoadError = () => {
|
|
41
|
-
setLoading(false);
|
|
42
|
-
message.error("加载 PDF 文件失败");
|
|
43
|
-
if (onCancel) onCancel();
|
|
44
|
-
};
|
|
45
|
-
const onPageLoadSuccess = ({
|
|
46
|
-
width
|
|
47
|
-
}) => {
|
|
48
|
-
setPdfWidth(width);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// 内联模式的PDF内容
|
|
52
|
-
const renderPdfContent = () => /*#__PURE__*/jsxs(Fragment, {
|
|
53
|
-
children: [loading && /*#__PURE__*/jsx("div", {
|
|
54
|
-
style: {
|
|
55
|
-
display: "flex",
|
|
56
|
-
justifyContent: "center",
|
|
57
|
-
alignItems: "center",
|
|
58
|
-
height: "72vh"
|
|
59
|
-
},
|
|
60
|
-
children: /*#__PURE__*/jsx(Spin, {
|
|
61
|
-
size: "large"
|
|
62
|
-
})
|
|
63
|
-
}), /*#__PURE__*/jsx("div", {
|
|
64
|
-
style: {
|
|
65
|
-
height: isFullscreen ? "calc(100vh - 40px - 24px - 8px - 32px - 12px)" : "72vh",
|
|
66
|
-
overflowY: "auto",
|
|
67
|
-
padding: "24px",
|
|
68
|
-
...style
|
|
69
|
-
},
|
|
70
|
-
children: /*#__PURE__*/jsx(Document, {
|
|
71
|
-
file: !file.includes(fileUrl) ? fileUrl + file : file,
|
|
72
|
-
onLoadSuccess: onDocumentLoadSuccess,
|
|
73
|
-
onLoadError: onDocumentLoadError,
|
|
74
|
-
children: Array.from({
|
|
75
|
-
length: numPages
|
|
76
|
-
}).map((_, index) => /*#__PURE__*/jsx(Page, {
|
|
77
|
-
pageNumber: index + 1,
|
|
78
|
-
onLoadSuccess: onPageLoadSuccess
|
|
79
|
-
}, `page_${index + 1}`))
|
|
80
|
-
})
|
|
81
|
-
})]
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// 如果是内联模式,直接返回PDF内容
|
|
85
|
-
if (inline) {
|
|
86
|
-
return renderPdfContent();
|
|
87
|
-
}
|
|
88
|
-
const onDownloadFile = () => {
|
|
89
|
-
isFullscreen && exitFullscreen();
|
|
90
|
-
downloadFile({
|
|
91
|
-
url: file,
|
|
92
|
-
name
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// 默认弹窗模式
|
|
97
|
-
return /*#__PURE__*/jsx("div", {
|
|
98
|
-
ref: fullscreenRef,
|
|
99
|
-
children: /*#__PURE__*/jsx(Modal, {
|
|
100
|
-
style: {
|
|
101
|
-
top: isFullscreen ? 0 : 100,
|
|
102
|
-
maxWidth: isFullscreen ? "100vw" : "calc(100vw - 32px)",
|
|
103
|
-
paddingBottom: isFullscreen ? 0 : 24
|
|
104
|
-
},
|
|
105
|
-
open: visible,
|
|
106
|
-
maskClosable: false,
|
|
107
|
-
width: isFullscreen ? "100vw" : pdfWidth + 100,
|
|
108
|
-
title: "PDF\u9884\u89C8",
|
|
109
|
-
onCancel: () => {
|
|
110
|
-
isFullscreen && exitFullscreen();
|
|
111
|
-
onCancel();
|
|
112
|
-
},
|
|
113
|
-
getContainer: false,
|
|
114
|
-
footer: [/*#__PURE__*/jsx(Button, {
|
|
115
|
-
onClick: () => {
|
|
116
|
-
isFullscreen && exitFullscreen();
|
|
117
|
-
onCancel();
|
|
118
|
-
},
|
|
119
|
-
children: "\u5173\u95ED"
|
|
120
|
-
}, "cancel"), !loading && /*#__PURE__*/jsx(Button, {
|
|
121
|
-
onClick: () => {
|
|
122
|
-
isFullscreen ? exitFullscreen() : enterFullscreen();
|
|
123
|
-
},
|
|
124
|
-
children: isFullscreen ? "退出全屏" : "全屏"
|
|
125
|
-
}, "fullScreen"), /*#__PURE__*/jsx(Button, {
|
|
126
|
-
type: "primary",
|
|
127
|
-
onClick: onDownloadFile,
|
|
128
|
-
children: "\u4E0B\u8F7D"
|
|
129
|
-
}, "download")],
|
|
130
|
-
children: renderPdfContent()
|
|
131
|
-
})
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
Pdf.displayName = "Pdf";
|
|
135
|
-
|
|
136
|
-
export { Pdf as default };
|
|
1
|
+
import{useFullscreen as e}from"ahooks";import{Modal as r,Button as o,Spin as i,message as n}from"antd";import{useState as t,useRef as l}from"react";import{pdfjs as a,Document as d,Page as s}from"react-pdf";import c from"../../hooks/useDownloadFile/index.js";import{getFileUrl as p}from"../../utils/index.js";import"react-pdf/dist/Page/AnnotationLayer.css";import"react-pdf/dist/Page/TextLayer.css";import"./index.less";import{jsxs as m,jsx as f,Fragment as h}from"react/jsx-runtime";function u(u){const{visible:x=!1,onCancel:g,file:v,name:y,inline:w=!1,style:k={}}=u,C=p(),[j,F]=t(0),[P,b]=t(600),[L,S]=t(!0),D=l(null),[A,{enterFullscreen:N,exitFullscreen:W}]=e(D),{downloadFile:$}=c();a.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${a.version}/build/pdf.worker.min.mjs`;const z=({numPages:e})=>{F(e),S(!1)},B=()=>{S(!1),n.error("加载 PDF 文件失败"),g&&g()},E=({width:e})=>{b(e)},G=()=>m(h,{children:[L&&f("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"72vh"},children:f(i,{size:"large"})}),f("div",{style:{height:A?"calc(100vh - 40px - 24px - 8px - 32px - 12px)":"72vh",overflowY:"auto",padding:"24px",...k},children:f(d,{file:v.includes(C)?v:C+v,onLoadSuccess:z,onLoadError:B,children:Array.from({length:j}).map((e,r)=>f(s,{pageNumber:r+1,onLoadSuccess:E},`page_${r+1}`))})})]});return w?G():f("div",{ref:D,children:f(r,{style:{top:A?0:100,maxWidth:A?"100vw":"calc(100vw - 32px)",paddingBottom:A?0:24},open:x,maskClosable:!1,width:A?"100vw":P+100,title:"PDF预览",onCancel:()=>{A&&W(),g()},getContainer:!1,footer:[f(o,{onClick:()=>{A&&W(),g()},children:"关闭"},"cancel"),!L&&f(o,{onClick:()=>{A?W():N()},children:A?"退出全屏":"全屏"},"fullScreen"),f(o,{type:"primary",onClick:()=>{A&&W(),$({url:v,name:y})},children:"下载"},"download")],children:G()})})}u.displayName="Pdf";export{u as default};
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getFileUrl } from '../../utils/index.js';
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
const PreviewImg = props => {
|
|
6
|
-
const {
|
|
7
|
-
files = [],
|
|
8
|
-
fileUrlKey = "filePath"
|
|
9
|
-
} = props;
|
|
10
|
-
const fileUrl = getFileUrl();
|
|
11
|
-
return /*#__PURE__*/jsx(Image.PreviewGroup, {
|
|
12
|
-
children: files.filter(Boolean).map(item => /*#__PURE__*/jsx(Image, {
|
|
13
|
-
src: item[fileUrlKey] ? fileUrl + item[fileUrlKey] : fileUrl + item,
|
|
14
|
-
wrapperStyle: {
|
|
15
|
-
marginRight: 10,
|
|
16
|
-
marginBottom: 10
|
|
17
|
-
},
|
|
18
|
-
width: 100,
|
|
19
|
-
height: 100,
|
|
20
|
-
alt: ""
|
|
21
|
-
}, item[fileUrlKey] || item))
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
PreviewImg.displayName = "PreviewImg";
|
|
25
|
-
|
|
26
|
-
export { PreviewImg as default };
|
|
1
|
+
import{Image as r}from"antd";import{getFileUrl as e}from"../../utils/index.js";import{jsx as t}from"react/jsx-runtime";const i=i=>{const{files:o=[],fileUrlKey:a="filePath"}=i,m=e();return t(r.PreviewGroup,{children:o.filter(Boolean).map(e=>t(r,{src:e[a]?m+e[a]:m+e,wrapperStyle:{marginRight:10,marginBottom:10},width:100,height:100,alt:""},e[a]||e))})};i.displayName="PreviewImg";export{i as default};
|
|
@@ -1,78 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import Pdf from '../Pdf/index.js';
|
|
4
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
const PreviewPdf = props => {
|
|
7
|
-
const {
|
|
8
|
-
files = [],
|
|
9
|
-
nameKey = "",
|
|
10
|
-
urlKey = "",
|
|
11
|
-
name = "",
|
|
12
|
-
url = ""
|
|
13
|
-
} = props;
|
|
14
|
-
const [visible, setVisible] = useState(false);
|
|
15
|
-
const [currentSrc, setCurrentSrc] = useState("");
|
|
16
|
-
const [currentName, setCurrentName] = useState("");
|
|
17
|
-
const previewPdf = (src, name) => {
|
|
18
|
-
setVisible(true);
|
|
19
|
-
setCurrentSrc(src);
|
|
20
|
-
setCurrentName(name);
|
|
21
|
-
};
|
|
22
|
-
const onCancel = () => {
|
|
23
|
-
setVisible(false);
|
|
24
|
-
setCurrentSrc("");
|
|
25
|
-
setCurrentName("");
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// 单个文件预览模式
|
|
29
|
-
if (files.length === 0 && name && url) {
|
|
30
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
31
|
-
children: [/*#__PURE__*/jsxs(Space, {
|
|
32
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
33
|
-
children: name
|
|
34
|
-
}), /*#__PURE__*/jsx(Button, {
|
|
35
|
-
type: "primary",
|
|
36
|
-
size: "small",
|
|
37
|
-
onClick: () => previewPdf(url, name),
|
|
38
|
-
children: "\u9884\u89C8"
|
|
39
|
-
})]
|
|
40
|
-
}), /*#__PURE__*/jsx(Pdf, {
|
|
41
|
-
visible: visible,
|
|
42
|
-
file: currentSrc,
|
|
43
|
-
name: currentName,
|
|
44
|
-
onCancel: onCancel
|
|
45
|
-
})]
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// 多文件预览模式
|
|
50
|
-
if (files.length > 0 && !name && !url) {
|
|
51
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
52
|
-
children: [files.map(item => /*#__PURE__*/jsx("div", {
|
|
53
|
-
style: {
|
|
54
|
-
marginTop: 5
|
|
55
|
-
},
|
|
56
|
-
children: /*#__PURE__*/jsxs(Space, {
|
|
57
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
58
|
-
children: item.name || item.fileName || item[nameKey]
|
|
59
|
-
}), /*#__PURE__*/jsx(Button, {
|
|
60
|
-
type: "primary",
|
|
61
|
-
size: "small",
|
|
62
|
-
onClick: () => previewPdf(item.filePath || item[urlKey], item.name || item.fileName || item[nameKey]),
|
|
63
|
-
children: "\u9884\u89C8"
|
|
64
|
-
})]
|
|
65
|
-
})
|
|
66
|
-
}, item.filePath || item[urlKey])), /*#__PURE__*/jsx(Pdf, {
|
|
67
|
-
visible: visible,
|
|
68
|
-
file: currentSrc,
|
|
69
|
-
name: currentName,
|
|
70
|
-
onCancel: onCancel
|
|
71
|
-
})]
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
};
|
|
76
|
-
PreviewPdf.displayName = "PreviewPdf";
|
|
77
|
-
|
|
78
|
-
export { PreviewPdf as default };
|
|
1
|
+
import{Space as e,Button as i}from"antd";import{useState as l}from"react";import n from"../Pdf/index.js";import{jsxs as r,Fragment as a,jsx as m}from"react/jsx-runtime";const t=t=>{const{files:c=[],nameKey:d="",urlKey:o="",name:s="",url:f=""}=t,[p,h]=l(!1),[y,u]=l(""),[P,v]=l(""),C=(e,i)=>{h(!0),u(e),v(i)},g=()=>{h(!1),u(""),v("")};return 0===c.length&&s&&f?r(a,{children:[r(e,{children:[m("span",{children:s}),m(i,{type:"primary",size:"small",onClick:()=>C(f,s),children:"预览"})]}),m(n,{visible:p,file:y,name:P,onCancel:g})]}):c.length>0&&!s&&!f?r(a,{children:[c.map(l=>m("div",{style:{marginTop:5},children:r(e,{children:[m("span",{children:l.name||l.fileName||l[d]}),m(i,{type:"primary",size:"small",onClick:()=>C(l.filePath||l[o],l.name||l.fileName||l[d]),children:"预览"})]})},l.filePath||l[o])),m(n,{visible:p,file:y,name:P,onCancel:g})]}):null};t.displayName="PreviewPdf";export{t as default};
|