@cloudbase/weda-ui 3.4.0 → 3.4.2

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 (81) hide show
  1. package/dist/configs/actions/showMessage.json +45 -0
  2. package/dist/configs/actions/showModal.json +21 -0
  3. package/dist/configs/actions/showToast.json +11 -2
  4. package/dist/configs/components/button.json +1 -1
  5. package/dist/configs/components/calendar.json +1 -1
  6. package/dist/configs/components/carousel.json +76 -66
  7. package/dist/configs/components/chart/bar.json +39 -3
  8. package/dist/configs/components/chart/line.json +5 -2
  9. package/dist/configs/components/chart/pie.json +5 -2
  10. package/dist/configs/components/chart/statisticsCard.json +6 -6
  11. package/dist/configs/components/container.json +16 -2
  12. package/dist/configs/components/dataView.json +47 -4
  13. package/dist/configs/components/form/departTreeSelect.json +1 -1
  14. package/dist/configs/components/form/form.json +1 -1
  15. package/dist/configs/components/form/location.json +2 -2
  16. package/dist/configs/components/form/richText.json +2 -2
  17. package/dist/configs/components/form/uploader.json +1 -1
  18. package/dist/configs/components/form/uploaderFile.json +4 -3
  19. package/dist/configs/components/form/userTreeSelect.json +1 -1
  20. package/dist/configs/components/formdetail.json +6 -1
  21. package/dist/configs/components/graphicCard.json +1 -1
  22. package/dist/configs/components/image.json +6 -3
  23. package/dist/configs/components/link.json +5 -2
  24. package/dist/configs/components/listView.json +148 -43
  25. package/dist/configs/components/lottery.json +1 -1
  26. package/dist/configs/components/modal.json +2 -1
  27. package/dist/configs/components/navLayout.json +1 -1
  28. package/dist/configs/components/navigationBar.json +1 -1
  29. package/dist/configs/components/richtextview.json +5 -2
  30. package/dist/configs/components/scrollVeiw.json +109 -73
  31. package/dist/configs/components/swiper.json +47 -38
  32. package/dist/configs/components/tabs.json +1 -1
  33. package/dist/configs/components/text.json +12 -6
  34. package/dist/configs/components/wedaVideo.json +1 -1
  35. package/dist/configs/components/wxOpenApi/phone.json +2 -2
  36. package/dist/configs/components/wxOpenApi/phoneCode.json +2 -2
  37. package/dist/configs/components/wxOpenApi/share.json +9 -8
  38. package/dist/configs/components/wxOpenApi/userInfo.json +15 -3
  39. package/dist/configs/index.d.ts +2 -0
  40. package/dist/configs/index.js +2 -0
  41. package/dist/web/actions/index.d.ts +1 -0
  42. package/dist/web/actions/index.js +1 -0
  43. package/dist/web/actions/showMessage/index.css +6 -0
  44. package/dist/web/actions/showMessage/index.d.ts +17 -0
  45. package/dist/web/actions/showMessage/index.js +39 -0
  46. package/dist/web/components/button/index.d.ts +3 -2
  47. package/dist/web/components/button/index.js +14 -3
  48. package/dist/web/components/common/use-loop-render-detect.js +7 -6
  49. package/dist/web/components/form/form/index.js +21 -50
  50. package/dist/web/components/form/uploader/uploader.h5.js +1 -1
  51. package/dist/web/components/form/uploader/uploader.pc.js +2 -0
  52. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +12 -10
  53. package/dist/web/components/form/uploaderFile/uploadFile.pc.d.ts +11 -0
  54. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +10 -8
  55. package/dist/web/components/form/userOrgSelect/comTool.js +4 -3
  56. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +3 -4
  57. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +6 -7
  58. package/dist/web/components/form/userOrgSelect/getUserService.js +2 -1
  59. package/dist/web/components/form/userOrgSelect/userOrgSelect.css +10 -12
  60. package/dist/web/components/form/userOrgSelect/userTreeSelect.h5.js +4 -6
  61. package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.js +49 -28
  62. package/dist/web/components/form/userOrgSelect/utils.d.ts +1 -0
  63. package/dist/web/components/form/userOrgSelect/utils.js +15 -0
  64. package/dist/web/components/formdetail/index.css +40 -27
  65. package/dist/web/components/formdetail/index.js +22 -19
  66. package/dist/web/components/link/index.js +2 -1
  67. package/dist/web/components/listView/index.css +5 -1
  68. package/dist/web/components/listView/index.js +22 -2
  69. package/dist/web/components/listView/interface.d.ts +1 -1
  70. package/dist/web/components/navigationBar/index.js +8 -3
  71. package/dist/web/components/phone/index.js +4 -1
  72. package/dist/web/components/phoneCode/index.js +4 -1
  73. package/dist/web/components/richText/index.d.ts +1 -1
  74. package/dist/web/components/richText/index.js +6 -6
  75. package/dist/web/components/share/index.js +4 -1
  76. package/dist/web/components/text/index.js +2 -1
  77. package/dist/web/components/userInfo/index.js +4 -1
  78. package/dist/web/utils/console.js +1 -1
  79. package/dist/web/utils/platform.d.ts +11 -1
  80. package/dist/web/utils/platform.js +61 -12
  81. package/package.json +12 -1
