@cloudbase/weda-ui 3.1.6 → 3.2.0

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 (82) hide show
  1. package/dist/configs/components/chart/bar.json +14 -7
  2. package/dist/configs/components/chart/line.json +14 -7
  3. package/dist/configs/components/chart/pie.json +12 -6
  4. package/dist/configs/components/form/departTreeSelect.json +124 -0
  5. package/dist/configs/components/form/userTreeSelect.json +128 -0
  6. package/dist/configs/components/formdetail.json +105 -0
  7. package/dist/configs/components/listView.json +9 -1
  8. package/dist/configs/components/lottery.json +1 -1
  9. package/dist/configs/components/tabs.json +10 -9
  10. package/dist/configs/components/wxOpenApi/share.json +5 -2
  11. package/dist/configs/index.d.ts +6 -0
  12. package/dist/configs/index.js +6 -0
  13. package/dist/docs/common/format.js +24 -5
  14. package/dist/web/actions/showModal/index.css +3 -0
  15. package/dist/web/actions/showModal/index.d.ts +1 -0
  16. package/dist/web/actions/showModal/index.js +1 -0
  17. package/dist/web/components/calendar/index.js +10 -2
  18. package/dist/web/components/carousel/index.js +4 -0
  19. package/dist/web/components/chart/common/core/eChartBase.js +8 -2
  20. package/dist/web/components/form/form/index.js +10 -7
  21. package/dist/web/components/form/location/common/mapChoose.js +2 -0
  22. package/dist/web/components/form/location/common/mapView.js +2 -0
  23. package/dist/web/components/form/location/components/LocationH5/location.h5.js +3 -1
  24. package/dist/web/components/form/location/components/LocationH5/location.module.css +3 -0
  25. package/dist/web/components/form/select/h5.js +4 -0
  26. package/dist/web/components/form/select/index.js +2 -8
  27. package/dist/web/components/form/switch/index.js +3 -2
  28. package/dist/web/components/form/switch/switch.module.css +7 -0
  29. package/dist/web/components/form/uploader/uploader.h5.d.ts +1 -0
  30. package/dist/web/components/form/uploader/uploader.h5.js +41 -17
  31. package/dist/web/components/form/uploader/uploader.pc.js +31 -2
  32. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +36 -14
  33. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +34 -11
  34. package/dist/web/components/form/userOrgSelect/comTool.d.ts +7 -0
  35. package/dist/web/components/form/userOrgSelect/comTool.js +89 -0
  36. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.d.ts +20 -0
  37. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +259 -0
  38. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.d.ts +4 -0
  39. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +153 -0
  40. package/dist/web/components/form/userOrgSelect/departTreeSelect/index.d.ts +2 -0
  41. package/dist/web/components/form/userOrgSelect/departTreeSelect/index.js +17 -0
  42. package/dist/web/components/form/userOrgSelect/index.d.ts +2 -0
  43. package/dist/web/components/form/userOrgSelect/index.js +17 -0
  44. package/dist/web/components/form/userOrgSelect/userOrgSelect.less +643 -0
  45. package/dist/web/components/form/userOrgSelect/userTreeSelect.h5.d.ts +24 -0
  46. package/dist/web/components/form/userOrgSelect/userTreeSelect.h5.js +276 -0
  47. package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.d.ts +9 -0
  48. package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.js +229 -0
  49. package/dist/web/components/form/userOrgSelect/utils.d.ts +35 -0
  50. package/dist/web/components/form/userOrgSelect/utils.js +72 -0
  51. package/dist/web/components/formdetail/index.css +115 -0
  52. package/dist/web/components/formdetail/index.d.ts +28 -0
  53. package/dist/web/components/formdetail/index.js +170 -0
  54. package/dist/web/components/index.d.ts +3 -0
  55. package/dist/web/components/index.js +3 -0
  56. package/dist/web/components/listView/index.css +35 -5
  57. package/dist/web/components/listView/index.js +92 -68
  58. package/dist/web/components/listView/interface.d.ts +5 -0
  59. package/dist/web/components/lottery/index.js +2 -1
  60. package/dist/web/components/lottery/lotteryUtil.js +1 -0
  61. package/dist/web/components/navigationBar/index.css +21 -29
  62. package/dist/web/components/richText/index.css +1 -0
  63. package/dist/web/components/swiper/index.js +5 -1
  64. package/dist/web/components/wedaVideo/index.js +1 -0
  65. package/dist/web/utils/getUserService.d.ts +17 -0
  66. package/dist/web/utils/getUserService.js +148 -0
  67. package/dist/web/utils/platform.js +2 -0
  68. package/dist/web/weda-ui.css +9 -0
  69. package/package.json +14 -13
  70. package/dist/asset-manifest.json +0 -17
  71. package/dist/index.html +0 -88
  72. package/dist/static/js/bundle.js +0 -963
  73. package/dist/static/js/bundle.js.map +0 -1
  74. package/dist/static/js/main.chunk.js +0 -8841
  75. package/dist/static/js/main.chunk.js.map +0 -1
  76. package/dist/static/js/vendors~main.chunk.js +0 -247885
  77. package/dist/static/js/vendors~main.chunk.js.map +0 -1
  78. package/dist/static/media/ef6fa527e24e354765d806b826b41391.fa67580a.svg +0 -627
  79. package/dist/web/components/auth/index.d.ts +0 -10
  80. package/dist/web/components/auth/index.js +0 -37
  81. package/dist/web/utils/events.d.ts +0 -1
  82. package/dist/web/utils/events.js +0 -2
