@cloudbase/weda-ui 3.4.11 → 3.4.13

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 (168) hide show
  1. package/dist/configs/components/common/form-input-required.js +3 -3
  2. package/dist/configs/components/customer-service.js +3 -0
  3. package/dist/configs/components/dataView.js +20 -10
  4. package/dist/configs/components/form-checkbox.js +15 -2
  5. package/dist/configs/components/form-date.js +1 -1
  6. package/dist/configs/components/form-depart-tree-select.js +1 -1
  7. package/dist/configs/components/form-email.js +17 -2
  8. package/dist/configs/components/form-input.js +17 -2
  9. package/dist/configs/components/form-location.js +1 -1
  10. package/dist/configs/components/form-multi-region.js +1 -1
  11. package/dist/configs/components/form-phone.js +17 -2
  12. package/dist/configs/components/form-radio.js +15 -2
  13. package/dist/configs/components/form-rich-text.js +1 -1
  14. package/dist/configs/components/form-select-multiple.js +362 -0
  15. package/dist/configs/components/form-select.js +1 -1
  16. package/dist/configs/components/form-switch.js +16 -3
  17. package/dist/configs/components/form-text-area.js +15 -2
  18. package/dist/configs/components/form-time.js +1 -1
  19. package/dist/configs/components/form-url.js +17 -2
  20. package/dist/configs/components/form-user-tree-select.js +14 -1
  21. package/dist/configs/components/listView.js +32 -49
  22. package/dist/configs/components/table.json +1 -54
  23. package/dist/configs/components/wd-bubble.js +46 -8
  24. package/dist/configs/components/wd-button.js +3 -0
  25. package/dist/configs/components/wd-checkbox.js +464 -0
  26. package/dist/configs/components/wd-form.js +66 -10
  27. package/dist/configs/components/wd-input-email.js +37 -0
  28. package/dist/configs/components/wd-input-phone.js +43 -0
  29. package/dist/configs/components/wd-input-url.js +37 -0
  30. package/dist/configs/components/wd-input.js +94 -0
  31. package/dist/configs/components/wd-official-account.js +87 -0
  32. package/dist/configs/components/wd-radio.js +443 -0
  33. package/dist/configs/components/wd-switch.js +315 -0
  34. package/dist/configs/components/wd-table.js +11 -59
  35. package/dist/configs/components/wd-textarea.js +82 -0
  36. package/dist/configs/components/wd-tree.js +443 -0
  37. package/dist/configs/components/web-view.js +3 -0
  38. package/dist/configs/index.js +24 -1
  39. package/dist/configs/type-utils/type-form.js +681 -0
  40. package/dist/docs/common/components/json-schema-view.js +1 -1
  41. package/dist/docs/common/components/methods-view.js +1 -1
  42. package/dist/docs/common/components/properties-view.js +3 -1
  43. package/dist/docs/common/format.js +7 -7
  44. package/dist/docs/common/tableView.js +3 -1
  45. package/dist/enum/index.js +196 -0
  46. package/dist/style/index.scss +1 -1
  47. package/dist/web/actions/showMessage/index.js +4 -1
  48. package/dist/web/components/carousel/index.js +1 -1
  49. package/dist/web/components/customer-service/customer-service.js +19 -2
  50. package/dist/web/components/dataView/index.js +16 -3
  51. package/dist/web/components/flow/common/hooks/useCommonFlowData/flow-get.js +5 -1
  52. package/dist/web/components/flow/common/request.js +5 -5
  53. package/dist/web/components/flow/modules/operations/controls-items/flow-task-info-modal.js +90 -0
  54. package/dist/web/components/form/formcell/index.css +13 -1
  55. package/dist/web/components/form/formcell/index.js +1 -1
  56. package/dist/web/components/form/location/components/LocationH5/location.h5.js +1 -1
  57. package/dist/web/components/form/select/dropdown-select/index.js +9 -3
  58. package/dist/web/components/form/select/h5.js +18 -8
  59. package/dist/web/components/form/select/index.js +9 -10
  60. package/dist/web/components/form/select/region/index.js +1 -1
  61. package/dist/web/components/form/selectMultiple/dropdown-select/h5.js +111 -0
  62. package/dist/web/components/form/selectMultiple/dropdown-select/index.css +270 -0
  63. package/dist/web/components/form/selectMultiple/dropdown-select/index.js +206 -0
  64. package/dist/web/components/form/selectMultiple/dropdown-select/pc.js +115 -0
  65. package/dist/web/components/form/selectMultiple/dropdown-select/ui.js +113 -0
  66. package/dist/web/components/form/selectMultiple/h5.js +40 -0
  67. package/dist/web/components/form/selectMultiple/index.js +94 -0
  68. package/dist/web/components/form/selectMultiple/request.js +76 -0
  69. package/dist/web/components/form/selectMultiple/status/allEmpty.js +5 -0
  70. package/dist/web/components/form/selectMultiple/status/empty.js +19 -0
  71. package/dist/web/components/form/selectMultiple/status/index.css +63 -0
  72. package/dist/web/components/form/selectMultiple/status/index.js +7 -0
  73. package/dist/web/components/form/selectMultiple/status/loading.js +19 -0
  74. package/dist/web/components/form/selectMultiple/status/propsType.js +1 -0
  75. package/dist/web/components/form/selectMultiple/status/retry.js +19 -0
  76. package/dist/web/components/form/tips/index.css +9 -3
  77. package/dist/web/components/form/uploader/index.css +10 -0
  78. package/dist/web/components/form/uploader/uploader.h5.js +60 -62
  79. package/dist/web/components/form/uploader/uploader.pc.js +48 -41
  80. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +8 -33
  81. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +8 -37
  82. package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +76 -50
  83. package/dist/web/components/form/userOrgSelect/common/utils.js +24 -8
  84. package/dist/web/components/form/userOrgSelect/component/depart-select/depart-select-pc.js +3 -8
  85. package/dist/web/components/form/userOrgSelect/component/depart-select/index.js +14 -18
  86. package/dist/web/components/form/userOrgSelect/component/depart-select/org-modal-pc.js +20 -14
  87. package/dist/web/components/form/userOrgSelect/component/modal-select-h5.js +1 -1
  88. package/dist/web/components/form/userOrgSelect/component/org-tree.js +21 -9
  89. package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +76 -15
  90. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-model.js +2 -7
  91. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-select-pc.js +6 -4
  92. package/dist/web/components/form/userOrgSelect/component/userOrgSelect.css +8 -2
  93. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +25 -51
  94. package/dist/web/components/form/userOrgSelect/hooks/use-depart-data.js +10 -6
  95. package/dist/web/components/form-input-hooks/index.js +41 -15
  96. package/dist/web/components/form-select-multiple/index.js +26 -0
  97. package/dist/web/components/form-upload-file/index.js +0 -1
  98. package/dist/web/components/form-user-tree-select/index.js +2 -2
  99. package/dist/web/components/formdetail/index.css +31 -1
  100. package/dist/web/components/formdetail/index.js +33 -1
  101. package/dist/web/components/index.js +27 -11
  102. package/dist/web/components/listView/index.js +20 -5
  103. package/dist/web/components/navigationBar/common.js +1 -1
  104. package/dist/web/components/navigationBar/horizontalMenu.js +1 -1
  105. package/dist/web/components/navigationBar/index.css +11 -0
  106. package/dist/web/components/navigationBar/index.js +8 -1
  107. package/dist/web/components/phone/index.js +26 -1
  108. package/dist/web/components/phoneCode/index.js +3 -1
  109. package/dist/web/components/richText/index.css +70 -67
  110. package/dist/web/components/richText/index.js +311 -251
  111. package/dist/web/components/richText/richtext.module.css +1 -0
  112. package/dist/web/components/richTextView/index.css +39 -0
  113. package/dist/web/components/richTextView/index.js +1 -1
  114. package/dist/web/components/share/index.js +26 -1
  115. package/dist/web/components/table/ImportFileModalByApi/uploadCSVFile.js +1 -1
  116. package/dist/web/components/wd-checkbox/checkbox.js +34 -0
  117. package/dist/web/components/wd-checkbox/index.js +3 -0
  118. package/dist/web/components/wd-checkbox-list/checkboxList.js +140 -0
  119. package/dist/web/components/wd-checkbox-list/index.js +3 -0
  120. package/dist/web/components/wd-form/hooks/use-remote-value.js +9 -2
  121. package/dist/web/components/wd-form/index.js +69 -34
  122. package/dist/web/components/wd-form/wd-form.js +42 -0
  123. package/dist/web/components/wd-form-cell/index.js +3 -0
  124. package/dist/web/components/wd-form-cell/wd-form-cell.js +42 -0
  125. package/dist/web/components/wd-form-item/index.js +4 -0
  126. package/dist/web/components/wd-form-item/wd-form-item.js +55 -0
  127. package/dist/web/components/wd-form-item/wd-input-group.js +24 -0
  128. package/dist/web/components/wd-icon/wd-icon.js +10 -2
  129. package/dist/web/components/wd-input/index.js +3 -0
  130. package/dist/web/components/wd-input/wd-input.js +155 -0
  131. package/dist/web/components/wd-input-email/index.js +3 -0
  132. package/dist/web/components/wd-input-email/wd-input-email.js +13 -0
  133. package/dist/web/components/wd-input-group/index.js +3 -0
  134. package/dist/web/components/wd-input-group/wd-input-group.js +10 -0
  135. package/dist/web/components/wd-input-phone/index.js +3 -0
  136. package/dist/web/components/wd-input-phone/wd-input-phone.js +14 -0
  137. package/dist/web/components/wd-input-url/index.js +3 -0
  138. package/dist/web/components/wd-input-url/wd-input-url.js +13 -0
  139. package/dist/web/components/wd-input-wrap/index.js +3 -0
  140. package/dist/web/components/wd-input-wrap/wd-input-wrap.js +18 -0
  141. package/dist/web/components/wd-official-account/index.css +29 -0
  142. package/dist/web/components/wd-official-account/index.js +36 -0
  143. package/dist/web/components/wd-radio/index.js +3 -0
  144. package/dist/web/components/wd-radio/wd-radio.js +30 -0
  145. package/dist/web/components/wd-radio-list/index.js +3 -0
  146. package/dist/web/components/wd-radio-list/wd-radio-list.js +104 -0
  147. package/dist/web/components/wd-switch/index.js +3 -0
  148. package/dist/web/components/wd-switch/wd-switch.js +52 -0
  149. package/dist/web/components/wd-table/components/FieldRender/index.js +5 -4
  150. package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +4 -0
  151. package/dist/web/components/wd-table/components/Table/index.js +40 -9
  152. package/dist/web/components/wd-table/hooks/useQueryParams.js +4 -1
  153. package/dist/web/components/wd-table/hooks/useTableData.js +6 -1
  154. package/dist/web/components/wd-table/hooks/useViewFields.js +1 -1
  155. package/dist/web/components/wd-table/utils/index.js +6 -2
  156. package/dist/web/components/wd-table/wd-table.js +125 -99
  157. package/dist/web/components/wd-textarea/index.js +3 -0
  158. package/dist/web/components/wd-textarea/wd-textarea.js +78 -0
  159. package/dist/web/components/wd-tree/index.js +3 -0
  160. package/dist/web/components/wd-tree/utils.js +291 -0
  161. package/dist/web/components/wd-tree/wd-tree.js +193 -0
  162. package/dist/web/utils/constant.js +16 -0
  163. package/dist/web/utils/datasource.js +2 -2
  164. package/dist/web/utils/date.js +3 -3
  165. package/dist/web/utils/hooks/useFormLegacy.js +112 -0
  166. package/dist/web/utils/tool.js +12 -2
  167. package/dist/web/weda-ui.css +197 -3
  168. package/package.json +6 -5
