@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
@@ -1,10 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import * as PropTypes from 'prop-types';
3
- import { useSyncValue } from '../../../utils/useSyncValue';
4
- import isObjectEqual from '../../../utils/isObjectEqual';
5
3
  import weui from '../../../utils/weui';
6
4
  import { CommonFormPropsType } from '../types';
7
-
5
+ import isObjectEqual from '../../../utils/isObjectEqual';
8
6
  import {
9
7
  Upload,
10
8
  ConfigProvider,
@@ -23,11 +21,11 @@ import {
23
21
  isHttpFileID,
24
22
  transSize,
25
23
  downloadFile,
24
+ transFileCloudidToName,
26
25
  } from '../../../utils/platform';
27
26
  import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
28
27
  import classNames from '../../../utils/classnames';
29
28
  import { renderDecorator } from '../renderDecorator';
30
-
31
29
  // 默认组件类前缀
32
30
  const CLASS_PREFIX = 'weda-upload-file-mobile';
33
31
  // 默认图片类型
@@ -74,12 +72,20 @@ export function UploadFileH5({
74
72
  uploadPath = 'weda-uploader',
75
73
  single = true,
76
74
  onChange = null,
75
+ isEdit = true,
77
76
  }: IUploadFileH5) {
78
- const [fileIDList, setfileIDList] = React.useState(
79
- filterStrList([].concat(defaultValue, value))
80
- ); // 上传成功文件ID列表,fileID[]
77
+ const [fileIDList, setfileIDList] = React.useState(filterStrList([].concat(defaultValue, value))); // 上传成功文件ID列表,fileID[]
81
78
  const [fileList, setFileList] = React.useState([]); // 上传中的文件列表,file[],file为原始文件 + uuid属性
82
79
  const [fileSizeObj, setFileSizeObj] = React.useState({}); // 管理上传文件大小 {uuid:size}
80
+ // 两次默认值不同, 需要刷新
81
+ const prevDefaultRef = React.useRef<any>([]);
82
+ React.useMemo(()=>{
83
+ //有有效默认值时不刷新,解决初次渲染默认值不显示问题
84
+ if(defaultValue&&!isObjectEqual(prevDefaultRef.current,defaultValue)&&(JSON.stringify(prevDefaultRef.current)=='[]'||!prevDefaultRef.current)){
85
+ prevDefaultRef.current =defaultValue;
86
+ setfileIDList(filterStrList([].concat(defaultValue)));
87
+ }
88
+ },[defaultValue]);
83
89
  React.useEffect(() => {
84
90
  // 外部 onChange 事件
85
91
  const pureFileIDList = fileIDList.filter(
@@ -115,9 +121,9 @@ export function UploadFileH5({
115
121
  // 上传时新增事件
116
122
  if (type === 'add') {
117
123
  fileID && setFileSizeObj((obj) => ({ ...obj, [fileID]: size }));
118
- fileID && setfileIDList((list) => [...list, fileID]);
124
+ fileID && setfileIDList([...fileIDList, fileID]);
119
125
  } else {
120
- fileID && setfileIDList((list) => list.filter((f) => f !== fileID));
126
+ fileID && setfileIDList(fileIDList.filter((f) => f !== fileID));
121
127
  }
122
128
  uuid && setFileList((list) => list.filter((item) => uuid !== item?._uuid));
123
129
  };
@@ -141,74 +147,81 @@ export function UploadFileH5({
141
147
  downloadVisible,
142
148
  deleteVisible,
143
149
  onChange: handleChange,
150
+ isEdit,
144
151
  events,
145
152
  fileSizeObj,
146
153
  }}
147
154
  >
148
155
  <div data-testid="uploadFileH5" className={cls} id={id} style={style}>
149
156
  <div className={classNames(`${CLASS_PREFIX}`)}>
150
- <div className={classNames(`${CLASS_PREFIX}__hd`, layout)}>
151
- <div>
152
- {btnDisabled ? (
153
- <Button
154
- type="weak"
155
- className={classNames(`${CLASS_PREFIX}__btn--weak`)}
156
- disabled={btnDisabled}
157
- >
158
- {btnTitle}
159
- </Button>
160
- ) : (
161
- <div>
162
- <input
163
- id="uploaderInput"
164
- type="file"
165
- data-testid="button-up"
166
- className="weui-uploader-mobile__input"
167
- accept={accepts.join(',')}
168
- multiple={!single}
169
- onChange={(e) => {
170
- const fileList = [...e.target.files];
171
- if (single && fileList.length > 1) {
172
- weui.alert(`上传文件总数不能超过1个`);
173
- return false;
174
- }
175
- if (
176
- fileList.length + fileIDList.length >
177
- maxUploadCount
178
- ) {
179
- weui.alert(`上传文件总数不能超过${maxUploadCount}个`);
180
- return false;
181
- }
182
- if (
183
- maxSize &&
184
- fileList.some((f) => f.size > maxSize * 1024 * 1024)
185
- ) {
186
- weui.alert(`请上传不超过${maxSize}M的文件`);
187
- return false;
188
- }
189
- if (fileList.some((f) => f.size > 1024 * 1024 * 1024)) {
190
- weui.alert(`请上传不超过1024M的文件`);
191
- return false;
192
- }
193
- fileList.forEach((f) => (f['_uuid'] = v4()));
194
- setFileList((list) => [...list, ...fileList]);
195
- }}
196
- />
197
- <a
157
+ {isEdit && (
158
+ <div className={classNames(`${CLASS_PREFIX}__hd`, layout)}>
159
+ <div>
160
+ {btnDisabled ? (
161
+ <Button
198
162
  type="weak"
199
- className="wedatea2td-btn wedatea2td-btn--weak"
163
+ className={classNames(`${CLASS_PREFIX}__btn--weak`)}
164
+ disabled={btnDisabled}
200
165
  >
201
- 点击上传
202
- </a>
203
- {!single && (
204
- <Text className={`${CLASS_PREFIX}__tips`}>
205
- 支持批量上传
206
- </Text>
207
- )}
208
- </div>
209
- )}
166
+ {btnTitle}
167
+ </Button>
168
+ ) : (
169
+ <div>
170
+ <input
171
+ id="uploaderInput"
172
+ type="file"
173
+ data-testid="button-up"
174
+ className="weui-uploader-mobile__input"
175
+ accept={accepts.join(',')}
176
+ multiple={!single}
177
+ onChange={(e) => {
178
+ const fileList = [...e.target.files];
179
+ if (single && fileList.length > 1) {
180
+ weui.alert(`上传文件总数不能超过1个`);
181
+ return false;
182
+ }
183
+ if (
184
+ fileList.length + fileIDList.length >
185
+ maxUploadCount
186
+ ) {
187
+ weui.alert(
188
+ `上传文件总数不能超过${maxUploadCount}个`
189
+ );
190
+ return false;
191
+ }
192
+ if (
193
+ maxSize &&
194
+ fileList.some((f) => f.size > maxSize * 1024 * 1024)
195
+ ) {
196
+ weui.alert(`请上传不超过${maxSize}M的文件`);
197
+ return false;
198
+ }
199
+ if (
200
+ fileList.some((f) => f.size > 1024 * 1024 * 1024)
201
+ ) {
202
+ weui.alert(`请上传不超过1024M的文件`);
203
+ return false;
204
+ }
205
+ fileList.forEach((f) => (f['_uuid'] = v4()));
206
+ setFileList((list) => [...list, ...fileList]);
207
+ }}
208
+ />
209
+ <a
210
+ type="weak"
211
+ className="wedatea2td-btn wedatea2td-btn--weak"
212
+ >
213
+ 点击上传
214
+ </a>
215
+ {!single && (
216
+ <Text className={`${CLASS_PREFIX}__tips`}>
217
+ 支持批量上传
218
+ </Text>
219
+ )}
220
+ </div>
221
+ )}
222
+ </div>
210
223
  </div>
211
- </div>
224
+ )}
212
225
  <div className={`${CLASS_PREFIX}__bd`}>
213
226
  <List>
214
227
  {fileIDList.map((d) => (
@@ -267,6 +280,7 @@ export interface IUploadFileH5 extends CommonFormPropsType {
267
280
  uploadPath?: string; // 上传路径
268
281
  single?: boolean; // 单张上传还是多张上传,对应 onChange 参数为字符串还是字符串数组,value 在处理过程统一转为字符串数组
269
282
  onChange?: (v: any) => void; // 配合 fomily 受控使用
283
+ isEdit: boolean; // 当前是编辑态还是展示态,展示态会去掉删除等按钮
270
284
  }
271
285
 
272
286
  /**
@@ -298,11 +312,7 @@ const TcbFileEcho = ({
298
312
  //上传文件名称
299
313
  const label = React.useMemo(() => {
300
314
  if (isCloudFileID(fileID)) {
301
- const uuidReg = /file-[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}-/;
302
- const lastIndex = `${fileID}`.lastIndexOf('/');
303
- const name = `${fileID}`.slice(lastIndex + 1);
304
- const label = name.replace(uuidReg, '');
305
- return label;
315
+ return transFileCloudidToName(fileID);
306
316
  } else {
307
317
  return fileID;
308
318
  }
@@ -367,7 +377,7 @@ const TcbFileUpload = ({
367
377
  try {
368
378
  setStatus('UPLOAD_STATUS_PENDING');
369
379
  const { fileID } = await tcb.uploadFile({
370
- cloudPath: `${uploadPath}/${`file-${uuid}-${title}`}`,
380
+ cloudPath: `${uploadPath}/${uuid.replaceAll('-', '')}-${file?.name}`,
371
381
  filePath: file,
372
382
  onUploadProgress: (progressEvent) => {
373
383
  let percent = 0;
@@ -430,6 +440,7 @@ const UploadFileStatus = ({
430
440
  title = null,
431
441
  percentSize = 0,
432
442
  }: IUploadFileStatus) => {
443
+ const { isEdit } = React.useContext(FileContext) || {};
433
444
  //上传中、待上传状态
434
445
  if (
435
446
  status == 'UPLOAD_STATUS_LOADING' ||
@@ -470,23 +481,28 @@ const UploadFileStatus = ({
470
481
  <Tooltip title={title}>
471
482
  <Text className={`${CLASS_PREFIX}__file-name`}>{title}</Text>
472
483
  </Tooltip>
473
- <div className={`${CLASS_PREFIX}__file-status`}>
474
- <Icon
475
- type={
476
- statusMap[status]?.icon || statusMap['UPLOAD_STATUS_PENDING'].icon
477
- }
478
- ></Icon>
479
- <Text className={`${CLASS_PREFIX}__file-status--msg`}>
480
- {statusMap[status]?.title ||
481
- statusMap['UPLOAD_STATUS_PENDING'].title}
482
- </Text>
483
- </div>
484
+ {isEdit && (
485
+ <div className={`${CLASS_PREFIX}__file-status`}>
486
+ <Icon
487
+ type={
488
+ statusMap[status]?.icon ||
489
+ statusMap['UPLOAD_STATUS_PENDING'].icon
490
+ }
491
+ ></Icon>
492
+ <Text className={`${CLASS_PREFIX}__file-status--msg`}>
493
+ {statusMap[status]?.title ||
494
+ statusMap['UPLOAD_STATUS_PENDING'].title}
495
+ </Text>
496
+ </div>
497
+ )}
484
498
  </div>
485
- <div className={`${CLASS_PREFIX}__file-foot`}>
486
- <div>
487
- <Text>{size}</Text>
499
+ {isEdit && (
500
+ <div className={`${CLASS_PREFIX}__file-foot`}>
501
+ <div>
502
+ <Text>{size}</Text>
503
+ </div>
488
504
  </div>
489
- </div>
505
+ )}
490
506
  </>
491
507
  );
492
508
  };
@@ -514,36 +530,39 @@ const UploadFileAction = ({
514
530
  onReLoad = null,
515
531
  onCancel = null,
516
532
  }: IUploadFileAction) => {
517
- const { onChange, downloadVisible, deleteVisible } =
533
+ const { onChange, downloadVisible, deleteVisible, isEdit } =
518
534
  React.useContext(FileContext) || {};
519
535
  // 操作列按钮-删除
520
- const renderDelete = () => (
521
- <Icon
522
- type="delete"
523
- style={{ cursor: 'pointer' }}
524
- onClick={() => onChange?.({ fileID, uuid, type: 'delete' })}
525
- />
526
- );
536
+ const renderDelete = () =>
537
+ isEdit && (
538
+ <Icon
539
+ type="delete"
540
+ style={{ cursor: 'pointer' }}
541
+ onClick={() => onChange?.({ fileID, uuid, type: 'delete' })}
542
+ />
543
+ );
527
544
 
528
545
  // 操作列按钮-取消
529
- const renderCancel = () => (
530
- <Icon
531
- type="dismiss"
532
- style={{ cursor: 'pointer' }}
533
- onClick={() => onCancel?.(uuid)}
534
- />
535
- );
546
+ const renderCancel = () =>
547
+ isEdit && (
548
+ <Icon
549
+ type="dismiss"
550
+ style={{ cursor: 'pointer' }}
551
+ onClick={() => onCancel?.(uuid)}
552
+ />
553
+ );
536
554
 
537
555
  // 操作列按钮-重新上传
538
- const renderReLoad = () => (
539
- <Icon
540
- type="refresh"
541
- style={{ cursor: 'pointer' }}
542
- onClick={() => {
543
- onReLoad?.(file);
544
- }}
545
- />
546
- );
556
+ const renderReLoad = () =>
557
+ isEdit && (
558
+ <Icon
559
+ type="refresh"
560
+ style={{ cursor: 'pointer' }}
561
+ onClick={() => {
562
+ onReLoad?.(file);
563
+ }}
564
+ />
565
+ );
547
566
 
548
567
  // 操作列按钮-下载
549
568
  const renderDownLoad = () => (
@@ -16,11 +16,13 @@ import {
16
16
  transSize,
17
17
  downloadFile,
18
18
  cutFileTitle,
19
+ transFileCloudidToName,
19
20
  } from '../../../utils/platform';
20
21
  import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
21
22
  import classNames from '../../../utils/classnames';
22
23
  import { renderDecorator } from '../renderDecorator';
23
24
  import { CommonFormPropsType } from '../types';
25
+ import isObjectEqual from '../../../utils/isObjectEqual';
24
26
 
25
27
  // 默认组件类前缀
26
28
  const CLASS_PREFIX = 'weda-upload-file-pc';
@@ -66,12 +68,20 @@ export function UploadFilePc({
66
68
  onChange = null,
67
69
  isEdit = true,
68
70
  }: IUploaderFilePc) {
69
- const [fileIDList, setfileIDList] = React.useState(
70
- filterStrList([].concat(defaultValue, value))
71
- ); // 上传成功文件ID列表,fileID[]
71
+
72
+
73
+ const [fileIDList, setfileIDList] = React.useState(filterStrList([].concat(defaultValue, value))); // 上传成功文件ID列表,fileID[]
72
74
  const [fileList, setFileList] = React.useState([]); // 上传中的文件列表,file[],file为原始文件 + uuid属性
73
75
  const [fileSizeObj, setFileSizeObj] = React.useState({}); // 管理上传文件大小 {uuid:size}
74
-
76
+ // 两次默认值不同, 需要刷新
77
+ const prevDefaultRef = React.useRef<any>([]);
78
+ React.useMemo(()=>{
79
+ //有有效默认值时不刷新,解决初次渲染默认值不显示问题
80
+ if(defaultValue&&!isObjectEqual(prevDefaultRef.current,defaultValue)&&(JSON.stringify(prevDefaultRef.current)=='[]'||!prevDefaultRef.current)){
81
+ prevDefaultRef.current =defaultValue;
82
+ setfileIDList(filterStrList([].concat(defaultValue)));
83
+ }
84
+ },[defaultValue]);
75
85
  React.useEffect(() => {
76
86
  // 外部 onChange 事件
77
87
  const pureFileIDList = fileIDList.filter(
@@ -88,7 +98,6 @@ export function UploadFilePc({
88
98
  events?.success?.({ value: pureFileIDList });
89
99
  }
90
100
  }, [fileIDList]);
91
-
92
101
  // 外层组件类
93
102
  const cls = classNames({
94
103
  'weda-ui': true,
@@ -283,11 +292,7 @@ const TcbFileEcho = ({ fileID }: ITcbFileEcho) => {
283
292
 
284
293
  const title = React.useMemo(() => {
285
294
  if (isCloudFileID(fileID)) {
286
- const uuidReg = /file-[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}-/;
287
- const lastIndex = `${fileID}`.lastIndexOf('/');
288
- const name = `${fileID}`.slice(lastIndex + 1);
289
- const title = name.replace(uuidReg, '');
290
- return title;
295
+ return transFileCloudidToName(fileID);
291
296
  } else {
292
297
  return fileID;
293
298
  }
@@ -342,7 +347,7 @@ const TcbFileUpload = ({ file }: ITcbFileUpload) => {
342
347
  try {
343
348
  setStatus('0');
344
349
  const { fileID } = await tcb.uploadFile({
345
- cloudPath: `${uploadPath}/${`file-${uuid}-${title}`}`,
350
+ cloudPath: `${uploadPath}/${uuid.replaceAll('-', '')}-${file?.name}`,
346
351
  filePath: file,
347
352
  onUploadProgress: (progressEvent) => {
348
353
  let percent = 0;
@@ -0,0 +1,159 @@
1
+ /* pc style */
2
+ .weda-graphic-card {
3
+ width: 100%;
4
+ }
5
+
6
+ .weda-graphic-card .weda-graphic-card__wrapper {
7
+ width: 100%;
8
+ padding: 0 24px;
9
+ }
10
+
11
+ .weda-graphic-card .weda-graphic-card__row {
12
+ margin: 0;
13
+ padding: 20px 0;
14
+ }
15
+
16
+ .weda-graphic-card .weda-graphic-card__col {
17
+ padding: 0;
18
+ }
19
+
20
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__col-body {
21
+ width: 100%;
22
+ }
23
+
24
+ .weda-graphic-card .weda-graphic-card__col .wedatea2td-grid__box,
25
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__col-body {
26
+ display: flex;
27
+ flex-direction: column;
28
+ justify-content: space-between;
29
+ align-items: center;
30
+ }
31
+
32
+ .weda-graphic-card
33
+ .weda-graphic-card__col.weda-graphic-card__col--left
34
+ .wedatea2td-grid__box,
35
+ .weda-graphic-card
36
+ .weda-graphic-card__col.weda-graphic-card__col--left
37
+ .weda-graphic-card__col-body {
38
+ align-items: flex-start;
39
+ width: 100%;
40
+ }
41
+
42
+ .weda-graphic-card
43
+ .weda-graphic-card__col.weda-graphic-card__col--right
44
+ .wedatea2td-grid__box,
45
+ .weda-graphic-card
46
+ .weda-graphic-card__col.weda-graphic-card__col--right
47
+ .weda-graphic-card__col-body {
48
+ align-items: flex-end;
49
+ width: 100%;
50
+ }
51
+ .weda-graphic-card
52
+ .weda-graphic-card__col.weda-graphic-card__col--center
53
+ .wedatea2td-grid__box,
54
+ .weda-graphic-card
55
+ .weda-graphic-card__col.weda-graphic-card__col--center
56
+ .weda-graphic-card__col-body {
57
+ align-items: center;
58
+ width: 100%;
59
+ }
60
+ .weda-graphic-card
61
+ .weda-graphic-card__col.weda-graphic-card__col--justify
62
+ .wedatea2td-grid__box,
63
+ .weda-graphic-card
64
+ .weda-graphic-card__col.weda-graphic-card__col--justify
65
+ .weda-graphic-card__col-body {
66
+ width: 100%;
67
+ }
68
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__icon {
69
+ width: 100%;
70
+ height: 200px;
71
+ }
72
+
73
+ .weda-graphic-card .weda-graphic-card__icon .weda-graphic-card__img {
74
+ width: 100%;
75
+ height: 100%;
76
+ object-fit: cover;
77
+ }
78
+
79
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__detail {
80
+ width: 100%;
81
+ }
82
+
83
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__title {
84
+ font-size: 16px;
85
+ line-height: 24px;
86
+ text-align: center;
87
+ color: rgba(0, 0, 0, 0.9);
88
+ display: -webkit-box;
89
+ overflow: hidden;
90
+ text-overflow: ellipsis;
91
+ -webkit-box-orient: vertical;
92
+ -webkit-line-clamp: 2;
93
+ }
94
+
95
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__desc {
96
+ font-size: 14px;
97
+ line-height: 22px;
98
+ color: rgba(0, 0, 0, 0.4);
99
+ text-align: center;
100
+ display: -webkit-box;
101
+ overflow: hidden;
102
+ text-overflow: ellipsis;
103
+ -webkit-box-orient: vertical;
104
+ -webkit-line-clamp: 2;
105
+ }
106
+
107
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__btn--text {
108
+ font-size: 14px;
109
+ line-height: 22px;
110
+ color: #0052d9;
111
+ margin-right: 8px;
112
+ }
113
+
114
+ .weda-graphic-card .weda-graphic-card__btn-icon {
115
+ margin-bottom: 2px;
116
+ }
117
+
118
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__title {
119
+ margin-top: 20px;
120
+ }
121
+
122
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__desc {
123
+ margin-top: 8px;
124
+ }
125
+
126
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__btn {
127
+ margin-top: 20px;
128
+ }
129
+
130
+ /* h5 style */
131
+ .weda-graphic-card-mobile .weda-graphic-card__wrapper {
132
+ width: 100%;
133
+ padding: 0 16px;
134
+ }
135
+
136
+ .weda-graphic-card-mobile .weda-graphic-card__row {
137
+ padding: 18px 0;
138
+ margin: 0 -5.5px;
139
+ }
140
+
141
+ .weda-graphic-card-mobile .weda-graphic-card__col {
142
+ padding: 0 5.5px !important;
143
+ }
144
+
145
+ .weda-graphic-card-mobile .weda-graphic-card__col .weda-graphic-card__detail {
146
+ padding: 0 !important;
147
+ }
148
+
149
+ .weda-graphic-card-mobile .weda-graphic-card__col .weda-graphic-card__title {
150
+ margin-top: 16px;
151
+ }
152
+
153
+ .weda-graphic-card-mobile .weda-graphic-card__col .weda-graphic-card__desc {
154
+ margin-top: 6px;
155
+ }
156
+
157
+ .weda-graphic-card-mobile .weda-graphic-card__col .weda-graphic-card__btn {
158
+ margin-top: 16px;
159
+ }