@hzab/form-render 1.3.3 → 1.4.0-beta
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 +5 -0
- package/package.json +3 -2
- package/src/components/LocationListPicker/components/AddrList/index.less +5 -0
- package/src/components/LocationListPicker/components/AddrList/index.tsx +35 -10
- package/src/components/LocationListPicker/components/Popup/index.less +1 -1
- package/src/components/LocationListPicker/components/Popup/index.tsx +24 -20
- package/src/components/LocationListPicker/index.less +11 -1
- package/src/components/LocationListPicker/index.tsx +255 -62
- package/src/components/LocationPicker/Map/AMap/common/loader.ts +1 -1
- package/src/components/LocationPicker/Map/AMap/common/utils.ts +146 -7
- package/src/components/LocationPicker/Map/AMap/index.jsx +2 -1
- package/src/components/LocationPicker/README.md +1 -0
- package/src/components/LocationPicker/common/utils.ts +5 -2
- package/src/components/LocationPicker/components/ModalContent/index.tsx +115 -28
- package/src/components/LocationPicker/components/PickerInfo/index.tsx +10 -1
- package/src/components/LocationPicker/components/ResInfo/index.less +9 -1
- package/src/components/LocationPicker/components/ResInfo/index.tsx +20 -7
- package/src/components/LocationPicker/index.tsx +26 -9
@@ -20,6 +20,7 @@ export const LocationPicker = observer(function (props: any) {
|
|
20
20
|
* 直接显示 show
|
21
21
|
*/
|
22
22
|
mode = "dialog",
|
23
|
+
element = "Polypoint",
|
23
24
|
/**
|
24
25
|
* 选择器和地图的布局
|
25
26
|
* 水平 hor
|
@@ -35,6 +36,7 @@ export const LocationPicker = observer(function (props: any) {
|
|
35
36
|
lonKey = "longitude",
|
36
37
|
latKey = "latitude",
|
37
38
|
addrKey = "address",
|
39
|
+
pointsKey = "points",
|
38
40
|
value,
|
39
41
|
// 搜索框是否自动搜索
|
40
42
|
isAutoSearch = true,
|
@@ -45,21 +47,25 @@ export const LocationPicker = observer(function (props: any) {
|
|
45
47
|
|
46
48
|
const [loading, setLoading] = useState(false);
|
47
49
|
const [defaultLocation, setDefaultLocation] = useState({
|
48
|
-
lon:
|
49
|
-
lat:
|
50
|
-
addr: "
|
50
|
+
lon: "",
|
51
|
+
lat: "",
|
52
|
+
addr: "",
|
53
|
+
points: [],
|
51
54
|
});
|
52
55
|
const [visible, setVisible] = useState(mode === "show");
|
53
56
|
// 解决 弹窗关闭之后 visible 无法传入 ModalContent 的问题
|
54
57
|
const [visibleKey, setVisibleKey] = useState(0);
|
55
58
|
const pickInfoRef = useRef(defaultLocation);
|
59
|
+
const modalContentRef = useRef();
|
56
60
|
|
57
61
|
useEffect(() => {
|
58
62
|
const propsVal = getPropsValue(value, {
|
59
63
|
lonKey,
|
60
64
|
latKey,
|
61
65
|
addrKey,
|
66
|
+
pointsKey,
|
62
67
|
});
|
68
|
+
setPickInfo(propsVal)
|
63
69
|
if (!propsVal.lon || !propsVal.lat) {
|
64
70
|
setLoading(true);
|
65
71
|
// 如果没有传入的经纬度,获取当前实际的经纬度数据
|
@@ -76,6 +82,7 @@ export const LocationPicker = observer(function (props: any) {
|
|
76
82
|
lon,
|
77
83
|
lat,
|
78
84
|
addr,
|
85
|
+
points: [],
|
79
86
|
};
|
80
87
|
setDefaultLocation(pickInfoRef.current);
|
81
88
|
setLoading(false);
|
@@ -105,11 +112,17 @@ export const LocationPicker = observer(function (props: any) {
|
|
105
112
|
[lonKey]: info.lon,
|
106
113
|
[latKey]: info.lat,
|
107
114
|
[addrKey]: info.addr,
|
115
|
+
[pointsKey]: info.points,
|
108
116
|
};
|
109
117
|
props.onChange && props.onChange(_res);
|
110
118
|
}
|
111
119
|
|
112
|
-
function onOk() {
|
120
|
+
async function onOk() {
|
121
|
+
// 多边形时确定直接保存修改,无需双击结束
|
122
|
+
if (element !== "Polypoint") {
|
123
|
+
// @ts-ignore
|
124
|
+
await modalContentRef.current?.editDone();
|
125
|
+
}
|
113
126
|
onChange();
|
114
127
|
onClose();
|
115
128
|
}
|
@@ -132,6 +145,7 @@ export const LocationPicker = observer(function (props: any) {
|
|
132
145
|
* 直接显示 show
|
133
146
|
*/
|
134
147
|
mode: mode ?? "dialog",
|
148
|
+
element: element ?? "Polypoint",
|
135
149
|
layout: layout ?? "ver",
|
136
150
|
// 是否允许搜索
|
137
151
|
hasSearch: hasSearch ?? true,
|
@@ -142,6 +156,7 @@ export const LocationPicker = observer(function (props: any) {
|
|
142
156
|
lonKey: lonKey ?? "longitude",
|
143
157
|
latKey: latKey ?? "latitude",
|
144
158
|
addrKey: addrKey ?? "address",
|
159
|
+
pointsKey: pointsKey ?? "points",
|
145
160
|
// 搜索框是否自动搜索
|
146
161
|
isAutoSearch: isAutoSearch ?? true,
|
147
162
|
visible,
|
@@ -151,11 +166,14 @@ export const LocationPicker = observer(function (props: any) {
|
|
151
166
|
setLoading,
|
152
167
|
};
|
153
168
|
|
169
|
+
function onDialogInit(params) {
|
170
|
+
modalContentRef.current = params;
|
171
|
+
}
|
172
|
+
|
154
173
|
return (
|
155
174
|
<div className="location-picker">
|
156
|
-
{mode === "show"
|
157
|
-
|
158
|
-
) : (
|
175
|
+
{mode === "show" && <ModalContent {..._props} setPickInfo={setResInfo} init={onDialogInit} />}
|
176
|
+
{mode === "dialog" && (
|
159
177
|
<>
|
160
178
|
{/* 弹窗 */}
|
161
179
|
{/* 有弹窗时,显示表单选中的结果 */}
|
@@ -166,10 +184,9 @@ export const LocationPicker = observer(function (props: any) {
|
|
166
184
|
onCancel={onClose}
|
167
185
|
onOk={onOk}
|
168
186
|
visible={visible}
|
169
|
-
confirmLoading={loading}
|
170
187
|
width={modalConf?.width || isHor ? "1024px" : "720px"}
|
171
188
|
>
|
172
|
-
<ModalContent {..._props} setPickInfo={setPickInfo} />
|
189
|
+
<ModalContent {..._props} setPickInfo={setPickInfo} init={onDialogInit} />
|
173
190
|
</Modal>
|
174
191
|
</>
|
175
192
|
)}
|