@@ -14,12 +14,12 @@ const uploadPath = 'weda-uploader';
14
14
  /**
15
15
  * H5端
16
16
  */
17
- export function ImageUploaderH5({ title: label, maxUploadCount, maxSize = 10, acceptTypes = IMAGE_TYPES, className, id, events = emptyObject, layout, defaultValue, single = false, disabled = false, requiredFlag = false, labelVisible = true, onChange, style, imgTypeCls, $node, }) {
17
+ export function ImageUploaderH5({ title: label, maxUploadCount, maxSize = 10, acceptTypes = IMAGE_TYPES, className, id, events = emptyObject, layout: _layout, defaultValue, single = false, disabled = false, requiredFlag = false, labelVisible = true, onChange, style, imgTypeCls, $node, }) {
18
18
  var _a;
19
+ const layout = _layout !== 'vertical' ? 'horizontal' : 'vertical';
20
+ const layoutCls = layout === 'horizontal' ? 'weda-formcells weui-flex' : '';
19
21
  const cls = classNames({
20
22
  'weda-ui': true,
21
- 'weui-cells': true,
22
- 'weui-cells_form': true,
23
23
  [className]: className,
24
24
  });
25
25
  // 上传中
@@ -48,23 +48,16 @@ export function ImageUploaderH5({ title: label, maxUploadCount, maxSize = 10, ac
48
48
  return maxUploadCount;
49
49
  }, [single, maxUploadCount]);
50
50
  const deleteFile = (url) => {
51
- if (single) {
52
- setInputValue('');
53
- return;
54
- }
55
- setInputValue((list) => list.filter((f) => f !== url));
51
+ const value = single ? '' : fileIdList.filter((f) => f !== url);
52
+ setInputValue(value);
53
+ handleChange([].concat(value));
54
+ };
55
+ const handleChange = (ids) => {
56
+ const value = single ? ids[0] || '' : ids;
57
+ setInputValue(value);
58
+ onChange === null || onChange === void 0 ? void 0 : onChange(value);
59
+ events === null || events === void 0 ? void 0 : events.change({ value });
56
60
  };
57
- React.useEffect(() => {
58
- if (single) {
59
- const file = fileIdList[0] || '';
60
- onChange && onChange(file);
61
- events.change && events.change({ value: file });
62
- }
63
- else {
64
- onChange && onChange(fileIdList);
65
- events.change && events.change({ value: fileIdList });
66
- }
67
- }, [fileIdList]);
68
61
  const onProgress = (progressEvent) => {
69
62
  let percentCompleted = 0;
70
63
  try {
@@ -74,28 +67,29 @@ export function ImageUploaderH5({ title: label, maxUploadCount, maxSize = 10, ac
74
67
  catch (e) { }
75
68
  setProgress(percentCompleted);
76
69
  };
77
- const uploadToTcb = (file) => {
78
- setUploading(true);
79
- getCloudInstance().then(async (tcb) => {
80
- try {
81
- const cloudPath = `${uploadPath}/${randomStr()}-${file === null || file === void 0 ? void 0 : file.name.replace(/[%#]/g, '-')}`;
82
- const { fileID } = await tcb.uploadFile({
83
- cloudPath,
84
- filePath: file,
85
- onUploadProgress: onProgress,
86
- });
87
- fileID && setInputValue((list) => [...list, fileID]);
88
- fileID && events.success && events.success({ value: fileID, file });
89
- }
90
- catch (err) {
91
- weui.alert('上传失败,请检查网络后重试');
92
- events.error && events.error(err);
93
- }
94
- finally {
95
- setUploading(false);
96
- setProgress(0);
97
- }
98
- });
70
+ const uploadToTcb = async (file) => {
71
+ var _a;
72
+ try {
73
+ setUploading(true);
74
+ const tcb = await getCloudInstance();
75
+ const cloudPath = `${uploadPath}/${randomStr()}-${file === null || file === void 0 ? void 0 : file.name.replace(/[%#]/g, '-')}`;
76
+ const { fileID } = await tcb.uploadFile({
77
+ cloudPath,
78
+ filePath: file,
79
+ onUploadProgress: onProgress,
80
+ });
81
+ (_a = events.success) === null || _a === void 0 ? void 0 : _a.call(events, { value: fileID, file });
82
+ setUploading(false);
83
+ return fileID;
84
+ }
85
+ catch (err) {
86
+ weui.alert('上传失败,请检查网络后重试');
87
+ events.error && events.error(err);
88
+ }
89
+ finally {
90
+ setUploading(false);
91
+ setProgress(0);
92
+ }
99
93
  };
100
94
  const accepts = React.useMemo(() => {
101
95
  return acceptTypes.includes('image/*') || acceptTypes.length === 0
@@ -132,25 +126,29 @@ export function ImageUploaderH5({ title: label, maxUploadCount, maxSize = 10, ac
132
126
  }
133
127
  return fileIdList.length < maxUploadCount;
134
128
  }, [fileIdList, single, maxUploadCount, uploading]);
135
- return (_jsx("div", { className: cls, id: id, style: style, children: _jsx("div", { children: _jsxs("div", { className: classNames('weui-uploader', layout), children: [_jsx("div", { className: classNames('weui-uploader__hd', layout), children: _jsx(UploaderLabel, { layout: layout, label: label, labelVisible: labelVisible, currentCount: fileIdList.length, maxCount: finalMaxImgCount, requiredFlag: requiredFlag }) }), _jsxs("div", { className: "weui-uploader__bd", children: [_jsxs("ul", { className: "weui-uploader__files", id: "uploaderFiles", children: [(fileIdList !== null && fileIdList !== void 0 ? fileIdList : []).map((f) => (_jsx(SingleImage, { src: f, deleteBySrc: deleteFile, disabled: disabled, imgTypeCls: imgTypeCls }, f))), fileIdList.length < 1 && formType === 'read' && _jsx(_Fragment, { children: "\u2014" }), uploading && (_jsx("li", { className: `weui-uploader__file weui-uploader__file_status ${imgTypeCls}`, children: _jsxs("div", { className: "weui-uploader__file-content", children: [progress, "%"] }) }))] }), showAdd && formType !== 'read' && (_jsx("div", { className: `weui-uploader__input-box ${imgTypeCls}`, children: !disabled && (_jsx("input", { "data-testid": "uploaderh5_input", id: "uploaderInput", className: "weui-uploader__input", type: "file", accept: accepts.join(','), multiple: !single && !(browserEnv().android && browserEnv().weixin), onChange: (e) => {
136
- const files = [...e.target.files];
137
- if (!islegalType(files, accepts))
138
- return;
139
- if (files.some((f) => f.size > maxSize * 1024 * 1024)) {
140
- weui.alert(`请上传不超过 ${maxSize}M 的图片`);
141
- return false;
142
- }
143
- if (files.length > finalMaxImgCount) {
144
- // 防止一下子选择过多文件
145
- weui.alert(`最多只能上传${finalMaxImgCount}张图片,请重新选择`);
146
- return false;
147
- }
148
- if (fileIdList.length + files.length > finalMaxImgCount) {
149
- weui.alert(`最多只能上传${finalMaxImgCount}张图片`);
150
- return false;
151
- }
152
- files.forEach((f) => uploadToTcb(f));
153
- } })) }))] })] }) }) }));
129
+ const uploadChange = async (e) => {
130
+ const files = [...e.target.files];
131
+ if (!islegalType(files, accepts))
132
+ return;
133
+ if (files.some((f) => f.size > maxSize * 1024 * 1024)) {
134
+ weui.alert(`请上传不超过 ${maxSize}M 的图片`);
135
+ return false;
136
+ }
137
+ if (files.length > finalMaxImgCount) {
138
+ // 防止一下子选择过多文件
139
+ weui.alert(`最多只能上传${finalMaxImgCount}张图片,请重新选择`);
140
+ return false;
141
+ }
142
+ if (fileIdList.length + files.length > finalMaxImgCount) {
143
+ weui.alert(`最多只能上传${finalMaxImgCount}张图片`);
144
+ return false;
145
+ }
146
+ const promiseAll = files.map((f) => uploadToTcb(f));
147
+ const result = await Promise.all(promiseAll);
148
+ const ids = [].concat(fileIdList, result);
149
+ handleChange(ids);
150
+ };
151
+ return (_jsx("div", { className: cls, id: id, style: style, children: _jsxs("div", { className: classNames('weui-uploader weui-cells weui-cells_form weda-formcells', layout, layoutCls), children: [_jsx("div", { className: classNames('weui-uploader__hd', layout), children: _jsx(UploaderLabel, { layout: layout, label: label, labelVisible: labelVisible, currentCount: fileIdList.length, maxCount: finalMaxImgCount, requiredFlag: requiredFlag }) }), _jsxs("div", { className: "weui-uploader__bd", children: [_jsxs("ul", { className: "weui-uploader__files", id: "uploaderFiles", children: [(fileIdList !== null && fileIdList !== void 0 ? fileIdList : []).map((f) => (_jsx(SingleImage, { src: f, deleteBySrc: deleteFile, disabled: disabled, imgTypeCls: imgTypeCls }, f))), fileIdList.length < 1 && formType === 'read' && _jsx(_Fragment, { children: "\u2014" }), uploading && (_jsx("li", { className: `weui-uploader__file weui-uploader__file_status ${imgTypeCls}`, children: _jsxs("div", { className: "weui-uploader__file-content", children: [progress, "%"] }) }))] }), showAdd && formType !== 'read' && (_jsx("div", { className: `weui-uploader__input-box ${imgTypeCls}`, children: !disabled && (_jsx("input", { "data-testid": "uploaderh5_input", id: "uploaderInput", className: "weui-uploader__input", type: "file", accept: accepts.join(','), multiple: !single && !(browserEnv().android && browserEnv().weixin), onChange: uploadChange })) }))] })] }) }));
154
152
  }
155
153
  function SingleImage({ src, deleteBySrc, disabled, imgTypeCls, }) {
156
154
  const cls = classNames({
@@ -176,7 +174,7 @@ function SingleImage({ src, deleteBySrc, disabled, imgTypeCls, }) {
176
174
  }
177
175
  const UploaderLabel = ({ layout, label, currentCount, maxCount, requiredFlag, labelVisible, }) => {
178
176
  if (layout === 'horizontal') {
179
- return (_jsx(React.Fragment, { children: _jsx(_Fragment, { children: labelVisible && (_jsxs("div", { className: "weda-formcells__label weui-cell", children: [_jsxs("div", { children: [_jsx("p", { className: "weui-uploader__title", children: label }), _jsxs("div", { className: "weui-uploader__info", children: [_jsx("span", { id: "uploadCount", children: currentCount }), "/", maxCount] })] }), requiredFlag && (_jsx("label", { className: "weda-formcells__flag", children: "*" }))] })) }) }));
177
+ return (_jsx(React.Fragment, { children: _jsx(_Fragment, { children: labelVisible && (_jsx("div", { className: "weda-formcells__label weui-cell", children: _jsxs("div", { children: [requiredFlag && (_jsx("label", { className: "weda-formcells__flag", children: "*" })), _jsx("p", { className: "weui-uploader__title", children: label }), _jsxs("div", { className: "weui-uploader__info", children: [_jsx("span", { id: "uploadCount", children: currentCount }), "/", maxCount] })] }) })) }) }));
180
178
  }
181
- return (_jsx(React.Fragment, { children: _jsx(_Fragment, { children: labelVisible && (_jsxs("div", { className: "weda-formcells__label weui-cell", children: [_jsxs("div", { className: "weui-uploader__label", children: [_jsx("p", { className: "weui-uploader__title", children: label }), requiredFlag && (_jsx("label", { className: "weda-formcells__flag", children: "*" }))] }), _jsxs("div", { className: "weui-uploader__info", children: [_jsx("span", { id: "uploadCount", children: currentCount }), "/", maxCount] })] })) }) }));
179
+ return (_jsx(React.Fragment, { children: _jsx(_Fragment, { children: labelVisible && (_jsxs("div", { className: "weda-formcells__label weui-cell", children: [_jsxs("div", { className: "weui-uploader__label", children: [requiredFlag && (_jsx("label", { className: "weda-formcells__flag", children: "*" })), _jsx("p", { className: "weui-uploader__title", children: label })] }), _jsxs("div", { className: "weui-uploader__info", children: [_jsx("span", { id: "uploadCount", children: currentCount }), "/", maxCount] })] })) }) }));
182
180
  };
@@ -44,32 +44,27 @@ export function UploaderPCInner(props) {
44
44
  const [progress, setProgress] = React.useState(0);
45
45
  // 文件列表
46
46
  const [fileIDList, setfileIDList] = React.useState([]);
47
- const fileRef = React.useRef([]);
48
47
  const formType = ((_a = getParentForm($node)) === null || _a === void 0 ? void 0 : _a.formType) || 'create';
48
+ const defaultValueRef = React.useRef(null);
49
49
  React.useEffect(() => {
50
+ if (isObjectEqual(defaultValueRef.current, defaultValue))
51
+ return;
50
52
  let initialValue = []
51
53
  .concat(value ? value : defaultValue)
52
54
  .filter((d) => typeof d === 'string' && d !== '');
53
55
  if (single) {
54
56
  initialValue = initialValue[0] ? [initialValue[0]] : [];
55
57
  }
58
+ defaultValueRef.current = defaultValue;
56
59
  setfileIDList(initialValue);
57
60
  }, [defaultValue, single]);
58
- // 值变化事件
59
- React.useEffect(() => {
60
- if (!isObjectEqual(fileRef.current, fileIDList)) {
61
- if (single) {
62
- const file = fileIDList[0] || '';
63
- onChange && onChange(file);
64
- events.change && events.change({ value: file });
65
- }
66
- else {
67
- onChange && onChange(fileIDList);
68
- events.change && events.change({ value: fileIDList });
69
- }
70
- fileRef.current = fileIDList;
71
- }
72
- });
61
+ const handleChange = (ids) => {
62
+ var _a;
63
+ setfileIDList(ids);
64
+ const value = single ? ids[0] || '' : ids;
65
+ onChange === null || onChange === void 0 ? void 0 : onChange(value);
66
+ (_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value });
67
+ };
73
68
  //验证上传文件类型是否合法
74
69
  const islegalType = (files, accepts) => {
75
70
  const illegalType = [];
@@ -114,32 +109,43 @@ export function UploaderPCInner(props) {
114
109
  catch (e) { }
115
110
  return false;
116
111
  }
117
- uploadTcb(file);
112
+ const ids = fileList.filter((f) => !!f.id);
113
+ if (ids.length < fileList.length)
114
+ return false;
115
+ uploadTcbMulti(fileList);
118
116
  return false;
119
117
  };
118
+ // 多张上传
119
+ const uploadTcbMulti = async (files) => {
120
+ const promiseAll = files.map((f) => uploadTcb(f));
121
+ const result = await Promise.all(promiseAll);
122
+ const ids = [].concat(fileIDList, result);
123
+ handleChange(ids);
124
+ };
120
125
  // 自定义上传到 Tcb 的 COS
121
- const uploadTcb = (file) => {
122
- setUploading(true);
123
- getCloudInstance().then(async (tcb) => {
124
- try {
125
- const cloudPath = `${uploadPath}/${randomStr()}-${file === null || file === void 0 ? void 0 : file.name.replace(/[%#]/g, '-')}`;
126
- const { fileID } = await tcb.uploadFile({
127
- cloudPath,
128
- filePath: file,
129
- onUploadProgress: onProgress,
130
- });
131
- fileID && setfileIDList((list) => [...list, fileID]);
132
- fileID && events.success && events.success({ value: fileID, file });
133
- }
134
- catch (err) {
135
- message.error({ content: '上传失败,请检查网络后重试' });
136
- events.error && events.error(err);
137
- }
138
- finally {
139
- setUploading(false);
140
- setProgress(0);
141
- }
142
- });
126
+ const uploadTcb = async (file) => {
127
+ var _a;
128
+ try {
129
+ setUploading(true);
130
+ const tcb = await getCloudInstance();
131
+ const cloudPath = `${uploadPath}/${randomStr()}-${file === null || file === void 0 ? void 0 : file.name.replace(/[%#]/g, '-')}`;
132
+ const { fileID } = await tcb.uploadFile({
133
+ cloudPath,
134
+ filePath: file,
135
+ onUploadProgress: onProgress,
136
+ });
137
+ (_a = events.success) === null || _a === void 0 ? void 0 : _a.call(events, { value: fileID, file });
138
+ setUploading(false);
139
+ return fileID;
140
+ }
141
+ catch (err) {
142
+ message.error({ content: '上传失败,请检查网络后重试' });
143
+ events.error && events.error(err);
144
+ }
145
+ finally {
146
+ setUploading(false);
147
+ setProgress(0);
148
+ }
143
149
  };
144
150
  // 计算上传进度
145
151
  const onProgress = (progressEvent) => {
@@ -153,7 +159,8 @@ export function UploaderPCInner(props) {
153
159
  };
154
160
  // 删除图片
155
161
  const deleteHandle = (fileID) => {
156
- setfileIDList((list) => list.filter((d) => d !== fileID));
162
+ const ids = fileIDList.filter((d) => d !== fileID);
163
+ handleChange(ids);
157
164
  };
158
165
  // 转换后的属性
159
166
  const extraProps = {};
@@ -201,7 +208,7 @@ export const TcbImage = (props) => {
201
208
  export function encodeConvert(src) {
202
209
  if (src) {
203
210
  try {
204
- return 'https://' + decodeURIComponent(src.split('https://')[1]);
211
+ return decodeURIComponent(src);
205
212
  }
206
213
  catch (e) {
207
214
  return src;
@@ -56,22 +56,16 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
56
56
  }
57
57
  }, [defaultValue]);
58
58
  React.useEffect(() => {
59
- var _a, _b, _c;
59
+ var _a, _b;
60
+ if (isObjectEqual(fileRef.current, fileIDList))
61
+ return;
60
62
  // 外部 onChange 事件
61
63
  const pureFileIDList = fileIDList.filter((d) => isCloudFileID(d) || isHttpFileID(d));
62
- if (single) {
63
- const file = pureFileIDList[0] || '';
64
- file && onChange && onChange(file);
65
- (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: file });
66
- }
67
- else {
68
- onChange && onChange(pureFileIDList);
69
- (_b = events === null || events === void 0 ? void 0 : events.change) === null || _b === void 0 ? void 0 : _b.call(events, { value: pureFileIDList });
70
- }
71
- if (!isObjectEqual(fileRef.current, fileIDList)) {
72
- (_c = events === null || events === void 0 ? void 0 : events.success) === null || _c === void 0 ? void 0 : _c.call(events, { value: pureFileIDList });
73
- fileRef.current = fileIDList;
74
- }
64
+ const value = single ? pureFileIDList[0] || '' : pureFileIDList;
65
+ onChange === null || onChange === void 0 ? void 0 : onChange(value);
66
+ (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value });
67
+ (_b = events === null || events === void 0 ? void 0 : events.success) === null || _b === void 0 ? void 0 : _b.call(events, { value: pureFileIDList });
68
+ fileRef.current = fileIDList;
75
69
  }, [fileIDList]);
76
70
  // 外层组件类
77
71
  const cls = classNames({
@@ -86,19 +80,6 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
86
80
  ? ['*']
87
81
  : Array.from(new Set(acceptTypes));
88
82
  }, [acceptTypes]);
89
- const islegalType = (files, accepts) => {
90
- const illegalType = [];
91
- for (const file of files) {
92
- if (!accepts.includes(file === null || file === void 0 ? void 0 : file.type)) {
93
- illegalType.push(file === null || file === void 0 ? void 0 : file.type);
94
- }
95
- }
96
- if (illegalType.length > 0) {
97
- weui.alert('不支持上传' + Array.from(new Set(illegalType)).join(',') + '格式文件');
98
- return false;
99
- }
100
- return true;
101
- };
102
83
  // 上传后文件列表 fileIDList 改变事件,'add'|'delete'
103
84
  const handleChange = ({ fileID, uuid, type, size }) => {
104
85
  // 上传时新增事件
@@ -135,12 +116,6 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
135
116
  fileSizeObj,
136
117
  }, children: _jsx("div", { "data-testid": "uploadFileH5", className: cls, id: id, style: style, children: _jsxs("div", { className: classNames(`${CLASS_PREFIX}`), children: [isEdit && (_jsx("div", { className: classNames(`${CLASS_PREFIX}__hd`, layout), children: _jsx("div", { children: btnDisabled ? (_jsx(Button, { type: "weak", className: classNames(`${CLASS_PREFIX}__btn--weak`), disabled: btnDisabled, children: btnTitle })) : (_jsxs("div", { children: [_jsx("input", { id: "uploaderInput", type: "file", "data-testid": "button-up", className: "weui-uploader-mobile__input", accept: accepts.join(','), multiple: !single, onChange: (e) => {
137
118
  const fileList = [...e.target.files];
138
- //校验逻辑与图片有出入,文件类型限制为全部时,不设限
139
- if (!(accepts.includes('*') ||
140
- accepts.includes('') ||
141
- accepts.length === 0) &&
142
- !islegalType(fileList, accepts))
143
- return;
144
119
  if (single && fileList.length > 1) {
145
120
  weui.alert(`上传文件总数不能超过1个`);
146
121
  return false;
@@ -57,22 +57,16 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
57
57
  }
58
58
  }, [defaultValue]);
59
59
  React.useEffect(() => {
60
- var _a, _b, _c;
60
+ var _a, _b;
61
+ if (isObjectEqual(fileRef.current, fileIDList))
62
+ return;
61
63
  // 外部 onChange 事件
62
64
  const pureFileIDList = fileIDList.filter((d) => isCloudFileID(d) || isHttpFileID(d));
63
- if (single) {
64
- const file = pureFileIDList[0] || '';
65
- onChange === null || onChange === void 0 ? void 0 : onChange(file);
66
- (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: file });
67
- }
68
- else {
69
- onChange === null || onChange === void 0 ? void 0 : onChange(pureFileIDList);
70
- (_b = events === null || events === void 0 ? void 0 : events.change) === null || _b === void 0 ? void 0 : _b.call(events, { value: pureFileIDList });
71
- }
72
- if (!isObjectEqual(fileRef.current, fileIDList)) {
73
- (_c = events === null || events === void 0 ? void 0 : events.success) === null || _c === void 0 ? void 0 : _c.call(events, { value: pureFileIDList });
74
- fileRef.current = fileIDList;
75
- }
65
+ const value = single ? pureFileIDList[0] || '' : pureFileIDList;
66
+ onChange === null || onChange === void 0 ? void 0 : onChange(value);
67
+ (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value });
68
+ (_b = events === null || events === void 0 ? void 0 : events.success) === null || _b === void 0 ? void 0 : _b.call(events, { value: pureFileIDList });
69
+ fileRef.current = fileIDList;
76
70
  }, [fileIDList]);
77
71
  // 外层组件类
78
72
  const cls = classNames({
@@ -81,11 +75,6 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
81
75
  });
82
76
  // 批量上传文件前置事件
83
77
  const handleBefore = (file, fileList, isAccepted, error) => {
84
- if (!((acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('*')) ||
85
- (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('')) ||
86
- (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.length) === 0) &&
87
- !islegalType(fileList, uploadProps['accept']))
88
- return;
89
78
  if (fileList.length + fileIDList.length > maxUploadCount) {
90
79
  message.warning({ content: `上传文件总数不能超过${maxUploadCount}个` });
91
80
  return false;
@@ -137,24 +126,6 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
137
126
  (single && fileList.length > 0) ||
138
127
  disabled);
139
128
  }, [disabled, fileIDList.length, fileList, maxUploadCount, single]);
140
- //验证上传文件类型是否合法
141
- const islegalType = (files, accepts) => {
142
- const illegalType = [];
143
- for (const file of files) {
144
- if (!accepts.includes(file === null || file === void 0 ? void 0 : file.type)) {
145
- illegalType.push(file === null || file === void 0 ? void 0 : file.type);
146
- }
147
- }
148
- if (illegalType.length > 0) {
149
- message.error({
150
- content: '不支持上传' +
151
- Array.from(new Set(illegalType)).join(',') +
152
- '格式文件',
153
- });
154
- return false;
155
- }
156
- return true;
157
- };
158
129
  return renderDecorator(_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(FileContext.Provider, { value: {
159
130
  uploadPath,
160
131
  downloadVisible,
@@ -26,12 +26,15 @@ export const getUserListByIds = async (porps) => {
26
26
  * @returns
27
27
  */
28
28
  export const errorHandle = (error, action) => {
29
- var _a;
29
+ var _a, _b;
30
+ console.error(`接口 ${action} 出错: `, error);
30
31
  if (error === null || error === void 0 ? void 0 : error.result) {
31
- return `${(_a = error === null || error === void 0 ? void 0 : error.result) === null || _a === void 0 ? void 0 : _a.message}(${action}${error === null || error === void 0 ? void 0 : error.requestId})`;
32
+ return (error === null || error === void 0 ? void 0 : error.requestId)
33
+ ? `${(_a = error === null || error === void 0 ? void 0 : error.result) === null || _a === void 0 ? void 0 : _a.message}(${error === null || error === void 0 ? void 0 : error.requestId})`
34
+ : `${(_b = error === null || error === void 0 ? void 0 : error.result) === null || _b === void 0 ? void 0 : _b.message}`;
32
35
  }
33
36
  else {
34
- return `${action}(${(error === null || error === void 0 ? void 0 : error.message) || error})`;
37
+ return `${(error === null || error === void 0 ? void 0 : error.message) || error}`;
35
38
  }
36
39
  };
37
40
  /**
@@ -42,23 +45,28 @@ export const errorHandle = (error, action) => {
42
45
  */
43
46
  export const fetchUserListByIds = async (selectUserIds = [], request) => {
44
47
  try {
45
- let pageNo = 1;
46
- const pageSize = 50;
47
- let records = [];
48
- let total = 9999;
49
- for (let index = 0; index < Math.floor(total / pageSize) + 1; index++) {
50
- const data = await request('DescribeWedaUsersRuntime', {
51
- pageNo: pageNo,
52
- pageSize: pageSize,
53
- UserIds: selectUserIds || [],
48
+ const PAGE_SIZE = 50;
49
+ const total = selectUserIds.length;
50
+ const records = [];
51
+ const promises = [];
52
+ for (let index = 1; index <= Math.ceil(total / PAGE_SIZE); index++) {
53
+ const start = (index - 1) * PAGE_SIZE;
54
+ const end = start + PAGE_SIZE;
55
+ promises.push(request('DescribeWedaUsersRuntime', {
56
+ UserIds: selectUserIds.slice(start, end),
54
57
  UserType: 'internalUser',
55
58
  NeedPrimaryColumn: true,
56
59
  IsNoRelatedOrgFlag: false,
57
- });
58
- pageNo = pageNo + 1;
59
- if (data === null || data === void 0 ? void 0 : data.UserList) {
60
- total = (data === null || data === void 0 ? void 0 : data.Total) || 0;
61
- records = records.concat(data === null || data === void 0 ? void 0 : data.UserList);
60
+ PageNo: 1,
61
+ PageSize: PAGE_SIZE,
62
+ }));
63
+ }
64
+ const results = await Promise.all(promises);
65
+ for (const res of results) {
66
+ if (res.UserList &&
67
+ Array.isArray(res.UserList) &&
68
+ res.UserList.length > 0) {
69
+ records.push(...res.UserList);
62
70
  }
63
71
  }
64
72
  return records;
@@ -171,44 +179,62 @@ async function fetchUsersByOrgId(params, request) {
171
179
  throw errorHandle(error, 'LazyDescribeOrgs');
172
180
  }
173
181
  }
174
- /**
175
- * 获取当前组织列表总数
176
- */
177
- export const fetchOrgTotal = async (request) => {
178
- try {
179
- return await request('DescribeOrgs', {
180
- pageNo: 1,
181
- pageSize: 1,
182
- }).then((data) => {
183
- return (data === null || data === void 0 ? void 0 : data.Total) || 0;
184
- });
185
- }
186
- catch (error) {
187
- console.error('错误', error);
188
- throw errorHandle(error, 'fetchOrgTotal');
189
- }
190
- };
191
182
  /**
192
183
  *获取全量组织数据
193
184
  */
194
- export const DescribeOrgs = async (request) => {
185
+ export const DescribeOrgs = async (request, params) => {
195
186
  try {
196
- const total = await fetchOrgTotal(request);
197
- let records = [];
198
- if (total > 0) {
199
- const resultPromise = [];
200
- for (let index = 1; index <= Math.ceil(total / 1000); index++) {
201
- const DescribeOrgsByPage = request('DescribeOrgs', {
202
- pageNo: index,
203
- pageSize: 1000,
204
- }) || {};
205
- resultPromise.push(DescribeOrgsByPage);
187
+ const PAGE_SIZE = 1000;
188
+ // 如果传递了 params.corpScopes 参数,则只拉取这些企业下的部门展示
189
+ const corpScopes = params === null || params === void 0 ? void 0 : params.corpScopes;
190
+ const queryList = [];
191
+ if (corpScopes && Array.isArray(corpScopes) && corpScopes.length > 0) {
192
+ if (corpScopes.length === 1) {
193
+ queryList.push({
194
+ Key: '_organizationId',
195
+ Rel: 'eq',
196
+ Val: corpScopes[0],
197
+ });
206
198
  }
207
- await Promise.all(resultPromise).then((data) => {
208
- (data || []).map((item) => {
209
- records = records.concat(item === null || item === void 0 ? void 0 : item.DataList);
199
+ else {
200
+ queryList.push({
201
+ Key: '_organizationId',
202
+ Rel: 'in',
203
+ Val: corpScopes,
210
204
  });
211
- });
205
+ }
206
+ }
207
+ const QueryWhereList = queryList.length > 0 ? queryList : undefined;
208
+ const result = await request('DescribeOrgs', {
209
+ pageNo: 1,
210
+ pageSize: PAGE_SIZE,
211
+ QueryWhereList,
212
+ });
213
+ const Total = (result === null || result === void 0 ? void 0 : result.Total) || 0;
214
+ const DataList = (result === null || result === void 0 ? void 0 : result.DataList) || [];
215
+ const total = Number(Total);
216
+ // 一页拉取了全部数据,直接返回
217
+ if (total <= PAGE_SIZE) {
218
+ return DataList;
219
+ }
220
+ const records = [...DataList];
221
+ const promises = [];
222
+ // 从第二页开始,并发拉取所有
223
+ for (let index = 2; index <= Math.ceil(total / PAGE_SIZE); index++) {
224
+ promises.push(request('DescribeOrgs', {
225
+ pageNo: index,
226
+ pageSize: PAGE_SIZE,
227
+ QueryWhereList,
228
+ }));
229
+ }
230
+ const results = await Promise.all(promises);
231
+ for (const res of results) {
232
+ if (res &&
233
+ res.DataList &&
234
+ Array.isArray(res.DataList) &&
235
+ res.DataList.length > 0) {
236
+ records.push(...res.DataList);
237
+ }
212
238
  }
213
239
  return records;
214
240
  }
@@ -256,6 +282,6 @@ export const fetchViewList = async () => {
256
282
  }
257
283
  catch (error) {
258
284
  console.error('错误', error);
259
- throw errorHandle(error, 'DescribeOrgs');
285
+ throw errorHandle(error, 'fetchViewList');
260
286
  }
261
287
  };