@@ -33,6 +33,7 @@ import NavLayout from './components/navLayout.json';
33
33
  import WedaVideo from './components/wedaVideo.json';
34
34
  import showToast from './actions/showToast.json';
35
35
  import showModal from './actions/showModal.json';
36
+ import showMessage from './actions/showMessage.json';
36
37
  import ListView from './components/listView.json';
37
38
  import NavigationBar from './components/navigationBar.json';
38
39
  import Line from './components/chart/line.json';
@@ -104,6 +105,7 @@ export const components = {
104
105
  export const actions = {
105
106
  showToast,
106
107
  showModal,
108
+ showMessage,
107
109
  };
108
110
  export default {
109
111
  components,
@@ -1,2 +1,3 @@
1
1
  export { default as showToast } from "./showToast";
2
2
  export { default as showModal } from "./showModal";
3
+ export { default as showMessage } from "./showMessage";
@@ -1,2 +1,3 @@
1
1
  export { default as showToast } from './showToast';
2
2
  export { default as showModal } from './showModal';
3
+ export { default as showMessage } from './showMessage';
@@ -0,0 +1,6 @@
1
+ .weda-showmessage__none > .wedatea2td-icon {
2
+ display: none;
3
+ }
4
+
5
+ /*# sourceURL=webpack://./src/web/actions/showMessage/index.css */
6
+ /*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8uL3NyYy93ZWIvYWN0aW9ucy9zaG93TWVzc2FnZS9pbmRleC5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7RUFDRSxhQUFhO0FBQ2YiLCJzb3VyY2VzQ29udGVudCI6WyIud2VkYS1zaG93bWVzc2FnZV9fbm9uZSA+IC53ZWRhdGVhMnRkLWljb24ge1xuICBkaXNwbGF5OiBub25lO1xufVxuIl0sInNvdXJjZVJvb3QiOiIifQ== */
@@ -0,0 +1,17 @@
1
+ import type { unknownFunction } from '../../types';
2
+ import './index.css';
3
+ interface messageProps {
4
+ data: {
5
+ title?: string;
6
+ icon?: 'success' | 'error' | 'warning' | 'loading' | 'none';
7
+ duration?: number;
8
+ };
9
+ _origin?: (params: {
10
+ title?: string;
11
+ icon?: string;
12
+ duration?: number;
13
+ }) => void;
14
+ event: Record<string, unknownFunction>;
15
+ }
16
+ export default function showMessage(props: messageProps): void;
17
+ export {};
@@ -0,0 +1,39 @@
1
+ import { isH5Platform } from '../../utils/platform';
2
+ import { message } from 'tea-component';
3
+ import './index.css';
4
+ const iconType = {
5
+ success: 'success',
6
+ error: 'error',
7
+ warning: 'warning',
8
+ loading: 'loading',
9
+ none: 'none',
10
+ };
11
+ export default function showMessage(props) {
12
+ var _a, _b, _c, _d;
13
+ try {
14
+ const { data: { title, icon = 'none', duration = 1500 }, _origin, } = props;
15
+ const smallScreen = (_b = (_a = window === null || window === void 0 ? void 0 : window.matchMedia('(max-width: 1024px)')) === null || _a === void 0 ? void 0 : _a.matches) !== null && _b !== void 0 ? _b : isH5Platform();
16
+ const touchDevice = (_d = (_c = window === null || window === void 0 ? void 0 : window.matchMedia('(pointer:coarse)')) === null || _c === void 0 ? void 0 : _c.matches) !== null && _d !== void 0 ? _d : smallScreen;
17
+ const platform = touchDevice || smallScreen ? 'h5' : 'pc';
18
+ if (platform === 'h5') {
19
+ _origin &&
20
+ _origin({
21
+ title: title,
22
+ icon,
23
+ duration: duration || 1500,
24
+ });
25
+ }
26
+ else {
27
+ const realIcon = iconType[icon];
28
+ const isNotShowIcon = realIcon === 'none' || !realIcon;
29
+ message[isNotShowIcon ? 'success' : icon]({
30
+ className: `weda-showmessage__${icon}`,
31
+ content: title,
32
+ duration: duration || 1500,
33
+ });
34
+ }
35
+ }
36
+ catch (error) {
37
+ console.error('showMessage error', error);
38
+ }
39
+ }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import type { CommonPropsType } from '../../types';
2
+ import type { CommonPropsType, unknownFunction } from '../../types';
3
3
  import './index.css';
4
- declare const Button: ({ text, size, type, contentSlot, formType, loading, disabled, events, className, style, id, }: PropsType) => JSX.Element;
4
+ declare const Button: ({ text, size, type, contentSlot, formType, loading, disabled, events, className, style, id, ...props }: PropsType) => JSX.Element;
5
5
  export interface PropsType extends CommonPropsType {
6
6
  /**
7
7
  * 内容
@@ -28,5 +28,6 @@ export interface PropsType extends CommonPropsType {
28
28
  */
29
29
  formType?: 'button' | 'submit' | 'reset';
30
30
  contentSlot?: string;
31
+ [handlers: `on${string}`]: unknownFunction;
31
32
  }
32
33
  export default Button;
@@ -5,7 +5,7 @@ import { usePlatform } from '../../utils/platform';
5
5
  import './index.css';
6
6
  import { emptyObject } from '../../utils/constant';
7
7
  // 不用 react-weui 而直接用底层实现的原因是 react-weui 不能支持表单类型
8
- const Button = ({ text, size, type, contentSlot, formType, loading, disabled, events = emptyObject, className, style, id, }) => {
8
+ const Button = ({ text, size, type, contentSlot, formType, loading, disabled, events = emptyObject, className, style, id, ...props }) => {
9
9
  const platform = usePlatform();
10
10
  const isH5 = platform === 'h5';
11
11
  const cls = classNames({
@@ -23,18 +23,29 @@ const Button = ({ text, size, type, contentSlot, formType, loading, disabled, ev
23
23
  [className]: className,
24
24
  });
25
25
  const onClick = (e) => {
26
+ var _a;
26
27
  if (events.tap) {
27
28
  events.tap({}, { originEvent: e });
28
29
  }
30
+ (_a = props === null || props === void 0 ? void 0 : props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
29
31
  };
32
+ const propsStartWithOn = React.useMemo(() => {
33
+ return Object.keys(props).reduce((acc, cur) => {
34
+ if (cur.startsWith('on')) {
35
+ acc[cur] = props[cur];
36
+ }
37
+ return acc;
38
+ }, {});
39
+ }, [props]);
40
+ const teaBtnType = React.useMemo(() => toTeaButtonType(type), [type]);
30
41
  if (platform === 'h5') {
31
- return (React.createElement("button", { className: cls, disabled: disabled, type: formType, style: style, id: id, onClick: onClick },
42
+ return (React.createElement("button", { className: cls, disabled: disabled, type: formType, style: style, id: id, ...propsStartWithOn, onClick: onClick },
32
43
  loading && (React.createElement("span", { className: "weui-btn_loading" },
33
44
  React.createElement("i", { className: "weui-loading" }))),
34
45
  text ? text : contentSlot));
35
46
  }
36
47
  return (React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
37
- React.createElement(TeaButton, { loading: loading, onClick: onClick, disabled: disabled, htmlType: formType, type: toTeaButtonType(type), style: style, className: cls, id: id }, text ? text : contentSlot)));
48
+ React.createElement(TeaButton, { loading: loading, disabled: disabled, htmlType: formType, type: teaBtnType, style: style, className: cls, id: id, ...propsStartWithOn, onClick: onClick }, text ? text : contentSlot)));
38
49
  };
39
50
  function toTeaButtonType(type) {
40
51
  if (type === 'primary')
@@ -1,5 +1,6 @@
1
1
  import { useSyncedRef } from '@react-hookz/web';
2
2
  import { useCallback, useEffect, useRef } from 'react';
3
+ import { debug } from '../../utils/console';
3
4
  export const useRenderCount = () => {
4
5
  const countRef = useRef(0);
5
6
  const syncedRef = useSyncedRef(++countRef.current);
@@ -104,12 +105,12 @@ export const useLoopRenderDetect = (inputOptions = defaultOptions) => {
104
105
  };
105
106
  }, []);
106
107
  const fps = useFps();
107
- // console.log({
108
- // timeWindow: options.timeWindowMs,
109
- // fps,
110
- // renderCount,
111
- // limit: options.limit,
112
- // });
108
+ debug('loop:detect').log({
109
+ timeWindow: options.timeWindowMs,
110
+ fps,
111
+ renderCount,
112
+ limit: options.limit,
113
+ });
113
114
  if ((renderCount > options.limit && fps < 1) ||
114
115
  renderCount > options.limit * 3) {
115
116
  reset();
@@ -5,6 +5,7 @@ import { usePlatform, isInIde } from '../../../utils/platform';
5
5
  import { callDataSource, callConnector } from '../../../utils/tcb';
6
6
  import weui from '../../../utils/weui';
7
7
  import './index.css';
8
+ import isObjectEqual from '../../../utils/isObjectEqual';
8
9
  const formTypeWithInitValue = ['edit', 'read'];
9
10
  /**
10
11
  * 表单容器组件
@@ -20,7 +21,9 @@ export default function Form({ className, contentSlot, style, id, layout, formTy
20
21
  'gsd-h5-react-form-pc': platform === 'pc',
21
22
  [className]: className,
22
23
  });
23
- const timeRef = React.useRef(null);
24
+ const preParamGetItemRef = React.useRef(null);
25
+ const preDataIdRef = React.useRef(null);
26
+ const timeoutRef = React.useRef(null);
24
27
  React.useEffect(() => {
25
28
  const getData = async () => {
26
29
  var _a, _b;
@@ -64,12 +67,24 @@ export default function Form({ className, contentSlot, style, id, layout, formTy
64
67
  }
65
68
  };
66
69
  if (dataSourceName && formTypeWithInitValue.includes(formType)) {
67
- if ((isDataModel && _id) ||
68
- (!isDataModel && paramGetItem && methodGetItem)) {
69
- clearTimeout(timeRef.current);
70
- // 防抖
70
+ // https://git.woa.com/QBase/lcap/weda-ui/merge_requests/542 对象要小心死循环
71
+ if ((isDataModel &&
72
+ _id &&
73
+ !isObjectEqual(preDataIdRef.current, _id, true)) ||
74
+ (!isDataModel &&
75
+ paramGetItem &&
76
+ methodGetItem &&
77
+ !isObjectEqual(preParamGetItemRef.current, paramGetItem))) {
78
+ if (timeoutRef.current !== null) {
79
+ return () => {
80
+ clearTimeout(timeoutRef.current);
81
+ };
82
+ }
83
+ preParamGetItemRef.current = paramGetItem;
84
+ preDataIdRef.current = _id;
71
85
  // eslint-disable-next-line rulesdir/no-timer
72
- timeRef.current = setTimeout(() => getData(), 100);
86
+ timeoutRef.current = setTimeout(getData, 100);
87
+ getData();
73
88
  }
74
89
  }
75
90
  }, [
@@ -81,50 +96,6 @@ export default function Form({ className, contentSlot, style, id, layout, formTy
81
96
  methodGetItem,
82
97
  paramGetItem,
83
98
  ]);
84
- React.useEffect(() => {
85
- // 因编辑器render时序问题暂不上线
86
- // 获取字段权限
87
- // const authValue = {
88
- // isDataModel,
89
- // dataSourceFields: [],
90
- // dataSourceFieldsWidthAuthList: [],
91
- // };
92
- // const getDataSourceFieldsWithAuth = async () => {
93
- // try {
94
- // const datasource = await getDataSourceByName(dataSourceName);
95
- // if (!isInIde()) {
96
- // // 判断是否是预览区,编辑器编辑区 dataSourceName 查询的返回一致,编辑区用的本地的数据源数据返回固定
97
- // authValue.dataSourceFieldsWidthAuthList =
98
- // datasource?.resourceCheckInfos?.map((item) => item.ReadWrite);
99
- // authValue.dataSourceFields = Object.keys(
100
- // datasource?.schema?.properties || {}
101
- // );
102
- // }
103
- // events?.onInitDataSourceFieldsWithAuth?.(authValue);
104
- // } catch (err) {
105
- // events?.onInitDataSourceFieldsWithAuth?.(authValue);
106
- // alertError(
107
- // platform,
108
- // `获取数据源字段权限信息失败,字段权限可能无法正确展示,错误信息:${err}`
109
- // );
110
- // console.error('getDataSourceFieldsWithAuth err', err);
111
- // }
112
- // };
113
- // // 兼容私有环境,新接口不存在的情况,产品策略完善后移除
114
- // if (
115
- // window?.['_isPrivate'] &&
116
- // !window?.app?.cloud?.getDataSourceProfileAsync
117
- // ) {
118
- // events?.onInitDataSourceFieldsWithAuth?.({ isDataModel });
119
- // return;
120
- // }
121
- // if (isDataModel && dataSourceName) {
122
- // getDataSourceFieldsWithAuth();
123
- // } else {
124
- // // 在表单容器里面的表单元素 if 默认是 false,需要通过onInitDataSourceFieldsWithAuth设置为true
125
- // events?.onInitDataSourceFieldsWithAuth?.({ isDataModel });
126
- // }
127
- }, [formType, isDataModel, platform, dataSourceName, events]);
128
99
  // pc 渲染
129
100
  const renderPc = () => {
130
101
  return (React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
@@ -138,7 +138,7 @@ export function ImageUploaderH5({ title: label, maxUploadCount, maxSize = 10, ac
138
138
  React.createElement("div", { className: "weui-uploader__file-content" },
139
139
  progress,
140
140
  "%")))),
141
- showAdd && (React.createElement("div", { className: "weui-uploader__input-box" }, !disabled && (React.createElement("input", { id: "uploaderInput", className: "weui-uploader__input", type: "file", accept: accepts.join(','), multiple: true, onChange: (e) => {
141
+ showAdd && (React.createElement("div", { className: "weui-uploader__input-box" }, !disabled && (React.createElement("input", { id: "uploaderInput", className: "weui-uploader__input", type: "file", accept: accepts.join(','), multiple: !single, onChange: (e) => {
142
142
  const files = [...e.target.files];
143
143
  if (!islegalType(files, accepts))
144
144
  return;
@@ -156,6 +156,8 @@ export function UploaderPCInner(props) {
156
156
  };
157
157
  // 转换后的属性
158
158
  const extraProps = {};
159
+ //是否支持多选
160
+ extraProps['multiple'] = !single;
159
161
  extraProps['accept'] =
160
162
  acceptTypes.includes('image/*') || acceptTypes.length === 0
161
163
  ? IMAGE_TYPES
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import weui from '../../../utils/weui';
3
3
  import isObjectEqual from '../../../utils/isObjectEqual';
4
4
  import { ConfigProvider, Button, Icon, Text, List, Progress, Tooltip, message, } from 'tea-component';
5
- import { filterStrList, isCloudFileID, isHttpFileID, transSize, downloadFile, transFileCloudidToName, randomStr, } from '../../../utils/platform';
5
+ import { filterStrList, isCloudFileID, isHttpFileID, transSize, downloadFile, transFileCloudidToName, randomStr, isInIde, } from '../../../utils/platform';
6
6
  import { getCloudInstance } from '../../../utils/tcb';
7
7
  import classNames from '../../../utils/classnames';
8
8
  import { renderDecorator } from '../renderDecorator';
@@ -37,15 +37,17 @@ layout, id = '', style = defaultStyle, labelVisible = true, label = '上传文
37
37
  // 组件属性
38
38
  tips = '', btnTitle = '点击上传', maxUploadCount = 9, maxSize = 10, deleteVisible = true, downloadVisible = true, value = emptyArray, // 需要兼容 cloud:和https: 协议,需要兼容字符串和字符串数组
39
39
  events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true, onChange = null, isEdit = true, }) {
40
- const [fileIDList, setfileIDList] = React.useState(filterStrList([].concat(defaultValue, value))); // 上传成功文件ID列表,fileID[]
40
+ const [fileIDList, setfileIDList] = React.useState(isInIde() ? [] : filterStrList([].concat(defaultValue, value))); // 上传成功文件ID列表,fileID[]
41
41
  const [fileList, setFileList] = React.useState([]); // 上传中的文件列表,file[],file为原始文件 + uuid属性
42
42
  const [fileSizeObj, setFileSizeObj] = React.useState({}); // 管理上传文件大小 {uuid:size}
43
43
  // 两次默认值不同, 需要刷新
44
44
  const prevDefaultRef = React.useRef([]);
45
45
  const fileRef = React.useRef(fileIDList);
46
+ const maxSizeLimit = maxSize > 500 ? 500 : maxSize;
46
47
  React.useMemo(() => {
47
48
  //有有效默认值时不刷新,解决初次渲染默认值不显示问题
48
- if (defaultValue &&
49
+ if (!isInIde() &&
50
+ defaultValue &&
49
51
  !isObjectEqual(prevDefaultRef.current, defaultValue) &&
50
52
  (JSON.stringify(prevDefaultRef.current) == '[]' ||
51
53
  !prevDefaultRef.current)) {
@@ -115,7 +117,7 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
115
117
  multiple: !single,
116
118
  };
117
119
  tips && (uploadProps['label'] = tips);
118
- maxSize && (uploadProps['maxSize'] = maxSize * 1024 * 1024);
120
+ maxSizeLimit && (uploadProps['maxSize'] = maxSizeLimit * 1024 * 1024);
119
121
  const btnDisabled = fileIDList.length >= maxUploadCount ||
120
122
  (single && fileIDList.length > 0) ||
121
123
  disabled;
@@ -150,9 +152,9 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
150
152
  weui.alert(`上传文件总数不能超过${maxUploadCount}个`);
151
153
  return false;
152
154
  }
153
- if (maxSize &&
154
- fileList.some((f) => f.size > maxSize * 1024 * 1024)) {
155
- weui.alert(`请上传不超过${maxSize}M的文件`);
155
+ if (maxSizeLimit &&
156
+ fileList.some((f) => f.size > maxSizeLimit * 1024 * 1024)) {
157
+ weui.alert(`请上传不超过${maxSizeLimit}M的文件`);
156
158
  return false;
157
159
  }
158
160
  if (fileList.some((f) => f.size > 1024 * 1024 * 1024)) {
@@ -203,7 +205,7 @@ const TcbFileEcho = ({ fileID, disabled }) => {
203
205
  React.createElement("div", { className: `${CLASS_PREFIX}__item-left` },
204
206
  React.createElement(UploadFileStatus, { title: label, size: fileSizeObj[fileID] || '--' })),
205
207
  React.createElement("div", { className: `${CLASS_PREFIX}__btn-group` },
206
- React.createElement(UploadFileAction, { disabled: disabled, status: "UPLOAD_STATUS_SUCCESS", fileID: fileID, src: src }))));
208
+ React.createElement(UploadFileAction, { title: label, disabled: disabled, status: "UPLOAD_STATUS_SUCCESS", fileID: fileID, src: src }))));
207
209
  };
208
210
  /**
209
211
  * 基于 File 上传文件过程组件
@@ -296,7 +298,7 @@ const UploadFileStatus = ({ status = 'UPLOAD_STATUS_SUCCESS', percent = 0, size,
296
298
  * 操作列组件, onChange 从最外层 UploadFilePc 传进来
297
299
  * props: { status, fileID, uuid, src, onChange }
298
300
  */
299
- const UploadFileAction = ({ status = 'UPLOAD_STATUS_PENDING', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, disabled, }) => {
301
+ const UploadFileAction = ({ status = 'UPLOAD_STATUS_PENDING', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, disabled, title = 'downfile', }) => {
300
302
  const { onChange, downloadVisible, deleteVisible, isEdit } = React.useContext(FileContext) || {};
301
303
  // 操作列按钮-删除
302
304
  const renderDelete = () => isEdit && (React.createElement(Button, { icon: "delete", onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }), disabled: disabled }));
@@ -307,7 +309,7 @@ const UploadFileAction = ({ status = 'UPLOAD_STATUS_PENDING', fileID = '', uuid
307
309
  onReLoad === null || onReLoad === void 0 ? void 0 : onReLoad(file);
308
310
  } }));
309
311
  // 操作列按钮-下载
310
- const renderDownLoad = () => (React.createElement(Button, { icon: "download", onClick: () => downloadFile(src) }));
312
+ const renderDownLoad = () => (React.createElement(Button, { icon: "download", onClick: () => downloadFile(src, title) }));
311
313
  switch (status) {
312
314
  case 'UPLOAD_STATUS_PENDING':
313
315
  return renderCancel();
@@ -22,3 +22,14 @@ export interface IUploaderFilePc extends CommonFormPropsType {
22
22
  isEdit?: boolean;
23
23
  onChange?: unknownFunction;
24
24
  }
25
+ export interface IUploadFileAction {
26
+ status?: string;
27
+ fileID?: string;
28
+ uuid?: string;
29
+ src?: string;
30
+ file?: any;
31
+ onReLoad?: any;
32
+ onCancel?: any;
33
+ disabled: boolean;
34
+ title?: string;
35
+ }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Upload, ConfigProvider, Button, message, Icon, Text, List, } from 'tea-component';
3
- import { filterStrList, isCloudFileID, isHttpFileID, transSize, downloadFile, cutFileTitle, transFileCloudidToName, randomStr, } from '../../../utils/platform';
3
+ import { filterStrList, isCloudFileID, isHttpFileID, transSize, downloadFile, cutFileTitle, transFileCloudidToName, randomStr, isInIde, } from '../../../utils/platform';
4
4
  import { getCloudInstance } from '../../../utils/tcb';
5
5
  import classNames from '../../../utils/classnames';
6
6
  import { renderDecorator } from '../renderDecorator';
@@ -28,15 +28,17 @@ layout, id = '', style, labelVisible = true, label = '上传文件', requiredFla
28
28
  decorator, tips = '', btnTitle = '点击上传', maxUploadCount = 9, maxSize = 1024, single = true, defaultValue = emptyArray, // 组件默认初始化值
29
29
  value = emptyArray, // 用于模型组件中 formily 的值管理
30
30
  acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPath = 'weda-uploader', onChange = null, isEdit = true, }) {
31
- const [fileIDList, setfileIDList] = React.useState(filterStrList([].concat(defaultValue, value))); // 上传成功文件ID列表,fileID[]
31
+ const [fileIDList, setfileIDList] = React.useState(isInIde() ? [] : filterStrList([].concat(defaultValue, value))); // 上传成功文件ID列表,fileID[]
32
32
  const [fileList, setFileList] = React.useState([]); // 上传中的文件列表,file[],file为原始文件 + uuid属性
33
33
  const [fileSizeObj, setFileSizeObj] = React.useState({}); // 管理上传文件大小 {uuid:size}
34
34
  // 两次默认值不同, 需要刷新
35
35
  const prevDefaultRef = React.useRef([]);
36
36
  const fileRef = React.useRef(fileIDList);
37
+ const maxSizeLimit = maxSize > 500 ? 500 : maxSize;
37
38
  React.useMemo(() => {
38
39
  //有有效默认值时不刷新,解决初次渲染默认值不显示问题
39
- if (defaultValue &&
40
+ if (!isInIde() &&
41
+ defaultValue &&
40
42
  !isObjectEqual(prevDefaultRef.current, defaultValue) &&
41
43
  (JSON.stringify(prevDefaultRef.current) == '[]' ||
42
44
  !prevDefaultRef.current)) {
@@ -85,7 +87,7 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
85
87
  errorList.push('上传文件类型错误');
86
88
  }
87
89
  if (error.find((item) => (item === null || item === void 0 ? void 0 : item.code) === 'file-too-large')) {
88
- errorList.push(`上传文件大小不能超过${maxSize}M`);
90
+ errorList.push(`上传文件大小不能超过${maxSizeLimit}M`);
89
91
  }
90
92
  message.error({ content: errorList.join(', ') });
91
93
  }
@@ -116,7 +118,7 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
116
118
  uploadProps['accept'] = Array.from(new Set(acceptTypes));
117
119
  }
118
120
  tips && (uploadProps['title'] = tips);
119
- maxSize && (uploadProps['maxSize'] = maxSize * 1024 * 1024);
121
+ maxSize && (uploadProps['maxSize'] = maxSizeLimit * 1024 * 1024);
120
122
  const btnDisabled = fileIDList.length >= maxUploadCount || (single && fileIDList.length > 0);
121
123
  //验证上传文件类型是否合法
122
124
  const islegalType = (files, accepts) => {
@@ -193,7 +195,7 @@ const TcbFileEcho = ({ fileID, disabled }) => {
193
195
  React.createElement("div", { className: `${CLASS_PREFIX}--item-status` },
194
196
  React.createElement(UploadFileStatus, null)),
195
197
  React.createElement("div", { className: `${CLASS_PREFIX}--item-action` },
196
- React.createElement(UploadFileAction, { disabled: disabled, status: "2", fileID: fileID, src: src }))));
198
+ React.createElement(UploadFileAction, { title: title, disabled: disabled, status: "2", fileID: fileID, src: src }))));
197
199
  };
