@cloudbase/weda-ui 3.20.1 → 3.20.3

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 (76) hide show
  1. package/dist/configs/components/chart/bar.js +2 -2
  2. package/dist/configs/components/chart/line.js +2 -2
  3. package/dist/configs/components/chart/pie.js +2 -2
  4. package/dist/configs/components/chart/statisticsCard.json +5 -12
  5. package/dist/configs/components/form/location.json +3 -9
  6. package/dist/configs/components/form-location.d.ts +2 -2
  7. package/dist/configs/components/form-location.js +1 -1
  8. package/dist/configs/components/form-user-tree-select.js +1 -1
  9. package/dist/configs/components/scrollVeiw.json +43 -79
  10. package/dist/configs/components/wd-calendar.d.ts +4 -0
  11. package/dist/configs/components/wd-calendar.js +23 -1
  12. package/dist/configs/components/wd-cascader.d.ts +7 -12
  13. package/dist/configs/components/wd-cascader.js +12 -1
  14. package/dist/configs/components/wd-checkbox.d.ts +4 -1
  15. package/dist/configs/components/wd-checkbox.js +11 -1
  16. package/dist/configs/components/wd-location.d.ts +2 -2
  17. package/dist/configs/components/wd-location.js +1 -1
  18. package/dist/configs/components/wd-member.d.ts +2 -0
  19. package/dist/configs/components/wd-member.js +5 -1
  20. package/dist/configs/components/wd-radio.d.ts +4 -1
  21. package/dist/configs/components/wd-rich-text.d.ts +2 -0
  22. package/dist/configs/components/wd-rich-text.js +1 -0
  23. package/dist/configs/components/wd-select-multiple.d.ts +4 -1
  24. package/dist/configs/components/wd-select-multiple.js +11 -1
  25. package/dist/configs/components/wd-select.d.ts +4 -1
  26. package/dist/configs/components/wd-table.js +3 -2
  27. package/dist/configs/components/wd-tag-select.d.ts +4 -1
  28. package/dist/configs/components/wd-tag-select.js +11 -1
  29. package/dist/configs/components/wd-top-tab.d.ts +1 -1
  30. package/dist/configs/components/wd-top-tab.js +2 -1
  31. package/dist/configs/components/wd-upload-file.d.ts +2 -0
  32. package/dist/configs/components/wd-upload-file.js +1 -0
  33. package/dist/configs/components/wd-upload-image.d.ts +18 -11
  34. package/dist/configs/components/wd-upload-image.js +8 -6
  35. package/dist/configs/index.d.ts +130 -74
  36. package/dist/configs/type-utils/type-form.d.ts +12 -4
  37. package/dist/configs/type-utils/type-form.js +54 -4
  38. package/dist/enum/index.js +1 -0
  39. package/dist/style/index.css +1 -0
  40. package/dist/style/index.scss +1 -1
  41. package/dist/style/weda-ui.min.css +2 -2
  42. package/dist/web/components/form/location/common/propsConfig.d.ts +3 -3
  43. package/dist/web/components/form/location/common/propsConfig.js +2 -2
  44. package/dist/web/components/form/location/components/LocationH5/location.h5.js +36 -27
  45. package/dist/web/components/form/location/components/LocationPC/Header.js +2 -2
  46. package/dist/web/components/form/location/components/LocationPC/location.PC.js +38 -41
  47. package/dist/web/components/form/uploader/upload/index.d.ts +1 -0
  48. package/dist/web/components/form/uploader/upload/index.js +7 -5
  49. package/dist/web/components/form/uploader/uploader.h5.d.ts +1 -0
  50. package/dist/web/components/form/uploader/uploader.pc.js +1 -1
  51. package/dist/web/components/form/uploader/util.d.ts +1 -0
  52. package/dist/web/components/form/uploader/util.js +7 -3
  53. package/dist/web/components/form/uploaderFile/uploadFile.h5.d.ts +2 -1
  54. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +11 -8
  55. package/dist/web/components/form/uploaderFile/uploadFile.pc.d.ts +2 -1
  56. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +11 -8
  57. package/dist/web/components/form-location/index.d.ts +1 -1
  58. package/dist/web/components/form-location/index.js +3 -3
  59. package/dist/web/components/form-user-tree-select/index.js +4 -2
  60. package/dist/web/components/richText/index.d.ts +4 -1
  61. package/dist/web/components/richText/index.js +16 -14
  62. package/dist/web/components/uploaderFileView/index.js +3 -3
  63. package/dist/web/components/wd-calendar/wd-calendar.js +4 -11
  64. package/dist/web/components/wd-calendar/weeks.d.ts +1 -1
  65. package/dist/web/components/wd-calendar/weeks.js +2 -2
  66. package/dist/web/components/wd-form/index.js +12 -7
  67. package/dist/web/components/wd-location/wd-location.d.ts +1 -1
  68. package/dist/web/components/wd-location/wd-location.js +2 -2
  69. package/dist/web/components/wd-member/wd-member.js +4 -2
  70. package/dist/web/components/wd-rich-text/wd-rich-text.js +2 -2
  71. package/dist/web/components/wd-select/select/selectUI.js +4 -1
  72. package/dist/web/components/wd-table/components/ExportFileModalByApi/index.js +3 -2
  73. package/dist/web/components/wd-table/hooks/useTableData.js +8 -3
  74. package/dist/web/components/wd-upload-file/wd-upload-file.js +2 -2
  75. package/dist/web/components/wd-upload-image/wd-upload-image.js +2 -2
  76. package/package.json +2 -2
