@cloudbase/weda-ui 3.2.1 → 3.3.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.
- package/dist/src/configs/components/chart/bar.json +9 -1
- package/dist/src/configs/components/chart/line.json +8 -0
- package/dist/src/configs/components/chart/pie.json +8 -0
- package/dist/src/web/actions/showModal/index.js +0 -1
- package/dist/src/web/components/calendar/index.js +39 -37
- package/dist/src/web/components/carousel/index.js +62 -62
- package/dist/src/web/components/chart/bar/index.js +6 -2
- package/dist/src/web/components/chart/common/Chart.d.ts +1 -0
- package/dist/src/web/components/chart/common/Chart.js +9 -1
- package/dist/src/web/components/chart/common/chart-custom-connector.js +1 -1
- package/dist/src/web/components/chart/common/core/eChartBase.js +1 -1
- package/dist/src/web/components/chart/common/data-transform.js +3 -1
- package/dist/src/web/components/chart/common/useChart.js +13 -2
- package/dist/src/web/components/chart/line/index.js +2 -2
- package/dist/src/web/components/chart/pie/index.js +2 -2
- package/dist/src/web/components/common/error-boundary.d.ts +5 -0
- package/dist/src/web/components/common/error-boundary.js +33 -0
- package/dist/src/web/components/common/use-loop-render-detect.d.ts +11 -0
- package/dist/src/web/components/common/use-loop-render-detect.js +124 -0
- package/dist/src/web/components/form/checkbox/index.js +29 -29
- package/dist/src/web/components/form/form/index.js +24 -15
- package/dist/src/web/components/form/input/index.js +11 -3
- package/dist/src/web/components/form/location/common/mapChoose.js +6 -5
- package/dist/src/web/components/form/location/common/mapView.js +9 -6
- package/dist/src/web/components/form/location/common/tmap.d.ts +3 -0
- package/dist/src/web/components/form/location/common/tmap.js +21 -0
- package/dist/src/web/components/form/location/common/useLocationInfo.js +3 -2
- package/dist/src/web/components/form/location/components/LocationH5/location.h5.js +6 -3
- package/dist/src/web/components/form/location/components/LocationPC/location.PC.js +5 -1
- package/dist/src/web/components/form/location/index.js +7 -0
- package/dist/src/web/components/form/radio/index.js +3 -3
- package/dist/src/web/components/form/select/allTimePicker/index.js +1 -0
- package/dist/src/web/components/form/select/h5.js +18 -4
- package/dist/src/web/components/form/select/index.js +15 -1
- package/dist/src/web/components/form/select/use-options.js +1 -1
- package/dist/src/web/components/form/uploader/uploader.h5.js +2 -2
- package/dist/src/web/components/form/uploader/uploader.pc.js +1 -1
- package/dist/src/web/components/form/uploaderFile/uploadFile.h5.js +9 -7
- package/dist/src/web/components/form/uploaderFile/uploadFile.pc.js +9 -6
- package/dist/src/web/components/form/userOrgSelect/comTool.js +3 -9
- package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +39 -34
- package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.d.ts +1 -1
- package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +35 -36
- package/dist/src/web/components/form/userOrgSelect/getUserService.d.ts +11 -0
- package/dist/src/web/components/form/userOrgSelect/getUserService.js +159 -0
- package/dist/src/web/components/form/userOrgSelect/userTreeSelect.h5.d.ts +3 -2
- package/dist/src/web/components/form/userOrgSelect/userTreeSelect.h5.js +37 -19
- package/dist/src/web/components/form/userOrgSelect/userTreeSelect.pc.d.ts +1 -1
- package/dist/src/web/components/form/userOrgSelect/userTreeSelect.pc.js +111 -129
- package/dist/src/web/components/form/userOrgSelect/utils.d.ts +3 -2
- package/dist/src/web/components/form/userOrgSelect/utils.js +24 -16
- package/dist/src/web/components/formdetail/index.js +14 -11
- package/dist/src/web/components/graphicCard/index.js +5 -6
- package/dist/src/web/components/image/index.js +1 -1
- package/dist/src/web/components/listView/index.js +1 -0
- package/dist/src/web/components/lottery/index.js +10 -16
- package/dist/src/web/components/navLayout/index.js +1 -1
- package/dist/src/web/components/navigationBar/horizontalMenu.js +1 -1
- package/dist/src/web/components/navigationBar/index.js +6 -6
- package/dist/src/web/components/richText/index.js +1 -2
- package/dist/src/web/components/richTextView/index.js +20 -18
- package/dist/src/web/components/scrollView/index.d.ts +1 -2
- package/dist/src/web/components/scrollView/index.js +7 -5
- package/dist/src/web/components/swiper/index.js +62 -62
- package/dist/src/web/components/tabs/index.js +6 -1
- package/dist/src/web/components/tabs/tabs.h5.js +2 -0
- package/dist/src/web/components/text/index.js +10 -8
- package/dist/src/web/components/uploaderFileView/index.js +1 -1
- package/dist/src/web/components/uploaderView/index.js +1 -1
- package/dist/src/web/components/wedaVideo/index.js +15 -3
- package/dist/src/web/utils/console.d.ts +3 -0
- package/dist/src/web/utils/console.js +26 -0
- package/dist/src/web/utils/platform.js +1 -1
- package/dist/src/web/utils/tcb.js +1 -1
- package/dist/src/web/utils/useSyncValue.js +1 -0
- package/dist/web/components/form/input/index.css +16 -0
- package/dist/web/components/form/userOrgSelect/userOrgSelect.css +4 -0
- package/package.json +20 -20
|
@@ -61,6 +61,7 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
|
|
|
61
61
|
(_c = events === null || events === void 0 ? void 0 : events.success) === null || _c === void 0 ? void 0 : _c.call(events, { value: pureFileIDList });
|
|
62
62
|
fileRef.current = fileIDList;
|
|
63
63
|
}
|
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
65
|
}, [fileIDList]);
|
|
65
66
|
// 外层组件类
|
|
66
67
|
const cls = classNames({
|
|
@@ -209,12 +210,9 @@ const TcbFileUpload = ({ file, disabled }) => {
|
|
|
209
210
|
const title = (file === null || file === void 0 ? void 0 : file.name) || '';
|
|
210
211
|
const uuid = file === null || file === void 0 ? void 0 : file._uuid;
|
|
211
212
|
return { size, title, uuid };
|
|
212
|
-
}, [file === null || file === void 0 ? void 0 : file._uuid]);
|
|
213
|
-
React.useEffect(() => {
|
|
214
|
-
handleUpload(file);
|
|
215
|
-
}, [file === null || file === void 0 ? void 0 : file._uuid]);
|
|
213
|
+
}, [file === null || file === void 0 ? void 0 : file._uuid, file === null || file === void 0 ? void 0 : file.name, file === null || file === void 0 ? void 0 : file.size]);
|
|
216
214
|
// 上传过程
|
|
217
|
-
const handleUpload = async (file) => {
|
|
215
|
+
const handleUpload = React.useCallback(async (file) => {
|
|
218
216
|
const tcb = await getCloudInstance();
|
|
219
217
|
try {
|
|
220
218
|
setStatus('0');
|
|
@@ -235,7 +233,12 @@ const TcbFileUpload = ({ file, disabled }) => {
|
|
|
235
233
|
setStatus('3');
|
|
236
234
|
events.error && events.error(e);
|
|
237
235
|
}
|
|
238
|
-
}
|
|
236
|
+
},
|
|
237
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
238
|
+
[size, uploadPath, uuid]);
|
|
239
|
+
React.useEffect(() => {
|
|
240
|
+
handleUpload(file);
|
|
241
|
+
}, [file, file._uuid, handleUpload]);
|
|
239
242
|
return (React.createElement("div", { className: `${CLASS_PREFIX}--item ${CLASS_PREFIX}--item-body` },
|
|
240
243
|
React.createElement("div", { className: `${CLASS_PREFIX}--item-title`, title: title }, cutFileTitle(title)),
|
|
241
244
|
React.createElement("div", { className: `${CLASS_PREFIX}--item-size` }, size),
|
|
@@ -10,7 +10,6 @@ export const DimTreeContent = (props) => {
|
|
|
10
10
|
const loadDepartData = async (id) => {
|
|
11
11
|
const node = getNode(treeData, id, 'id');
|
|
12
12
|
if (node.children) {
|
|
13
|
-
//resolve();
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
16
15
|
try {
|
|
@@ -27,15 +26,13 @@ export const DimTreeContent = (props) => {
|
|
|
27
26
|
}
|
|
28
27
|
else {
|
|
29
28
|
//@ts-ignore jsx
|
|
30
|
-
const children = dealOrgData(Orgs).concat(needUser ? dealUserData(Users) : []);
|
|
29
|
+
const children = dealOrgData(Orgs).concat(needUser ? dealUserData(Users, false, node.orgId) : []);
|
|
31
30
|
Object.assign(node, { children });
|
|
32
31
|
}
|
|
33
32
|
setTreeData([...treeData]);
|
|
34
|
-
// resolve();
|
|
35
33
|
return;
|
|
36
34
|
}
|
|
37
35
|
catch (error) {
|
|
38
|
-
//reject(error);
|
|
39
36
|
return;
|
|
40
37
|
}
|
|
41
38
|
};
|
|
@@ -58,11 +55,8 @@ export const DimTreeContent = (props) => {
|
|
|
58
55
|
setLoading(false);
|
|
59
56
|
//@ts-ignore jsx
|
|
60
57
|
resData = dealOrgData(Orgs).concat(needUser ? dealUserData(Users) : []);
|
|
58
|
+
setTreeData(resData);
|
|
61
59
|
}
|
|
62
|
-
else {
|
|
63
|
-
resData = dealOrgData((await request('SearchByCondition', {})) || []);
|
|
64
|
-
}
|
|
65
|
-
setTreeData(resData);
|
|
66
60
|
}
|
|
67
61
|
catch (e) {
|
|
68
62
|
setLoading(false);
|
|
@@ -76,7 +70,7 @@ export const DimTreeContent = (props) => {
|
|
|
76
70
|
!(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 ? '成员' : '部门'}数据` })),
|
|
77
71
|
!!(treeData === null || treeData === void 0 ? void 0 : treeData.length) && !loading && !(errInfo === null || errInfo === void 0 ? void 0 : errInfo.errorStatus) && (React.createElement(React.Fragment, null,
|
|
78
72
|
React.createElement("div", { className: "tree-select-warp" },
|
|
79
|
-
React.createElement(Tree, { selectable: false, selectStrictly: true, activable: true, activeIds: activeIds, selectedIds: selectedIds, data: treeData, onLoad: loadDepartData, onActive: onActive, onSelect: onSelect, fullExpandable: needUser ? true : false, className: `tree-select ${treeClassName}` })),
|
|
73
|
+
React.createElement(Tree, { selectable: false, selectStrictly: true, activable: true, activeIds: activeIds, selectedIds: selectedIds, data: treeData, onLoad: loadDepartData, onActive: onActive, onSelect: onSelect, height: 324, fullExpandable: needUser ? true : false, className: `tree-select ${treeClassName}` })),
|
|
80
74
|
React.createElement("div", { className: "dim-tree-footer" },
|
|
81
75
|
React.createElement(Button, { type: "weak", className: "din-btn din-btn--cancle", onClick: onCancel }, "\u53D6\u6D88"),
|
|
82
76
|
React.createElement(Button, { type: "primary", className: "din-btn din-btn--primary", onClick: onConfirm }, "\u786E\u5B9A"))))));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
2
2
|
import { emptyObject } from '../../../../utils/constant';
|
|
3
3
|
import { renderDecorator } from '../../renderDecorator';
|
|
4
4
|
import { IconFont } from 'tdesign-icons-react';
|
|
5
5
|
import classNames from '../../../../utils/classnames';
|
|
6
|
-
import { getDepartById, defaultRequest
|
|
6
|
+
import { getDepartById, defaultRequest } from '../getUserService';
|
|
7
7
|
import { dealOrgData } from '../utils';
|
|
8
8
|
import { Modal, Button, ConfigProvider, Radio, Status } from 'tea-component';
|
|
9
9
|
import isObjectEqual from '../../../../utils/isObjectEqual';
|
|
@@ -38,6 +38,19 @@ export function DepartTreeSelectH5({ id, className, style, events = emptyObject,
|
|
|
38
38
|
errorStatus: false,
|
|
39
39
|
errorMessage: null,
|
|
40
40
|
});
|
|
41
|
+
// 初始化数据
|
|
42
|
+
const initOrgsData = useCallback(async () => {
|
|
43
|
+
try {
|
|
44
|
+
setTitleText('选择部门');
|
|
45
|
+
const resData = (await request('InitRootOrgs', {})) || [];
|
|
46
|
+
const data = dealOrgData(resData);
|
|
47
|
+
setOrgsTreeData(data);
|
|
48
|
+
setOriginalOrgData([{ index: count, treeData: data, title: '选择部门' }]);
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
52
|
+
}
|
|
53
|
+
}, [count, request]);
|
|
41
54
|
const handleFocus = (value) => {
|
|
42
55
|
setIsSearch(value);
|
|
43
56
|
};
|
|
@@ -103,42 +116,34 @@ export function DepartTreeSelectH5({ id, className, style, events = emptyObject,
|
|
|
103
116
|
if ((defaultValue &&
|
|
104
117
|
!isObjectEqual(prevDefaultRef.current !== defaultValue)) ||
|
|
105
118
|
(confirmValue && !isObjectEqual(prevConfirmRef.current !== confirmValue))) {
|
|
119
|
+
const getdefaultUser = async () => {
|
|
120
|
+
var _a;
|
|
121
|
+
try {
|
|
122
|
+
if ((defaultValueType === 'confirmDepart' &&
|
|
123
|
+
confirmValue.length !== 0) ||
|
|
124
|
+
defaultValue.length !== 0) {
|
|
125
|
+
const orgId = confirmValue.length !== 0 ? confirmValue : defaultValue;
|
|
126
|
+
const defaultDepart = await getDepartById({
|
|
127
|
+
_id: orgId,
|
|
128
|
+
});
|
|
129
|
+
setValue(defaultDepart);
|
|
130
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(orgId);
|
|
131
|
+
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, {
|
|
132
|
+
value: orgId,
|
|
133
|
+
data: { content: defaultDepart },
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
139
|
+
}
|
|
140
|
+
};
|
|
106
141
|
getdefaultUser();
|
|
107
142
|
prevDefaultRef.current = defaultValue;
|
|
108
143
|
prevConfirmRef.current = confirmValue;
|
|
109
144
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var _a;
|
|
113
|
-
try {
|
|
114
|
-
if ((defaultValueType === 'confirmDepart' && confirmValue.length !== 0) ||
|
|
115
|
-
defaultValue.length !== 0) {
|
|
116
|
-
const orgId = confirmValue.length !== 0 ? confirmValue : defaultValue;
|
|
117
|
-
const defaultDepart = await getDepartById({
|
|
118
|
-
_id: orgId,
|
|
119
|
-
});
|
|
120
|
-
setValue(defaultDepart);
|
|
121
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(orgId);
|
|
122
|
-
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: orgId, data: { content: defaultDepart } });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
// 初始化数据
|
|
130
|
-
const initOrgsData = async () => {
|
|
131
|
-
try {
|
|
132
|
-
setTitleText('选择部门');
|
|
133
|
-
const resData = (await request('InitRootOrgs', {})) || [];
|
|
134
|
-
const data = dealOrgData(resData);
|
|
135
|
-
setOrgsTreeData(data);
|
|
136
|
-
setOriginalOrgData([{ index: count, treeData: data, title: '选择部门' }]);
|
|
137
|
-
}
|
|
138
|
-
catch (e) {
|
|
139
|
-
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
140
|
-
}
|
|
141
|
-
};
|
|
145
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
146
|
+
}, [defaultValueType, confirmValue, defaultValue, initOrgsData]);
|
|
142
147
|
//点击部门节点,获取子部门节点
|
|
143
148
|
const loadDepartData = async (node, count) => {
|
|
144
149
|
try {
|
package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IDepartTreeSelec } from './departTreeSelect.h5';
|
|
3
3
|
import '../userOrgSelect.css';
|
|
4
|
-
export declare function DepartTreeSelectPC({ id, className, style, events, label, labelVisible,
|
|
4
|
+
export declare function DepartTreeSelectPC({ id, className, style, events, label, labelVisible, defaultValue, confirmValue, placeholder, defaultValueType, disabled, layout, requiredFlag, size, multiple, onChange, decorator, request, }: IDepartTreeSelec): JSX.Element;
|
|
@@ -4,13 +4,11 @@ import { renderDecorator } from '../../renderDecorator';
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { Dropdown, ConfigProvider, Text } from 'tea-component';
|
|
6
6
|
import { getNode, getRelationData, dealOrgData } from '../utils';
|
|
7
|
-
import { getDepartById, defaultRequest
|
|
7
|
+
import { getDepartById, defaultRequest } from '../getUserService';
|
|
8
8
|
import '../userOrgSelect.css';
|
|
9
9
|
import { DimTreeContent } from '../comTool';
|
|
10
10
|
import isObjectEqual from '../../../../utils/isObjectEqual';
|
|
11
|
-
export function DepartTreeSelectPC({ id, className, style, events = emptyObject, label = '人员选择', labelVisible = true, placeholder,
|
|
12
|
-
// name = 'formUserTreeSelect',
|
|
13
|
-
defaultValue = '', confirmValue = '', defaultValueType = 'noneDepart', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', decorator, multiple = false, onChange = null, request = defaultRequest, }) {
|
|
11
|
+
export function DepartTreeSelectPC({ id, className, style, events = emptyObject, label = '人员选择', labelVisible = true, defaultValue = '', confirmValue = '', placeholder = '请选择部门', defaultValueType = 'noneDepart', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', multiple = false, onChange = null, decorator, request = defaultRequest, }) {
|
|
14
12
|
// 两次默认值不同, 需要刷新
|
|
15
13
|
const prevDefaultRef = React.useRef(null);
|
|
16
14
|
const prevConfirmRef = React.useRef(null);
|
|
@@ -32,6 +30,36 @@ defaultValue = '', confirmValue = '', defaultValueType = 'noneDepart', disabled
|
|
|
32
30
|
errorMessage: null,
|
|
33
31
|
});
|
|
34
32
|
useEffect(() => {
|
|
33
|
+
// 初始化数据
|
|
34
|
+
const initOrgsData = async () => {
|
|
35
|
+
try {
|
|
36
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
37
|
+
const resData = (await request('InitRootOrgs', {})) || [];
|
|
38
|
+
const data = dealOrgData(resData);
|
|
39
|
+
setTreeData(data);
|
|
40
|
+
setOriginalTreeData([...data]);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const getdefaultUser = async () => {
|
|
47
|
+
var _a;
|
|
48
|
+
try {
|
|
49
|
+
if ((defaultValueType === 'confirmDepart' && confirmValue.length !== 0) ||
|
|
50
|
+
defaultValue.length !== 0) {
|
|
51
|
+
const orgId = confirmValue.length !== 0 ? confirmValue : defaultValue;
|
|
52
|
+
const defaultUser = await getDepartById({
|
|
53
|
+
_id: orgId,
|
|
54
|
+
});
|
|
55
|
+
setCurSelectItem({ orgId: orgId, content: defaultUser });
|
|
56
|
+
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: orgId, data: { content: defaultUser } });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
61
|
+
}
|
|
62
|
+
};
|
|
35
63
|
initOrgsData();
|
|
36
64
|
if ((defaultValue &&
|
|
37
65
|
!isObjectEqual(prevDefaultRef.current !== defaultValue)) ||
|
|
@@ -40,7 +68,8 @@ defaultValue = '', confirmValue = '', defaultValueType = 'noneDepart', disabled
|
|
|
40
68
|
prevDefaultRef.current = defaultValue;
|
|
41
69
|
prevConfirmRef.current = confirmValue;
|
|
42
70
|
}
|
|
43
|
-
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
}, [defaultValueType, confirmValue, defaultValue, request]);
|
|
44
73
|
useEffect(() => {
|
|
45
74
|
if (open) {
|
|
46
75
|
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
@@ -49,37 +78,7 @@ defaultValue = '', confirmValue = '', defaultValueType = 'noneDepart', disabled
|
|
|
49
78
|
setActiveIds(node ? [node.id] : []);
|
|
50
79
|
setSelectIds(node ? [node.id] : []);
|
|
51
80
|
}
|
|
52
|
-
}, [open, treeData]);
|
|
53
|
-
// 初始化数据
|
|
54
|
-
const initOrgsData = async () => {
|
|
55
|
-
try {
|
|
56
|
-
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
57
|
-
const resData = (await request('InitRootOrgs', {})) || [];
|
|
58
|
-
const data = dealOrgData(resData);
|
|
59
|
-
setTreeData(data);
|
|
60
|
-
setOriginalTreeData([...data]);
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const getdefaultUser = async () => {
|
|
67
|
-
var _a;
|
|
68
|
-
try {
|
|
69
|
-
if ((defaultValueType === 'confirmDepart' && confirmValue.length !== 0) ||
|
|
70
|
-
defaultValue.length !== 0) {
|
|
71
|
-
const orgId = confirmValue.length !== 0 ? confirmValue : defaultValue;
|
|
72
|
-
const defaultUser = await getDepartById({
|
|
73
|
-
_id: orgId,
|
|
74
|
-
});
|
|
75
|
-
setCurSelectItem({ orgId: orgId, content: defaultUser });
|
|
76
|
-
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: orgId, data: { content: defaultUser } });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
81
|
-
}
|
|
82
|
-
};
|
|
81
|
+
}, [curSelectItem === null || curSelectItem === void 0 ? void 0 : curSelectItem.orgId, open, treeData]);
|
|
83
82
|
const reset = (close, value = '') => {
|
|
84
83
|
var _a;
|
|
85
84
|
setSelectIds([]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 根据_id查询部门数据
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
export function getDepartById(data: any): Promise<any>;
|
|
6
|
+
export function initRootOrgs(data: any): Promise<any>;
|
|
7
|
+
export function getDeparts(data: any): Promise<any>;
|
|
8
|
+
export function searchByCondition(data: any): Promise<any>;
|
|
9
|
+
export function defaultRequest(action: any, params: any, type?: any): Promise<any>;
|
|
10
|
+
export function getDataSourceByName(dbName: any): Promise<any>;
|
|
11
|
+
export function getUserInfo(): Promise<any>;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { callWedaApi, callDataSource } from '../../../utils/tcb';
|
|
2
|
+
/**
|
|
3
|
+
* 默认请求统一处理方法
|
|
4
|
+
* @param {*} action
|
|
5
|
+
* @param {*} params
|
|
6
|
+
* @param {*} type
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export const defaultRequest = async (action, params, type = 'callWedaApi') => {
|
|
10
|
+
try {
|
|
11
|
+
if (type === 'callWedaApi') {
|
|
12
|
+
const res = await callWedaApi({
|
|
13
|
+
action: action,
|
|
14
|
+
data: params,
|
|
15
|
+
});
|
|
16
|
+
return res;
|
|
17
|
+
}
|
|
18
|
+
else if (type === 'callDataSource' && action === 'getUserById') {
|
|
19
|
+
const datasource = await getDataSourceByName('sys_user');
|
|
20
|
+
const userInfoList = [];
|
|
21
|
+
let pageNo = 1;
|
|
22
|
+
const setInitUserDataHandle = async () => {
|
|
23
|
+
const res = await callWedaApi({
|
|
24
|
+
action: 'DescribeWedaUsersRuntime',
|
|
25
|
+
data: {
|
|
26
|
+
pageNo: pageNo,
|
|
27
|
+
pageSize: 200,
|
|
28
|
+
UserIds: (params === null || params === void 0 ? void 0 : params.idList) || [],
|
|
29
|
+
UserType: 'internalUser',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const resData = ((res === null || res === void 0 ? void 0 : res.UserList) || []).map((item) => {
|
|
33
|
+
const userInfo = JSON.parse(item === null || item === void 0 ? void 0 : item.UserExtend) || {};
|
|
34
|
+
return {
|
|
35
|
+
value: item === null || item === void 0 ? void 0 : item.UserId,
|
|
36
|
+
data: {
|
|
37
|
+
content: (datasource === null || datasource === void 0 ? void 0 : datasource.schema['x-primary-column']) === 'name'
|
|
38
|
+
? item === null || item === void 0 ? void 0 : item.Name
|
|
39
|
+
: userInfo[datasource === null || datasource === void 0 ? void 0 : datasource.schema['x-primary-column']] ||
|
|
40
|
+
(item === null || item === void 0 ? void 0 : item.UserId),
|
|
41
|
+
},
|
|
42
|
+
orgs: item === null || item === void 0 ? void 0 : item.Orgs,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
userInfoList.push.apply(userInfoList, resData);
|
|
46
|
+
if ((res === null || res === void 0 ? void 0 : res.Total) > pageNo * 100) {
|
|
47
|
+
pageNo += 1;
|
|
48
|
+
await setInitUserDataHandle();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
(params === null || params === void 0 ? void 0 : params.idList.length) > 0 && (await setInitUserDataHandle());
|
|
52
|
+
return userInfoList;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error(action + '错误', error);
|
|
57
|
+
throw errorHandle(error, action);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* 获取用户表schema
|
|
62
|
+
*/
|
|
63
|
+
export const getDataSourceByName = async (dbName) => {
|
|
64
|
+
// dbName 为空时
|
|
65
|
+
if (!dbName)
|
|
66
|
+
return;
|
|
67
|
+
const datasource = await window.app.cloud.getDataSourceProfile(dbName);
|
|
68
|
+
return datasource;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* 根据_id查询部门数据
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
export async function getDepartById(data) {
|
|
75
|
+
try {
|
|
76
|
+
const datasource = await getDataSourceByName('sys_department');
|
|
77
|
+
const res = await callDataSource({
|
|
78
|
+
dataSourceName: 'sys_department',
|
|
79
|
+
methodName: 'wedaGetItem',
|
|
80
|
+
params: data,
|
|
81
|
+
});
|
|
82
|
+
return res[datasource === null || datasource === void 0 ? void 0 : datasource.schema['x-primary-column']] || (res === null || res === void 0 ? void 0 : res._id);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error('错误', error);
|
|
86
|
+
throw errorHandle(error, 'getDepartById');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 获取当前登录人信息
|
|
91
|
+
* */
|
|
92
|
+
export const getUserInfo = () => {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const userInfo = (_b = (_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.auth) === null || _b === void 0 ? void 0 : _b.getUserInfo();
|
|
95
|
+
return Promise.resolve(userInfo);
|
|
96
|
+
};
|
|
97
|
+
/*
|
|
98
|
+
* 初始化加载部门数据
|
|
99
|
+
* @author servernnyu
|
|
100
|
+
*/
|
|
101
|
+
export async function initRootOrgs(data) {
|
|
102
|
+
try {
|
|
103
|
+
const res = await callWedaApi({
|
|
104
|
+
action: 'InitRootOrgs',
|
|
105
|
+
data,
|
|
106
|
+
});
|
|
107
|
+
return res;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.error('错误', error);
|
|
111
|
+
throw errorHandle(error, 'InitRootOrgs');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/*
|
|
115
|
+
* 懒加载部门数据 LazyDescribeOrgs
|
|
116
|
+
* OrgId:组织架构Id,为根节点就不传了,我就会去查根节点
|
|
117
|
+
* DescribeCondition:查询条件,现在可以传{"Key":"NeedUser","Value": "true"}
|
|
118
|
+
*/
|
|
119
|
+
export async function getDeparts(data) {
|
|
120
|
+
try {
|
|
121
|
+
const res = await callWedaApi({
|
|
122
|
+
action: 'LazyDescribeOrgs',
|
|
123
|
+
data,
|
|
124
|
+
});
|
|
125
|
+
return res;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.error('错误', error);
|
|
129
|
+
throw errorHandle(error, 'LazyDescribeOrgs');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/*
|
|
133
|
+
SearchByCondition接口
|
|
134
|
+
入参:
|
|
135
|
+
KeyWords:关键词
|
|
136
|
+
SearchCondition:搜索条件,当前要传俩,一个是是否关联用户同上,一个是SeachType,SearchByRole和SearchByOrg, NeedUser
|
|
137
|
+
*/
|
|
138
|
+
export async function searchByCondition(data) {
|
|
139
|
+
try {
|
|
140
|
+
const res = await callWedaApi({
|
|
141
|
+
action: 'SearchByCondition',
|
|
142
|
+
data,
|
|
143
|
+
});
|
|
144
|
+
return res;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error('错误', error);
|
|
148
|
+
throw errorHandle(error, 'SearchByCondition');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const errorHandle = (error, action) => {
|
|
152
|
+
var _a;
|
|
153
|
+
if (error === null || error === void 0 ? void 0 : error.result) {
|
|
154
|
+
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})`;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
return `${action}(${error === null || error === void 0 ? void 0 : error.message})`;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CommonFormPropsType } from '../types';
|
|
3
3
|
import './userOrgSelect.css';
|
|
4
|
-
export declare function UserTreeSelectH5({ id, className, style, events, label, labelVisible, name, placeholder, defaultValueType, defaultValue, confirmValue, disabled, layout, requiredFlag, multiple, //是否多选
|
|
5
|
-
focus: autoFocus, onChange,
|
|
4
|
+
export declare function UserTreeSelectH5({ id, className, style, events, label, labelVisible, name, placeholder, defaultValueType, defaultValue, confirmValue, disabled, layout, requiredFlag, decorator, multiple, //是否多选
|
|
5
|
+
focus: autoFocus, onChange, modelOpen, request, }: IUserTreeSelec): JSX.Element;
|
|
6
6
|
export interface IUserTreeSelec extends CommonFormPropsType {
|
|
7
7
|
defaultValue?: Readonly<string | string[]>;
|
|
8
8
|
confirmValue?: string;
|
|
@@ -22,5 +22,6 @@ export interface IUserTreeSelec extends CommonFormPropsType {
|
|
|
22
22
|
dropDownStyle?: React.CSSProperties;
|
|
23
23
|
onChange?: (v: any) => void;
|
|
24
24
|
request?: any;
|
|
25
|
+
modelOpen?: boolean;
|
|
25
26
|
getUserByIdRequest?: (v: any) => any;
|
|
26
27
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
2
2
|
import { emptyObject, emptyArray } from '../../../utils/constant';
|
|
3
3
|
import { renderDecorator } from '../renderDecorator';
|
|
4
4
|
import { IconFont } from 'tdesign-icons-react';
|
|
5
5
|
import classNames from '../../../utils/classnames';
|
|
6
|
-
import { getUserInfo, defaultRequest } from '
|
|
7
|
-
import {
|
|
6
|
+
import { getUserInfo, defaultRequest } from './getUserService';
|
|
7
|
+
import { dealOrgData, dealUserData } from './utils';
|
|
8
8
|
import { Modal, Button, ConfigProvider, Radio, Status } from 'tea-component';
|
|
9
9
|
import { isInIde, filterStrList } from '../../../utils/platform';
|
|
10
10
|
import './userOrgSelect.css';
|
|
11
11
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
12
12
|
import destr from 'destr';
|
|
13
13
|
import { ErrorStatus, ModalSearch } from './comTool';
|
|
14
|
-
export function UserTreeSelectH5({ id, className, style, events = emptyObject, label = '成员选择', labelVisible = true, name = 'formUserTreeSelect', placeholder = '请选择成员', defaultValueType = 'noneUser', defaultValue = emptyArray, confirmValue = '', disabled = false, layout = 'horizontal', requiredFlag = false, multiple = false, //是否多选
|
|
15
|
-
focus: autoFocus = false, onChange = null,
|
|
14
|
+
export function UserTreeSelectH5({ id, className, style, events = emptyObject, label = '成员选择', labelVisible = true, name = 'formUserTreeSelect', placeholder = '请选择成员', defaultValueType = 'noneUser', defaultValue = emptyArray, confirmValue = '', disabled = false, layout = 'horizontal', requiredFlag = false, decorator, multiple = false, //是否多选
|
|
15
|
+
focus: autoFocus = false, onChange = null, modelOpen = false, request = defaultRequest, }) {
|
|
16
16
|
var _a;
|
|
17
17
|
const cls = classNames({
|
|
18
18
|
'weda-ui': true,
|
|
@@ -84,15 +84,21 @@ focus: autoFocus = false, onChange = null, decorator, request = defaultRequest,
|
|
|
84
84
|
setVisible(false);
|
|
85
85
|
};
|
|
86
86
|
const onConfirm = (selectItem = []) => {
|
|
87
|
-
var _a, _b, _c
|
|
87
|
+
var _a, _b, _c;
|
|
88
88
|
const contentList = selectItem.map((e) => e === null || e === void 0 ? void 0 : e.content);
|
|
89
89
|
setValue([...contentList]);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
const idList = selectItem.map((e) => e === null || e === void 0 ? void 0 : e.userId);
|
|
91
|
+
prevDefaultRef.current = [...idList];
|
|
92
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? idList : (_a = selectItem[0]) === null || _a === void 0 ? void 0 : _a.userId);
|
|
93
|
+
(_b = events === null || events === void 0 ? void 0 : events.change) === null || _b === void 0 ? void 0 : _b.call(events, multiple
|
|
94
|
+
? { value: idList, data: selectItem }
|
|
95
|
+
: { value: (_c = selectItem[0]) === null || _c === void 0 ? void 0 : _c.userId, data: selectItem });
|
|
93
96
|
initOrgsData();
|
|
94
97
|
setVisible(false);
|
|
95
98
|
};
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
setVisible(modelOpen);
|
|
101
|
+
}, [modelOpen]);
|
|
96
102
|
useEffect(() => {
|
|
97
103
|
initOrgsData();
|
|
98
104
|
if ((defaultValue &&
|
|
@@ -104,8 +110,9 @@ focus: autoFocus = false, onChange = null, decorator, request = defaultRequest,
|
|
|
104
110
|
prevDefaultRef.current = defaultValue;
|
|
105
111
|
prevConfirmRef.current = confirmValue;
|
|
106
112
|
}
|
|
113
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
114
|
}, [defaultValueType, confirmValue, defaultValue]);
|
|
108
|
-
const getDefaultUser = async () => {
|
|
115
|
+
const getDefaultUser = useCallback(async () => {
|
|
109
116
|
var _a;
|
|
110
117
|
try {
|
|
111
118
|
//默认显示登录用户时
|
|
@@ -130,18 +137,29 @@ focus: autoFocus = false, onChange = null, decorator, request = defaultRequest,
|
|
|
130
137
|
const userSelectList = await request('getUserById', {
|
|
131
138
|
idList: userIdList || [],
|
|
132
139
|
}, 'callDataSource');
|
|
133
|
-
setValue(
|
|
140
|
+
setValue(userSelectList.map((list) => { var _a; return (_a = list === null || list === void 0 ? void 0 : list.data) === null || _a === void 0 ? void 0 : _a.content; }));
|
|
141
|
+
setSelectItem(userSelectList.map((list) => {
|
|
142
|
+
var _a;
|
|
143
|
+
return { userId: list === null || list === void 0 ? void 0 : list.value, content: (_a = list === null || list === void 0 ? void 0 : list.data) === null || _a === void 0 ? void 0 : _a.content };
|
|
144
|
+
}));
|
|
134
145
|
}
|
|
135
146
|
}
|
|
136
147
|
catch (e) {
|
|
137
148
|
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
138
149
|
}
|
|
139
|
-
};
|
|
150
|
+
}, [confirmValue, defaultValue, defaultValueType, request, events, onChange]);
|
|
140
151
|
// 初始化数据
|
|
141
|
-
const initOrgsData = async () => {
|
|
152
|
+
const initOrgsData = useCallback(async () => {
|
|
142
153
|
try {
|
|
143
154
|
const resData = (await request('InitRootOrgs', {})) || [];
|
|
144
|
-
const
|
|
155
|
+
const pageNo = 1;
|
|
156
|
+
const noOrgUserData = await request('DescribeWedaUsersRuntime', {
|
|
157
|
+
pageNo: pageNo,
|
|
158
|
+
pageSize: 200,
|
|
159
|
+
IsNoRelatedOrgFlag: true,
|
|
160
|
+
UserType: 'internalUser',
|
|
161
|
+
});
|
|
162
|
+
const data = dealOrgData(resData).concat(dealUserData(noOrgUserData === null || noOrgUserData === void 0 ? void 0 : noOrgUserData.UserList));
|
|
145
163
|
setTitleText('选择成员');
|
|
146
164
|
setOrgsTreeData(destr(data));
|
|
147
165
|
setOriginalOrgData([{ index: count, treeData: data, title: '选择成员' }]);
|
|
@@ -149,7 +167,7 @@ focus: autoFocus = false, onChange = null, decorator, request = defaultRequest,
|
|
|
149
167
|
catch (e) {
|
|
150
168
|
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
151
169
|
}
|
|
152
|
-
};
|
|
170
|
+
}, [request, count]);
|
|
153
171
|
//点击部门节点,获取子部门节点
|
|
154
172
|
const loadDepartData = async (node, count) => {
|
|
155
173
|
setTitleText(node === null || node === void 0 ? void 0 : node.content);
|
|
@@ -215,9 +233,9 @@ focus: autoFocus = false, onChange = null, decorator, request = defaultRequest,
|
|
|
215
233
|
} },
|
|
216
234
|
React.createElement("div", { className: "weda-select-user-dept__list-item-wrap" },
|
|
217
235
|
(item === null || item === void 0 ? void 0 : item.isUser) && (React.createElement(Radio.Group, { value: (_a = selectItem.filter((e) => (e === null || e === void 0 ? void 0 : e.userId) === (item === null || item === void 0 ? void 0 : item.userId))[0]) === null || _a === void 0 ? void 0 : _a.userId, onChange: (value) => {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
236
|
+
const ids = selectItem.map((item) => item === null || item === void 0 ? void 0 : item.userId);
|
|
237
|
+
// 多选情况,取消选中某元素时
|
|
238
|
+
if (ids.indexOf(value) !== -1) {
|
|
221
239
|
setSelectItem(selectItem.filter((e) => e.userId !== value));
|
|
222
240
|
}
|
|
223
241
|
else {
|
|
@@ -238,7 +256,7 @@ focus: autoFocus = false, onChange = null, decorator, request = defaultRequest,
|
|
|
238
256
|
React.createElement("div", null,
|
|
239
257
|
selectItem.length > 0 && (React.createElement("div", { className: "weda-select-user-dept__select-result" },
|
|
240
258
|
React.createElement("div", { className: "weda-select-user-dept__select-label" }, "\u5DF2\u9009\u62E9"),
|
|
241
|
-
React.createElement("div", { className: "weda-select-user-dept__result-list" }, selectItem.map((d) => (React.createElement("div", { key: d === null || d === void 0 ? void 0 : d.userId, className: "weda-select-user-dept__result-item", onClick: () => {
|
|
259
|
+
React.createElement("div", { className: "weda-select-user-dept__result-list" }, selectItem.map((d) => (React.createElement("div", { key: (d === null || d === void 0 ? void 0 : d.userId) || (d === null || d === void 0 ? void 0 : d.value), className: "weda-select-user-dept__result-item", onClick: () => {
|
|
242
260
|
setSelectItem(selectItem.filter((e) => (e === null || e === void 0 ? void 0 : e.userId) !== (d === null || d === void 0 ? void 0 : d.userId)));
|
|
243
261
|
} }, d === null || d === void 0 ? void 0 :
|
|
244
262
|
d.content,
|
|
@@ -6,4 +6,4 @@ style, events, label, labelVisible, //标题显隐
|
|
|
6
6
|
defaultValue, //默认值,支持数组
|
|
7
7
|
confirmValue, placeholder, defaultValueType, disabled, layout, modelType, requiredFlag, size, multiple, //多选
|
|
8
8
|
onChange, request, //接口请求
|
|
9
|
-
decorator, matchButtonWidth, dropDownStyle, }: IUserTreeSelec): JSX.Element;
|
|
9
|
+
decorator, matchButtonWidth, modelOpen, dropDownStyle, }: IUserTreeSelec): JSX.Element;
|