198
200
  /**
199
201
  * 基于 File 上传文件过程表格行组件
@@ -267,7 +269,7 @@ const UploadFileStatus = ({ status = '2', percent = 0 }) => {
267
269
  * 操作列组件, onChange 从最外层 UploadFilePc 传进来
268
270
  * props: { status, fileID, uuid, src, onChange }
269
271
  */
270
- const UploadFileAction = ({ status = '0', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, disabled, }) => {
272
+ const UploadFileAction = ({ title = 'downfile', status = '0', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, disabled, }) => {
271
273
  const { onChange, downloadVisible, deleteVisible, isEdit } = React.useContext(FileContext) || {};
272
274
  // 操作列按钮-删除
273
275
  const renderDelete = () => isEdit &&
@@ -279,7 +281,7 @@ const UploadFileAction = ({ status = '0', fileID = '', uuid = '', src = '', file
279
281
  onReLoad === null || onReLoad === void 0 ? void 0 : onReLoad(file);
280
282
  } }, "\u91CD\u65B0\u4E0A\u4F20"));
281
283
  // 操作列按钮-下载
282
- const renderDownLoad = () => downloadVisible && (React.createElement(Button, { type: "link", title: "\u70B9\u51FB\u4E0B\u8F7D\u6587\u4EF6", onClick: () => downloadFile(src) }, "\u4E0B\u8F7D"));
284
+ const renderDownLoad = () => downloadVisible && (React.createElement(Button, { type: "link", title: "\u70B9\u51FB\u4E0B\u8F7D\u6587\u4EF6", onClick: () => downloadFile(src, title) }, "\u4E0B\u8F7D"));
283
285
  switch (status) {
284
286
  case '0':
285
287
  return renderCancel();
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { SearchBox, Status, Tree, LoadingTip, Button } from 'tea-component';
3
- import { getNode, dealUserData, dealOrgData } from './utils';
3
+ import { getNode, dealUserData, dealOrgData, getUserDepartID } from './utils';
4
4
  import classNames from '../../../utils/classnames';
5
5
  export const DimTreeContent = (props) => {
6
6
  const { selectedIds, onSelect, onActive, activeIds, treeClassName, data: treeData, setTreeData, onCancel, onConfirm, needUser, onReset, request, errorInfo = { errorStatus: false, errorMessage: '' }, } = props;
@@ -54,7 +54,8 @@ export const DimTreeContent = (props) => {
54
54
  );
55
55
  setLoading(false);
56
56
  //@ts-ignore jsx
57
- resData = dealOrgData(Orgs).concat(needUser ? dealUserData(Users) : []);
57
+ const treeUsers = getUserDepartID(Users);
58
+ resData = dealOrgData(Orgs).concat(needUser ? dealUserData(treeUsers) : []);
58
59
  setTreeData(resData);
59
60
  }
60
61
  }
