@hzab/form-render 1.6.3 → 1.6.5

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,12 @@
1
+ # @hzab/form-render@1.6.4
2
+
3
+ fix: 修复LocationListPicker组件在编辑时第一次无法正确渲染的bug。
4
+ feat: LocationPicker渲染时增加范围
5
+
6
+ # @hzab/form-render@1.6.3
7
+
8
+ fix: 修复LocationListPicker组件的Pupup弹窗在某些时候漂移的bug。
9
+
1
10
  # @hzab/form-render@1.6.2
2
11
 
3
12
  feat:自增列表组件新增删除二次确认功能
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/form-render",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -49,6 +49,7 @@ export const LocationListPicker = observer((props) => {
49
49
  const popupRef = useRef();
50
50
  const isEditingRef = useRef();
51
51
  const mapBoxRef = useRef(null)
52
+ const [mapInitCompleted, setMapInitCompleted] = useState(false);
52
53
 
53
54
  useEffect(() => {
54
55
  return () => {
@@ -60,7 +61,8 @@ export const LocationListPicker = observer((props) => {
60
61
  }, []);
61
62
 
62
63
  useEffect(() => {
63
- if (!Array.isArray(value) || value?.length == 0 || !mapUtilsRef.current) {
64
+
65
+ if (!Array.isArray(value) || value?.length == 0 || !mapInitCompleted) {
64
66
  return;
65
67
  }
66
68
  // 处理 id
@@ -70,11 +72,11 @@ export const LocationListPicker = observer((props) => {
70
72
  }
71
73
  });
72
74
  listRef.current = value || [];
73
- renderMarker();
74
- }, [value]);
75
+ renderMarker(value);
76
+ }, [value, mapInitCompleted]);
75
77
 
76
- function renderMarker() {
77
- listRef.current?.forEach((item) => {
78
+ function renderMarker(value = []) {
79
+ (listRef.current || value)?.forEach((item) => {
78
80
  if (item.type === "polygon") {
79
81
  mapUtilsRef.current.setPolygon({
80
82
  ...item,
@@ -105,6 +107,7 @@ export const LocationListPicker = observer((props) => {
105
107
  onClick: onPolygonClick,
106
108
  });
107
109
 
110
+ mapUtils && setMapInitCompleted(true);
108
111
  renderMarker();
109
112
  mapUtilsRef.current.setFitView();
110
113
  }
@@ -11,18 +11,20 @@
11
11
  }
12
12
  */
13
13
  export function getPropsValue(value = {}, opt) {
14
- const { lonKey = "longitude", latKey = "latitude", addrKey = "address", pointsKey = "points" } = opt || {};
14
+ const { lonKey = "longitude", latKey = "latitude", addrKey = "address", pointsKey = "points", rangeKey = "range" } = opt || {};
15
15
 
16
16
  let lon = value[lonKey];
17
17
  let lat = value[latKey];
18
18
  let addr = value[addrKey];
19
19
  let points = value[pointsKey];
20
+ let range = value[rangeKey];
20
21
 
21
22
  const res = {
22
23
  lon,
23
24
  lat,
24
25
  addr,
25
- points
26
+ points,
27
+ range
26
28
  };
27
29
  return res;
28
30
  }
@@ -38,6 +38,7 @@ export const ModalContent = observer((props: any) => {
38
38
  latKey = "latitude",
39
39
  addrKey = "address",
40
40
  pointsKey = "points",
41
+ rangeKey = "range",
41
42
  value,
42
43
  // 搜索框是否自动搜索
43
44
  isAutoSearch = true,
@@ -63,8 +64,9 @@ export const ModalContent = observer((props: any) => {
63
64
  latKey,
64
65
  addrKey,
65
66
  pointsKey,
67
+ rangeKey
66
68
  }),
67
- [lonKey, latKey, addrKey, pointsKey, value, value?.[pointsKey], value?.[lonKey], value?.[latKey], value?.[addrKey]],
69
+ [lonKey, latKey, addrKey, pointsKey,rangeKey, value, value?.[rangeKey], value?.[pointsKey], value?.[lonKey], value?.[latKey], value?.[addrKey]],
68
70
  );
69
71
 
70
72
  const [loading, setLoading] = useState(props.loading || false);
@@ -167,6 +169,7 @@ export const ModalContent = observer((props: any) => {
167
169
  addr,
168
170
  lon: center[0],
169
171
  lat: center[1],
172
+ range: 0
170
173
  });
171
174
  }
172
175
  }
@@ -178,14 +181,17 @@ export const ModalContent = observer((props: any) => {
178
181
  let _lon = defaultLocation.lon;
179
182
  let _lat = defaultLocation.lat;
180
183
  let _points = defaultLocation.points;
184
+ let _range = defaultLocation.range
181
185
  if (pickInfo.lon && pickInfo.lat) {
182
186
  _lon = pickInfo.lon;
183
187
  _lat = pickInfo.lat;
184
188
  _points = pickInfo.points;
189
+ _range = pickInfo.range
185
190
  } else if (formatValRef.current?.lon && formatValRef.current?.lat) {
186
191
  _lon = formatValRef.current?.lon;
187
192
  _lat = formatValRef.current?.lat;
188
193
  _points = formatValRef.current?.points;
194
+ _range = formatValRef.current?.range;
189
195
  }
190
196
 
191
197
  setMapCenter(_lon, _lat);
@@ -211,6 +217,7 @@ export const ModalContent = observer((props: any) => {
211
217
  // 禁用、只读情况使用 marker 展示点位
212
218
  if (element === "Polypoint") {
213
219
  mapUtilsRef.current?.setPickerMarker(_lon, _lat);
220
+ mapUtilsRef.current.setCircle(_lon, _lat, _range);
214
221
  } else {
215
222
  setDrawEditor(_points, true);
216
223
  }