@cloudbase/weda-ui 0.2.15 → 1.0.21

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.
Files changed (250) hide show
  1. package/README.md +41 -169
  2. package/package.json +28 -15
  3. package/src/configs/components/calendar.json +78 -0
  4. package/src/configs/components/carousel.json +273 -0
  5. package/src/configs/components/chart/bar.json +724 -0
  6. package/src/configs/components/chart/line.json +679 -0
  7. package/src/configs/components/chart/pie.json +497 -0
  8. package/src/configs/components/chart/statisticsCard.json +379 -0
  9. package/src/configs/components/container.json +7 -2
  10. package/src/configs/components/dataView.json +154 -0
  11. package/src/configs/components/form/checkbox.json +97 -5
  12. package/src/configs/components/form/location.json +152 -0
  13. package/src/configs/components/form/radio.json +96 -4
  14. package/src/configs/components/form/select.json +245 -11
  15. package/src/configs/components/form/uploaderFile.json +2 -1
  16. package/src/configs/components/graphicCard.json +410 -0
  17. package/src/configs/components/image.json +7 -2
  18. package/src/configs/components/link.json +20 -4
  19. package/src/configs/components/listView.json +277 -0
  20. package/src/configs/components/modal.json +37 -5
  21. package/src/configs/components/navLayout.json +362 -0
  22. package/src/configs/components/navigationBar.json +59 -0
  23. package/src/configs/components/richtextview.json +4 -1
  24. package/src/configs/components/scrollVeiw.json +74 -22
  25. package/src/configs/components/swiper.json +6 -3
  26. package/src/configs/components/tabs.json +51 -8
  27. package/src/configs/components/text.json +33 -25
  28. package/src/configs/components/wxOpenApi/phone.json +141 -0
  29. package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
  30. package/src/configs/components/wxOpenApi/share.json +167 -0
  31. package/src/configs/components/wxOpenApi/userInfo.json +174 -0
  32. package/src/configs/index.js +34 -0
  33. package/src/mp/components/button/index.js +12 -13
  34. package/src/mp/components/button/index.wxml +1 -1
  35. package/src/mp/components/calendar/arrowright--line.svg +11 -0
  36. package/src/mp/components/calendar/index.js +238 -0
  37. package/src/mp/components/calendar/index.json +4 -0
  38. package/src/mp/components/calendar/index.wxml +37 -0
  39. package/src/mp/components/calendar/index.wxss +178 -0
  40. package/src/mp/components/carousel/index.js +88 -0
  41. package/src/mp/components/carousel/index.json +7 -0
  42. package/src/mp/components/carousel/index.wxml +6 -0
  43. package/src/mp/components/chart/bar/index.js +258 -0
  44. package/src/mp/components/chart/bar/index.json +6 -0
  45. package/src/mp/components/chart/bar/index.wxml +3 -0
  46. package/src/mp/components/chart/bar/index.wxss +9 -0
  47. package/src/mp/components/chart/common/config/bar.js +50 -0
  48. package/src/mp/components/chart/common/config/global.js +16 -0
  49. package/src/mp/components/chart/common/config/line.js +48 -0
  50. package/src/mp/components/chart/common/config/pie.js +36 -0
  51. package/src/mp/components/chart/common/core/eChartBar.js +263 -0
  52. package/src/mp/components/chart/common/core/eChartBase.js +375 -0
  53. package/src/mp/components/chart/common/core/eChartLine.js +229 -0
  54. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  55. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  56. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  57. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  58. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  59. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  60. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  61. package/src/mp/components/chart/line/index.js +247 -0
  62. package/src/mp/components/chart/line/index.json +6 -0
  63. package/src/mp/components/chart/line/index.wxml +3 -0
  64. package/src/mp/components/chart/line/index.wxss +9 -0
  65. package/src/mp/components/chart/pie/index.js +182 -0
  66. package/src/mp/components/chart/pie/index.json +6 -0
  67. package/src/mp/components/chart/pie/index.wxml +4 -0
  68. package/src/mp/components/chart/pie/index.wxss +9 -0
  69. package/src/mp/components/chart/statisticsCard/index.js +253 -0
  70. package/src/mp/components/chart/statisticsCard/index.json +4 -0
  71. package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
  72. package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
  73. package/src/mp/components/dataView/index.js +34 -0
  74. package/src/mp/components/dataView/index.json +7 -0
  75. package/src/mp/components/dataView/index.wxml +15 -0
  76. package/src/mp/components/dataView/index.wxss +0 -0
  77. package/src/mp/components/form/checkbox/index.js +41 -2
  78. package/src/mp/components/form/checkbox/index.wxml +1 -1
  79. package/src/mp/components/form/input/index.js +1 -1
  80. package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
  81. package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
  82. package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
  83. package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
  84. package/src/mp/components/form/location/index.js +382 -0
  85. package/src/mp/components/form/location/index.json +6 -0
  86. package/src/mp/components/form/location/index.wxml +25 -0
  87. package/src/mp/components/form/location/index.wxss +91 -0
  88. package/src/mp/components/form/radio/index.js +38 -0
  89. package/src/mp/components/form/select/index.js +360 -40
  90. package/src/mp/components/form/select/index.wxml +21 -6
  91. package/src/mp/components/form/select/region/index.js +98 -0
  92. package/src/mp/components/form/textarea/index.wxml +6 -5
  93. package/src/mp/components/form/uploader/index.js +84 -48
  94. package/src/mp/components/form/uploader/index.wxml +15 -3
  95. package/src/mp/components/form/uploaderFile/index.js +106 -27
  96. package/src/mp/components/graphicCard/chevron-right.svg +3 -0
  97. package/src/mp/components/graphicCard/index.js +203 -0
  98. package/src/mp/components/graphicCard/index.json +4 -0
  99. package/src/mp/components/graphicCard/index.wxml +29 -0
  100. package/src/mp/components/graphicCard/index.wxss +157 -0
  101. package/src/mp/components/image/index.js +0 -1
  102. package/src/mp/components/listView/arrow-right-line.svg +3 -0
  103. package/src/mp/components/listView/index.js +285 -0
  104. package/src/mp/components/listView/index.json +4 -0
  105. package/src/mp/components/listView/index.wxml +40 -0
  106. package/src/mp/components/listView/index.wxss +155 -0
  107. package/src/mp/components/listView/more-line.svg +3 -0
  108. package/src/mp/components/navLayout/index.js +123 -0
  109. package/src/mp/components/navLayout/index.json +7 -0
  110. package/src/mp/components/navLayout/index.wxml +25 -0
  111. package/src/mp/components/navLayout/index.wxss +1193 -0
  112. package/src/mp/components/navigationBar/index.js +193 -0
  113. package/src/mp/components/navigationBar/index.json +6 -0
  114. package/src/mp/components/navigationBar/index.wxml +88 -0
  115. package/src/mp/components/navigationBar/index.wxss +1257 -0
  116. package/src/mp/components/swiper/index.wxml +2 -0
  117. package/src/mp/components/tabs/index.js +7 -2
  118. package/src/mp/components/tabs/index.wxml +2 -1
  119. package/src/mp/components/text/index.js +0 -25
  120. package/src/mp/components/text/index.wxml +3 -3
  121. package/src/mp/components/wxOpenApi/phone/index.js +117 -0
  122. package/src/mp/components/wxOpenApi/phone/index.json +4 -0
  123. package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
  124. package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
  125. package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
  126. package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
  127. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
  128. package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
  129. package/src/mp/components/wxOpenApi/share/index.js +117 -0
  130. package/src/mp/components/wxOpenApi/share/index.json +4 -0
  131. package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
  132. package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
  133. package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
  134. package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
  135. package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
  136. package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
  137. package/src/mp/index.json +18 -2
  138. package/src/mp/style/weda-ui.wxss +2 -0
  139. package/src/mp/utils/debounce.js +133 -0
  140. package/src/mp/utils/destr.js +48 -0
  141. package/src/mp/utils/dr_square_point.js +25 -0
  142. package/src/mp/utils/platform.js +25 -0
  143. package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
  144. package/src/mp/utils/spark-md5.js +776 -0
  145. package/src/mp/utils/tcb.js +62 -0
  146. package/src/setupTests.js +2 -1
  147. package/src/web/components/button/index.css +8 -1
  148. package/src/web/components/button/index.tsx +3 -2
  149. package/src/web/components/calendar/index.css +382 -0
  150. package/src/web/components/calendar/index.jsx +312 -0
  151. package/src/web/components/calendar/util.js +90 -0
  152. package/src/web/components/carousel/index.css +119 -0
  153. package/src/web/components/carousel/index.tsx +417 -0
  154. package/src/web/components/chart/bar/index.tsx +140 -0
  155. package/src/web/components/chart/common/config/bar.js +49 -0
  156. package/src/web/components/chart/common/config/global.js +16 -0
  157. package/src/web/components/chart/common/config/line.js +50 -0
  158. package/src/web/components/chart/common/config/pie.js +37 -0
  159. package/src/web/components/chart/common/core/eChartBar.js +265 -0
  160. package/src/web/components/chart/common/core/eChartBase.ts +383 -0
  161. package/src/web/components/chart/common/core/eChartLine.js +231 -0
  162. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  163. package/src/web/components/chart/common/core/type.ts +34 -0
  164. package/src/web/components/chart/common/echart.css +106 -0
  165. package/src/web/components/chart/common/echarts.ts +33 -0
  166. package/src/web/components/chart/common/useChart.tsx +69 -0
  167. package/src/web/components/chart/line/index.tsx +136 -0
  168. package/src/web/components/chart/pie/index.tsx +99 -0
  169. package/src/web/components/chart/statisticsCard/index.css +62 -0
  170. package/src/web/components/chart/statisticsCard/index.tsx +307 -0
  171. package/src/web/components/chart/statisticsCard/interface.ts +14 -0
  172. package/src/web/components/dataView/index.tsx +20 -0
  173. package/src/web/components/dataView/interface.ts +6 -0
  174. package/src/web/components/form/checkbox/index.tsx +55 -23
  175. package/src/web/components/form/location/common/mapChoose.css +178 -0
  176. package/src/web/components/form/location/common/mapChoose.jsx +343 -0
  177. package/src/web/components/form/location/common/mapView.jsx +190 -0
  178. package/src/web/components/form/location/common/propsConfig.js +54 -0
  179. package/src/web/components/form/location/common/selectModal.css +44 -0
  180. package/src/web/components/form/location/common/selectModal.jsx +82 -0
  181. package/src/web/components/form/location/common/useLocationInfo.js +100 -0
  182. package/src/web/components/form/location/components/LocationH5/index.css +243 -0
  183. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
  184. package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
  185. package/src/web/components/form/location/components/LocationPC/index.css +44 -0
  186. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
  187. package/src/web/components/form/location/constants.js +4 -0
  188. package/src/web/components/form/location/index.css +0 -0
  189. package/src/web/components/form/location/index.jsx +25 -0
  190. package/src/web/components/form/radio/index.tsx +84 -53
  191. package/src/web/components/form/select/h5.tsx +389 -71
  192. package/src/web/components/form/select/index.css +10 -0
  193. package/src/web/components/form/select/index.tsx +404 -144
  194. package/src/web/components/form/select/region/index.ts +122 -31
  195. package/src/web/components/form/select/time.jsx +90 -0
  196. package/src/web/components/form/select/year.tsx +170 -0
  197. package/src/web/components/form/uploader/uploader.h5.tsx +19 -4
  198. package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
  199. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
  200. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
  201. package/src/web/components/graphicCard/index.css +159 -0
  202. package/src/web/components/graphicCard/index.tsx +310 -0
  203. package/src/web/components/image/image.tsx +1 -2
  204. package/src/web/components/image/index.tsx +1 -1
  205. package/src/web/components/index.js +24 -2
  206. package/src/web/components/link/index.tsx +6 -3
  207. package/src/web/components/listView/arrow-right-line.svg +3 -0
  208. package/src/web/components/listView/index.css +143 -0
  209. package/src/web/components/listView/index.tsx +359 -0
  210. package/src/web/components/listView/interface.ts +98 -0
  211. package/src/web/components/modal/index.tsx +3 -1
  212. package/src/web/components/navLayout/index.css +332 -0
  213. package/src/web/components/navLayout/index.tsx +247 -0
  214. package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
  215. package/src/web/components/navigationBar/common.tsx +198 -0
  216. package/src/web/components/navigationBar/h5Menu.tsx +179 -0
  217. package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
  218. package/src/web/components/navigationBar/index.css +762 -0
  219. package/src/web/components/navigationBar/index.tsx +231 -0
  220. package/src/web/components/navigationBar/type.d.ts +111 -0
  221. package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
  222. package/src/web/components/phone/index.css +0 -0
  223. package/src/web/components/phone/index.tsx +22 -0
  224. package/src/web/components/phoneCode/index.css +0 -0
  225. package/src/web/components/phoneCode/index.tsx +22 -0
  226. package/src/web/components/richTextView/index.tsx +3 -5
  227. package/src/web/components/share/index.css +0 -0
  228. package/src/web/components/share/index.tsx +38 -0
  229. package/src/web/components/tabs/index.tsx +4 -2
  230. package/src/web/components/tabs/tabs.h5.tsx +50 -37
  231. package/src/web/components/tabs/tabs.pc.tsx +23 -10
  232. package/src/web/components/text/index.tsx +6 -14
  233. package/src/web/components/uploaderFileView/index.css +9 -9
  234. package/src/web/components/uploaderFileView/index.jsx +32 -23
  235. package/src/web/components/userInfo/index.css +0 -0
  236. package/src/web/components/userInfo/index.tsx +30 -0
  237. package/src/web/types.d.ts +15 -14
  238. package/src/web/utils/debounce.js +98 -0
  239. package/src/web/utils/platform.js +40 -0
  240. package/src/web/utils/tcb.js +49 -0
  241. package/src/web/utils/tmap.js +4 -0
  242. package/src/web/weda-ui.css +2 -0
  243. package/CHANGELOG.md +0 -240
  244. package/src/.DS_Store +0 -0
  245. package/src/configs/.DS_Store +0 -0
  246. package/src/mp/.gitignore +0 -10
  247. package/src/web/.DS_Store +0 -0
  248. package/src/web/components/form/select/region/cities.ts +0 -2410
  249. package/src/web/components/form/select/region/provinces.ts +0 -240
  250. package/src/web/components/form/select/region/regions.ts +0 -20645