@@ -64,7 +65,7 @@ export const DimTreeContent = (props) => {
64
65
  }
65
66
  };
66
67
  return (React.createElement(React.Fragment, null,
67
- React.createElement(SearchBox, { onSearch: search, onClear: () => onReset(), onChange: (val) => !val && onReset() }),
68
+ React.createElement(SearchBox, { onSearch: search, onClear: () => onReset(), onChange: (val) => !val && onReset(), "data-testid": "SearchBox" }),
68
69
  React.createElement("div", { className: "tree-search-loading" }, loading && React.createElement(LoadingTip, null)),
69
70
  (errInfo === null || errInfo === void 0 ? void 0 : errInfo.errorStatus) && (React.createElement(ErrorStatus, { size: "l", title: "\u63A5\u53E3\u8C03\u7528\u5931\u8D25", description: (errInfo === null || errInfo === void 0 ? void 0 : errInfo.errorMessage) || null })),
70
71
  !(treeData === null || treeData === void 0 ? void 0 : treeData.length) && !loading && !(errInfo === null || errInfo === void 0 ? void 0 : errInfo.errorStatus) && (React.createElement(Status, { className: "dim-tree-select--blank", icon: 'blank', size: 's', title: `暂无${needUser ? '成员' : '部门'}数据` })),
@@ -117,16 +117,15 @@ export function DepartTreeSelectH5({ id, className, style, events = emptyObject,
117
117
  //获取组织结构
118
118
  useEffect(() => {
119
119
  initOrgsData();
120
- if ((defaultValue &&
121
- !isObjectEqual(prevDefaultRef.current !== defaultValue)) ||
122
- (confirmValue && !isObjectEqual(prevConfirmRef.current !== confirmValue))) {
120
+ if ((defaultValue && !isObjectEqual(prevDefaultRef.current, defaultValue)) ||
121
+ (confirmValue && !isObjectEqual(prevConfirmRef.current, confirmValue))) {
123
122
  const getdefaultUser = async () => {
124
123
  var _a;
125
124
  try {
126
125
  if ((defaultValueType === 'confirmDepart' &&
127
126
  confirmValue.length !== 0) ||
128
127
  defaultValue.length !== 0) {
129
- const orgId = confirmValue.length !== 0 ? confirmValue : defaultValue;
128
+ const orgId = defaultValue.length !== 0 ? defaultValue : confirmValue;
130
129
  const defaultDepart = await getDepartById({
131
130
  _id: orgId,
132
131
  });
@@ -48,7 +48,7 @@ export function DepartTreeSelectPC({ id, className, style, events = emptyObject,
48
48
  try {
49
49
  if ((defaultValueType === 'confirmDepart' && confirmValue.length !== 0) ||
50
50
  defaultValue.length !== 0) {
51
- const orgId = confirmValue.length !== 0 ? confirmValue : defaultValue;
51
+ const orgId = defaultValue.length !== 0 ? defaultValue : confirmValue;
52
52
  const defaultUser = await getDepartById({
53
53
  _id: orgId,
54
54
  });
@@ -61,15 +61,14 @@ export function DepartTreeSelectPC({ id, className, style, events = emptyObject,
61
61
  }
62
62
  };
63
63
  initOrgsData();
64
- if ((defaultValue &&
65
- !isObjectEqual(prevDefaultRef.current !== defaultValue)) ||
66
- (confirmValue && !isObjectEqual(prevConfirmRef.current !== confirmValue))) {
64
+ if ((defaultValue && !isObjectEqual(prevDefaultRef.current, defaultValue)) ||
65
+ (confirmValue && !isObjectEqual(prevConfirmRef.current, confirmValue))) {
67
66
  getdefaultUser();
68
67
  prevDefaultRef.current = defaultValue;
69
68
  prevConfirmRef.current = confirmValue;
70
69
  }
71
70
  // eslint-disable-next-line react-hooks/exhaustive-deps
72
- }, [defaultValueType, confirmValue, defaultValue, request]);
71
+ }, [defaultValueType, confirmValue, defaultValue]);
73
72
  useEffect(() => {
74
73
  if (open) {
75
74
  setErrorInfo({ errorStatus: false, errorMessage: null });
@@ -86,7 +85,7 @@ export function DepartTreeSelectPC({ id, className, style, events = emptyObject,
86
85
  setErrorInfo({ errorStatus: false, errorMessage: null });
87
86
  setActiveIds([]);
88
87
  onChange === null || onChange === void 0 ? void 0 : onChange(value);
89
- (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value });
88
+ (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value, data: null });
90
89
  close && setOpen(false);
91
90
  };
92
91
  // 外层组件类
@@ -104,7 +103,7 @@ export function DepartTreeSelectPC({ id, className, style, events = emptyObject,
104
103
  React.createElement(Dropdown, { className: classNames(`department-tree-select`, `size-${size}`), destroyOnClose: false, open: open, onOpenChange: (open) => {
105
104
  setOpen(open);
106
105
  setErrorInfo({ errorStatus: false, errorMessage: null });
107
- }, button: React.createElement(SelectViewContainer, { curSelectItem: curSelectItem, multiple: multiple, placeholder: placeholder, moveIn: moveIn, onChange: () => reset(true) }), style: { width: '100%' }, appearance: multiple ? 'pure' : 'button', clickClose: false, disabled: disabled }, () => (React.createElement("div", { className: "dim-tree-select" },
106
+ }, button: React.createElement(SelectViewContainer, { curSelectItem: curSelectItem, multiple: multiple, placeholder: placeholder, moveIn: moveIn, onChange: () => reset(true) }), style: { width: '100%' }, appearance: multiple ? 'pure' : 'button', clickClose: false, disabled: disabled }, () => (React.createElement("div", { className: "dim-tree-select dim-tree-select--user" },
108
107
  React.createElement(DimTreeContent, { data: treeData, setTreeData: setTreeData, selectedIds: selectIds, activeIds: activeIds, needUser: false, request: request, errorInfo: errorInfo, searchType: "SearchByOrg", onActive: (ids) => {
109
108
  setActiveIds(ids);
110
109
  setSelectIds(ids);
@@ -39,7 +39,8 @@ export const defaultRequest = async (action, params, type = 'callWedaApi') => {
39
39
  : userInfo[datasource === null || datasource === void 0 ? void 0 : datasource.schema['x-primary-column']] ||
40
40
  (item === null || item === void 0 ? void 0 : item.UserId),
41
41
  },
42
- orgs: item === null || item === void 0 ? void 0 : item.Orgs,
42
+ //优先展示主岗部门,对象格式
43
+ orgs: (item === null || item === void 0 ? void 0 : item.MainOrg) ? [].concat(item === null || item === void 0 ? void 0 : item.MainOrg) : (item === null || item === void 0 ? void 0 : item.Orgs) || [],
43
44
  };
44
45
  });
45
46
  userInfoList.push.apply(userInfoList, resData);