@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,359 @@
1
+ import React, {
2
+ useState,
3
+ useEffect,
4
+ useRef,
5
+ useMemo,
6
+ useCallback,
7
+ } from 'react';
8
+ import { IListView } from './interface';
9
+ import { callDataSource } from '../../utils/tcb';
10
+ import { isInIde } from '../../utils/platform';
11
+ import classNames from '../../utils/classnames';
12
+ import isequal from 'lodash.isequal';
13
+ import './index.css';
14
+
15
+ const REL_DICT = {
16
+ equal: 'eq', // 等于
17
+ unequal: 'neq', // 不等于
18
+ include: 'search', // 包含
19
+ exclude: '_exclude', // 不包含
20
+ begin_with: '_begin_with', // 开头是
21
+ greater: 'gt', // 大于
22
+ greater_or_equal: 'gte', // 大于等于
23
+ bigger_or_equal: 'gte', //大于等于
24
+ less: 'lt', // 小于
25
+ less_or_equal: 'lte', // 小于等于
26
+ in: 'in', // 多选值
27
+ not_in: 'nin', // 不在多选值
28
+ };
29
+ const ORDERTYPE = ['asc', 'desc'];
30
+ const BLOCK_NAME = 'weda-list-view';
31
+ const isNull = (val) => [undefined, null].includes(val);
32
+ const getIdeMockData = (length = 3) => Array.from({ length }).map((d) => ({}));
33
+ const getWhereList = (where) => {
34
+ let result = [];
35
+ Array.isArray(where) &&
36
+ where.forEach((item1) => {
37
+ if (item1?.groupLogic !== 'or' && Array.isArray(item1?.logicData)) {
38
+ item1?.logicData.forEach((item2) => {
39
+ let [rel, val] = [REL_DICT[item2?.rel], item2?.value];
40
+ if ('_begin_with' === rel) {
41
+ rel = 'regex';
42
+ val = `^${val}`;
43
+ }
44
+ if ('_exclude' === rel) {
45
+ rel = 'regex';
46
+ val = `^((?!${val}).)*$`;
47
+ }
48
+ if (item2?.logic !== 'or' && item2?.key && rel && !isNull(val)) {
49
+ result.push({ key: item2.key, rel, val });
50
+ }
51
+ });
52
+ }
53
+ });
54
+ return result;
55
+ };
56
+
57
+ /**
58
+ * 数据容器-列表视图
59
+ */
60
+ export default function ListView(props: IListView) {
61
+ const {
62
+ datasource,
63
+ orderBy,
64
+ orderType,
65
+ where,
66
+ template = 'simpleList',
67
+ pageSize = 5,
68
+ pagination = 'loadMoreButton',
69
+ events,
70
+ className,
71
+ children,
72
+ appCloud = { callDataSource, isInIde },
73
+ beforeDataChange = (v) => v,
74
+ ...rest
75
+ } = props;
76
+
77
+ const methodName = useMemo(
78
+ () => datasource?.extra?.methodName || 'wedaGetRecords',
79
+ [datasource?.extra?.methodName]
80
+ ); // 默认方法名
81
+ const [pageNo, setPageNo] = useState(1); // 分页状态
82
+ const [loading, setLoading] = useState(false); // 触底刷新加载状态
83
+ const [entry, setEntry] = useState(null); // 触底的observer对象
84
+ const paramRef = useRef({
85
+ dataSourceName: datasource.name,
86
+ methodName,
87
+ params: { orderBy, orderType, where, pageNo: 1, pageSize },
88
+ pagination,
89
+ }); // 最新请求参数
90
+ const dataRef = useRef({ total: 0, records: [] }); // 最新数据列表
91
+ const observeRef = useRef(null); // 当前监听对象
92
+ const isIdeMockData = !datasource?.name && appCloud?.isInIde?.(); // 在ide环境且未绑定数据源时,存在mock数据逻辑
93
+ const shouldBottomLoad =
94
+ pagination === 'bottomLoad' && entry?.isIntersecting && !loading; // 能否触底加载
95
+
96
+ // 组件卸载时触发
97
+ useEffect(() => {
98
+ return () => {
99
+ observeRef.current?.disconnect();
100
+ events?.onDataChange?.({ data: beforeDataChange([]) });
101
+ };
102
+ }, []);
103
+
104
+ // props 基本类型监听,需重新分页;处于 ide 且未绑定数据源时返回mock数据
105
+ useEffect(() => {
106
+ dataRef.current = { total: 0, records: [] };
107
+ if (datasource?.name) {
108
+ fetchData({
109
+ dataSourceName: datasource.name,
110
+ methodName,
111
+ params: {
112
+ ...paramRef.current?.params,
113
+ orderBy,
114
+ orderType,
115
+ pageNo: 1,
116
+ pageSize,
117
+ },
118
+ pagination,
119
+ });
120
+ } else {
121
+ if (isIdeMockData) {
122
+ events?.onDataChange?.({
123
+ data: beforeDataChange(getIdeMockData(pageSize)),
124
+ });
125
+ }
126
+ }
127
+ }, [datasource?.name, methodName, pageSize, pagination, orderBy, orderType]);
128
+
129
+ // props 对象类型监听,需重新分页
130
+ useEffect(() => {
131
+ if (!isequal(paramRef.current?.params?.where, where)) {
132
+ dataRef.current = { total: 0, records: [] };
133
+ fetchData({
134
+ params: { pageNo: 1, where },
135
+ });
136
+ }
137
+ });
138
+
139
+ // 监听触底加载事件,这里面的 setLoading 用 setTimeout包裹起来,所以会先执行新的children渲染,再执行 loading
140
+ useEffect(() => {
141
+ if (shouldBottomLoad && hasNextPage()) {
142
+ fetchData({
143
+ params: { pageNo: (paramRef.current?.params?.pageNo || 1) + 1 },
144
+ });
145
+ }
146
+ }, [shouldBottomLoad]);
147
+
148
+ // 触底监控对象
149
+ const nodeRefCallback = useCallback((node) => {
150
+ if (node) {
151
+ observeRef.current?.disconnect();
152
+ observeRef.current = new IntersectionObserver((entries) => {
153
+ setEntry(entries?.[0]);
154
+ });
155
+ observeRef.current.observe(node);
156
+ }
157
+ }, []);
158
+
159
+ // 能否点击下一页
160
+ const hasNextPage = () => {
161
+ const { pageNo = 1, pageSize = 5 } = paramRef.current?.params || {};
162
+ const { total = 0 } = dataRef.current || {};
163
+ return pageNo * pageSize < total;
164
+ };
165
+
166
+ /**
167
+ * 列表视图拉取数据
168
+ * 方法仅依赖入参和paramRef的参数
169
+ */
170
+ const fetchData = async (param: {
171
+ dataSourceName?: string;
172
+ methodName?: string;
173
+ params?: any;
174
+ pagination?: any;
175
+ }) => {
176
+ if (loading) return;
177
+ setLoading(true);
178
+ // 合并参数
179
+ const fetchParam = {
180
+ ...paramRef.current,
181
+ ...param,
182
+ params: { ...paramRef.current.params, ...param?.params },
183
+ };
184
+ const { dataSourceName, methodName, params } = fetchParam;
185
+ const { orderBy, orderType, pageNo, pageSize, where } = params || {};
186
+ const tcbParams = {};
187
+ // tcb分页参数
188
+ if (!isNull(pageNo) && !isNull(pageSize)) {
189
+ tcbParams['pageNo'] = pageNo;
190
+ tcbParams['pageSize'] = pageSize;
191
+ }
192
+ // tcb排序参数
193
+ if (orderBy && ORDERTYPE.includes(orderType)) {
194
+ tcbParams['orderBy'] = orderBy;
195
+ tcbParams['orderType'] = orderType;
196
+ }
197
+ // tcb过滤参数
198
+ const whereEffected = [].concat(getWhereList(where));
199
+ whereEffected.length > 0 && (tcbParams['where'] = whereEffected);
200
+ // tcb结果和事件
201
+ const data = await appCloud?.callDataSource({
202
+ dataSourceName,
203
+ methodName,
204
+ params: tcbParams,
205
+ });
206
+ paramRef.current = fetchParam;
207
+ onEnvets(data);
208
+ };
209
+
210
+ /**
211
+ * 根据fetchData方法返回值,回调给外部事件
212
+ * datasource 是对象类型,所以总能拿到最新的值
213
+ */
214
+ const onEnvets = (data) => {
215
+ const fetchRecords = [].concat(data?.records || []);
216
+ const total = data?.total || fetchRecords.length;
217
+ if (
218
+ ['loadMoreButton', 'bottomLoad'].includes(paramRef.current.pagination)
219
+ ) {
220
+ dataRef.current = {
221
+ total,
222
+ records: [...dataRef.current.records, ...fetchRecords],
223
+ };
224
+ } else {
225
+ dataRef.current = { total, records: fetchRecords };
226
+ }
227
+ events?.onDataChange?.({
228
+ data: beforeDataChange(dataRef.current.records || []),
229
+ });
230
+ if (JSON.stringify(data) === '{}') {
231
+ events?.queryFail?.({ datasource });
232
+ } else {
233
+ if (total === 0) {
234
+ events?.queryEmpty?.({ datasource, data: beforeDataChange([]) });
235
+ }
236
+ events?.querySuccess?.({
237
+ datasource,
238
+ data: beforeDataChange(dataRef.current.records),
239
+ });
240
+ }
241
+ setPageNo(paramRef.current?.params?.pageNo || 1);
242
+ window.setTimeout(() => setLoading(false));
243
+ };
244
+
245
+ /**
246
+ * 分页,加载更多
247
+ */
248
+ const renderLoadMore = () => {
249
+ let disabled = !hasNextPage();
250
+ if (isIdeMockData) {
251
+ disabled = false;
252
+ }
253
+ return (
254
+ !disabled &&
255
+ (loading ? (
256
+ LoadingSymbol
257
+ ) : (
258
+ <div
259
+ className={`${BLOCK_NAME}__more-text`}
260
+ onClick={() => fetchData({ params: { pageNo: pageNo + 1 } })}
261
+ >
262
+ 加载更多
263
+ </div>
264
+ ))
265
+ );
266
+ };
267
+
268
+ /**
269
+ * 分页,底部刷新
270
+ */
271
+ const renderBottomLoad = () => {
272
+ return (
273
+ <div ref={nodeRefCallback} className={`${BLOCK_NAME}__bottom-load`}>
274
+ {loading ? LoadingSymbol : !hasNextPage() && LoadEnd}
275
+ </div>
276
+ );
277
+ };
278
+
279
+ /**
280
+ * 分页,分页器,含ideMockData的判断
281
+ */
282
+ const renderPagination = () => {
283
+ const preDisabeld = pageNo <= 1;
284
+ const nextDisabeld = !hasNextPage();
285
+ const total = dataRef.current?.total || 0;
286
+ return (
287
+ <div className={`${BLOCK_NAME}__more-pagination`}>
288
+ <div
289
+ className={classNames(
290
+ `${BLOCK_NAME}__pagination-pre`,
291
+ preDisabeld ? '' : 'active'
292
+ )}
293
+ onClick={() =>
294
+ !preDisabeld && fetchData({ params: { pageNo: pageNo - 1 } })
295
+ }
296
+ >
297
+ 上一页
298
+ </div>
299
+ <div className={classNames(`${BLOCK_NAME}__pagination-text`)}>
300
+ <span className="active">
301
+ {isIdeMockData ? 1 : total ? pageNo : 0}
302
+ </span>
303
+ /{isIdeMockData ? 1 : Math.ceil(total / pageSize)}
304
+ </div>
305
+ <div
306
+ className={classNames(
307
+ `${BLOCK_NAME}__pagination-next`,
308
+ nextDisabeld ? '' : 'active'
309
+ )}
310
+ onClick={() =>
311
+ !nextDisabeld && fetchData({ params: { pageNo: pageNo + 1 } })
312
+ }
313
+ >
314
+ 下一页
315
+ </div>
316
+ </div>
317
+ );
318
+ };
319
+
320
+ /**
321
+ * 加载中状态组件
322
+ */
323
+ const LoadingSymbol = (
324
+ <div className={`${BLOCK_NAME}__more-symbol`}>
325
+ <div className={`${BLOCK_NAME}__symbol-item`}></div>
326
+ <div className={`${BLOCK_NAME}__symbol-item`}></div>
327
+ <div className={`${BLOCK_NAME}__symbol-item`}></div>
328
+ </div>
329
+ );
330
+
331
+ /**
332
+ * 加载到底状态组件
333
+ */
334
+ const LoadEnd = <div></div>;
335
+
336
+ return (
337
+ <div
338
+ // eslint-disable-next-line react/jsx-props-no-spreading
339
+ {...rest}
340
+ className={classNames('weda-ui', `${BLOCK_NAME}__containor`, className)}
341
+ >
342
+ {children && (
343
+ <div className={template === 'cardList' ? `${BLOCK_NAME}-card` : ''}>
344
+ {children}
345
+ </div>
346
+ )}
347
+ <div
348
+ className={classNames(
349
+ `${BLOCK_NAME}__more`,
350
+ `${BLOCK_NAME}__more-${pagination}`
351
+ )}
352
+ >
353
+ {pagination === 'bottomLoad' && renderBottomLoad()}
354
+ {pagination === 'loadMoreButton' && renderLoadMore()}
355
+ {pagination === 'pagination' && renderPagination()}
356
+ </div>
357
+ </div>
358
+ );
359
+ }
@@ -0,0 +1,98 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * 数据容器公共属性
5
+ */
6
+ export interface IDataContainer {
7
+ /**
8
+ * 数据模型
9
+ */
10
+ datasource?: {
11
+ name?: string;
12
+ extra?: {
13
+ viewId?: string;
14
+ methodName?: string;
15
+ };
16
+ };
17
+ /**
18
+ * 数据筛选
19
+ */
20
+ where?: {
21
+ groupLogic?: null | 'or' | 'and';
22
+ logicData?: {
23
+ keyType?: 'field' | 'var-font';
24
+ key: string;
25
+ rel: 'eq' | 'neq' | 'lt' | 'gt' | 'gte' | 'lte' | 'in' | 'nin' | 'search';
26
+ value: any;
27
+ valueType?: 'const' | 'var-font' | 'relative-amount' | 'field';
28
+ expression?: string | boolean;
29
+ logic?: null | 'or' | 'and' | string;
30
+ extra?: {
31
+ type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | string;
32
+ format?: string | null;
33
+ isExpression?: boolean;
34
+ };
35
+ }[];
36
+ }[];
37
+ /**
38
+ * 容器事件
39
+ */
40
+ events?: {
41
+ queryEmpty?: any;
42
+ querySuccess?: any;
43
+ queryFail?: any;
44
+ onDataChange?: (param: any) => any;
45
+ };
46
+ /**
47
+ * 类
48
+ */
49
+ className?: string;
50
+ /**
51
+ * app.cloud 对象依赖,默认会从 window.app 取值
52
+ */
53
+ appCloud?: { callDataSource?: any; isInIde?: any };
54
+ /**
55
+ * 子元素
56
+ */
57
+ children?: React.ReactNode | undefined;
58
+ /**
59
+ * 其他属性
60
+ */
61
+ [key: string]: any;
62
+ }
63
+
64
+ /**
65
+ * 数据容器-列表视图
66
+ */
67
+ export interface IListView extends IDataContainer {
68
+ /**
69
+ * 数据字段
70
+ */
71
+ orderBy?: string;
72
+ /**
73
+ * 数据类型
74
+ */
75
+ orderType?: 'desc' | 'asc';
76
+ /**
77
+ * 模板
78
+ */
79
+ template?:
80
+ | 'simpleList'
81
+ | 'detailList'
82
+ | 'imageTextList'
83
+ | 'cardList'
84
+ | 'none';
85
+ /**
86
+ * 显示行数
87
+ */
88
+ pageSize?: number;
89
+ /**
90
+ * 分页类型,加载更多|底部刷新|分页器
91
+ */
92
+ pagination?: 'loadMoreButton' | 'bottomLoad' | 'pagination' | 'none';
93
+
94
+ /**
95
+ * 调用 onDataChange 之前的数据转换,如列表视图需要接受 array,而数据视图需要接受 object
96
+ */
97
+ beforeDataChange?: (param: any) => any;
98
+ }
@@ -10,7 +10,7 @@ export interface PropTypes extends ModalProps {
10
10
  isDefaultButton: boolean,
11
11
  emit?: unknownFunction,
12
12
  events: Record<string, unknownFunction>,
13
-
13
+ size: ModalProps['size'],
14
14
  }
15
15
 
16
16
  export default function WeDaModal(_props: PropTypes) {
@@ -22,6 +22,7 @@ export default function WeDaModal(_props: PropTypes) {
22
22
  customContent,
23
23
  isDefaultButton,
24
24
  emit,
25
+ size,
25
26
  events,
26
27
  ...props
27
28
  } = _props;
@@ -29,6 +30,7 @@ export default function WeDaModal(_props: PropTypes) {
29
30
  return (
30
31
  <ConfigProvider classPrefix="wedatea2td">
31
32
  <Modal
33
+ size={size}
32
34
  className={classNames('weda-ui', 'lcap-modal', 'container', className)}
33
35
  visible={visible}
34
36
  onClose={() => {