@@ -0,0 +1,323 @@
1
+ import * as React from 'react';
2
+ import { ConfigProvider } from 'tea-component';
3
+
4
+ import classNames from '../../../../../utils/classnames';
5
+ import weui from '../../../../../utils/weui';
6
+ import { renderDecorator } from '../../../renderDecorator';
7
+
8
+ import MapView from '../../common/mapView';
9
+ import SelectModal from '../../common/selectModal';
10
+ import useLocationInfo from '../../common/useLocationInfo';
11
+ import { propTypes, defaultProps } from '../../common/propsConfig';
12
+ import { callDataSource } from '../../../../../utils/tcb';
13
+ import Header from './Header';
14
+
15
+ import './index.css';
16
+
17
+ const { useState, useEffect, useRef } = React;
18
+
19
+ export default function LocationPC(props) {
20
+ // 属性、变量
21
+ const {
22
+ // 系统属性
23
+ id,
24
+ className,
25
+ style,
26
+ events,
27
+ // 组件属性
28
+ value,
29
+ label,
30
+ labelVisible,
31
+ customLocation,
32
+ locationType,
33
+ showLngLat,
34
+ showMap,
35
+ drag,
36
+ zoom,
37
+ disabled,
38
+ requiredFlag,
39
+ decorator,
40
+ dataSource,
41
+ } = props;
42
+ const cls = classNames({
43
+ 'weda-ui': true,
44
+ cloudbase_standard: true,
45
+ [className]: className,
46
+ });
47
+
48
+ const [isSelectMapVisible, setIsSelectMapVisible] = useState(false);
49
+ const [dataSourceStatus, setDataSourceStatus] = useState({
50
+ status: false,
51
+ message: '连接器初始化中',
52
+ });
53
+ const [userSelectStatus, setUserSelectStatus] = useState('default');
54
+ const [APIKEY, setAPIKEY] = useState('');
55
+
56
+ const eventsChange = (value, noaddr) => {
57
+ const { poiname, latitude, longitude } = value;
58
+ let res = {
59
+ address: poiname,
60
+ geopoint: {
61
+ coordinates: [longitude, latitude],
62
+ type: 'Point',
63
+ },
64
+ };
65
+ if (noaddr) {
66
+ res = null;
67
+ }
68
+ events.change &&
69
+ events.change({
70
+ value: res,
71
+ });
72
+ };
73
+ const {
74
+ location,
75
+ setLocation,
76
+ apiKeyStatus,
77
+ setApiKeyStatus,
78
+ currentLocStatus,
79
+ currentLocations,
80
+ } = useLocationInfo({
81
+ apiKey: APIKEY,
82
+ locationType,
83
+ dataSourceStatus,
84
+ eventsChange,
85
+ });
86
+
87
+ useEffect(() => {
88
+ if (value || !currentLocations.current) return;
89
+ setUserSelectStatus('default');
90
+ // 重置表单时
91
+ const {
92
+ poiname,
93
+ latlng: { lat, lng },
94
+ } = currentLocations.current;
95
+ let location = {
96
+ poiname,
97
+ latlng: { lat, lng },
98
+ };
99
+ if (locationType === 1) {
100
+ location.locationType = 1;
101
+ eventsChange({}, true);
102
+ } else if (locationType === 2) {
103
+ eventsChange({
104
+ latitude: lat,
105
+ longitude: lng,
106
+ poiname: poiname,
107
+ });
108
+ }
109
+ setLocation(location);
110
+ }, [value, locationType]);
111
+
112
+ // 事件
113
+ const handleChooseLocation = () => {
114
+ if (disabled) return;
115
+ if (!dataSourceStatus.status) return weui.alert(dataSourceStatus.message);
116
+ if (!apiKeyStatus.status) return weui.alert(apiKeyStatus.message);
117
+ if (!currentLocStatus) return weui.alert('获取当前位置信息中,请稍等');
118
+ setIsSelectMapVisible(true);
119
+ };
120
+ const onChangeLocation = (value) => {
121
+ const { poiname, latlng } = value;
122
+ events.change &&
123
+ events.change({
124
+ value: {
125
+ address: poiname,
126
+ geopoint: {
127
+ coordinates: [latlng.lng, latlng.lat],
128
+ type: 'Point',
129
+ },
130
+ },
131
+ });
132
+ setUserSelectStatus('selected');
133
+ };
134
+
135
+ useEffect(() => {
136
+ // 调用连接器数据源方法
137
+ if (dataSource.name) {
138
+ callDataSource({
139
+ dataSourceName: dataSource.name,
140
+ methodName: 'getApiKey',
141
+ })
142
+ .then((res) => {
143
+ if (res.apiKey) {
144
+ setAPIKEY(res.apiKey);
145
+ setDataSourceStatus({
146
+ status: true,
147
+ message: '',
148
+ });
149
+ setApiKeyStatus({ status: true, message: '' });
150
+ }
151
+ })
152
+ .catch((error) => {
153
+ console.log('datasources error', error);
154
+ setDataSourceStatus({
155
+ status: false,
156
+ message: error,
157
+ });
158
+ });
159
+ } else {
160
+ setDataSourceStatus({
161
+ status: false,
162
+ message: '"地图定位组件"需进行地图配置,请检查',
163
+ });
164
+ weui.alert('"地图定位组件"需进行地图配置,请检查');
165
+ }
166
+ }, [dataSource]);
167
+
168
+ useEffect(() => {
169
+ let loc = {
170
+ latlng: {
171
+ lat: 39.98410411,
172
+ lng: 116.307503,
173
+ },
174
+ poiname: '',
175
+ locationType,
176
+ };
177
+ switch (locationType) {
178
+ case 2:
179
+ // @ts-ignore
180
+ loc = {
181
+ latlng: {
182
+ lat: location.latlng.lat,
183
+ lng: location.latlng.lng,
184
+ },
185
+ poiname: location.poiname,
186
+ };
187
+ break;
188
+ case 3:
189
+ if (checkCustomLocation(customLocation)) {
190
+ weui.alert('位置输入格式错误 请检查');
191
+ } else {
192
+ // @ts-ignore
193
+ loc = {
194
+ latlng: {
195
+ lat: customLocation.latitude,
196
+ lng: customLocation.longitude,
197
+ },
198
+ poiname: customLocation.poiname,
199
+ };
200
+ }
201
+ break;
202
+ }
203
+ setLocation(loc);
204
+ // 暂不支持自定位置,初始化表单值都是null
205
+ eventsChange(
206
+ {
207
+ latitude: loc.latlng.lat,
208
+ longitude: loc.latlng.lng,
209
+ poiname: loc.poiname,
210
+ },
211
+ true
212
+ );
213
+ }, [locationType]);
214
+
215
+ useEffect(() => {
216
+ if (locationType != 3) {
217
+ return;
218
+ }
219
+ if (checkCustomLocation(customLocation)) {
220
+ weui.alert('位置输入格式错误 请检查');
221
+ return;
222
+ }
223
+ let { latitude, longitude, poiname } = customLocation;
224
+ let loc = {
225
+ latlng: {
226
+ lat: latitude,
227
+ lng: longitude,
228
+ },
229
+ poiname: poiname,
230
+ };
231
+ setLocation(loc);
232
+ }, [customLocation, locationType]);
233
+
234
+ const checkCustomLocation = (params) => {
235
+ let { latitude, longitude } = params;
236
+ let message = '';
237
+ if (Object.prototype.toString.call(params) !== '[object Object]') {
238
+ return (message = '位置输入格式错误 请检查');
239
+ } else if (!latitude || !Number(latitude)) {
240
+ return (message = '位置输入格式错误 请检查');
241
+ } else if (!longitude || !Number(longitude)) {
242
+ return (message = '位置输入格式错误 请检查');
243
+ } else if (!params) {
244
+ return (message = '位置输入格式错误 请检查');
245
+ }
246
+ };
247
+
248
+ const getIsShowMap = () => {
249
+ let status = showMap;
250
+ // @ts-ignore
251
+ if (locationType === 1 && location.locationType === 1) {
252
+ status = false;
253
+ } else if (locationType === 2 && !dataSourceStatus.status) {
254
+ status = false;
255
+ } else if (locationType === 2 && !apiKeyStatus.status) {
256
+ status = false;
257
+ } else if (!currentLocStatus) {
258
+ status = false;
259
+ }
260
+ return status;
261
+ };
262
+
263
+ const LocationEl = (
264
+ <ConfigProvider classPrefix="wedatea2td">
265
+ <div
266
+ className={classNames(
267
+ 'wedatea2td-form__controls wedatea2td-form__controls_wrap',
268
+ className
269
+ )}
270
+ style={style}
271
+ data-testid="_weda-fn-map"
272
+ >
273
+ <div className="_weda-fn-map">
274
+ <Header
275
+ isEdit={userSelectStatus === 'selected'}
276
+ info={location}
277
+ onClick={handleChooseLocation}
278
+ disabled={disabled}
279
+ showLngLat={showLngLat}
280
+ locationType={locationType}
281
+ apiKeyStatus={apiKeyStatus}
282
+ currentLocStatus={currentLocStatus}
283
+ dataSourceStatus={dataSourceStatus.status}
284
+ />
285
+ {getIsShowMap() ? (
286
+ <div className={classNames('form-location-map-pc')}>
287
+ <MapView
288
+ APIKEY={APIKEY}
289
+ drag={drag}
290
+ zoom={zoom}
291
+ latlng={location.latlng}
292
+ />
293
+ </div>
294
+ ) : null}
295
+ </div>
296
+ </div>
297
+ <SelectModal
298
+ isSelectMapVisible={isSelectMapVisible}
299
+ setIsSelectMapVisible={setIsSelectMapVisible}
300
+ location={location}
301
+ setLocation={setLocation}
302
+ APIKEY={APIKEY}
303
+ chooseLocation={onChangeLocation}
304
+ />
305
+ </ConfigProvider>
306
+ );
307
+
308
+ return renderDecorator(
309
+ LocationEl,
310
+ decorator
311
+ )({
312
+ id,
313
+ className: cls,
314
+ style,
315
+ label: labelVisible ? label : null,
316
+ multiCell: false,
317
+ requiredFlag,
318
+ });
319
+ }
320
+
321
+ LocationPC.propTypes = propTypes;
322
+
323
+ LocationPC.defaultProps = defaultProps;
@@ -0,0 +1,4 @@
1
+ const KEY = 'XX5BZ-UJLKR-B7WWP-WURRR-UYBGS-4VBMM';
2
+ const tmapApiUrl = 'https://map.qq.com/api/gljs';
3
+
4
+ export { KEY, tmapApiUrl };
File without changes
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { ConfigProvider } from 'tea-component';
3
+ import './index.css';
4
+ import { usePlatform } from '../../../utils/platform';
5
+ import LocationH5 from './components/LocationH5/location.h5';
6
+ import LocationPC from './components/LocationPC/location.PC';
7
+
8
+ export default function Location(props) {
9
+ const platform = usePlatform();
10
+
11
+ if (props?.showType === 'pc') {
12
+ return <LocationPC {...props} />;
13
+ }
14
+ if (props?.showType === 'h5') {
15
+ return <LocationH5 {...props} />;
16
+ }
17
+
18
+ return platform === 'h5' ? (
19
+ <ConfigProvider classPrefix="wedatea2td">
20
+ <LocationH5 {...props} />
21
+ </ConfigProvider>
22
+ ) : (
23
+ <LocationPC {...props} />
24
+ );
25
+ }
@@ -1,14 +1,16 @@
1
- import * as React from 'react';
2
- import {ConfigProvider, Radio as TeaRadio} from 'tea-component';
1
+ import React, { useEffect, useState } from 'react';
2
+ import { ConfigProvider, Radio as TeaRadio } from 'tea-component';
3
3
 