@@ -83,15 +83,29 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
83
83
  ? ['*']
84
84
  : Array.from(new Set(acceptTypes));
85
85
  }, [acceptTypes]);
86
+ const islegalType = (files, accepts) => {
87
+ const illegalType = [];
88
+ for (const file of files) {
89
+ accepts.some((item) => item === (file === null || file === void 0 ? void 0 : file.type))
90
+ ? null
91
+ : illegalType.push(file === null || file === void 0 ? void 0 : file.type);
92
+ }
93
+ if (illegalType.length > 0) {
94
+ weui.alert('不支持上传' + Array.from(new Set(illegalType)).join(',') + '格式文件');
95
+ return false;
96
+ }
97
+ return true;
98
+ };
86
99
  // 上传后文件列表 fileIDList 改变事件,'add'|'delete'
87
100
  const handleChange = ({ fileID, uuid, type, size }) => {
88
101
  // 上传时新增事件
89
102
  if (type === 'add') {
90
103
  fileID && setFileSizeObj((obj) => ({ ...obj, [fileID]: size }));
91
- fileID && setfileIDList([...fileIDList, fileID]);
104
+ fileID && setfileIDList((fileIDList) => [...fileIDList, fileID]);
92
105
  }
93
106
  else {
94
- fileID && setfileIDList(fileIDList.filter((f) => f !== fileID));
107
+ fileID &&
108
+ setfileIDList((fileIDList) => fileIDList.filter((f) => f !== fileID));
95
109
  }
96
110
  uuid && setFileList((list) => list.filter((item) => uuid !== (item === null || item === void 0 ? void 0 : item._uuid)));
97
111
  };
@@ -120,6 +134,12 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
120
134
  React.createElement("div", null, btnDisabled ? (React.createElement(Button, { type: "weak", className: classNames(`${CLASS_PREFIX}__btn--weak`), disabled: btnDisabled }, btnTitle)) : (React.createElement("div", null,
121
135
  React.createElement("input", { id: "uploaderInput", type: "file", "data-testid": "button-up", className: "weui-uploader-mobile__input", accept: accepts.join(','), multiple: !single, onChange: (e) => {
122
136
  const fileList = [...e.target.files];
137
+ //校验逻辑与图片有出入,文件类型限制为全部时,不设限
138
+ if (!(accepts.includes('*') ||
139
+ accepts.includes('') ||
140
+ accepts.length === 0) &&
141
+ !islegalType(fileList, accepts))
142
+ return;
123
143
  if (single && fileList.length > 1) {
124
144
  weui.alert(`上传文件总数不能超过1个`);
125
145
  return false;
@@ -145,8 +165,8 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
145
165
  !single && (React.createElement(Text, { className: `${CLASS_PREFIX}__tips` }, "\u652F\u6301\u6279\u91CF\u4E0A\u4F20"))))))),
146
166
  React.createElement("div", { className: `${CLASS_PREFIX}__bd` },
147
167
  React.createElement(List, null,
148
- fileIDList.map((d) => (React.createElement(List.Item, { key: d }, React.createElement(TcbFileEcho, { fileID: d, fileList: fileList, onChange: handleChange, deleteVisible: deleteVisible, downloadVisible: downloadVisible })))),
149
- fileList.map((item) => (React.createElement(List.Item, { key: item === null || item === void 0 ? void 0 : item._uuid }, React.createElement(TcbFileUpload, { file: item, downloadVisible: downloadVisible, deleteVisible: deleteVisible })))))))))))({
168
+ fileIDList.map((d) => (React.createElement(List.Item, { key: d }, React.createElement(TcbFileEcho, { fileID: d, fileList: fileList, onChange: handleChange, disabled: disabled, deleteVisible: deleteVisible, downloadVisible: downloadVisible })))),
169
+ fileList.map((item) => (React.createElement(List.Item, { key: item === null || item === void 0 ? void 0 : item._uuid }, React.createElement(TcbFileUpload, { disabled: disabled, file: item, downloadVisible: downloadVisible, deleteVisible: deleteVisible && !disabled })))))))))))({
150
170
  id,
151
171
  className: cls,
152
172
  style,
@@ -159,7 +179,7 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
159
179
  /**
160
180
  * 基于 FileID 文件回显组件
161
181
  */
162
- const TcbFileEcho = ({ fileID }) => {
182
+ const TcbFileEcho = ({ fileID, disabled }) => {
163
183
  const [src, setSrc] = React.useState('');
164
184
  const { fileSizeObj } = React.useContext(FileContext) || {};
165
185
  React.useEffect(() => {
@@ -191,12 +211,12 @@ const TcbFileEcho = ({ fileID }) => {
191
211
  React.createElement("div", { className: `${CLASS_PREFIX}__item-left` },
192
212
  React.createElement(UploadFileStatus, { title: label, size: fileSizeObj[fileID] || '--' })),
193
213
  React.createElement("div", { className: `${CLASS_PREFIX}__btn-group` },
194
- React.createElement(UploadFileAction, { status: "UPLOAD_STATUS_SUCCESS", fileID: fileID, src: src }))));
214
+ React.createElement(UploadFileAction, { disabled: disabled, status: "UPLOAD_STATUS_SUCCESS", fileID: fileID, src: src }))));
195
215
  };
196
216
  /**
197
217
  * 基于 File 上传文件过程组件
198
218
  */
199
- const TcbFileUpload = ({ file }) => {
219
+ const TcbFileUpload = ({ file, disabled }) => {
200
220
  const { uploadPath, onChange, events } = React.useContext(FileContext) || {};
201
221
  const [percent, setPercent] = React.useState(0); // 上传进度
202
222
  const [status, setStatus] = React.useState('UPLOAD_STATUS_PENDING'); // 上传状态
@@ -242,7 +262,7 @@ const TcbFileUpload = ({ file }) => {
242
262
  React.createElement(UploadFileAction, { file: file, uuid: file === null || file === void 0 ? void 0 : file._uuid, status: status, onCancel: (uuid) => {
243
263
  cancleRef.current = uuid;
244
264
  onChange === null || onChange === void 0 ? void 0 : onChange({ type: 'delete', uuid });
245
- }, onReLoad: handleUpload }))));
265
+ }, onReLoad: handleUpload, disabled: disabled }))));
246
266
  };
