@hzab/form-render-mobile 1.1.1 → 1.1.3-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/form-render-mobile",
3
- "version": "1.1.1",
3
+ "version": "1.1.3-beta",
4
4
  "description": "formily-form-render-mobile",
5
5
  "main": "lib",
6
6
  "scripts": {
@@ -50,6 +50,39 @@ export class MapUtils {
50
50
  this.markerIconConf = markerIconConf || {};
51
51
  }
52
52
 
53
+ /**
54
+ * 设置范围
55
+ * @param rangeArr
56
+ *
57
+ */
58
+ setMapRang({
59
+ map = this.map,
60
+ AMap = this.AMap || window.AMap,
61
+ rangeArr = [],
62
+ rangeKey = "range",
63
+ lonKey = "longitude",
64
+ latKey = "latitude",
65
+ }) {
66
+ // 获取地图上所有覆盖物
67
+ const overlays = map?.getAllOverlays() || [];
68
+ // 遍历覆盖物并删除圆形
69
+ overlays?.forEach((overlay: any) => {
70
+ if (overlay instanceof AMap.Circle) {
71
+ overlay.setMap(null);
72
+ }
73
+ });
74
+ //范围圆覆盖
75
+ rangeArr.forEach((item: any) => {
76
+ const circle = new AMap.Circle({
77
+ center: new AMap.LngLat(...[item[lonKey], item[latKey]]), // 圆心位置
78
+ radius: Number(item[rangeKey]), // 圆半径(米)
79
+ fillColor: "#1890ff", // 圆形填充颜色
80
+ strokeColor: "#40a9ff", // 描边颜色
81
+ });
82
+ map.add(circle);
83
+ });
84
+ }
85
+
53
86
  /**
54
87
  * 获取地图中心点
55
88
  * @param map
@@ -38,6 +38,7 @@ export const ModalContent = observer((props: any) => {
38
38
  lonKey = "longitude",
39
39
  latKey = "latitude",
40
40
  addrKey = "address",
41
+ rangeKey = "range",
41
42
  value,
42
43
  // 搜索框是否自动搜索
43
44
  isAutoSearch = true,
@@ -48,6 +49,7 @@ export const ModalContent = observer((props: any) => {
48
49
  readOnly,
49
50
  markerIconConf,
50
51
  icons,
52
+ rangeArr = [],
51
53
  } = props;
52
54
 
53
55
  const mapUtilsRef = useRef<MapUtils>();
@@ -71,6 +73,15 @@ export const ModalContent = observer((props: any) => {
71
73
  setLoading(props.loading);
72
74
  }, [props.loading]);
73
75
 
76
+ useEffect(() => {
77
+ //设置范围
78
+ mapUtilsRef.current?.setMapRang({
79
+ lonKey,
80
+ latKey,
81
+ rangeKey,
82
+ rangeArr: rangeArr,
83
+ });
84
+ }, [rangeArr]);
74
85
  useEffect(() => {
75
86
  if (visible) {
76
87
  let _lon = defaultLocation.lon;
@@ -112,6 +123,13 @@ export const ModalContent = observer((props: any) => {
112
123
  // 禁用、只读情况使用 marker 展示点位
113
124
  mapUtilsRef.current?.setPickerMarker(_lon, _lat);
114
125
  }
126
+ //设置范围
127
+ mapUtilsRef.current?.setMapRang({
128
+ lonKey,
129
+ latKey,
130
+ rangeKey,
131
+ rangeArr: rangeArr,
132
+ });
115
133
  }
116
134
 
117
135
  /**
@@ -41,10 +41,12 @@ export const LocationPicker = observer(function (props: any) {
41
41
  lonKey = "longitude",
42
42
  latKey = "latitude",
43
43
  addrKey = "address",
44
+ rangeKey = "range",
44
45
  value,
45
46
  // 搜索框是否自动搜索
46
47
  isAutoSearch = true,
47
48
  icons = {},
49
+ rangeArr = [],
48
50
  } = props;
49
51
 
50
52
  const [defaultLocation, setDefaultLocation] = useState({
@@ -150,6 +152,8 @@ export const LocationPicker = observer(function (props: any) {
150
152
  lonKey: lonKey ?? "longitude",
151
153
  latKey: latKey ?? "latitude",
152
154
  addrKey: addrKey ?? "address",
155
+ rangeKey: rangeKey ?? "range",
156
+ rangeArr: rangeArr ?? [],
153
157
  value,
154
158
  // 搜索框是否自动搜索
155
159
  isAutoSearch: isAutoSearch ?? true,
@@ -110,7 +110,7 @@ class OssUpload {
110
110
  */
111
111
  export async function handleOssUpload(files, opt) {
112
112
  const _files = files;
113
- const { ossUrl, signatureParams, ossParams, axiosConf } = opt || {};
113
+ const { ossUrl, signatureParams, ossParams, axiosConf, beforeUpload } = opt || {};
114
114
  const ossUpload = new OssUpload({
115
115
  axios: opt.axios,
116
116
  axiosConf: axiosConf,
@@ -126,18 +126,23 @@ export async function handleOssUpload(files, opt) {
126
126
  promise.push(Promise.resolve(file.ossUrl));
127
127
  } else {
128
128
  promise.push(
129
- ossUpload
130
- .upload(file, {
131
- signatureParams: {
132
- isPublic: 1,
133
- ...(signatureParams || {}),
134
- },
135
- ossParams,
136
- axiosConf,
137
- })
138
- .then((res) => {
139
- return Promise.resolve(res?.data?.data?.fileUrl);
140
- }),
129
+ new Promise(async (resolve, reject) => {
130
+ const f = (await (beforeUpload && beforeUpload(file, { reject }))) || file;
131
+ ossUpload
132
+ .upload(f, {
133
+ signatureParams: {
134
+ isPublic: 1,
135
+ ...(signatureParams || {}),
136
+ },
137
+ ossParams,
138
+ axiosConf,
139
+ })
140
+ .then((res) => {
141
+ resolve(res?.data?.data?.fileUrl);
142
+ return Promise.resolve(res?.data?.data?.fileUrl);
143
+ })
144
+ .catch(reject);
145
+ }),
141
146
  );
142
147
  }
143
148
  });
@@ -255,13 +255,16 @@ function Uploader(props, ref) {
255
255
  {disabled || readOnly || (maxCount > 0 && fileList.length >= maxCount) ? null : (
256
256
  <>
257
257
  <div
258
- className="uploader-add-btn"
258
+ className={`uploader-add-btn ${loading ? "uploader-add-btn-loading" : ""}`}
259
259
  onClick={() => {
260
+ if (loading) {
261
+ return;
262
+ }
260
263
  setActionSheetVisible(true);
261
264
  }}
262
265
  loading={loading}
263
266
  >
264
- {uploadBtnNode ? uploadBtnNode : "+"}
267
+ {loading ? "上传中..." : uploadBtnNode ? uploadBtnNode : "+"}
265
268
  </div>
266
269
  <ActionSheet
267
270
  cancelText="取消"
@@ -11,6 +11,7 @@
11
11
  margin-bottom: 2vw;
12
12
  vertical-align: top;
13
13
  border-radius: 4px;
14
+ border: 1px dashed #e3e3e3;
14
15
  .file-item-content-box {
15
16
  width: 100%;
16
17
  height: 100%;
@@ -38,6 +39,9 @@
38
39
  .uploader-add-btn {
39
40
  font-size: 6vw;
40
41
  }
42
+ .uploader-add-btn-loading {
43
+ font-size: 3vw;
44
+ }
41
45
  .aria-hidden {
42
46
  display: none;
43
47
  }
package/src/index.less CHANGED
@@ -1,61 +1,147 @@
1
1
  .form-render {
2
+ background: #F5F5F5;
3
+ padding: 32px;
2
4
  font-size: 4vw;
5
+
6
+ .adm-formily-layout {
7
+ background: #ffffff;
8
+ }
9
+
10
+ .adm-card {
11
+ background: #ffffff;
12
+ padding: 0;
13
+
14
+ .adm-card-header {
15
+ padding: 0;
16
+ background: #F5F5F5;
17
+ padding-top: 24px;
18
+
19
+ }
20
+
21
+ .adm-card-body {
22
+ padding: 0;
23
+ }
24
+
25
+ .adm-card-header-title {
26
+ font-size: 32px;
27
+ font-weight: 500;
28
+ margin-bottom: 24px;
29
+
30
+ }
31
+ }
32
+
33
+ .adm-card:last-child {
34
+ margin-bottom: 0;
35
+ }
36
+
37
+ .adm-card:first-child {
38
+ .adm-card-header {
39
+ padding-top: 0px;
40
+ }
41
+ }
42
+
3
43
  .formily-form-item {
4
- padding: 1.6vw;
44
+ padding: 24px 0;
45
+ margin: 0 24px;
46
+
47
+ border-bottom: 2px solid #F2F2F5;
48
+
5
49
  &.layout-vertical {
50
+
6
51
  .adm-formily-item-label,
7
52
  .adm-formily-item-control {
8
53
  width: 100%;
54
+
55
+
9
56
  }
10
57
  }
58
+
59
+ .adm-formily-item-asterisk {
60
+ font-size: 28px;
61
+ }
62
+
63
+ .adm-input-element {
64
+ font-size: 28px;
65
+ }
66
+
67
+ .adm-radio {
68
+ .adm-radio-content {
69
+ font-size: 28px;
70
+ color: #333333;
71
+ }
72
+
73
+ .adm-radio-icon {
74
+ width: 32px;
75
+ height: 32px;
76
+ }
77
+ }
78
+
79
+ .adm-formily-item-help-enter-active {
80
+ font-size: 28px;
81
+ }
82
+ }
83
+
84
+ .formily-form-item:last-child {
85
+ border-bottom: none;
11
86
  }
87
+
12
88
  .adm-formily-item-layout-vertical {
13
89
  .adm-formily-item-asterisk {
14
90
  top: unset;
15
91
  margin-left: unset;
16
92
  }
17
93
  }
94
+
18
95
  .adm-formily-item-asterisk {
19
96
  min-width: 3vw;
20
97
  position: unset;
21
98
  margin-left: 0;
22
99
  padding-right: 1vw;
23
100
  }
101
+
24
102
  .adm-formily-item-control {
25
103
  .adm-formily-item-extra {
26
104
  line-height: 1.3;
27
105
  }
28
106
  }
107
+
29
108
  .adm-formily-item {
30
109
  font-size: 4vw;
110
+
31
111
  .adm-list-item-title {
32
112
  font-size: 4vw;
33
113
  }
114
+
34
115
  .adm-formily-item-label {
35
116
  align-items: unset;
36
117
  line-height: 1.5;
37
118
  }
119
+
38
120
  .adm-formily-item-error-help {
39
121
  line-height: 1.5;
40
122
  }
123
+
41
124
  .adm-formily-item-control .adm-formily-item-control-content .adm-formily-item-control-content-component {
42
125
  line-height: 1.5;
43
126
  }
44
127
  }
128
+
45
129
  .adm-list-body {
46
130
  background-color: unset;
131
+
47
132
  .adm-card-body {
48
133
  .adm-list-item-content {
49
134
  border-top: unset;
50
135
  }
51
136
  }
52
137
  }
138
+
53
139
  .picker-box {
54
140
  display: flex;
55
141
  justify-content: space-between;
56
142
  align-items: center;
57
- .picker-right-icon {
58
- }
143
+
144
+ .picker-right-icon {}
59
145
  }
60
146
 
61
147
  .adm-formily-item-control-align-right {
@@ -67,6 +153,7 @@
67
153
  .placeholder {
68
154
  color: #ccc;
69
155
  }
156
+
70
157
  &.content-right {
71
158
  .adm-formily-item-control-content-component {
72
159
  display: flex;
@@ -79,6 +166,7 @@
79
166
  .adm-formily-item-asterisk {
80
167
  display: none;
81
168
  }
169
+
82
170
  .adm-selector-item-disabled {
83
171
  opacity: 1;
84
172
  }
@@ -88,4 +176,4 @@
88
176
  & .adm-checkbox {
89
177
  padding-right: 10px;
90
178
  }
91
- }
179
+ }