4
- import {usePlatform} from '../../../utils/platform';
4
+ import { usePlatform } from '../../../utils/platform';
5
5
  import classNames from '../../../utils/classnames';
6
6
  import getLocalCounter from '../../../utils/getLocalCounter';
7
7
  import isObjectEqual from '../../../utils/isObjectEqual';
8
+ import { callWedaApi } from '../../../utils/tcb';
8
9
 
9
10
  import './index.css';
10
11
  import { renderDecorator } from '../renderDecorator';
11
12
  import { CommonFormPropsType } from '../types';
13
+ import destr from 'destr';
12
14
 
13
15
  export default function Radio({
14
16
  // 系统属性
@@ -19,6 +21,8 @@ export default function Radio({
19
21
  // 组件属性
20
22
  label = '标题',
21
23
  labelVisible = true,
24
+ format = '',
25
+ enumName = '',
22
26
  name = 'formRadio',
23
27
  range = [],
24
28
  layout = 'horizontal',
@@ -39,19 +43,44 @@ export default function Radio({
39
43
  'weui-check__label': isH5,
40
44
  'weui-cell_disabled': isH5 && disabled,
41
45
  });
42
-
46
+ const [option, setOption] = useState(range);
43
47
  const [checkedItemValue, setCheckedItemValue] = React.useState(
44
- range.find((item) => item.checked)?.value
48
+ option.find((item) => item.checked)?.value
45
49
  );
46
50
  // 两次range不同时, 需要刷新checkedItemValue
47
51
  const prevRangeRef = React.useRef<PropsType['range']>();
48
52
  React.useEffect(() => {
49
- if (!isObjectEqual(prevRangeRef.current, range)) {
50
- prevRangeRef.current = range;
51
- setCheckedItemValue(range.find((item) => item.checked)?.value);
53
+ if (!isObjectEqual(prevRangeRef.current, option)) {
54
+ prevRangeRef.current = option;
55
+ setCheckedItemValue(option.find((item) => item.checked)?.value);
52
56
  }
53
57
  });
54
58
 
59
+ useEffect(() => {
60
+ // 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
61
+ if (format === 'x-enum' && enumName) {
62
+ fetchData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
63
+ }
64
+ }, []);
65
+
66
+ const fetchData = async (param:
67
+ { OptNameList?: object, PageIndex?: number, PageSize?: number }
68
+ ) => {
69
+ let data = await callWedaApi({
70
+ action: 'DescribeGeneralOptionsDetailList',
71
+ data: param,
72
+ });
73
+ const config = destr(data?.Items?.[0]?.Config) ?? [];
74
+ const enumOption = config.map(item => {
75
+ return {
76
+ label: item.value,
77
+ value: item.key,
78
+ checked: false
79
+ };
80
+ });
81
+ setOption(enumOption);
82
+ };
83
+
55
84
  /**
56
85
  * 在ios h5端, label和input的绑定不生效
57
86
  * 导致 onChange 事件触发有问题, 所以改为监听 onClick 事件
@@ -70,55 +99,55 @@ export default function Radio({
70
99
  // 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
71
100
  const hashcode = React.useMemo(() => getLocalCounter(), []);
72
101
  let radioElement;
73
- if(isH5) {
102
+ if (isH5) {
74
103
 
75
- radioElement = range.map(({ label, value }, index) => {
104
+ radioElement = option.map(({ label, value }, index) => {
76
105
  const _id = `radio-${hashcode}-${index}`;
77
106
  const _name = `radio-${hashcode}-${name}`;
78
107
  return (
79
- <div
80
- className={subCls}
81
- key={_id}
82
- onClickCapture={getChangeHandler(value)}
83
- >
84
- <div className="weui-cell__hd">
85
- <input
86
- type="radio"
87
- className="weui-check"
88
- value={value}
89
- name={_name}
90
- id={_id}
91
- checked={checkedItemValue === value}
92
- disabled={disabled}
93
- onClick={(e) => e.stopPropagation()}
108
+ <div
109
+ className={subCls}
110
+ key={_id}
111
+ onClickCapture={getChangeHandler(value)}
112
+ >
113
+ <div className="weui-cell__hd">
114
+ <input
115
+ type="radio"
116
+ className="weui-check"
117
+ value={value}
118
+ name={_name}
119
+ id={_id}
120
+ checked={checkedItemValue === value}
121
+ disabled={disabled}
122
+ onClick={(e) => e.stopPropagation()}
94
123
  />
95
- <i className="weui-icon-checked"></i>
124
+ <i className="weui-icon-checked"></i>
125
+ </div>
126
+ <div className="weui-cell__bd">
127
+ <p>{label}</p>
128
+ </div>
96
129
  </div>
97
- <div className="weui-cell__bd">
98
- <p>{label}</p>
99
- </div>
100
- </div>
101
- );
102
- });
103
- } else {
104
- // pc
105
- radioElement = (<ConfigProvider classPrefix="wedatea2td">
106
- <TeaRadio.Group
107
- disabled={disabled}
108
- value={checkedItemValue}
109
- onChange={(value, {event}) => getChangeHandler(value)(event)}
110
- >
111
- {range.map(({value, label}, index) => {
112
- const _id = `radio-${hashcode}-${index}`;
113
- return (
114
- <TeaRadio key={_id} name={value} id={_id}>
115
- {label}
116
- </TeaRadio>
117
- );
118
- })}
119
- </TeaRadio.Group>
120
- </ConfigProvider>);
121
- }
130
+ );
131
+ });
132
+ } else {
133
+ // pc
134
+ radioElement = (<ConfigProvider classPrefix="wedatea2td">
135
+ <TeaRadio.Group
136
+ disabled={disabled}
137
+ value={checkedItemValue}
138
+ onChange={(value, { event }) => getChangeHandler(value)(event)}
139
+ >
140
+ {option.map(({ value, label }, index) => {
141
+ const _id = `radio-${hashcode}-${index}`;
142
+ return (
143
+ <TeaRadio key={_id} name={value} id={_id}>
144
+ {label}
145
+ </TeaRadio>
146
+ );
147
+ })}
148
+ </TeaRadio.Group>
149
+ </ConfigProvider>);
150
+ }
122
151
  return renderDecorator(radioElement, decorator)({
123
152
  id,
124
153
  className: cls,
@@ -132,5 +161,7 @@ export default function Radio({
132
161
 
133
162
  export interface PropsType extends CommonFormPropsType {
134
163
  // 组件属性
135
- range?: ({label: string} & Record<string, any>)[];
136
- }
164
+ range?: ({ label: string } & Record<string, any>)[];
165
+ format?: string;
166
+ enumName?: string;
167
+ }