247
267
  /**
248
268
  * 上传文件状态组件
@@ -261,7 +281,9 @@ const UploadFileStatus = ({ status = 'UPLOAD_STATUS_SUCCESS', percent = 0, size,
261
281
  React.createElement(Progress, { percent: percent, theme: "default", strokeColor: '#0052D9', className: `${CLASS_PREFIX}__file-progress` })))),
262
282
  React.createElement("div", { className: `${CLASS_PREFIX}__file-foot` },
263
283
  React.createElement("div", null,
264
- React.createElement(Text, null, `${Math.floor(percentSize)}K/`),
284
+ React.createElement(Text, null,
285
+ Math.floor(percentSize),
286
+ "K/"),
265
287
  React.createElement(Text, null, size)),
266
288
  React.createElement(Text, null, status === 'UPLOAD_STATUS_PENDING' ? '等待上传' : '上传中'))));
267
289
  }
@@ -282,18 +304,18 @@ const UploadFileStatus = ({ status = 'UPLOAD_STATUS_SUCCESS', percent = 0, size,
282
304
  * 操作列组件, onChange 从最外层 UploadFilePc 传进来
283
305
  * props: { status, fileID, uuid, src, onChange }
284
306
  */
285
- const UploadFileAction = ({ status = 'UPLOAD_STATUS_PENDING', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, }) => {
307
+ const UploadFileAction = ({ status = 'UPLOAD_STATUS_PENDING', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, disabled, }) => {
286
308
  const { onChange, downloadVisible, deleteVisible, isEdit } = React.useContext(FileContext) || {};
287
309
  // 操作列按钮-删除
288
- const renderDelete = () => isEdit && (React.createElement(Icon, { type: "delete", style: { cursor: 'pointer' }, onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }) }));
310
+ const renderDelete = () => isEdit && (React.createElement(Button, { icon: "delete", onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }), disabled: disabled }));
289
311
  // 操作列按钮-取消
290
- const renderCancel = () => isEdit && (React.createElement(Icon, { type: "dismiss", style: { cursor: 'pointer' }, onClick: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(uuid) }));
312
+ const renderCancel = () => isEdit && React.createElement(Button, { icon: "dismiss", onClick: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(uuid) });
291
313
  // 操作列按钮-重新上传
