@hzab/form-render 1.6.12 → 1.6.13

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # @hzab/form-render@1.6.13
2
+
3
+ feat:locationListPicker在已有元素范围内可新增地址标记
4
+
1
5
  # @hzab/form-render@1.6.12
2
6
 
3
7
  feat: PersonnelSelect组件优化传值方式,支持复数据传入、返回
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@hzab/form-render",
3
- "version": "1.6.12",
3
+ "version": "1.6.13",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
7
7
  "dev": "webpack serve -c ./config/webpack.config.js --env local",
8
8
  "build": "webpack -c ./config/webpack.config.js --env production",
9
+ "publish-beta": "npm publish --beta",
9
10
  "publish-patch": "npm version patch && npm publish --access public",
10
11
  "publish-minor": "npm version minor && npm publish --access public",
11
12
  "publish-major": "npm version major && npm publish --access public"
@@ -89,7 +89,7 @@ export const LocationListPicker = observer((props) => {
89
89
  data: item,
90
90
  onClick: onMarkerClick,
91
91
  });
92
- mapUtilsRef.current.setCircle(item.longitude, item.latitude, item.range, { ...item });
92
+ mapUtilsRef.current.setCircle(item.longitude, item.latitude, item.range, { ...item, onClick: handleMarker });
93
93
  }
94
94
  });
95
95
  mapUtilsRef.current.setFitView();
@@ -199,8 +199,14 @@ export const LocationListPicker = observer((props) => {
199
199
  clearStatus();
200
200
  }
201
201
 
202
+
203
+ // 地图单击除现有元素范围外添加点位地址
204
+ function onMapClick(e) {
205
+ mapUtilsRef.current.isContains(e, handleMarker);
206
+ }
207
+
202
208
  // 处理 marker、范围 绘制填写逻辑
203
- async function onMapClick(e) {
209
+ async function handleMarker(e) {
204
210
  if (drawType.current !== "marker") {
205
211
  return;
206
212
  }
@@ -297,18 +303,20 @@ export const LocationListPicker = observer((props) => {
297
303
  }
298
304
 
299
305
  function onPolygonClick(e) {
300
- if (!isEditingRef.current) {
306
+ if (!isEditingRef.current && statusRef.current !== "add") {
301
307
  drawType.current = "polygon";
302
308
  const id = e.target.id;
303
309
  clearEdit(id);
304
310
  setActiveId(id);
305
311
  setActivePolygon(e.target);
312
+ } else if (statusRef.current === "add") {
313
+ handleMarker(e);
306
314
  }
307
315
  }
308
316
 
309
317
  function onMarkerClick(e, ...args) {
310
318
  clearActive();
311
- if (!isEditingRef.current) {
319
+ if (!isEditingRef.current && statusRef.current !== "add") {
312
320
  setShowTip(false);
313
321
  isEditingRef.current = false;
314
322
  const { id } = e.target.getExtData() || {};
@@ -412,7 +420,7 @@ export const LocationListPicker = observer((props) => {
412
420
  } else {
413
421
  setTipText("点击选择地址");
414
422
  setActiveMarkerIcon(item.id);
415
- onMapClick({
423
+ handleMarker({
416
424
  lnglat: {
417
425
  lng: item.longitude,
418
426
  lat: item.latitude,
@@ -458,7 +466,7 @@ export const LocationListPicker = observer((props) => {
458
466
  function setPoint(lng, lat) {
459
467
  mapUtilsRef.current.setCenter(lng, lat, { immediately: true });
460
468
  statusRef.current = "add";
461
- onMapClick({
469
+ handleMarker({
462
470
  lnglat: {
463
471
  lng,
464
472
  lat,
@@ -59,7 +59,7 @@ export class MapUtils {
59
59
  PolygonEditor: undefined,
60
60
  PolylineEditor: undefined,
61
61
  };
62
- public polygonEnum;
62
+ public polygonEnum = {};
63
63
  public polygonConf;
64
64
  public mapDomRef;
65
65
 
@@ -332,7 +332,7 @@ export class MapUtils {
332
332
  }
333
333
 
334
334
  setCircle(lon, lat, radius, opt?) {
335
- const { id = nanoid(), circle, map = this.map, AMap = this.AMap, circleConf = {} } = opt || {};
335
+ const { id = nanoid(), circle, map = this.map, AMap = this.AMap, onClick, circleConf = {} } = opt || {};
336
336
  if (!(AMap && map)) {
337
337
  throw new Error("请传入地图实例和 AMap");
338
338
  }
@@ -362,9 +362,10 @@ export class MapUtils {
362
362
  strokeWeight: 1, // 轮廓线宽度
363
363
  fillOpacity: 0.1, // 圆形填充透明度
364
364
  fillColor: "#0080FF", // 圆形填充颜色
365
- zIndex: 50, // 圆形的叠加顺序
365
+ zIndex: 100, // 圆形的叠加顺序
366
366
  ...circleConf,
367
367
  });
368
+ _c.on("click", onClick);
368
369
  this.circles[id] = _c;
369
370
  map?.add(_c);
370
371
  return _c;
@@ -375,6 +376,22 @@ export class MapUtils {
375
376
  delete this.circles[id];
376
377
  }
377
378
 
379
+
380
+ // 判断当前点击点位是否在地图现有元素范围内,并回调函数返回值
381
+ isContains(e, callBack) {
382
+ const element = {
383
+ ...this.circles,
384
+ ...this.polygonEnum,
385
+ };
386
+ const { lng, lat } = e.lnglat || {};
387
+ const point = new this.AMap.LngLat(lng, lat);
388
+ const isRange = Object.keys(element).some((key) => element[key].contains(point));
389
+ if (!isRange) {
390
+ callBack && callBack(e);
391
+ }
392
+ return isRange;
393
+ }
394
+
378
395
  /**
379
396
  * 创建或修改地图选点的 Marker
380
397
  * 在当前 utils 中唯一