@cqsjjb/jjb-react-admin-component 3.3.1-beta.0 → 3.3.1-beta.10
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/AMap/README.md +58 -0
- package/AMap/index.d.ts +40 -0
- package/AMap/index.js +372 -0
- package/AMap/index.less +19 -0
- package/AdaptiveTree/index.js +19 -5
- package/BMap/README.md +1 -1
- package/BMap/index.less +31 -32
- package/PhoneBox/dianchi.png +0 -0
- package/PhoneBox/dianchi.svg +1 -0
- package/PhoneBox/index.d.ts +21 -0
- package/PhoneBox/index.js +205 -0
- package/PhoneBox/index.less +116 -0
- package/PhoneBox/phone.png +0 -0
- package/PhoneBox/phone.svg +135 -0
- package/PhoneBox/shexiang.png +0 -0
- package/PhoneBox/shexiang.svg +61 -0
- package/PhoneBox/wangluo.png +0 -0
- package/PhoneBox/wangluo.svg +1 -0
- package/PhoneBox/xinhao.png +0 -0
- package/PhoneBox/xinhao.svg +1 -0
- package/Table/index.js +5 -4
- package/package.json +9 -8
- package/tools/index.js +87 -0
package/AMap/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
高德地图组件
|
|
2
|
+
|
|
3
|
+
## 代码演示
|
|
4
|
+
|
|
5
|
+
```jsx
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { Button } from 'antd';
|
|
8
|
+
import AMap from '@cqsjjb/jjb-react-admin-component/AMap';
|
|
9
|
+
|
|
10
|
+
function App() {
|
|
11
|
+
const [ open, setOpen ] = useState(false);
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<Button onClick={() => setOpen(true)}>打开地图</Button>
|
|
15
|
+
{open && (
|
|
16
|
+
<AMap
|
|
17
|
+
onOk={data => {
|
|
18
|
+
console.log(data);
|
|
19
|
+
setOpen(false);
|
|
20
|
+
}}
|
|
21
|
+
onCacnel={() => {
|
|
22
|
+
setOpen(false);
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
)}
|
|
26
|
+
</>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
34
|
+
|----------|:-----|:---------------------------------------------------------------------------------------------------------:|--------:|
|
|
35
|
+
| lng | 经度 | `number` | 116.404 |
|
|
36
|
+
| lat | 纬度 | `number` | 39.915 |
|
|
37
|
+
| title | 弹窗标题 | `string` | 高德地图 |
|
|
38
|
+
| width | 弹窗宽度 | `number` | 700 |
|
|
39
|
+
| onOk | 确认回调 | (data: { lng: number, lat: number, comp: <span style="color: red">IComp</span>, compText: Text }) => void | - |
|
|
40
|
+
| onCancel | 取消回调 | `() => void` | 700 |
|
|
41
|
+
|
|
42
|
+
## 确认回调-IComp
|
|
43
|
+
|
|
44
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
45
|
+
|--------------|:----|:--------:|----:|
|
|
46
|
+
| province | 省份 | `string` | - |
|
|
47
|
+
| city | 城市 | `string` | - |
|
|
48
|
+
| district | 区县 | `string` | - |
|
|
49
|
+
| street | 街道 | `string` | - |
|
|
50
|
+
| streetNumber | 门牌号 | `string` | - |
|
|
51
|
+
|
|
52
|
+
## 常见问题
|
|
53
|
+
* 加载地图失败,缺少必要的文件!
|
|
54
|
+
|
|
55
|
+
请确认应用public/index.html中是否导入高德地图SDK。
|
|
56
|
+
* onOk确认回调compText为undefined
|
|
57
|
+
|
|
58
|
+
请确认高德地图是否授权Web应用。
|
package/AMap/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface AMapProps {
|
|
4
|
+
/** 初始经度 默认-116.404 */
|
|
5
|
+
lng?: number;
|
|
6
|
+
/** 初始纬度 默认-39.915 */
|
|
7
|
+
lat?: number;
|
|
8
|
+
/** 标题 默认-高德地图 */
|
|
9
|
+
title?: string;
|
|
10
|
+
/** 地图弹窗宽度 默认-700 */
|
|
11
|
+
width?: number;
|
|
12
|
+
/** 确认事件 返回选择的位置信息 */
|
|
13
|
+
onOk?: (data: {
|
|
14
|
+
// 经度
|
|
15
|
+
lng: number;
|
|
16
|
+
// 纬度
|
|
17
|
+
lat: number;
|
|
18
|
+
// 选择的位置信息对象
|
|
19
|
+
comp?: {
|
|
20
|
+
// 省份
|
|
21
|
+
province: string;
|
|
22
|
+
// 城市
|
|
23
|
+
city: string;
|
|
24
|
+
// 区县
|
|
25
|
+
district: string;
|
|
26
|
+
// 街道
|
|
27
|
+
street: string;
|
|
28
|
+
// 门牌号
|
|
29
|
+
streetNumber: string;
|
|
30
|
+
};
|
|
31
|
+
// 选择的位置详细信息文本
|
|
32
|
+
compText?: string;
|
|
33
|
+
}) => void;
|
|
34
|
+
/** 取消事件 */
|
|
35
|
+
onCancel?: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare const AMap: React.FC<AMapProps>;
|
|
39
|
+
|
|
40
|
+
export default AMap;
|
package/AMap/index.js
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
|
2
|
+
import { Button, Col, message, Modal, Result, Row } from 'antd';
|
|
3
|
+
import './index.less';
|
|
4
|
+
const _A_MAP_SEARCH_ = '_A_MAP_SEARCH_';
|
|
5
|
+
const _A_MAP_DEFAULT_POINT_ = {
|
|
6
|
+
lng: 116.397437,
|
|
7
|
+
lat: 39.909148
|
|
8
|
+
};
|
|
9
|
+
export default function AMap({
|
|
10
|
+
lng: propLng,
|
|
11
|
+
lat: propLat,
|
|
12
|
+
title = '高德地图',
|
|
13
|
+
width = 700,
|
|
14
|
+
onOk,
|
|
15
|
+
onCancel
|
|
16
|
+
}) {
|
|
17
|
+
const [lng, setLng] = useState(_A_MAP_DEFAULT_POINT_.lng);
|
|
18
|
+
const [lat, setLat] = useState(_A_MAP_DEFAULT_POINT_.lat);
|
|
19
|
+
const GL = useRef(null);
|
|
20
|
+
const mapRef = useRef(null);
|
|
21
|
+
const markerRef = useRef(null);
|
|
22
|
+
const autoRef = useRef(null);
|
|
23
|
+
const placeSearchRef = useRef(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (typeof window.AMap === 'undefined') {
|
|
26
|
+
message.error('未导入高德地图文件,生成地图失败!').then(() => null);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
let mounted = true;
|
|
30
|
+
|
|
31
|
+
// 保证传入的初始值是 number(避免 NaN)
|
|
32
|
+
const initLng = Number(propLng) || _A_MAP_DEFAULT_POINT_.lng;
|
|
33
|
+
const initLat = Number(propLat) || _A_MAP_DEFAULT_POINT_.lat;
|
|
34
|
+
|
|
35
|
+
// 等待容器可见且尺寸非 0(Modal 动画或隐藏态时常为 0)
|
|
36
|
+
const waitForVisible = (el, timeout = 3000) => new Promise(resolve => {
|
|
37
|
+
const start = Date.now();
|
|
38
|
+
function check() {
|
|
39
|
+
if (!el) return resolve(false);
|
|
40
|
+
const r = el.getBoundingClientRect();
|
|
41
|
+
if (r.width > 0 && r.height > 0) return resolve(true);
|
|
42
|
+
if (Date.now() - start > timeout) return resolve(false);
|
|
43
|
+
requestAnimationFrame(check);
|
|
44
|
+
}
|
|
45
|
+
check();
|
|
46
|
+
});
|
|
47
|
+
async function init() {
|
|
48
|
+
if (!GL.current) {
|
|
49
|
+
console.warn('AMap container ref not ready');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const visible = await waitForVisible(GL.current, 3000);
|
|
53
|
+
if (!visible) {
|
|
54
|
+
// 继续也可,但记录一下。多数情况下等待后再 init 能解决 Pixel(NaN, 0)
|
|
55
|
+
console.warn('AMap container still not visible before init (proceeding anyway).');
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const map = new window.AMap.Map(GL.current, {
|
|
59
|
+
center: [initLng, initLat],
|
|
60
|
+
zoom: 18,
|
|
61
|
+
viewMode: '3D'
|
|
62
|
+
});
|
|
63
|
+
mapRef.current = map;
|
|
64
|
+
|
|
65
|
+
// 保证 state 与实际中心一致
|
|
66
|
+
setLng(initLng);
|
|
67
|
+
setLat(initLat);
|
|
68
|
+
|
|
69
|
+
// 插件加载、控件创建都做容错
|
|
70
|
+
window.AMap.plugin(['AMap.Scale', 'AMap.ToolBar', 'AMap.Geolocation', 'AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Geocoder'], () => {
|
|
71
|
+
try {
|
|
72
|
+
map.addControl(new window.AMap.Scale());
|
|
73
|
+
} catch (e) {
|
|
74
|
+
// 某些构建/版本中可能不存在
|
|
75
|
+
console.warn('Scale control failed', e);
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
map.addControl(new window.AMap.ToolBar({
|
|
79
|
+
position: 'RT'
|
|
80
|
+
}));
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.warn('ToolBar control failed', e);
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
// 使用合法角落(RB/RT/LB/LT),不要自定义 'BT'
|
|
86
|
+
const geolocation = new window.AMap.Geolocation({
|
|
87
|
+
position: 'RB',
|
|
88
|
+
offset: new window.AMap.Pixel(Number(20), Number(20)),
|
|
89
|
+
showCircle: false,
|
|
90
|
+
showButton: true
|
|
91
|
+
});
|
|
92
|
+
map.addControl(geolocation);
|
|
93
|
+
|
|
94
|
+
// 正确的回调签名 (status, result)
|
|
95
|
+
geolocation.getCurrentPosition((status, result) => {
|
|
96
|
+
if (status !== 'complete') {
|
|
97
|
+
// 不做致命处理,但提示
|
|
98
|
+
message.error('未开启定位,定位失败!');
|
|
99
|
+
} else {
|
|
100
|
+
// 如果需要可以从 result.position 取值
|
|
101
|
+
try {
|
|
102
|
+
const pos = result && result.position;
|
|
103
|
+
if (pos) {
|
|
104
|
+
const px = typeof pos.getLng === 'function' ? pos.getLng() : pos.lng;
|
|
105
|
+
const py = typeof pos.getLat === 'function' ? pos.getLat() : pos.lat;
|
|
106
|
+
if (!Number.isNaN(Number(px)) && !Number.isNaN(Number(py))) {
|
|
107
|
+
setLng(Number(px));
|
|
108
|
+
setLat(Number(py));
|
|
109
|
+
map.setCenter([Number(px), Number(py)]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} catch (e) {
|
|
113
|
+
// 忽略
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
} catch (e) {
|
|
118
|
+
console.warn('Geolocation init failed', e);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 初始 marker 放置
|
|
122
|
+
try {
|
|
123
|
+
markerRef.current = new window.AMap.Marker({
|
|
124
|
+
position: [initLng, initLat],
|
|
125
|
+
map
|
|
126
|
+
});
|
|
127
|
+
} catch (e) {
|
|
128
|
+
console.warn('Marker init failed', e);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// AutoComplete + PlaceSearch
|
|
132
|
+
try {
|
|
133
|
+
placeSearchRef.current = new window.AMap.PlaceSearch({
|
|
134
|
+
map
|
|
135
|
+
});
|
|
136
|
+
autoRef.current = new window.AMap.AutoComplete({
|
|
137
|
+
input: document.getElementById(_A_MAP_SEARCH_)
|
|
138
|
+
});
|
|
139
|
+
autoRef.current.on && autoRef.current.on('select', e => {
|
|
140
|
+
// e.poi 里可能是 AMap.LngLat 实例 / 对象 / 数组,做兼容处理
|
|
141
|
+
const poi = e && e.poi ? e.poi : null;
|
|
142
|
+
let loc = poi && (poi.location || poi.lnglat) || e && (e.location || e.lnglat) || null;
|
|
143
|
+
let foundLng = null;
|
|
144
|
+
let foundLat = null;
|
|
145
|
+
if (loc) {
|
|
146
|
+
if (typeof loc.getLng === 'function' && typeof loc.getLat === 'function') {
|
|
147
|
+
// AMap.LngLat 实例
|
|
148
|
+
foundLng = Number(loc.getLng());
|
|
149
|
+
foundLat = Number(loc.getLat());
|
|
150
|
+
} else if (typeof loc.lng === 'number' && typeof loc.lat === 'number') {
|
|
151
|
+
foundLng = Number(loc.lng);
|
|
152
|
+
foundLat = Number(loc.lat);
|
|
153
|
+
} else if (Array.isArray(loc)) {
|
|
154
|
+
foundLng = Number(loc[0]);
|
|
155
|
+
foundLat = Number(loc[1]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (foundLng != null && foundLat != null && !Number.isNaN(foundLng) && !Number.isNaN(foundLat)) {
|
|
159
|
+
setLng(foundLng);
|
|
160
|
+
setLat(foundLat);
|
|
161
|
+
map.setCenter([foundLng, foundLat]);
|
|
162
|
+
if (markerRef.current) {
|
|
163
|
+
markerRef.current.setPosition([foundLng, foundLat]);
|
|
164
|
+
} else {
|
|
165
|
+
markerRef.current = new window.AMap.Marker({
|
|
166
|
+
position: [foundLng, foundLat],
|
|
167
|
+
map
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
// 兜底:用 placeSearch 搜索 name(如果有)
|
|
172
|
+
const name = poi && (poi.name || poi.address) || e && (e.info || e.name);
|
|
173
|
+
if (name && placeSearchRef.current && placeSearchRef.current.search) {
|
|
174
|
+
placeSearchRef.current.search(name, (status, result) => {
|
|
175
|
+
// placeSearch 回调再处理,这里保持原有逻辑或按需增强
|
|
176
|
+
if (status === 'complete' && result && result.poiList && result.poiList.pois && result.poiList.pois.length > 0) {
|
|
177
|
+
const p = result.poiList.pois[0];
|
|
178
|
+
const loc2 = p.location || p.lnglat;
|
|
179
|
+
let x = null,
|
|
180
|
+
y = null;
|
|
181
|
+
if (loc2) {
|
|
182
|
+
if (typeof loc2.getLng === 'function') {
|
|
183
|
+
x = Number(loc2.getLng());
|
|
184
|
+
y = Number(loc2.getLat());
|
|
185
|
+
} else if (typeof loc2.lng === 'number') {
|
|
186
|
+
x = Number(loc2.lng);
|
|
187
|
+
y = Number(loc2.lat);
|
|
188
|
+
} else if (Array.isArray(loc2)) {
|
|
189
|
+
x = Number(loc2[0]);
|
|
190
|
+
y = Number(loc2[1]);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (!Number.isNaN(x) && !Number.isNaN(y)) {
|
|
194
|
+
setLng(x);
|
|
195
|
+
setLat(y);
|
|
196
|
+
map.setCenter([x, y]);
|
|
197
|
+
if (markerRef.current) markerRef.current.setPosition([x, y]);else markerRef.current = new window.AMap.Marker({
|
|
198
|
+
position: [x, y],
|
|
199
|
+
map
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
} catch (e) {
|
|
208
|
+
console.warn('AutoComplete / PlaceSearch init failed', e);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 点击选点
|
|
212
|
+
try {
|
|
213
|
+
map.on && map.on('click', e => {
|
|
214
|
+
const lnglat = e && e.lnglat;
|
|
215
|
+
if (!lnglat) return;
|
|
216
|
+
let clickLng = null;
|
|
217
|
+
let clickLat = null;
|
|
218
|
+
if (typeof lnglat.getLng === 'function') {
|
|
219
|
+
clickLng = Number(lnglat.getLng());
|
|
220
|
+
clickLat = Number(lnglat.getLat());
|
|
221
|
+
} else {
|
|
222
|
+
clickLng = Number(lnglat.lng || Array.isArray(lnglat) && lnglat[0]);
|
|
223
|
+
clickLat = Number(lnglat.lat || Array.isArray(lnglat) && lnglat[1]);
|
|
224
|
+
}
|
|
225
|
+
if (Number.isNaN(clickLng) || Number.isNaN(clickLat)) return;
|
|
226
|
+
setLng(clickLng);
|
|
227
|
+
setLat(clickLat);
|
|
228
|
+
if (markerRef.current) {
|
|
229
|
+
markerRef.current.setPosition([clickLng, clickLat]);
|
|
230
|
+
} else {
|
|
231
|
+
markerRef.current = new window.AMap.Marker({
|
|
232
|
+
position: [clickLng, clickLat],
|
|
233
|
+
map
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
} catch (e) {
|
|
238
|
+
console.warn('map.on click failed', e);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
} catch (err) {
|
|
242
|
+
console.error('AMap init error', err);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
init();
|
|
246
|
+
|
|
247
|
+
// cleanup
|
|
248
|
+
return () => {
|
|
249
|
+
mounted = false;
|
|
250
|
+
try {
|
|
251
|
+
if (mapRef.current) {
|
|
252
|
+
mapRef.current.destroy();
|
|
253
|
+
mapRef.current = null;
|
|
254
|
+
}
|
|
255
|
+
} catch (e) {
|
|
256
|
+
// ignore
|
|
257
|
+
}
|
|
258
|
+
markerRef.current = null;
|
|
259
|
+
autoRef.current = null;
|
|
260
|
+
placeSearchRef.current = null;
|
|
261
|
+
};
|
|
262
|
+
}, [propLng, propLat]);
|
|
263
|
+
|
|
264
|
+
// 重置、确认等操作(同样做 number guard)
|
|
265
|
+
const onResetMap = useCallback(() => {
|
|
266
|
+
const map = mapRef.current;
|
|
267
|
+
if (!map) return;
|
|
268
|
+
const x = Number(_A_MAP_DEFAULT_POINT_.lng);
|
|
269
|
+
const y = Number(_A_MAP_DEFAULT_POINT_.lat);
|
|
270
|
+
setLng(x);
|
|
271
|
+
setLat(y);
|
|
272
|
+
try {
|
|
273
|
+
map.setCenter([x, y]);
|
|
274
|
+
if (markerRef.current) {
|
|
275
|
+
markerRef.current.setPosition([x, y]);
|
|
276
|
+
} else {
|
|
277
|
+
markerRef.current = new window.AMap.Marker({
|
|
278
|
+
position: [x, y],
|
|
279
|
+
map
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
} catch (e) {
|
|
283
|
+
console.warn('reset map failed', e);
|
|
284
|
+
}
|
|
285
|
+
}, []);
|
|
286
|
+
const handleOk = useCallback(() => {
|
|
287
|
+
if (!mapRef.current) return;
|
|
288
|
+
// 确保 lng/lat 是 number
|
|
289
|
+
const x = Number(lng);
|
|
290
|
+
const y = Number(lat);
|
|
291
|
+
if (Number.isNaN(x) || Number.isNaN(y)) {
|
|
292
|
+
onOk && onOk({
|
|
293
|
+
lng,
|
|
294
|
+
lat,
|
|
295
|
+
comp: undefined,
|
|
296
|
+
compText: undefined
|
|
297
|
+
});
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
window.AMap.plugin('AMap.Geocoder', () => {
|
|
301
|
+
try {
|
|
302
|
+
const geocoder = new window.AMap.Geocoder();
|
|
303
|
+
geocoder.getAddress([x, y], (status, result) => {
|
|
304
|
+
let comp;
|
|
305
|
+
if (status === 'complete' && result && result.regeocode) {
|
|
306
|
+
comp = result.regeocode.addressComponent;
|
|
307
|
+
}
|
|
308
|
+
onOk && onOk({
|
|
309
|
+
lng: x,
|
|
310
|
+
lat: y,
|
|
311
|
+
comp,
|
|
312
|
+
compText: comp && [comp.province, comp.city, comp.district, comp.township, comp.street, comp.streetNumber].filter(Boolean).join('') || undefined
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
} catch (e) {
|
|
316
|
+
onOk && onOk({
|
|
317
|
+
lng: x,
|
|
318
|
+
lat: y,
|
|
319
|
+
comp: undefined,
|
|
320
|
+
compText: undefined
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}, [lng, lat, onOk]);
|
|
325
|
+
const hasMapScript = typeof window.AMap !== 'undefined';
|
|
326
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
327
|
+
open: true,
|
|
328
|
+
destroyOnClose: true,
|
|
329
|
+
title: title,
|
|
330
|
+
width: width,
|
|
331
|
+
footer: hasMapScript && /*#__PURE__*/React.createElement(Row, {
|
|
332
|
+
align: "middle",
|
|
333
|
+
justify: "space-between"
|
|
334
|
+
}, /*#__PURE__*/React.createElement(Col, null, "\u5750\u6807\uFF1A", [lng, lat].join('-')), /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/React.createElement(Button, {
|
|
335
|
+
ghost: true,
|
|
336
|
+
type: "primary",
|
|
337
|
+
style: {
|
|
338
|
+
marginRight: 12
|
|
339
|
+
},
|
|
340
|
+
onClick: onResetMap
|
|
341
|
+
}, "\u91CD\u7F6E\u5730\u56FE"), /*#__PURE__*/React.createElement(Button, {
|
|
342
|
+
type: "primary",
|
|
343
|
+
onClick: handleOk
|
|
344
|
+
}, "\u786E\u8BA4\u5750\u6807"))),
|
|
345
|
+
maskClosable: false,
|
|
346
|
+
onCancel: () => onCancel && onCancel()
|
|
347
|
+
}, hasMapScript ? /*#__PURE__*/React.createElement("div", {
|
|
348
|
+
style: {
|
|
349
|
+
position: 'relative'
|
|
350
|
+
}
|
|
351
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
352
|
+
ref: GL,
|
|
353
|
+
style: {
|
|
354
|
+
height: 500,
|
|
355
|
+
userSelect: 'none'
|
|
356
|
+
}
|
|
357
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
358
|
+
id: _A_MAP_SEARCH_,
|
|
359
|
+
type: "text",
|
|
360
|
+
maxLength: 30,
|
|
361
|
+
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u5B57\u67E5\u8BE2",
|
|
362
|
+
style: {
|
|
363
|
+
position: 'absolute',
|
|
364
|
+
top: 10,
|
|
365
|
+
left: 10,
|
|
366
|
+
zIndex: 1000
|
|
367
|
+
}
|
|
368
|
+
})) : /*#__PURE__*/React.createElement(Result, {
|
|
369
|
+
status: "error",
|
|
370
|
+
title: "\u52A0\u8F7D\u5730\u56FE\u5931\u8D25\uFF0C\u7F3A\u5C11\u5FC5\u8981\u7684\u6587\u4EF6\uFF01"
|
|
371
|
+
}));
|
|
372
|
+
}
|
package/AMap/index.less
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#_A_MAP_SEARCH_ {
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: 10px;
|
|
4
|
+
right: 10px;
|
|
5
|
+
z-index: 10;
|
|
6
|
+
color: rgb(102 102 102);
|
|
7
|
+
box-shadow: 1px 2px 1px rgb(0 0 0 / 15%);
|
|
8
|
+
border: none;
|
|
9
|
+
height: 32px;
|
|
10
|
+
line-height: 32px;
|
|
11
|
+
width: 300px;
|
|
12
|
+
padding: 0 10px;
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
outline: none;
|
|
15
|
+
border-radius: 3px;
|
|
16
|
+
}
|
|
17
|
+
.amap-sug-result {
|
|
18
|
+
z-index: 10240 !important;
|
|
19
|
+
}
|
package/AdaptiveTree/index.js
CHANGED
|
@@ -41,7 +41,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
41
41
|
* titleIcon={(node) => <FolderOpenOutlined />}
|
|
42
42
|
* />
|
|
43
43
|
*/
|
|
44
|
-
import React from 'react';
|
|
44
|
+
import React, { useState } from 'react';
|
|
45
45
|
import { Tree, Space } from "antd";
|
|
46
46
|
import { styled } from 'styled-components';
|
|
47
47
|
export default props => {
|
|
@@ -52,6 +52,8 @@ export default props => {
|
|
|
52
52
|
...rest
|
|
53
53
|
} = props;
|
|
54
54
|
const prefixCls = window.process.env.app.antd['ant-prefix'];
|
|
55
|
+
const [expandedKeys, setExpandedKeys] = useState([]);
|
|
56
|
+
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
55
57
|
const StyledAntdComponents = styled.div`
|
|
56
58
|
.${prefixCls}-tree {
|
|
57
59
|
width: 100%;
|
|
@@ -89,7 +91,6 @@ export default props => {
|
|
|
89
91
|
gap: 8px;
|
|
90
92
|
align-items: flex-start;
|
|
91
93
|
padding: 6px 0;
|
|
92
|
-
font-weight: bold;
|
|
93
94
|
transition: none;
|
|
94
95
|
cursor: ${props?.draggable ? 'grab' : 'point'};
|
|
95
96
|
.title-left {
|
|
@@ -110,6 +111,7 @@ export default props => {
|
|
|
110
111
|
|
|
111
112
|
// 获得指定索引的节点 ID
|
|
112
113
|
const getLevelIndexNodeIds = (targetIndexArr, key) => {
|
|
114
|
+
const children = props?.fieldNames?.children || 'children';
|
|
113
115
|
const pathNodes = [];
|
|
114
116
|
const pathNodesIds = [];
|
|
115
117
|
let currentData = props.treeData || [];
|
|
@@ -122,10 +124,10 @@ export default props => {
|
|
|
122
124
|
}
|
|
123
125
|
nextNode = currentData[index];
|
|
124
126
|
} else {
|
|
125
|
-
if (!currentData?.children || !Array.isArray(currentData
|
|
127
|
+
if (!currentData?.[children] || !Array.isArray(currentData[children]) || index < 0 || index >= currentData[children].length) {
|
|
126
128
|
return null;
|
|
127
129
|
}
|
|
128
|
-
nextNode = currentData
|
|
130
|
+
nextNode = currentData?.[children][index];
|
|
129
131
|
}
|
|
130
132
|
pathNodes.push(nextNode);
|
|
131
133
|
pathNodesIds.push(nextNode[key]);
|
|
@@ -175,11 +177,23 @@ export default props => {
|
|
|
175
177
|
}, item?.content || '');
|
|
176
178
|
}) : ''));
|
|
177
179
|
};
|
|
180
|
+
const onExpand = keys => {
|
|
181
|
+
setExpandedKeys(keys);
|
|
182
|
+
props.onExpand && props.onExpand(keys);
|
|
183
|
+
};
|
|
184
|
+
const onSelect = keys => {
|
|
185
|
+
setSelectedKeys(keys);
|
|
186
|
+
props.onSelect && props.onSelect(keys);
|
|
187
|
+
};
|
|
178
188
|
return /*#__PURE__*/React.createElement(StyledAntdComponents, null, /*#__PURE__*/React.createElement(Tree, _extends({
|
|
179
189
|
draggable: draggable ? {
|
|
180
190
|
icon: false
|
|
181
191
|
} : false,
|
|
182
192
|
titleRender: titleRender,
|
|
183
|
-
onCheck: onCheck
|
|
193
|
+
onCheck: onCheck,
|
|
194
|
+
expandedKeys: props?.expandedKeys || expandedKeys,
|
|
195
|
+
onExpand: onExpand,
|
|
196
|
+
selectedKeys: props?.selectedKeys || selectedKeys,
|
|
197
|
+
onSelect: onSelect
|
|
184
198
|
}, rest)));
|
|
185
199
|
};
|
package/BMap/README.md
CHANGED
package/BMap/index.less
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
#_B_MAP_SEARCH_ {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: 10px;
|
|
4
|
+
right: 10px;
|
|
5
|
+
z-index: 10;
|
|
6
|
+
color: rgb(102 102 102);
|
|
7
|
+
box-shadow: 1px 2px 1px rgb(0 0 0 / 15%);
|
|
8
|
+
border: none;
|
|
9
|
+
height: 32px;
|
|
10
|
+
line-height: 32px;
|
|
11
|
+
width: 300px;
|
|
12
|
+
padding: 0 10px;
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
outline: none;
|
|
15
|
+
border-radius: 3px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.tangram-suggestion-main {
|
|
19
|
+
z-index: 1000;
|
|
20
|
+
margin-top: 6px;
|
|
21
|
+
|
|
22
|
+
.tangram-suggestion {
|
|
8
23
|
border: none;
|
|
9
|
-
|
|
10
|
-
line-height: 32px;
|
|
11
|
-
width: 300px;
|
|
12
|
-
padding: 0 10px;
|
|
13
|
-
font-size: 12px;
|
|
14
|
-
outline: none;
|
|
24
|
+
box-shadow: 1px 2px 1px rgb(0 0 0 / 15%);
|
|
15
25
|
border-radius: 3px;
|
|
16
26
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#selCityWd {
|
|
30
|
-
box-sizing: content-box;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.city_content_top {
|
|
34
|
-
box-sizing: content-box;
|
|
35
|
-
}
|
|
36
|
-
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#selCityWd {
|
|
30
|
+
box-sizing: content-box;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.city_content_top {
|
|
34
|
+
box-sizing: content-box;
|
|
35
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" width="200px" height="200.00px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M938.667 426.667v-85.334c0-46.933-38.4-85.333-85.334-85.333H128c-46.933 0-85.333 38.4-85.333 85.333v341.334C42.667 729.6 81.067 768 128 768h725.333c46.934 0 85.334-38.4 85.334-85.333v-85.334c23.466 0 42.666-19.2 42.666-42.666v-85.334c0-23.466-19.2-42.666-42.666-42.666zM896 469.333v213.334c0 23.466-19.2 42.666-42.667 42.666H128c-23.467 0-42.667-19.2-42.667-42.666V341.333c0-23.466 19.2-42.666 42.667-42.666h725.333c23.467 0 42.667 19.2 42.667 42.666v128zM128 682.667h554.667V341.333H128v341.334z" fill="#2C2C2C" /></svg>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonProps } from 'antd';
|
|
3
|
+
|
|
4
|
+
export interface PhoneBoxProps {
|
|
5
|
+
/** 展示内容的URL */
|
|
6
|
+
iframeUrl?: string;
|
|
7
|
+
/** 是否显示空状态,默认false */
|
|
8
|
+
showEmpty?: boolean;
|
|
9
|
+
/** 大小,默认'normal' */
|
|
10
|
+
size?: 'normal' | 'small';
|
|
11
|
+
/** 右侧额外操作按钮 */
|
|
12
|
+
extraAction?: React.ReactNode;
|
|
13
|
+
/** 是否显示右侧的二维码预览,默认'false' */
|
|
14
|
+
showPerview?: string | boolean;
|
|
15
|
+
/** 刷新二维码URL的函数,不传时自动使用时间戳刷新二维码 */
|
|
16
|
+
fetchQrcodeUrl?: () => Promise<{ data: string }>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const PhoneBox: React.FC<PhoneBoxProps>;
|
|
20
|
+
|
|
21
|
+
export default PhoneBox;
|