292
- const renderReLoad = () => isEdit && (React.createElement(Icon, { type: "refresh", style: { cursor: 'pointer' }, onClick: () => {
314
+ const renderReLoad = () => isEdit && (React.createElement(Button, { icon: "refresh", onClick: () => {
293
315
  onReLoad === null || onReLoad === void 0 ? void 0 : onReLoad(file);
294
316
  } }));
295
317
  // 操作列按钮-下载
296
- const renderDownLoad = () => (React.createElement(Icon, { type: "download", style: { cursor: 'pointer' }, onClick: () => downloadFile(src) }));
318
+ const renderDownLoad = () => (React.createElement(Button, { icon: "download", onClick: () => downloadFile(src) }));
297
319
  switch (status) {
298
320
  case 'UPLOAD_STATUS_PENDING':
299
321
  return renderCancel();
@@ -68,6 +68,11 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
68
68
  });
69
69
  // 批量上传文件前置事件
70
70
  const handleBefore = (file, fileList, isAccepted, error) => {
71
+ if (!((acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('*')) ||
72
+ (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('')) ||
73
+ (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.length) === 0) &&
74
+ !islegalType(fileList, uploadProps['accept']))
75
+ return;
71
76
  if (fileList.length + fileIDList.length > maxUploadCount) {
72
77
  message.warning({ content: `上传文件总数不能超过${maxUploadCount}个` });
73
78
  return false;
@@ -112,6 +117,24 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
112
117
  tips && (uploadProps['title'] = tips);
113
118
  maxSize && (uploadProps['maxSize'] = maxSize * 1024 * 1024);
114
119
  const btnDisabled = fileIDList.length >= maxUploadCount || (single && fileIDList.length > 0);
120
+ //验证上传文件类型是否合法
121
+ const islegalType = (files, accepts) => {
122
+ const illegalType = [];
123
+ for (const file of files) {
124
+ accepts.some((item) => item === (file === null || file === void 0 ? void 0 : file.type))
125
+ ? null
126
+ : illegalType.push(file === null || file === void 0 ? void 0 : file.type);
127
+ }
128
+ if (illegalType.length > 0) {
129
+ message.error({
130
+ content: '不支持上传' +
131
+ Array.from(new Set(illegalType)).join(',') +
132
+ '格式文件',
133
+ });
134
+ return false;
135
+ }
136
+ return true;
137
+ };
115
138
  return renderDecorator(React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
116
139
  React.createElement(FileContext.Provider, { value: {
117
140
  uploadPath,
@@ -121,9 +144,9 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
121
144
  isEdit,
122
145
  events,
123
146
  fileSizeObj,
124
- } },
125
- React.createElement("div", { className: `${CLASS_PREFIX}` },
126
- isEdit && (React.createElement("div", { className: `${CLASS_PREFIX}__input-box` }, disabled || btnDisabled ? (React.createElement(Button, { type: "weak", disabled: true }, btnTitle)) : (React.createElement(Upload, { ...uploadProps, beforeUpload: handleBefore },
147
+ }, "data-testid": "button-up" },
148
+ React.createElement("div", { className: `${CLASS_PREFIX}`, "data-testid": "UploadFilePc" },
149
+ isEdit && (React.createElement("div", { className: `${CLASS_PREFIX}__input-box` }, disabled || btnDisabled ? (React.createElement(Button, { type: "weak", disabled: true }, btnTitle)) : (React.createElement(Upload, { ...uploadProps, beforeUpload: handleBefore, "data-testid": "Upload" },
127
150
  React.createElement(Button, { type: "weak", className: `${CLASS_PREFIX}__btn--weak` }, btnTitle),
128
151
  !single && (React.createElement(Text, { theme: "weak", className: `${CLASS_PREFIX}__btn-descripe` }, "\u652F\u6301\u6279\u91CF\u4E0A\u4F20")))))),
129
152
  React.createElement(List, { split: "divide" },
@@ -133,8 +156,8 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
133
156
  React.createElement("div", { className: `${CLASS_PREFIX}--item-size ${CLASS_PREFIX}--item-label` }, "\u5927\u5C0F"),
134
157
  React.createElement("div", { className: `${CLASS_PREFIX}--item-status ${CLASS_PREFIX}--item-label` }, "\u72B6\u6001"),
135
158
  React.createElement("div", { className: `${CLASS_PREFIX}--item-action` }, "\u64CD\u4F5C"))),
136
- fileIDList.map((d) => (React.createElement(List.Item, { key: d }, React.createElement(TcbFileEcho, { fileID: d })))),
137
- fileList.map((item) => (React.createElement(List.Item, { key: item === null || item === void 0 ? void 0 : item._uuid }, React.createElement(TcbFileUpload, { file: item })))),
159
+ fileIDList.map((d) => (React.createElement(List.Item, { key: d }, React.createElement(TcbFileEcho, { disabled: disabled, fileID: d })))),
160
+ fileList.map((item) => (React.createElement(List.Item, { key: item === null || item === void 0 ? void 0 : item._uuid }, React.createElement(TcbFileUpload, { disabled: disabled, file: item })))),
138
161
  isEdit && fileIDList.length === 0 && fileList.length === 0 && (React.createElement(List.Item, { className: `${CLASS_PREFIX}--item-empty` },
139
162
  React.createElement("div", { className: `${CLASS_PREFIX}--item` },
140
163
  "\u70B9\u51FB\u4E0A\u65B9\u201C",
@@ -152,7 +175,7 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
152
175
  /**
153
176
  * 基于 FileID 回显文件表格行组件
154
177
  */
155
- const TcbFileEcho = ({ fileID }) => {
178
+ const TcbFileEcho = ({ fileID, disabled }) => {
156
179
  const [src, setSrc] = React.useState('');
157
180
  const { fileSizeObj } = React.useContext(FileContext) || {};
158
181
  React.useEffect(() => {
@@ -184,12 +207,12 @@ const TcbFileEcho = ({ fileID }) => {
184
207
  React.createElement("div", { className: `${CLASS_PREFIX}--item-status` },
185
208
  React.createElement(UploadFileStatus, null)),
186
209
  React.createElement("div", { className: `${CLASS_PREFIX}--item-action` },
187
- React.createElement(UploadFileAction, { status: "2", fileID: fileID, src: src }))));
210
+ React.createElement(UploadFileAction, { disabled: disabled, status: "2", fileID: fileID, src: src }))));
188
211
  };
189
212
  /**
190
213
  * 基于 File 上传文件过程表格行组件
191
214
  */
192
- const TcbFileUpload = ({ file }) => {
215
+ const TcbFileUpload = ({ file, disabled }) => {
193
216
  const { uploadPath, onChange, events } = React.useContext(FileContext) || {};
194
217
  const [percent, setPercent] = React.useState(0); // 上传进度
195
218
  const [status, setStatus] = React.useState('0'); // 上传状态
@@ -236,7 +259,7 @@ const TcbFileUpload = ({ file }) => {
236
259
  React.createElement(UploadFileAction, { file: file, uuid: file === null || file === void 0 ? void 0 : file._uuid, status: status, onCancel: (uuid) => {
237
260
  cancleRef.current = uuid;
238
261
  onChange === null || onChange === void 0 ? void 0 : onChange({ type: 'delete', uuid });
239
- }, onReLoad: handleUpload }))));
262
+ }, disabled: disabled, onReLoad: handleUpload }))));
240
263
  };
241
264
  /**
242
265
  * 上传文件状态组件
@@ -258,11 +281,11 @@ const UploadFileStatus = ({ status = '2', percent = 0 }) => {
258
281
  * 操作列组件, onChange 从最外层 UploadFilePc 传进来
259
282
  * props: { status, fileID, uuid, src, onChange }
260
283
  */
261
- const UploadFileAction = ({ status = '0', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, }) => {
284
+ const UploadFileAction = ({ status = '0', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, disabled, }) => {
262
285
  const { onChange, downloadVisible, deleteVisible, isEdit } = React.useContext(FileContext) || {};
263
286
  // 操作列按钮-删除
264
287
  const renderDelete = () => isEdit &&
265
- deleteVisible && (React.createElement(Button, { type: "link", onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }) }, "\u5220\u9664"));
288
+ deleteVisible && (React.createElement(Button, { type: "link", disabled: disabled, onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }) }, "\u5220\u9664"));
266
289
  // 操作列按钮-取消
267
290
  const renderCancel = () => isEdit && (React.createElement(Button, { onClick: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(uuid), type: "link" }, "\u53D6\u6D88"));
268
291
  // 操作列按钮-重新上传
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const DimTreeContent: (props: any) => JSX.Element;
3
+ export declare const ErrorStatus: ({ size, title, description }: {
4
+ size: any;
5
+ title: any;
6
+ description: any;
7
+ }) => JSX.Element;
@@ -0,0 +1,89 @@
1
+ import React, { useState } from 'react';
2
+ import { SearchBox, Status, Tree, LoadingTip, Button } from 'tea-component';
3
+ import { getNode, dealUserData, dealOrgData } from './utils';
4
+ export const DimTreeContent = (props) => {
5
+ const { selectedIds, onSelect, onActive, activeIds, treeClassName, data: treeData, setTreeData, onCancel, onConfirm, needUser, onReset, request, errorInfo = { errorStatus: false, errorMessage: '' }, } = props;
6
+ //const commonParams = [callWedaApi, showToast, showError];
7
+ const [loading, setLoading] = useState(false);
8
+ const [errInfo, setErrInfo] = useState(errorInfo);
9
+ const loadDepartData = async (id) => {
10
+ const node = getNode(treeData, id, 'id');
11
+ if (node.children) {
12
+ //resolve();
13
+ return;
14
+ }
15
+ try {
16
+ // 部门
17
+ const { Orgs = [], Users = [] } = await request('LazyDescribeOrgs', {
18
+ OrgId: node.orgId,
19
+ DescribeCondition: {
20
+ NeedUser: !!needUser,
21
+ },
22
+ });
23
+ // 如果不存在数据
24
+ if (!(Orgs === null || Orgs === void 0 ? void 0 : Orgs.length) && !(Users === null || Users === void 0 ? void 0 : Users.length)) {
25
+ node.expandable = false;
26
+ }
27
+ else {
28
+ //@ts-ignore jsx
29
+ const children = dealOrgData(Orgs).concat(needUser ? dealUserData(Users) : []);
30
+ Object.assign(node, { children });
31
+ }
32
+ setTreeData([...treeData]);
33
+ // resolve();
34
+ return;
35
+ }
36
+ catch (error) {
37
+ //reject(error);
38
+ return;
39
+ }
40
+ };
41
+ // 根据关键词搜索
42
+ // const { run: runSearch, loading: searchLoading } = useRequest(searchByCondition, {
43
+ // manual: true,
44
+ // });
45
+ // 搜索
46
+ const search = async (key) => {
47
+ try {
48
+ setErrInfo({ errorStatus: false, errorMessage: null });
49
+ let resData = [];
50
+ if (key) {
51
+ setLoading(true);
52
+ const { Orgs = [], Users = [] } = await request('SearchByCondition', {
53
+ KeyWords: key,
54
+ SearchCondition: {
55
+ SearchType: 'SearchByOrg',
56
+ NeedUser: needUser,
57
+ },
58
+ }
59
+ // ...commonParams,
60
+ );
61
+ setLoading(false);
62
+ //@ts-ignore jsx
63
+ resData = dealOrgData(Orgs).concat(needUser ? dealUserData(Users) : []);
64
+ }
65
+ else {
66
+ resData = dealOrgData((await request('SearchByCondition', {})) || []);
67
+ }
68
+ setTreeData(resData);
69
+ }
70
+ catch (e) {
71
+ setLoading(false);
72
+ setErrInfo({ errorStatus: true, errorMessage: e });
73
+ }
74
+ };
75
+ return (React.createElement(React.Fragment, null,
76
+ React.createElement(SearchBox, { onSearch: search, onClear: () => onReset(), onChange: (val) => !val && onReset() }),
77
+ React.createElement("div", { className: "tree-search-loading" }, loading && React.createElement(LoadingTip, null)),
78
+ (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 })),
79
+ !(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 ? '成员' : '部门'}数据` })),
80
+ !!(treeData === null || treeData === void 0 ? void 0 : treeData.length) && !loading && !(errInfo === null || errInfo === void 0 ? void 0 : errInfo.errorStatus) && (React.createElement(React.Fragment, null,
81
+ React.createElement("div", { className: "tree-select-warp" },
82
+ React.createElement(Tree, { selectable: false, selectStrictly: true, activable: true, activeIds: activeIds, selectedIds: selectedIds, data: treeData, onLoad: loadDepartData, onActive: onActive, onSelect: onSelect, className: `tree-select ${treeClassName}` })),
83
+ React.createElement("div", { className: "dim-tree-footer" },
84
+ React.createElement(Button, { type: "weak", className: "din-btn din-btn--cancle", onClick: onCancel }, "\u53D6\u6D88"),
85
+ React.createElement(Button, { type: "primary", className: "din-btn din-btn--primary", onClick: onConfirm }, "\u786E\u5B9A"))))));
86
+ };
87
+ export const ErrorStatus = ({ size, title, description }) => {
88
+ return (React.createElement(Status, { className: "dim-tree-select--blank", icon: 'blank', size: size, title: title, description: description }));
89
+ };
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ import type { CommonFormPropsType } from '../../types';
3
+ import '../userOrgSelect.less';
4
+ export declare function DepartTreeSelectH5({ id, className, style, events, label, labelVisible, name, placeholder, defaultValueType, defaultValue, confirmValue, disabled, layout, requiredFlag, size, decorator, request, multiple, onChange, focus: autoFocus, getDepartByIdRequest, }: IDepartTreeSelec): JSX.Element;
5
+ export interface IDepartTreeSelec extends CommonFormPropsType {
6
+ defaultValue?: string;
7
+ confirmValue?: string;
8
+ placeholder?: string;
9
+ defaultValueType?: 'noneDepart' | 'confirmDepart';
10
+ maxLength?: number;
11
+ focus?: boolean;
12
+ size?: 's' | 'm' | 'l' | 'full';
13
+ clearable?: boolean;
14
+ multiple?: boolean;
15
+ relation?: object;
16
+ isMuti?: boolean;
17
+ onChange?: (v: any) => void;
18
+ request?: any;
19
+ getDepartByIdRequest?: (v: any) => any;
20
+ }
@@ -0,0 +1,259 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { emptyObject } from '../../../../utils/constant';
3
+ import { renderDecorator } from '../../renderDecorator';
4
+ import { IconFont } from 'tdesign-icons-react';
5
+ import classNames from '../../../../utils/classnames';
6
+ import { getDepartById, defaultRequest, } from '../../../../utils/getUserService';
7
+ import { dealOrgData } from '../utils';
8
+ import { Modal, Button, ConfigProvider, Radio, Status } from 'tea-component';
9
+ import isObjectEqual from '../../../../utils/isObjectEqual';
10
+ import '../userOrgSelect.less';
11
+ import { ErrorStatus } from '../comTool';
12
+ export function DepartTreeSelectH5({ id, className, style, events = emptyObject, label = '部门选择', labelVisible = true, name = 'formDepartTreeSelect', placeholder = '请选择部门', defaultValueType = 'noneDepart', defaultValue = '', confirmValue = '', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', decorator, request = defaultRequest, multiple = false, onChange = null, focus: autoFocus = false, getDepartByIdRequest = getDepartById, }) {
13
+ const cls = classNames({
14
+ 'weda-ui': true,
15
+ 'weda-select-user-dept': true,
16
+ [className]: className,
17
+ });
18
+ const subCls = classNames({
19
+ 'weui-cell': true,
20
+ 'weui-cell_active': true,
21
+ 'weui-cell_form': true,
22
+ 'weui-cell_disabled': disabled,
23
+ });
24
+ // 两次默认值不同, 需要刷新
25
+ const prevDefaultRef = React.useRef(null);
26
+ const prevConfirmRef = React.useRef(null);
27
+ const [value, setValue] = useState(null);
28
+ const [visible, setVisible] = React.useState(false);
29
+ const [isSearch, setIsSearch] = useState(false);
30
+ const [orgsTreeData, setOrgsTreeData] = useState([]);
31
+ const [originalOrgData, setOriginalOrgData] = useState([]);
32
+ const [count, setCount] = useState(1); //计数弹窗显示层级
33
+ const [selectItem, setSelectItem] = useState(null);
34
+ const [searchValue, setSearchValue] = useState('');
35
+ const [loading, setLoading] = useState({ id: null, status: false });
36
+ const [errorInfo, setErrorInfo] = useState({
37
+ errorStatus: false,
38
+ errorMessage: null,
39
+ });
40
+ const handleFocus = (value) => {
41
+ setIsSearch(value);
42
+ };
43
+ const cancleSearch = () => {
44
+ setErrorInfo({ errorStatus: false, errorMessage: null });
45
+ handleFocus(false);
46
+ setSearchValue('');
47
+ initOrgsData();
48
+ };
49
+ const changeSearchValue = async (event) => {
50
+ var _a;
51
+ try {
52
+ setErrorInfo({ errorStatus: false, errorMessage: null });
53
+ const sValue = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value;
54
+ setSearchValue(sValue);
55
+ if (sValue) {
56
+ const { Users = [], Orgs = [] } = await request('SearchByCondition', {
57
+ KeyWords: sValue.trim(),
58
+ SearchCondition: {
59
+ SearchType: 'SearchByOrg',
60
+ NeedUser: false,
61
+ },
62
+ });
63
+ setOrgsTreeData(dealOrgData(Orgs));
64
+ }
65
+ else {
66
+ setSearchValue('');
67
+ initOrgsData();
68
+ }
69
+ }
70
+ catch (e) {
71
+ setErrorInfo({ errorStatus: true, errorMessage: e });
72
+ }
73
+ };
74
+ const onInputChange = function (e) {
75
+ const text = typeof e === 'string' ? e : e.target.value;
76
+ const newValue = text;
77
+ setValue(newValue);
78
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
79
+ events.change({ value: newValue }, { originEvent: e });
80
+ };
81
+ const onFocus = function () {
82
+ setSearchValue('');
83
+ initOrgsData();
84
+ setVisible(true);
85
+ };
86
+ const onClose = () => {
87
+ setErrorInfo({ errorStatus: false, errorMessage: null });
88
+ setVisible(false);
89
+ initOrgsData();
90
+ };
91
+ const onConfirm = (selectItem) => {
92
+ var _a;
93
+ setErrorInfo({ errorStatus: false, errorMessage: null });
94
+ setValue(selectItem === null || selectItem === void 0 ? void 0 : selectItem.content);
95
+ onChange === null || onChange === void 0 ? void 0 : onChange(selectItem === null || selectItem === void 0 ? void 0 : selectItem.orgId);
96
+ (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: selectItem === null || selectItem === void 0 ? void 0 : selectItem.orgId, data: selectItem });
97
+ setVisible(false);
98
+ };
99
+ //获取组织结构
100
+ useEffect(() => {
101
+ initOrgsData();
102
+ if ((defaultValue &&
103
+ !isObjectEqual(prevDefaultRef.current !== defaultValue)) ||
104
+ (confirmValue && !isObjectEqual(prevConfirmRef.current !== confirmValue))) {
105
+ getdefaultUser();
106
+ prevDefaultRef.current = defaultValue;
107
+ prevConfirmRef.current = confirmValue;
108
+ }
109
+ }, [defaultValueType, confirmValue, defaultValue]);
110
+ const getdefaultUser = async () => {
111
+ var _a;
112
+ try {
113
+ if ((defaultValueType === 'confirmDepart' && confirmValue.length !== 0) ||
114
+ defaultValue.length !== 0) {
115
+ const orgId = confirmValue.length !== 0 ? confirmValue : defaultValue;
116
+ const defaultDepart = await getDepartById({
117
+ _id: orgId,
118
+ });
119
+ setValue(defaultDepart);
120
+ onChange === null || onChange === void 0 ? void 0 : onChange(orgId);
121
+ (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: orgId, data: { content: defaultDepart } });
122
+ }
123
+ }
124
+ catch (e) {
125
+ setErrorInfo({ errorStatus: true, errorMessage: e });
126
+ }
127
+ };
128
+ // 初始化数据
129
+ const initOrgsData = async () => {
130
+ try {
131
+ const resData = (await request('InitRootOrgs', {})) || [];
132
+ const data = dealOrgData(resData);
133
+ setOrgsTreeData(data);
134
+ setOriginalOrgData([{ index: count, treeData: data }]);
135
+ }
136
+ catch (e) {
137
+ setErrorInfo({ errorStatus: true, errorMessage: e });
138
+ }
139
+ };
140
+ //点击部门节点,获取子部门节点
141
+ const loadDepartData = async (node, count) => {
142
+ try {
143
+ setLoading({ id: node.orgId, status: true });
144
+ const { Orgs = [], Users = [] } = await request('LazyDescribeOrgs', {
145
+ OrgId: node.orgId,
146
+ DescribeCondition: {
147
+ NeedUser: true,
148
+ },
149
+ });
150
+ // 如果不存在数据
151
+ if (!(Orgs === null || Orgs === void 0 ? void 0 : Orgs.length)) {
152
+ orgsTreeData.forEach((item, index, orgsTreeData) => {
153
+ if (item.id == node.id) {
154
+ orgsTreeData[index].expandable = false;
155
+ }
156
+ });
157
+ setOrgsTreeData([...orgsTreeData]);
158
+ }
159
+ else {
160
+ const children = dealOrgData(Orgs);
161
+ setOrgsTreeData(children);
162
+ originalOrgData.push({ index: count + 1, treeData: children });
163
+ setCount(count + 1);
164
+ setOriginalOrgData(originalOrgData);
165
+ }
166
+ setLoading({ id: null, status: false });
167
+ }
168
+ catch (e) {
169
+ setErrorInfo({ errorStatus: true, errorMessage: e });
170
+ }
171
+ };
172
+ //判断当前页结构为第几层,如首次渲染则添加至orgsTreeData,二次进入刷新index数据
173
+ const retLevel = (count) => {
174
+ const storageOriTreeData = [];
175
+ if (count !== 1) {
176
+ originalOrgData.map((item) => {
177
+ if ((item === null || item === void 0 ? void 0 : item.index) < count) {
178
+ storageOriTreeData.push(item);
179
+ if ((item === null || item === void 0 ? void 0 : item.index) === count - 1) {
180
+ setCount(count - 1);
181
+ setOrgsTreeData((item === null || item === void 0 ? void 0 : item.treeData) || []);
182
+ }
183
+ }
184
+ else {
185
+ return;
186
+ }
187
+ });
188
+ setOriginalOrgData(storageOriTreeData);
189
+ }
190
+ else {
191
+ onClose();
192
+ }
193
+ };
194
+ return renderDecorator(React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
195
+ React.createElement("div", { className: subCls },
196
+ React.createElement("div", { className: "weui-cell__bd weui-flex" },
197
+ React.createElement("input", { className: "weui-input", placeholder: placeholder, value: value, disabled: disabled, name: name, autoFocus: autoFocus, onChange: onInputChange, onClick: onFocus, readOnly: true, role: "input" })),
198
+ React.createElement(Modal, { visible: visible, onClose: onClose, destroyOnClose: true, className: `weda-ui weda-select-user-dept__dialog` },
199
+ React.createElement(Modal.Body, { className: (selectItem === null || selectItem === void 0 ? void 0 : selectItem.userId) ? 'is-selected-value' : '' },
200
+ React.createElement("div", { className: "weda-select-user-dept__dialog-header", id: count.toString() },
201
+ React.createElement("div", { className: count == 1 ? '' : 'arrow-left', onClick: () => retLevel(count) }),
202
+ "\u9009\u62E9\u90E8\u95E8"),
203
+ React.createElement("div", { className: classNames({
204
+ 'weda-select-user-dept__dialog-search': true,
205
+ 'weda-select-user-dept__dialog-search-focus': isSearch,
206
+ }) },
207
+ React.createElement("div", { className: "weda-select-user-dept__dialog-search-box" },
208
+ React.createElement("input", { type: "text", onFocus: () => {
209
+ handleFocus(true);
210
+ }, value: searchValue, onClick: (e) => {
211
+ e.stopPropagation();
212
+ }, onChange: changeSearchValue, className: "weda-select-user-dept__dialog-search-input" }),
213
+ React.createElement("div", { className: classNames({
214
+ 'weda-select-user-dept__dialog-label': true,
215
+ 'weda-select-user-dept__dialog-label-value': searchValue,
216
+ }) },
217
+ React.createElement("span", { className: "search-icon" }),
218
+ React.createElement("span", { className: "search-placeholder" }, "\u641C\u7D22")),
219
+ searchValue && searchValue.length > 0 && (React.createElement("div", { className: "weda-select-user-dept__dialog-input-clear", onClick: changeSearchValue },
220
+ React.createElement("p", { className: "weda-select-user-dept__dialog-input-clear-close" })))),
221
+ React.createElement("span", { className: "weda-select-user-dept__dialog-search-cancel", onClick: cancleSearch }, "\u53D6\u6D88")),
222
+ (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.errorStatus) ? (React.createElement(ErrorStatus, { size: "l", title: "\u63A5\u53E3\u8C03\u7528\u5931\u8D25", description: (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.errorMessage) || null })) : orgsTreeData && orgsTreeData.length > 0 ? (React.createElement("div", { className: classNames('weda-select-user-dept__dialog-list') }, orgsTreeData.map((item, index) => (React.createElement("div", { className: "weda-select-user-dept__list-item", key: item === null || item === void 0 ? void 0 : item.id },
223
+ React.createElement("div", { className: "weda-select-user-dept__list-item-wrap" },
224
+ React.createElement(Radio.Group, { value: selectItem === null || selectItem === void 0 ? void 0 : selectItem.orgId, onChange: (value) => {
225
+ setSelectItem(item);
226
+ }, layout: "column" },
227
+ React.createElement(Radio, { name: item === null || item === void 0 ? void 0 : item.orgId },
228
+ React.createElement("div", { className: "weda-select-user-dept__item-detail" },
229
+ React.createElement("div", { className: "item-name" }, item === null || item === void 0 ? void 0 : item.content)))),
230
+ (item === null || item === void 0 ? void 0 : item.expandable) && loading.id !== item.orgId && (React.createElement("div", { className: "lcap-icon lcap-icon-chevronright", onClick: () => {
231
+ loadDepartData(item, count);
232
+ } })),
233
+ loading.id === item.orgId && (loading === null || loading === void 0 ? void 0 : loading.status) && (React.createElement("div", null,
234
+ React.createElement(IconFont, { name: "loading", className: `weda-grid-navigation__fonticon depart_loading` }))))))))) : (React.createElement(Status, { className: "dim-tree-select--blank", icon: 'blank', size: 's', title: `暂无部门数据` }))),
235
+ React.createElement(Modal.Footer, null,
236
+ React.createElement("div", null,
237
+ selectItem && (React.createElement("div", { className: "weda-select-user-dept__select-result" },
238
+ React.createElement("div", { className: "weda-select-user-dept__select-label" }, "\u5DF2\u9009\u62E9"),
239
+ React.createElement("div", { className: "weda-select-user-dept__result-list" },
240
+ React.createElement("div", { className: "weda-select-user-dept__result-item", onClick: () => {
241
+ setSelectItem(null);
242
+ setSearchValue(null);
243
+ } },
244
+ selectItem.content,
245
+ React.createElement("div", { className: "close" }))))),
246
+ React.createElement("div", { className: "weda-select-user-dept__btn-group" },
247
+ React.createElement(Button, { type: "weak", onClick: onClose }, "\u53D6\u6D88"),
248
+ React.createElement(Button, { type: "primary", onClick: () => onConfirm(selectItem) }, "\u786E\u5B9A"))))))))({
249
+ id,
250
+ className: cls,
251
+ style,
252
+ label: labelVisible ? label : null,
253
+ multiCell: false,
254
+ requiredFlag,
255
+ layout,
256
+ size,
257
+ decorator,
258
+ });
259
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IDepartTreeSelec } from './departTreeSelect.h5';
3
+ import '../userOrgSelect.less';
4
+ export declare function DepartTreeSelectPC({ id, className, style, events, label, labelVisible, name, defaultValue, confirmValue, placeholder, defaultValueType, disabled, layout, requiredFlag, size, multiple, onChange, decorator, relation, request, getDepartByIdRequest, }: IDepartTreeSelec): JSX.Element;