@@ -8,7 +8,7 @@ export namespace propTypes {
8
8
  const APIKEY: PropTypes.Requireable<string>;
9
9
  const showLngLat: PropTypes.Requireable<boolean>;
10
10
  const showMap: PropTypes.Requireable<boolean>;
11
- const defauleShowLocation: PropTypes.Requireable<boolean>;
11
+ const defaultShowLocation: PropTypes.Requireable<boolean>;
12
12
  const drag: PropTypes.Requireable<boolean>;
13
13
  const zoom: PropTypes.Requireable<boolean>;
14
14
  const disabled: PropTypes.Requireable<boolean>;
@@ -31,8 +31,8 @@ export namespace defaultProps {
31
31
  export { showLngLat_1 as showLngLat };
32
32
  const showMap_1: boolean;
33
33
  export { showMap_1 as showMap };
34
- const defauleShowLocation_1: boolean;
35
- export { defauleShowLocation_1 as defauleShowLocation };
34
+ const defaultShowLocation_1: boolean;
35
+ export { defaultShowLocation_1 as defaultShowLocation };
36
36
  const drag_1: boolean;
37
37
  export { drag_1 as drag };
38
38
  const zoom_1: boolean;
@@ -11,7 +11,7 @@ export const propTypes = {
11
11
  APIKEY: PropTypes.string,
12
12
  showLngLat: PropTypes.bool,
13
13
  showMap: PropTypes.bool,
14
- defauleShowLocation: PropTypes.bool,
14
+ defaultShowLocation: PropTypes.bool,
15
15
  drag: PropTypes.bool,
16
16
  zoom: PropTypes.bool,
17
17
  disabled: PropTypes.bool,
@@ -30,7 +30,7 @@ export const defaultProps = {
30
30
  APIKEY: '',
31
31
  showLngLat: false,
32
32
  showMap: false,
33
- defauleShowLocation: false,
33
+ defaultShowLocation: false,
34
34
  drag: true,
35
35
  zoom: true,
36
36
  disabled: false,
@@ -52,33 +52,24 @@ export default function LocationH5(props) {
52
52
  const currentLocations = useRef();
53
53
  const customLocation = useRef();
54
54
  useEffect(() => {
55
- if (value || !currentLocations.current)
56
- return;
57
- setUserSelectStatus('');
58
- // 重置表单时
59
- const { poiname, detailedAddress, latlng: { lat, lng }, } = currentLocations.current;
60
- let location = {
61
- poiname,
62
- detailedAddress,
63
- latlng: { lat, lng },
64
- };
65
- if (locationType === 1) {
66
- location.locationType = 1;
55
+ if (locationType !== 3) {
56
+ // 默认位置选择无时【locationType=1】
57
+ let location = {
58
+ latlng: {
59
+ lat: 39.98410411,
60
+ lng: 116.307503,
61
+ },
62
+ poiname: '',
63
+ detailedAddress: '',
64
+ locationType,
65
+ };
66
+ // 默认位置选择当前用户位置时【locationType=2】
67
+ if (locationType === 2 && currentLocations.current) {
68
+ location = currentLocations.current;
69
+ }
70
+ setLocation(location);
71
+ setUserSelectStatus((location === null || location === void 0 ? void 0 : location.detailedAddress) ? 'selected' : '');
67
72
  }
68
- setLocation(location);
69
- }, [value, locationType]);
70
- useEffect(() => {
71
- let loc = {
72
- latlng: {
73
- lat: 39.98410411,
74
- lng: 116.307503,
75
- },
76
- poiname: '',
77
- detailedAddress: '',
78
- locationType,
79
- };
80
- setLocation(loc);
81
- // 暂不支持自定位置,初始化表单值都是{}
82
73
  }, [locationType]);
83
74
  useEffect(() => {
84
75
  if (checkCustomLocation(value)) {
@@ -91,8 +82,26 @@ export default function LocationH5(props) {
91
82
  latlng: { lng: coordinates[0], lat: coordinates[1] },
92
83
  };
93
84
  customLocation.current = value;
94
- setUserSelectStatus('selected');
95
85
  setLocation(loc);
86
+ setUserSelectStatus('selected');
87
+ }
88
+ else {
89
+ // 默认位置选择无时【locationType=1】
90
+ let location = {
91
+ latlng: {
92
+ lat: 39.98410411,
93
+ lng: 116.307503,
94
+ },
95
+ poiname: '',
96
+ detailedAddress: '',
97
+ locationType,
98
+ };
99
+ // 默认位置选择当前用户位置时【locationType=2】
100
+ if (locationType === 2 && currentLocations.current) {
101
+ location = currentLocations.current;
102
+ }
103
+ setLocation(location);
104
+ setUserSelectStatus((location === null || location === void 0 ? void 0 : location.poiname) ? 'selected' : '');
96
105
  }
97
106
  }, [value]);
98
107
  // 获取定位信息
@@ -13,10 +13,10 @@ const Header = ({ onClick, isEdit, info, disabled, showLngLat, locationType, dat
13
13
  if (locationType === 1 && info.locationType === 1) {
14
14
  status = false;
15
15
  }
16
- else if (locationType === 2 && !dataSourceStatus) {
16
+ else if ([2, 3].includes(locationType) && !dataSourceStatus) {
17
17
  status = false;
18
18
  }
19
- else if (locationType === 2 && !apiKeyStatus.status) {
19
+ else if ([2, 3].includes(locationType) && !apiKeyStatus.status) {
20
20
  status = false;
21
21
  }
22
22
  else if (!currentLocStatus) {
@@ -56,6 +56,26 @@ export default function LocationPC(props) {
56
56
  dataSourceStatus,
57
57
  eventsChange,
58
58
  });
59
+ useEffect(() => {
60
+ if (locationType !== 3) {
61
+ // 默认位置选择无时【locationType=1】
62
+ let location = {
63
+ latlng: {
64
+ lat: 39.98410411,
65
+ lng: 116.307503,
66
+ },
67
+ poiname: '',
68
+ detailedAddress: '',
69
+ locationType,
70
+ };
71
+ // 默认位置选择当前用户位置时【locationType=2】
72
+ if (locationType === 2 && currentLocations.current) {
73
+ location = currentLocations.current;
74
+ }
75
+ setLocation(location);
76
+ setUserSelectStatus((location === null || location === void 0 ? void 0 : location.detailedAddress) ? 'selected' : '');
77
+ }
78
+ }, [locationType]);
59
79
  useEffect(() => {
60
80
  if (checkCustomLocation(value)) {
61
81
  // 表单为新增时回传点位信息
@@ -70,23 +90,25 @@ export default function LocationPC(props) {
70
90
  setLocation(loc);
71
91
  setUserSelectStatus('selected');
72
92
  }
73
- }, [value]);
74
- useEffect(() => {
75
- if (value || !currentLocations.current)
76
- return;
77
- setUserSelectStatus('');
78
- // 重置表单时
79
- const { poiname, detailedAddress, latlng: { lat, lng }, } = currentLocations.current;
80
- let location = {
81
- poiname,
82
- detailedAddress,
83
- latlng: { lat, lng },
84
- };
85
- if (locationType === 1) {
86
- location.locationType = 1;
93
+ else {
94
+ // 默认位置选择无时【locationType=1】
95
+ let location = {
96
+ latlng: {
97
+ lat: 39.98410411,
98
+ lng: 116.307503,
99
+ },
100
+ poiname: '',
101
+ detailedAddress: '',
102
+ locationType,
103
+ };
104
+ // 默认位置选择当前用户位置时【locationType=2】
105
+ if (locationType === 2 && currentLocations.current) {
106
+ location = currentLocations.current;
107
+ }
108
+ setLocation(location);
109
+ setUserSelectStatus((location === null || location === void 0 ? void 0 : location.poiname) ? 'selected' : '');
87
110
  }
88
- setLocation(location);
89
- }, [value, locationType]);
111
+ }, [value]);
90
112
  const showToast = (message) => {
91
113
  weui.toast(message, {
92
114
  duration: 3000,
@@ -156,31 +178,6 @@ export default function LocationPC(props) {
156
178
  });
157
179
  }
158
180
  }, [dataSource]);
159
- useEffect(() => {
160
- let loc = {
161
- latlng: {
162
- lat: 39.98410411,
163
- lng: 116.307503,
164
- },
165
- poiname: '',
166
- detailedAddress: '',
167
- locationType,
168
- };
169
- switch (locationType) {
170
- case 2:
171
- loc = {
172
- latlng: {
173
- lat: location.latlng.lat,
174
- lng: location.latlng.lng,
175
- },
176
- poiname: location.poiname,
177
- detailedAddress: location.detailedAddress,
178
- };
179
- break;
180
- }
181
- setLocation(loc);
182
- // 暂不支持自定位置,初始化表单值都是{}
183
- }, [locationType]);
184
181
  const getIsShowMap = () => {
185
182
  let status = showMap;
186
183
  if (locationType === 1 && location.locationType === 1) {
@@ -19,6 +19,7 @@ interface UploadProps extends EventsType {
19
19
  callbacks?: DataType['callbacks'];
20
20
  onChange?: (val?: any) => void;
21
21
  setUploadHandle?: (uploadHandle: any) => void;
22
+ storageType?: DataType['storageType'];
22
23
  children?: any;
23
24
  }
24
25
  export declare const IMAGE_TYPES: string[];
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { forwardRef, useState, useCallback, useEffect, useImperativeHandle } from 'react';
3
3
  import { getUuid } from '../../../../utils/tool';
4
- import { upload as uploadAction, checkBeforeUpload, getPreviewFileMap, getInitTempFile, getBase64 } from '../util';
4
+ import { upload as uploadAction, checkBeforeUpload, getPreviewFileMap, getInitTempFile, getBase64, storageTypeIsHttps, } from '../util';
5
5
  import { errorHandler } from '../../../../utils/error';
6
6
  import { isNil } from '../../../../utils/lodash';
7
7
  import { toBase64Uri } from '../../../../utils/file2base64';
@@ -19,7 +19,8 @@ export const IMAGE_TYPES = [
19
19
  'image/gif',
20
20
  ];
21
21
  export const Upload = forwardRef(function Upload({ children, ...props }, ref) {
22
- const { maxUploadCount, acceptTypes, multiple, maxSize, disabled, readOnly, name, isCompressBeforeUpload, compressQuality, compressedHeight, compressedWidth, events, onChange, callbacks, setUploadHandle, value: _value, sourceType, } = props;
22
+ const { maxUploadCount, acceptTypes, multiple, maxSize, disabled, readOnly, name, isCompressBeforeUpload, compressQuality, compressedHeight, compressedWidth, events, onChange, callbacks, setUploadHandle, value: _value, sourceType, storageType, } = props;
23
+ const _storageTypeIsHttps = storageTypeIsHttps(storageType);
23
24
  const inputRef = React.useRef(null);
24
25
  const [inputId, setInputId] = useState(() => {
25
26
  return getUuid();
@@ -50,6 +51,7 @@ export const Upload = forwardRef(function Upload({ children, ...props }, ref) {
50
51
  compressQuality,
51
52
  compressedHeight,
52
53
  compressedWidth,
54
+ storageType,
53
55
  }, equal);
54
56
  const [initFlag, setInitFlag] = useState(false);
55
57
  React.useEffect(() => {
@@ -72,7 +74,7 @@ export const Upload = forwardRef(function Upload({ children, ...props }, ref) {
72
74
  var _a;
73
75
  updatePreviewFile(allFile);
74
76
  const getTempFile = (allFile = []) => {
75
- let value = allFile.map((i) => i === null || i === void 0 ? void 0 : i.cloudId).filter((j) => !!j);
77
+ let value = allFile.map((i) => (_storageTypeIsHttps ? i.url.split('?')[0] : i === null || i === void 0 ? void 0 : i.cloudId)).filter((j) => !!j);
76
78
  value = !multiple ? value[0] || '' : value;
77
79
  return value;
78
80
  };
@@ -80,7 +82,7 @@ export const Upload = forwardRef(function Upload({ children, ...props }, ref) {
80
82
  onChange === null || onChange === void 0 ? void 0 : onChange(value);
81
83
  (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value, isDelete });
82
84
  setInputId(getUuid());
83
- }, [events, multiple, onChange]);
85
+ }, [events, multiple, onChange, storageType]);
84
86
  const uploadChange = useCallback(async (e) => {
85
87
  const { accepts, maxSize, maxUploadCount } = config;
86
88
  let files = [...e.target.files];
@@ -163,7 +165,7 @@ export const Upload = forwardRef(function Upload({ children, ...props }, ref) {
163
165
  onSuccess(item) {
164
166
  var _a;
165
167
  updatePreviewFile((allTempFile) => allTempFile.map((i) => (i.key === item.key ? { ...i, ...item } : i)));
166
- (_a = events === null || events === void 0 ? void 0 : events.success) === null || _a === void 0 ? void 0 : _a.call(events, { value: item.cloudId, file: item.file });
168
+ (_a = events === null || events === void 0 ? void 0 : events.success) === null || _a === void 0 ? void 0 : _a.call(events, { value: _storageTypeIsHttps ? item.url : item.cloudId, file: item.file });
167
169
  },
168
170
  onFail(err) {
169
171
  events === null || events === void 0 ? void 0 : events.error(err);
@@ -36,5 +36,6 @@ export interface H5UploaderProps extends Except<CommonFormPropsType, 'events'>,
36
36
  tempFile?: any;
37
37
  setTempFile?: any;
38
38
  setUploadHandle?: (arg?: any) => void;
39
+ storageType?: DataType['storageType'];
39
40
  }
40
41
  export {};
@@ -19,7 +19,7 @@ export const IMAGE_TYPES = [
19
19
  'image/gif',
20
20
  ];
21
21
  export function UploaderPCInner(props) {
22
- const { tips = '', btnTitle = '上传图片', maxUploadCount = 9, maxSize = 10, acceptTypes = IMAGE_TYPES, single = false, disabled = false, imgTypeCls, readOnly, sourceType, popupContainer: portalContainer, defaultValue, setUploadHandle: outSetUploadHandle, } = props;
22
+ const { tips = '', btnTitle = '上传图片', maxUploadCount = 9, acceptTypes = IMAGE_TYPES, single = false, disabled = false, imgTypeCls, readOnly, sourceType, popupContainer: portalContainer, defaultValue, setUploadHandle: outSetUploadHandle, } = props;
23
23
  const uploadRef = React.useRef(null);
24
24
  const [uploadHandle, setUploadHandle] = React.useState({});
25
25
  const tempFile = React.useMemo(() => (uploadHandle === null || uploadHandle === void 0 ? void 0 : uploadHandle.previewFile) || [], [uploadHandle === null || uploadHandle === void 0 ? void 0 : uploadHandle.previewFile]);
@@ -1,5 +1,6 @@
1
1
  import { TempFileProps } from './upload/index';
2
2
  export declare const DEFAULT_UPLOAD_PATH = "weda-uploader";
3
+ export declare const storageTypeIsHttps: (storageType: any) => boolean;
3
4
  export declare const getBase64: (files: any) => Promise<any[]>;
4
5
  export declare const uploadTcbMulti: (files: any, props: any) => Promise<any[]>;
5
6
  export declare const filenameRegex: RegExp;
@@ -4,6 +4,7 @@ import { toBase64Uri } from '../../../utils/file2base64';
4
4
  import { randomStr, alertErrorMessage } from '../../../utils/platform';
5
5
  import { errorHandler } from '../../../utils/error';
6
6
  export const DEFAULT_UPLOAD_PATH = 'weda-uploader';
7
+ export const storageTypeIsHttps = (storageType) => storageType === 'https';
7
8
  export const getBase64 = (files) => {
8
9
  return Promise.all(files.map(async (item) => {
9
10
  let tempUrl = '';
@@ -60,7 +61,7 @@ const uploadToTcb = async (item, props) => {
60
61
  _uploadPath = `${_uploadPath}/${sanitizeFilename(customUploadPath, '')}}`;
61
62
  }
62
63
  const cloudPath = `${_uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`;
63
- const { fileID } = await tcb.uploadFile({
64
+ const res = await tcb.uploadFile({
64
65
  cloudPath,
65
66
  filePath: file,
66
67
  onUploadProgress: (progressEvent) => {
@@ -84,7 +85,8 @@ const uploadToTcb = async (item, props) => {
84
85
  ...item,
85
86
  progress: 100,
86
87
  loading: false,
87
- cloudId: fileID,
88
+ cloudId: res.fileID,
89
+ url: res.download_url,
88
90
  };
89
91
  if (onUploadFinish) {
90
92
  onUploadFinish(fileItem);
@@ -172,6 +174,7 @@ export const getInitTempFile = ({ value }) => {
172
174
  tempUrl: '',
173
175
  progress: 100,
174
176
  loading: false,
177
+ url: '',
175
178
  }));
176
179
  return tempFile;
177
180
  };
@@ -189,8 +192,9 @@ export const IMAGE_TYPES = [
189
192
  ];
190
193
  export const upload = async (fileList, uploadInstance, allTempFile) => {
191
194
  const { config = {}, onComplete, onSuccess, onFail, onUploadProgress } = uploadInstance;
192
- const { isCompressBeforeUpload, compressQuality, compressedHeight, compressedWidth } = config;
195
+ const { isCompressBeforeUpload, compressQuality, compressedHeight, compressedWidth, storageType } = config;
193
196
  const result = await uploadTcbMulti(fileList, {
197
+ storageType,
194
198
  isCompressBeforeUpload,
195
199
  compressedHeight,
196
200
  compressedWidth,
@@ -3,7 +3,7 @@ import type { CommonFormPropsType } from '../types';
3
3
  import type { DataType } from '../../../../configs/components/wd-upload-file';
4
4
  export declare const FILES_TYPES: string[];
5
5
  export declare function UploadFileH5({ layout, id, style, labelVisible, label, requiredFlag, disabled, className, acceptTypes, tips, btnTitle, uploadTipText, maxUploadCount, maxSize, deleteVisible, downloadVisible, value, // 需要兼容 cloud:和https: 协议,需要兼容字符串和字符串数组
6
- events, defaultValue, uploadPath, single, onChange, isEdit, $node, readOnly, callbacks, }: IUploadFileH5): JSX.Element;
6
+ events, defaultValue, uploadPath, single, onChange, isEdit, $node, readOnly, callbacks, storageType, }: IUploadFileH5): JSX.Element;
7
7
  export interface IUploadFileH5 extends CommonFormPropsType {
8
8
  className?: string;
9
9
  label?: string;
@@ -24,4 +24,5 @@ export interface IUploadFileH5 extends CommonFormPropsType {
24
24
  readOnly?: boolean;
25
25
  callbacks?: DataType['callbacks'];
26
26
  uploadTipText?: string;
27
+ storageType?: DataType['storageType'];
27
28
  }
@@ -13,7 +13,7 @@ import { WdButton } from '../../wd-button/wd-button';
13
13
  import { toBase64Uri } from '../../../utils/file2base64';
14
14
  import { isNil } from '../../../utils/lodash';
15
15
  import { errorHandler } from '../../../utils/error';
16
- import { filenameRegex, checkAcceptedFiles } from '../uploader/util';
16
+ import { filenameRegex, checkAcceptedFiles, storageTypeIsHttps } from '../uploader/util';
17
17
  // 默认组件类前缀
18
18
  const CLASS_PREFIX = 'weda-upload-file-mobile';
19
19
  // 默认图片类型
@@ -42,8 +42,9 @@ export function UploadFileH5({
42
42
  layout, id = '', style = defaultStyle, labelVisible = true, label = '上传文件', requiredFlag = false, disabled = false, className = '', acceptTypes = emptyArray,
43
43
  // 组件属性
44
44
  tips = '', btnTitle = '点击上传', uploadTipText = '支持批量上传', maxUploadCount = 9, maxSize = 10, deleteVisible = true, downloadVisible = true, value = emptyArray, // 需要兼容 cloud:和https: 协议,需要兼容字符串和字符串数组
45
- events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true, onChange = null, isEdit = true, $node, readOnly, callbacks, }) {
45
+ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true, onChange = null, isEdit = true, $node, readOnly, callbacks, storageType = 'cloudID', }) {
46
46
  var _a;
47
+ const _storageTypeIsHttps = storageTypeIsHttps(storageType);
47
48
  const [fileIDList, setfileIDList] = React.useState(isInIde() ? [] : filterStrList([].concat(defaultValue, value))); // 上传成功文件ID列表,fileID[]
48
49
  const [fileList, setFileList] = React.useState([]); // 上传中的文件列表,file[],file为原始文件 + uuid属性
49
50
  const [fileSizeObj, setFileSizeObj] = React.useState({}); // 管理上传文件大小 {uuid:size}
@@ -94,8 +95,9 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
94
95
  return acceptTypes.includes('*') || acceptTypes.length === 0 ? ['*'] : Array.from(new Set(acceptTypes));
95
96
  }, [acceptTypes]);
96
97
  // 上传后文件列表 fileIDList 改变事件,'add'|'delete'
97
- const handleChange = ({ fileID, uuid, type, size, file }) => {
98
+ const handleChange = ({ fileID: _fileID, uuid, type, size, file, url }) => {
98
99
  var _a;
100
+ const fileID = _storageTypeIsHttps ? url : _fileID;
99
101
  if (fileID) {
100
102
  changeTypeRef.current = type;
101
103
  if (type === 'add') {
@@ -257,12 +259,12 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
257
259
  }, [file === null || file === void 0 ? void 0 : file._uuid]);
258
260
  // 上传过程
259
261
  const handleUpload = async (file) => {
260
- var _a, _b;
262
+ var _a, _b, _c;
261
263
  const tcb = await getCloudInstance();
262
264
  try {
263
265
  setStatus('UPLOAD_STATUS_PENDING');
264
266
  const _uploadPath = getDefaultUploadPath(uploadPath);
265
- const { fileID } = await tcb.uploadFile({
267
+ const { fileID, download_url } = await tcb.uploadFile({
266
268
  cloudPath: `${_uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
267
269
  filePath: file,
268
270
  onUploadProgress: (progressEvent) => {
@@ -272,7 +274,8 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
272
274
  setPercent(percent < 100 ? percent : 100);
273
275
  },
274
276
  });
275
- !cancelRef.current && (onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, type: 'add', uuid, size, file }));
277
+ const url = (_b = download_url === null || download_url === void 0 ? void 0 : download_url.split('?')) === null || _b === void 0 ? void 0 : _b[0];
278
+ !cancelRef.current && (onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, url, type: 'add', uuid, size, file }));
276
279
  setStatus('UPLOAD_STATUS_SUCCESS');
277
280
  }
278
281
  catch (err) {
@@ -282,7 +285,7 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
282
285
  id,
283
286
  });
284
287
  setStatus('UPLOAD_STATUS_ERROR');
285
- (_b = events === null || events === void 0 ? void 0 : events.error) === null || _b === void 0 ? void 0 : _b.call(events, err);
288
+ (_c = events === null || events === void 0 ? void 0 : events.error) === null || _c === void 0 ? void 0 : _c.call(events, err);
286
289
  }
287
290
  };
288
291
  return (_jsxs("div", { className: `${CLASS_PREFIX}__item`, role: "TcbFileUpload", children: [_jsx("div", { className: `${CLASS_PREFIX}__item-left`, children: _jsx(UploadFileStatus, { status: status, percent: percent, size: size, title: title, percentSize: (((file === null || file === void 0 ? void 0 : file.size) / 1024) * percent) / 100, formType: formType }) }), _jsx("div", { className: `${CLASS_PREFIX}__btn-group`, children: _jsx(UploadFileAction, { file: file, uuid: file === null || file === void 0 ? void 0 : file._uuid, status: status, onCancel: (uuid) => {
@@ -309,7 +312,7 @@ const UploadFileStatus = ({ status = 'UPLOAD_STATUS_SUCCESS', percent = 0, size,
309
312
  const UploadFileAction = ({ status = 'UPLOAD_STATUS_PENDING', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, disabled, title = 'downfile', }) => {
310
313
  const { onChange, downloadVisible, deleteVisible, isEdit } = React.useContext(FileContext) || {};
311
314
  // 操作列按钮-删除
312
- const renderDelete = () => isEdit && _jsx(Button, { icon: "delete", onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }), disabled: disabled });
315
+ const renderDelete = () => isEdit && (_jsx(Button, { icon: "delete", onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete', url: src }), disabled: disabled }));
313
316
  // 操作列按钮-取消
314
317
  const renderCancel = () => isEdit && _jsx(Button, { icon: "dismiss", onClick: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(uuid) });
315
318
  // 操作列按钮-重新上传
@@ -7,7 +7,7 @@ import type { DataType } from '../../../../configs/components/wd-upload-file';
7
7
  */
8
8
  export declare function UploadFilePc({ layout, id, style, labelVisible, label, requiredFlag, disabled, className, events, decorator, tips, btnTitle, uploadTipText, maxUploadCount, maxSize, single, defaultValue, // 组件默认初始化值
9
9
  value, // 用于模型组件中 formily 的值管理
10
- acceptTypes, downloadVisible, deleteVisible, uploadPath, onChange, isEdit, $node, readOnly, callbacks, }: IUploaderFilePc): JSX.Element;
10
+ acceptTypes, downloadVisible, deleteVisible, uploadPath, onChange, isEdit, $node, readOnly, callbacks, storageType, }: IUploaderFilePc): JSX.Element;
11
11
  export interface IUploaderFilePc extends CommonFormPropsType {
12
12
  btnTitle?: string;
13
13
  maxUploadCount?: number;
@@ -25,6 +25,7 @@ export interface IUploaderFilePc extends CommonFormPropsType {
25
25
  readOnly?: boolean;
26
26
  callbacks?: DataType['callbacks'];
27
27
  uploadTipText?: string;
28
+ storageType?: DataType['storageType'];
28
29
  }
29
30
  export interface IUploadFileAction {
30
31
  status?: string;
@@ -14,7 +14,7 @@ import { getParentForm } from '../../../utils/widget-api';
14
14
  import { toBase64Uri } from '../../../utils/file2base64';
15
15
  import { isNil } from '../../../utils/lodash';
16
16
  import { errorHandler } from '../../../utils/error';
17
- import { filenameRegex } from '../uploader/util';
17
+ import { filenameRegex, storageTypeIsHttps } from '../uploader/util';
18
18
  // 默认组件类前缀
19
19
  const CLASS_PREFIX = 'weda-upload-file-pc';
20
20
  // 上传状态字典
@@ -35,8 +35,9 @@ layout, id = '', style, labelVisible = true, label = '上传文件', requiredFla
35
35
  // 组件属性
36
36
  decorator, tips = '', btnTitle = '点击上传', uploadTipText = '支持批量上传', maxUploadCount = 9, maxSize = 1024, single = true, defaultValue = emptyArray, // 组件默认初始化值
37
37
  value = emptyArray, // 用于模型组件中 formily 的值管理
38
- acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPath = 'weda-uploader', onChange = null, isEdit = true, $node, readOnly, callbacks, }) {
38
+ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPath = 'weda-uploader', onChange = null, isEdit = true, $node, readOnly, callbacks, storageType = 'cloudID', }) {
39
39
  var _a;
40
+ const _storageTypeIsHttps = storageTypeIsHttps(storageType);
40
41
  const [fileIDList, setfileIDList] = React.useState(() => {
41
42
  let defaultVal = defaultValue;
42
43
  let val = value;
@@ -163,8 +164,9 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
163
164
  return Promise.reject(false);
164
165
  };
165
166
  // 上传后文件列表 fileIDList 改变事件,'add'|'delete'
166
- const handleChange = ({ fileID, uuid, type, size, file }) => {
167
+ const handleChange = ({ fileID: _fileID, uuid, type, size, file, url }) => {
167
168
  var _a;
169
+ const fileID = _storageTypeIsHttps ? url : _fileID;
168
170
  if (fileID) {
169
171
  changeTypeRef.current = type;
170
172
  if (type === 'add') {
@@ -220,7 +222,7 @@ const TcbFileEcho = ({ fileID, disabled, formType, readOnly }) => {
220
222
  const { fileSizeObj } = React.useContext(FileContext) || {};
221
223
  const { data: src } = useTempUrl(fileID);
222
224
  const title = React.useMemo(() => {
223
- if (isCloudFileID(fileID)) {
225
+ if (isCloudFileID(fileID) || isHttpFileID(fileID)) {
224
226
  return transFileCloudidToName(fileID);
225
227
  }
226
228
  else {
@@ -249,12 +251,12 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
249
251
  }, [file === null || file === void 0 ? void 0 : file._uuid]);
250
252
  // 上传过程
251
253
  const handleUpload = async (file) => {
252
- var _a;
254
+ var _a, _b;
253
255
  const tcb = await getCloudInstance();
254
256
  try {
255
257
  setStatus('0');
256
258
  const _uploadPath = getDefaultUploadPath(uploadPath);
257
- const { fileID } = await tcb.uploadFile({
259
+ const { fileID, download_url } = await tcb.uploadFile({
258
260
  cloudPath: `${_uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
259
261
  filePath: file,
260
262
  onUploadProgress: (progressEvent) => {
@@ -264,7 +266,8 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
264
266
  setPercent(percent < 100 ? percent : 100);
265
267
  },
266
268
  });
267
- !cancelRef.current && (onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, type: 'add', uuid, size, file }));
269
+ const url = (_b = download_url === null || download_url === void 0 ? void 0 : download_url.split('?')) === null || _b === void 0 ? void 0 : _b[0];
270
+ !cancelRef.current && (onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, url, type: 'add', uuid, size, file }));
268
271
  setStatus('2');
269
272
  }
270
273
  catch (e) {
@@ -301,7 +304,7 @@ const UploadFileAction = ({ title = 'downfile', status = '0', fileID = '', uuid
301
304
  // 操作列按钮-删除
302
305
  const renderDelete = () => isEdit &&
303
306
  deleteVisible &&
304
- !readOnly && (_jsx(WdButton, { text: "\u5220\u9664", size: "sm", variant: "link", disabled: disabled, events: { tap: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }) } }));
307
+ !readOnly && (_jsx(WdButton, { text: "\u5220\u9664", size: "sm", variant: "link", disabled: disabled, events: { tap: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete', url: src }) } }));
305
308
  // 操作列按钮-取消
306
309
  const renderCancel = () => isEdit && _jsx(WdButton, { events: { tap: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(uuid) }, variant: "link", text: "\u53D6\u6D88", size: "sm" });
307
310
  // 操作列按钮-重新上传
@@ -30,7 +30,7 @@ declare const FormLocation: React.ForwardRefExoticComponent<CommonPropsType & {
30
30
  customRange: number;
31
31
  requiredFlag: boolean;
32
32
  requiredMsg: string;
33
- defauleShowLocation: boolean;
33
+ defaultShowLocation: boolean;
34
34
  dataSource: Record<string, unknown>;
35
35
  } & {
36
36
  onChange: (v: DataType['value']) => void;
@@ -5,10 +5,10 @@ import Location from '../form/location';
5
5
  import Tips from '../form/tips';
6
6
  import { useFormInputTrait } from '../form-input-hooks';
7
7
  const FormLocation = React.forwardRef(function FormLocation(props, inputRef) {
8
- const { className, id, style, events, required, requiredFlag, label, labelVisible, customRange, dataSource, defauleShowLocation, locationRange, locationType, showLngLat, showMap, zoom, drag,
8
+ const { className, id, style, events, required, requiredFlag, label, labelVisible, customRange, dataSource, defaultShowLocation, locationRange, locationType, showLngLat, showMap, zoom, drag,
9
9
  // @ts-expect-error 里面有,但dataForm没有,但json有传
10
10
  customLocation, ...restProps } = props;
11
- const { value, name, onChange, disabled, layout, readOnly, validateErrorMsg, validateState, visible, } = useFormInputTrait({
11
+ const { value, name, onChange, disabled, layout, readOnly, validateErrorMsg, validateState, visible } = useFormInputTrait({
12
12
  name: restProps.name,
13
13
  inputRef,
14
14
  required,
@@ -18,6 +18,6 @@ const FormLocation = React.forwardRef(function FormLocation(props, inputRef) {
18
18
  if (!visible) {
19
19
  return null;
20
20
  }
21
- return (_jsxs(FormItemWrapper, { children: [_jsx(Location, { id: id, style: style, className: className, events: events, name: name, disabled: disabled, label: label, labelVisible: labelVisible, layout: layout, requiredFlag: required && requiredFlag, value: value, customLocation: customLocation, customRange: customRange, dataSource: dataSource, defauleShowLocation: defauleShowLocation, drag: drag, locationType: locationType, locationRange: locationRange, showLngLat: showLngLat, showMap: showMap, zoom: zoom, onChange: onChange, readOnly: readOnly }), (validateState === 'error' || validateState === 'warn') && (_jsx(Tips, { tips: validateErrorMsg, type: "warn" }))] }));
21
+ return (_jsxs(FormItemWrapper, { children: [_jsx(Location, { id: id, style: style, className: className, events: events, name: name, disabled: disabled, label: label, labelVisible: labelVisible, layout: layout, requiredFlag: required && requiredFlag, value: value, customLocation: customLocation, customRange: customRange, dataSource: dataSource, defaultShowLocation: defaultShowLocation, drag: drag, locationType: locationType, locationRange: locationRange, showLngLat: showLngLat, showMap: showMap, zoom: zoom, onChange: onChange, readOnly: readOnly }), (validateState === 'error' || validateState === 'warn') && _jsx(Tips, { tips: validateErrorMsg, type: "warn" })] }));
22
22
  });
23
23
  export default FormLocation;
@@ -5,16 +5,18 @@ import Tips from '../form/tips';
5
5
  import { useFormInputTrait, useParentForm } from '../form-input-hooks';
6
6
  import { FormItemWrapper } from '../common/form-item-wrapper';
7
7
  import { convertSingleValue } from '../../utils/tool';
8
+ import { parseStrToArr } from '../form/userOrgSelect/common/utils';
8
9
  const FormUserTreeSelect = React.forwardRef(function FormUserTreeSelect(props, inputRef) {
9
10
  const parent = useParentForm(props.$widget);
10
11
  const { className, id, style, events, required, requiredFlag, label, labelVisible, confirmValue, defaultValueType, multiple, size, where, secondDisplay, corpScope, ...restProps } = props;
11
12
  // 强制转换初始值
12
13
  const initRef = useRef(false);
13
14
  const formValue = useMemo(() => {
15
+ const _value = parseStrToArr(props.value);
14
16
  if (initRef.current)
15
- return props.value;
17
+ return _value;
16
18
  initRef.current = true;
17
- return convertSingleValue(props.value, !multiple);
19
+ return convertSingleValue(_value, !multiple);
18
20
  }, [props.value, multiple]);
19
21
  const { value, name, onChange, disabled, layout, readOnly, validateErrorMsg, validateState, visible } = useFormInputTrait({
20
22
  name: restProps.name,
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import './style';
3
+ import type { DataType } from '../../../configs/components/wd-rich-text';
3
4
  declare const _default: React.MemoExoticComponent<typeof RichText>;
4
5
  export default _default;
5
- declare function RichText({ id, style, className, events, label, labelVisible, value, readOnly, layout, disabled, requiredFlag, onChange, decorator, acceptTypes, initialContent, placeholder, iconPack, maxSize, cloudPath, visible, }: {
6
+ declare function RichText({ id, style, className, events, label, labelVisible, value, readOnly, layout, disabled, requiredFlag, onChange, decorator, acceptTypes, initialContent, placeholder, iconPack, maxSize, cloudPath, visible, storageType, }: {
6
7
  id: any;
7
8
  style: any;
8
9
  className?: string;
@@ -23,6 +24,7 @@ declare function RichText({ id, style, className, events, label, labelVisible, v
23
24
  maxSize: any;
24
25
  cloudPath: any;
25
26
  visible: any;
27
+ storageType?: string;
26
28
  }): JSX.Element;
27
29
  declare namespace RichText {
28
30
  var whyDidYouRender: boolean;
@@ -57,4 +59,5 @@ export interface WdRichTextProps {
57
59
  maxSize?: number;
58
60
  name?: string;
59
61
  cloudPath?: string;
62
+ storageType?: DataType['storageType'];
60
63
  }