@cloudbase/weda-ui 3.4.11 → 3.4.12
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/configs/components/common/form-input-required.js +3 -3
- package/dist/configs/components/customer-service.js +3 -0
- package/dist/configs/components/dataView.js +20 -10
- package/dist/configs/components/form-checkbox.js +15 -2
- package/dist/configs/components/form-email.js +17 -2
- package/dist/configs/components/form-input.js +17 -2
- package/dist/configs/components/form-phone.js +17 -2
- package/dist/configs/components/form-radio.js +15 -2
- package/dist/configs/components/form-select-multiple.js +362 -0
- package/dist/configs/components/form-switch.js +15 -2
- package/dist/configs/components/form-text-area.js +15 -2
- package/dist/configs/components/form-url.js +17 -2
- package/dist/configs/components/form-user-tree-select.js +13 -0
- package/dist/configs/components/listView.js +32 -49
- package/dist/configs/components/table.json +1 -54
- package/dist/configs/components/wd-bubble.js +46 -8
- package/dist/configs/components/wd-button.js +3 -0
- package/dist/configs/components/wd-checkbox.js +464 -0
- package/dist/configs/components/wd-form.js +66 -10
- package/dist/configs/components/wd-input-email.js +37 -0
- package/dist/configs/components/wd-input-phone.js +43 -0
- package/dist/configs/components/wd-input-url.js +37 -0
- package/dist/configs/components/wd-input.js +94 -0
- package/dist/configs/components/wd-official-account.js +87 -0
- package/dist/configs/components/wd-radio.js +443 -0
- package/dist/configs/components/wd-switch.js +315 -0
- package/dist/configs/components/wd-table.js +8 -56
- package/dist/configs/components/wd-textarea.js +82 -0
- package/dist/configs/components/wd-tree.js +443 -0
- package/dist/configs/components/web-view.js +3 -0
- package/dist/configs/index.js +24 -1
- package/dist/configs/type-utils/type-form.js +681 -0
- package/dist/docs/common/components/json-schema-view.js +1 -1
- package/dist/docs/common/components/methods-view.js +1 -1
- package/dist/docs/common/components/properties-view.js +3 -1
- package/dist/docs/common/format.js +7 -7
- package/dist/docs/common/tableView.js +3 -1
- package/dist/enum/index.js +196 -0
- package/dist/style/index.scss +1 -1
- package/dist/web/actions/showMessage/index.js +4 -1
- package/dist/web/components/carousel/index.js +1 -1
- package/dist/web/components/customer-service/customer-service.js +19 -2
- package/dist/web/components/dataView/index.js +16 -3
- package/dist/web/components/flow/common/hooks/useCommonFlowData/flow-get.js +5 -1
- package/dist/web/components/flow/common/request.js +5 -5
- package/dist/web/components/flow/modules/operations/controls-items/flow-task-info-modal.js +90 -0
- package/dist/web/components/form/formcell/index.css +13 -1
- package/dist/web/components/form/formcell/index.js +1 -1
- package/dist/web/components/form/location/components/LocationH5/location.h5.js +1 -1
- package/dist/web/components/form/select/dropdown-select/index.js +7 -1
- package/dist/web/components/form/select/h5.js +18 -8
- package/dist/web/components/form/select/index.js +9 -9
- package/dist/web/components/form/select/region/index.js +1 -1
- package/dist/web/components/form/selectMultiple/dropdown-select/h5.js +111 -0
- package/dist/web/components/form/selectMultiple/dropdown-select/index.css +270 -0
- package/dist/web/components/form/selectMultiple/dropdown-select/index.js +206 -0
- package/dist/web/components/form/selectMultiple/dropdown-select/pc.js +115 -0
- package/dist/web/components/form/selectMultiple/dropdown-select/ui.js +113 -0
- package/dist/web/components/form/selectMultiple/h5.js +40 -0
- package/dist/web/components/form/selectMultiple/index.js +94 -0
- package/dist/web/components/form/selectMultiple/request.js +76 -0
- package/dist/web/components/form/selectMultiple/status/allEmpty.js +5 -0
- package/dist/web/components/form/selectMultiple/status/empty.js +19 -0
- package/dist/web/components/form/selectMultiple/status/index.css +63 -0
- package/dist/web/components/form/selectMultiple/status/index.js +7 -0
- package/dist/web/components/form/selectMultiple/status/loading.js +19 -0
- package/dist/web/components/form/selectMultiple/status/propsType.js +1 -0
- package/dist/web/components/form/selectMultiple/status/retry.js +19 -0
- package/dist/web/components/form/tips/index.css +9 -3
- package/dist/web/components/form/uploader/index.css +10 -0
- package/dist/web/components/form/uploader/uploader.h5.js +60 -62
- package/dist/web/components/form/uploader/uploader.pc.js +48 -41
- package/dist/web/components/form/uploaderFile/uploadFile.h5.js +8 -33
- package/dist/web/components/form/uploaderFile/uploadFile.pc.js +8 -37
- package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +76 -50
- package/dist/web/components/form/userOrgSelect/common/utils.js +24 -8
- package/dist/web/components/form/userOrgSelect/component/depart-select/depart-select-pc.js +3 -8
- package/dist/web/components/form/userOrgSelect/component/depart-select/index.js +14 -18
- package/dist/web/components/form/userOrgSelect/component/depart-select/org-modal-pc.js +20 -14
- package/dist/web/components/form/userOrgSelect/component/modal-select-h5.js +1 -1
- package/dist/web/components/form/userOrgSelect/component/org-tree.js +21 -9
- package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +57 -10
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-model.js +2 -7
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-select-pc.js +6 -4
- package/dist/web/components/form/userOrgSelect/component/userOrgSelect.css +8 -2
- package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +25 -51
- package/dist/web/components/form/userOrgSelect/hooks/use-depart-data.js +3 -3
- package/dist/web/components/form-input-hooks/index.js +39 -14
- package/dist/web/components/form-select-multiple/index.js +26 -0
- package/dist/web/components/form-user-tree-select/index.js +2 -2
- package/dist/web/components/formdetail/index.css +31 -1
- package/dist/web/components/formdetail/index.js +30 -0
- package/dist/web/components/index.js +17 -1
- package/dist/web/components/listView/index.js +20 -5
- package/dist/web/components/phone/index.js +26 -1
- package/dist/web/components/phoneCode/index.js +3 -1
- package/dist/web/components/richText/index.css +70 -67
- package/dist/web/components/richText/index.js +311 -251
- package/dist/web/components/richText/richtext.module.css +1 -0
- package/dist/web/components/richTextView/index.css +39 -0
- package/dist/web/components/richTextView/index.js +1 -1
- package/dist/web/components/share/index.js +26 -1
- package/dist/web/components/wd-checkbox/checkbox.js +34 -0
- package/dist/web/components/wd-checkbox/index.js +3 -0
- package/dist/web/components/wd-checkbox-list/checkboxList.js +140 -0
- package/dist/web/components/wd-checkbox-list/index.js +3 -0
- package/dist/web/components/wd-form/index.js +25 -12
- package/dist/web/components/wd-form/wd-form.js +42 -0
- package/dist/web/components/wd-form-cell/index.js +3 -0
- package/dist/web/components/wd-form-cell/wd-form-cell.js +42 -0
- package/dist/web/components/wd-form-item/index.js +4 -0
- package/dist/web/components/wd-form-item/wd-form-item.js +55 -0
- package/dist/web/components/wd-form-item/wd-input-group.js +24 -0
- package/dist/web/components/wd-input/index.js +3 -0
- package/dist/web/components/wd-input/wd-input.js +155 -0
- package/dist/web/components/wd-input-email/index.js +3 -0
- package/dist/web/components/wd-input-email/wd-input-email.js +13 -0
- package/dist/web/components/wd-input-group/index.js +3 -0
- package/dist/web/components/wd-input-group/wd-input-group.js +10 -0
- package/dist/web/components/wd-input-phone/index.js +3 -0
- package/dist/web/components/wd-input-phone/wd-input-phone.js +14 -0
- package/dist/web/components/wd-input-url/index.js +3 -0
- package/dist/web/components/wd-input-url/wd-input-url.js +13 -0
- package/dist/web/components/wd-input-wrap/index.js +3 -0
- package/dist/web/components/wd-input-wrap/wd-input-wrap.js +18 -0
- package/dist/web/components/wd-official-account/index.css +29 -0
- package/dist/web/components/wd-official-account/index.js +36 -0
- package/dist/web/components/wd-radio/index.js +3 -0
- package/dist/web/components/wd-radio/wd-radio.js +30 -0
- package/dist/web/components/wd-radio-list/index.js +3 -0
- package/dist/web/components/wd-radio-list/wd-radio-list.js +104 -0
- package/dist/web/components/wd-switch/index.js +3 -0
- package/dist/web/components/wd-switch/wd-switch.js +52 -0
- package/dist/web/components/wd-table/components/FieldRender/index.js +5 -4
- package/dist/web/components/wd-table/components/Table/index.js +12 -2
- package/dist/web/components/wd-table/hooks/useQueryParams.js +4 -1
- package/dist/web/components/wd-table/utils/index.js +6 -2
- package/dist/web/components/wd-table/wd-table.js +70 -57
- package/dist/web/components/wd-textarea/index.js +3 -0
- package/dist/web/components/wd-textarea/wd-textarea.js +78 -0
- package/dist/web/components/wd-tree/index.js +3 -0
- package/dist/web/components/wd-tree/utils.js +291 -0
- package/dist/web/components/wd-tree/wd-tree.js +193 -0
- package/dist/web/utils/constant.js +16 -0
- package/dist/web/utils/datasource.js +2 -2
- package/dist/web/utils/date.js +3 -3
- package/dist/web/utils/hooks/useFormLegacy.js +111 -0
- package/dist/web/utils/tool.js +12 -2
- package/dist/web/weda-ui.css +193 -3
- package/package.json +6 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { callWedaApi } from '../../../../utils/tcb';
|
|
2
2
|
import destr from 'destr';
|
|
3
3
|
import { node } from 'prop-types';
|
|
4
|
+
import { textToString } from '../../../../utils/platform';
|
|
4
5
|
// 处理用户数据格式
|
|
5
6
|
export const dealUserData = (data = []) => {
|
|
6
7
|
return data.map((user) => {
|
|
@@ -12,6 +13,7 @@ export const dealUserData = (data = []) => {
|
|
|
12
13
|
const mainDep = (user === null || user === void 0 ? void 0 : user.MainOrg) ? [].concat(user === null || user === void 0 ? void 0 : user.MainOrg) : (user === null || user === void 0 ? void 0 : user.Orgs) || [];
|
|
13
14
|
return {
|
|
14
15
|
id: user === null || user === void 0 ? void 0 : user.UserId,
|
|
16
|
+
name: user === null || user === void 0 ? void 0 : user.Name,
|
|
15
17
|
userName: name,
|
|
16
18
|
content: name,
|
|
17
19
|
userId: user === null || user === void 0 ? void 0 : user.UserId,
|
|
@@ -192,14 +194,8 @@ export const displayUserInfo = (item, secondDisplay) => {
|
|
|
192
194
|
return list[0].label;
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
value = item === null || item === void 0 ? void 0 : item[secondDisplay];
|
|
198
|
-
}
|
|
199
|
-
else if ((_b = item === null || item === void 0 ? void 0 : item.userExtend) === null || _b === void 0 ? void 0 : _b[secondDisplay]) {
|
|
200
|
-
value = (_c = item === null || item === void 0 ? void 0 : item.userExtend) === null || _c === void 0 ? void 0 : _c[secondDisplay];
|
|
201
|
-
}
|
|
202
|
-
return value;
|
|
197
|
+
const value = (_b = item === null || item === void 0 ? void 0 : item[secondDisplay]) !== null && _b !== void 0 ? _b : (_c = item === null || item === void 0 ? void 0 : item.userExtend) === null || _c === void 0 ? void 0 : _c[secondDisplay];
|
|
198
|
+
return textToString(value);
|
|
203
199
|
};
|
|
204
200
|
/**
|
|
205
201
|
* 前端实现部门模糊搜索
|
|
@@ -306,3 +302,23 @@ export const formatTree = (nodes) => {
|
|
|
306
302
|
}
|
|
307
303
|
return [];
|
|
308
304
|
};
|
|
305
|
+
/**
|
|
306
|
+
* 根据code再树结构中查找节点
|
|
307
|
+
* @param treeData
|
|
308
|
+
* @param code
|
|
309
|
+
* @returns
|
|
310
|
+
*/
|
|
311
|
+
export const getNodeFromTreeByCode = (treeData, code) => {
|
|
312
|
+
for (const node of treeData) {
|
|
313
|
+
if (node.code === code) {
|
|
314
|
+
return node;
|
|
315
|
+
}
|
|
316
|
+
if (node.children) {
|
|
317
|
+
const result = getNodeFromTreeByCode(node.children, code);
|
|
318
|
+
if (result) {
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return null;
|
|
324
|
+
};
|
|
@@ -3,14 +3,12 @@ import React, { useState } from 'react';
|
|
|
3
3
|
import { renderDecorator } from '../../../renderDecorator';
|
|
4
4
|
import classNames from '../../../../../utils/classnames';
|
|
5
5
|
import { Dropdown, ConfigProvider } from 'tea-component';
|
|
6
|
-
//import {dealOrgData } from '../../utils';
|
|
7
6
|
import { defaultRequest } from '../../common/fetch-data-service';
|
|
8
7
|
import '../index.css';
|
|
9
8
|
import { OrgModalPC } from './org-modal-pc';
|
|
10
9
|
import { InputTags } from '../../component/input-tags';
|
|
11
|
-
import { filterStrList } from '../../../../../utils/platform';
|
|
12
10
|
export const OrgTreeContext = React.createContext(null);
|
|
13
|
-
export function DepartTreeSelectPC({ id, className, style, label = '部门选择', labelVisible = true, placeholder = '请选择部门', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', multiple = false, decorator, request = defaultRequest, confirmOrgList,
|
|
11
|
+
export function DepartTreeSelectPC({ id, className, style, label = '部门选择', labelVisible = true, placeholder = '请选择部门', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', multiple = false, decorator, request = defaultRequest, confirmOrgList, setConfirmOrgList, selectedOrgList, setSelectedOrgList, errorInfo, setErrorInfo, treeData, orgList, error, defaultExpandedIds, }) {
|
|
14
12
|
const [open, setOpen] = useState(false);
|
|
15
13
|
// 外层组件类
|
|
16
14
|
const cls = classNames({
|
|
@@ -25,21 +23,18 @@ export function DepartTreeSelectPC({ id, className, style, label = '部门选择
|
|
|
25
23
|
};
|
|
26
24
|
//取消 关闭弹窗
|
|
27
25
|
const onCancel = () => {
|
|
28
|
-
setSelectedOrgList(
|
|
26
|
+
setSelectedOrgList(confirmOrgList);
|
|
29
27
|
setOpen(false);
|
|
30
28
|
};
|
|
31
29
|
return renderDecorator(_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(OrgTreeContext.Provider, { value: {
|
|
32
|
-
selectedOrgList,
|
|
33
30
|
multiple,
|
|
34
31
|
setSelectedOrgList,
|
|
32
|
+
selectedOrgList,
|
|
35
33
|
confirmOrgList,
|
|
36
|
-
selectedOrgIds,
|
|
37
|
-
setSelectedOrgIds,
|
|
38
34
|
defaultExpandedIds,
|
|
39
35
|
request,
|
|
40
36
|
}, children: _jsx(Dropdown, { className: classNames(`weda-ui-org-selected`, `size-${size}`), open: open, onOpenChange: (open) => {
|
|
41
37
|
setOpen(open);
|
|
42
|
-
setSelectedOrgIds(filterStrList(confirmOrgIds));
|
|
43
38
|
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
44
39
|
}, appearance: 'button', button: _jsx(InputTags, { tagsList: confirmOrgList, placeholder: placeholder, multiple: multiple, errInfo: errorInfo, disabled: disabled, onClose: (e, item) => {
|
|
45
40
|
setConfirmOrgList(confirmOrgList.filter((l) => (l === null || l === void 0 ? void 0 : l.id) !== (item === null || item === void 0 ? void 0 : item.id)));
|
|
@@ -22,8 +22,6 @@ export default function DepartTreeSelect(props) {
|
|
|
22
22
|
const prevDefaultRef = React.useRef(null);
|
|
23
23
|
// 最终选定部门id
|
|
24
24
|
const [confirmOrgIds, setConfirmOrgIds] = useSyncValue(defaultValue, isObjectEqual);
|
|
25
|
-
//弹窗中被选中部门id集合
|
|
26
|
-
const [selectedOrgIds, setSelectedOrgIds] = useState([]);
|
|
27
25
|
// 最终选定部门集合
|
|
28
26
|
const [confirmOrgList, setConfirmOrgList] = useState([]);
|
|
29
27
|
//弹窗中被选中部门集合
|
|
@@ -61,23 +59,23 @@ export default function DepartTreeSelect(props) {
|
|
|
61
59
|
}
|
|
62
60
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
61
|
}, [defaultValueType, confirmValue]);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const getDefaultOrg = async (ids) => {
|
|
64
|
+
try {
|
|
65
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
66
|
+
if (ids && ids.length !== 0 && !isInIde()) {
|
|
67
|
+
const { orgList } = await getDepartByIds({ ids, request });
|
|
68
|
+
setConfirmOrgList(orgList || []);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
setConfirmOrgList([]);
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
|
-
|
|
74
|
+
catch (e) {
|
|
72
75
|
setConfirmOrgList([]);
|
|
76
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
73
77
|
}
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
setConfirmOrgList([]);
|
|
77
|
-
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
useEffect(() => {
|
|
78
|
+
};
|
|
81
79
|
try {
|
|
82
80
|
if (!isObjectEqual(prevDefaultRef.current, confirmOrgIds)) {
|
|
83
81
|
getDefaultOrg(confirmOrgIds);
|
|
@@ -116,8 +114,6 @@ export default function DepartTreeSelect(props) {
|
|
|
116
114
|
confirmOrgIds,
|
|
117
115
|
confirmOrgList,
|
|
118
116
|
setConfirmOrgList,
|
|
119
|
-
selectedOrgIds,
|
|
120
|
-
setSelectedOrgIds,
|
|
121
117
|
selectedOrgList,
|
|
122
118
|
setSelectedOrgList,
|
|
123
119
|
errorInfo,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState,
|
|
2
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
3
3
|
import { Button, Modal, Bubble } from 'tea-component';
|
|
4
4
|
import { ModalSearch } from '../modal-search';
|
|
5
5
|
import { OrgTreeContext } from './depart-select-pc';
|
|
@@ -10,7 +10,7 @@ import debounce from '../../../../../utils/debounce';
|
|
|
10
10
|
import '../index.css';
|
|
11
11
|
export const OrgModalPC = (props) => {
|
|
12
12
|
const { open, setOpen, onCancel, onConfirm, treeData, orgList, treeDataError, } = props;
|
|
13
|
-
const {
|
|
13
|
+
const { multiple, setSelectedOrgList, selectedOrgList, confirmOrgList, defaultExpandedIds, } = React.useContext(OrgTreeContext) || {};
|
|
14
14
|
const [searchOrgList, setSearchOrgList] = useState([]);
|
|
15
15
|
// 是否有搜索项
|
|
16
16
|
const [keyWords, setKeyWords] = useState('');
|
|
@@ -19,13 +19,7 @@ export const OrgModalPC = (props) => {
|
|
|
19
19
|
errorMessage: null,
|
|
20
20
|
});
|
|
21
21
|
const [loading, setLoading] = useState(false);
|
|
22
|
-
|
|
23
|
-
let selectOrgList = [];
|
|
24
|
-
[]
|
|
25
|
-
.concat(selectedOrgIds)
|
|
26
|
-
.map((e) => (selectOrgList = selectOrgList.concat(orgList.filter((item) => (item === null || item === void 0 ? void 0 : item.id) === e))));
|
|
27
|
-
setSelectedOrgList(selectOrgList);
|
|
28
|
-
}, [selectedOrgIds]);
|
|
22
|
+
const selectedIds = useMemo(() => selectedOrgList.map((item) => item.id), [selectedOrgList]);
|
|
29
23
|
//搜索值变化延迟响应,节流处理
|
|
30
24
|
const onSearch = debounce((key) => {
|
|
31
25
|
try {
|
|
@@ -45,12 +39,24 @@ export const OrgModalPC = (props) => {
|
|
|
45
39
|
setErrInfo({ errorStatus: true, errorMessage: e });
|
|
46
40
|
}
|
|
47
41
|
}, 500);
|
|
48
|
-
|
|
42
|
+
const handleSelectedIdsChange = useCallback((ids) => {
|
|
43
|
+
const items = [];
|
|
44
|
+
if (ids.length > 0) {
|
|
45
|
+
for (const id of ids) {
|
|
46
|
+
const item = orgList.find((i) => i.id === id);
|
|
47
|
+
if (item) {
|
|
48
|
+
items.push(item);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (items.length > 0) {
|
|
53
|
+
setSelectedOrgList(items);
|
|
54
|
+
}
|
|
55
|
+
}, [orgList, setSelectedOrgList]);
|
|
56
|
+
return (_jsxs(Modal, { disableEscape: true, maskClosable: false, visible: open, caption: "\u9009\u62E9\u90E8\u95E8", onClose: () => setOpen(false), className: "weda-ui weda-ui-user-select-modal", children: [_jsxs(Modal.Body, { children: [_jsxs("div", { className: "weda-ui-user-select-container", children: [_jsx(ModalSearch, { searchList: searchOrgList, errInfo: errInfo, loading: loading, keyWords: keyWords, selectedList: selectedOrgList, multiple: multiple, setSelectedList: setSelectedOrgList, setSelectedIds: handleSelectedIdsChange, selectedIds: selectedIds, onSearch: (key) => onSearch(key), onReset: () => setSearchOrgList([]), isUser: false }), keyWords.length === 0 && (_jsx(_Fragment, { children: _jsx("div", { className: "weda-ui-user-select-container-list", children: _jsx("div", { className: "weda-ui-user-select-container-list__start", children: _jsx(OrgTree, { selectedOrgId: selectedIds, mutiple: multiple,
|
|
49
57
|
//setSelectedOrgId={setSelectedOrgId}
|
|
50
|
-
isUser: false, treeData: treeData, treeDataError: treeDataError, selectable: true, defaultExpandedIds: defaultExpandedIds, onActive: (ids) => {
|
|
51
|
-
|
|
52
|
-
} }) }) }) }))] }), _jsx(SelectedList, { selectedList: selectedOrgList, isUser: false, onClose: (item) => {
|
|
53
|
-
setSelectedOrgIds(selectedOrgIds.filter((e) => e !== (item === null || item === void 0 ? void 0 : item.id)));
|
|
58
|
+
isUser: false, treeData: treeData, treeDataError: treeDataError, selectable: true, defaultExpandedIds: defaultExpandedIds, onActive: (ids) => handleSelectedIdsChange(ids) }) }) }) }))] }), _jsx(SelectedList, { selectedList: selectedOrgList, isUser: false, onClose: (item) => {
|
|
59
|
+
setSelectedOrgList(selectedOrgList.filter((data) => data.id !== (item === null || item === void 0 ? void 0 : item.id)));
|
|
54
60
|
} })] }), _jsxs(Modal.Footer, { children: [_jsx(Button, { type: "weak", onClick: onCancel, children: "\u53D6\u6D88" }), _jsx(Bubble, { content: selectedOrgList.length === 0 && confirmOrgList.length === 0
|
|
55
61
|
? '请选择部门'
|
|
56
62
|
: null, children: _jsx(Button, { type: "primary", onClick: onConfirm, disabled: selectedOrgList.length === 0 && confirmOrgList.length === 0, children: "\u786E\u5B9A" }) })] })] }));
|
|
@@ -197,7 +197,7 @@ export const ModalSelectH5 = (props) => {
|
|
|
197
197
|
document.getElementById('wd-search-input').blur();
|
|
198
198
|
e.stopPropagation();
|
|
199
199
|
};
|
|
200
|
-
return (_jsxs(Modal, { visible: open, onClose: () => {
|
|
200
|
+
return (_jsxs(Modal, { disableEscape: true, maskClosable: false, visible: open, onClose: () => {
|
|
201
201
|
onrest();
|
|
202
202
|
onClose();
|
|
203
203
|
}, destroyOnClose: true, className: `weda-ui weda-select-user-dept__dialog`, children: [_jsxs(Modal.Body, { className: ((_a = selectedUserList[0]) === null || _a === void 0 ? void 0 : _a.userId) ? 'is-selected-value' : '', children: [_jsx("div", { className: "weda-select-user-dept__dialog-header", children: '选择成员' }), _jsx(ModalSearchH5, { value: keyWords, onChange: (key) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Tree } from 'tea-component';
|
|
3
|
-
import { LoadingStatus, ErrorStatus } from './error-tips';
|
|
3
|
+
import { LoadingStatus, ErrorStatus, NullStatus } from './error-tips';
|
|
4
4
|
import './index.css';
|
|
5
5
|
export const OrgTree = (props) => {
|
|
6
6
|
const { selectedOrgId = [], treeData, treeDataError, onActive,
|
|
@@ -28,12 +28,24 @@ export const OrgTree = (props) => {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
//}
|
|
32
31
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
if (treeDataError) {
|
|
33
|
+
return _jsx(ErrorStatus, { description: treeDataError || null });
|
|
34
|
+
}
|
|
35
|
+
if (!treeData) {
|
|
36
|
+
return _jsx(LoadingStatus, {});
|
|
37
|
+
}
|
|
38
|
+
if (treeData.length > 0) {
|
|
39
|
+
return (_jsx(Tree, { className: "depart-tree", data: treeData, fullActivable: true, activable: true, selectable: selectable, selectedIds: selectedOrgId, activeIds: selectedOrgId, defaultExpandedIds: defaultExpandedIds, selectStrictly: true, onActive: (ids, context) => {
|
|
40
|
+
var _a;
|
|
41
|
+
onChange(ids, context === null || context === void 0 ? void 0 : context.active, context === null || context === void 0 ? void 0 : context.nodeId, (_a = context === null || context === void 0 ? void 0 : context.data) === null || _a === void 0 ? void 0 : _a.selectable);
|
|
42
|
+
}, onSelect: (ids, context) => {
|
|
43
|
+
onChange(ids, context === null || context === void 0 ? void 0 : context.selected, context === null || context === void 0 ? void 0 : context.nodeId, true);
|
|
44
|
+
},
|
|
45
|
+
// 开启虚拟滚动,优化大数据量性能!!
|
|
46
|
+
height: 320 }));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return _jsx(NullStatus, { description: "\u6682\u65E0\u6570\u636E", size: 's' });
|
|
50
|
+
}
|
|
39
51
|
};
|
|
@@ -11,8 +11,17 @@ import { emptyArray, emptyObject } from '../../../../../utils/constant';
|
|
|
11
11
|
import { useViewData } from '../../hooks/use-views-data';
|
|
12
12
|
import { useDepartData } from '../../hooks/use-depart-data';
|
|
13
13
|
import { parseStrToArr } from '../../common/utils';
|
|
14
|
+
import { useDeepCompareEffect } from '@react-hookz/web';
|
|
14
15
|
export default function UserTreeSelect(props) {
|
|
15
|
-
const { events = emptyObject, defaultValue = emptyArray, confirmValue = '', defaultValueType = 'noneUser', onChange = null, multiple = false, request = defaultRequest, where, confirmAction, closeAction,
|
|
16
|
+
const { events = emptyObject, defaultValue = emptyArray, confirmValue = '', defaultValueType = 'noneUser', onChange = null, multiple = false, request = defaultRequest, where, confirmAction, closeAction, secondDisplay, // 辅助信息
|
|
17
|
+
corpScope, // 展示企业范围
|
|
18
|
+
/**
|
|
19
|
+
* 以下两个属性 不用在组件库,企业工作台使用该组件时支持外部定义样式
|
|
20
|
+
* naked: 单纯使用该组件,而不在FormCell中使用(该组件实现默认在在)
|
|
21
|
+
* containerClass: string
|
|
22
|
+
* triggerElement: React.ReactNode
|
|
23
|
+
*/
|
|
24
|
+
naked = false, containerClass = '', triggerElement = null, } = props;
|
|
16
25
|
const platform = usePlatform();
|
|
17
26
|
const [errInfo, setErrInfo] = useState({
|
|
18
27
|
errorStatus: false,
|
|
@@ -22,6 +31,8 @@ export default function UserTreeSelect(props) {
|
|
|
22
31
|
const [selectUserIds, setSelectUserIds] = useSyncValue(defaultValue, isObjectEqual);
|
|
23
32
|
// 两次默认值不同, 需要刷新
|
|
24
33
|
const prevDefaultRef = React.useRef(null);
|
|
34
|
+
// 当前选中的部门id
|
|
35
|
+
const [selectedOrgId, setSelectedOrgId] = useState(null);
|
|
25
36
|
//弹窗中被选中用户集合
|
|
26
37
|
const [selectedUserList, setSelectedUserList] = useState([]);
|
|
27
38
|
//弹窗中被选中用户id集合
|
|
@@ -33,7 +44,25 @@ export default function UserTreeSelect(props) {
|
|
|
33
44
|
//组织下展示用户页大小
|
|
34
45
|
const pageSize = 200;
|
|
35
46
|
const { filterParams } = useViewData(where);
|
|
36
|
-
const
|
|
47
|
+
const [corpScopes, setCorpScopes] = useState([]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!corpScope) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const corpScopes = filterStrList(parseStrToArr(corpScope));
|
|
53
|
+
setCorpScopes(corpScopes);
|
|
54
|
+
}, [corpScope]);
|
|
55
|
+
const { treeData, error } = useDepartData({
|
|
56
|
+
request,
|
|
57
|
+
params: { corpScopes },
|
|
58
|
+
});
|
|
59
|
+
// 默认选中第一个部门
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
var _a;
|
|
62
|
+
if (!selectedOrgId && treeData && treeData.length > 0) {
|
|
63
|
+
setSelectedOrgId((_a = treeData[0]) === null || _a === void 0 ? void 0 : _a.id);
|
|
64
|
+
}
|
|
65
|
+
}, [selectedOrgId, treeData]);
|
|
37
66
|
useEffect(() => {
|
|
38
67
|
// 仅执行一次
|
|
39
68
|
if (defaultValueType === 'loginUser') {
|
|
@@ -86,13 +115,12 @@ export default function UserTreeSelect(props) {
|
|
|
86
115
|
catch (e) { }
|
|
87
116
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
117
|
}, [defaultValueType, selectUserIds]);
|
|
89
|
-
|
|
118
|
+
useDeepCompareEffect(() => {
|
|
90
119
|
var _a;
|
|
91
120
|
setSelectedUserList(confirmUserList);
|
|
92
121
|
onChange === null || onChange === void 0 ? void 0 : onChange(setOnChangeValue(multiple, confirmUserList));
|
|
93
122
|
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, setOnChangeValue(multiple, confirmUserList, true));
|
|
94
|
-
|
|
95
|
-
}, [confirmUserList]);
|
|
123
|
+
}, [confirmUserList === null || confirmUserList === void 0 ? void 0 : confirmUserList.map((user) => filterUserInfo(user))]);
|
|
96
124
|
/** 点击确认时获取所选用户,调用confirmAction,将所选用户向外传出 */
|
|
97
125
|
const onConfirmSelectUser = (selectedUserList) => {
|
|
98
126
|
const selectedUser = setOnChangeValue(multiple, selectedUserList, true);
|
|
@@ -115,6 +143,8 @@ export default function UserTreeSelect(props) {
|
|
|
115
143
|
errInfo,
|
|
116
144
|
open,
|
|
117
145
|
setOpen,
|
|
146
|
+
selectedOrgId,
|
|
147
|
+
setSelectedOrgId,
|
|
118
148
|
selectedUserList,
|
|
119
149
|
setSelectedUserList,
|
|
120
150
|
confirmUserList,
|
|
@@ -131,14 +161,21 @@ export default function UserTreeSelect(props) {
|
|
|
131
161
|
treeData,
|
|
132
162
|
error,
|
|
133
163
|
onConfirmSelectUser,
|
|
164
|
+
secondDisplay,
|
|
165
|
+
};
|
|
166
|
+
// 企业工作台使用该组件时,支持自定义样式
|
|
167
|
+
const extraProps = {
|
|
168
|
+
naked,
|
|
169
|
+
containerClass,
|
|
170
|
+
triggerElement,
|
|
134
171
|
};
|
|
135
172
|
if ((props === null || props === void 0 ? void 0 : props.showType) === 'pc') {
|
|
136
|
-
return _jsx(UserSelectPC, { ...restProps, ...
|
|
173
|
+
return _jsx(UserSelectPC, { ...props, ...restProps, ...extraProps });
|
|
137
174
|
}
|
|
138
175
|
if ((props === null || props === void 0 ? void 0 : props.showType) === 'h5') {
|
|
139
|
-
return _jsx(UserSelectH5, { ...restProps, ...
|
|
176
|
+
return _jsx(UserSelectH5, { ...props, ...restProps, ...extraProps });
|
|
140
177
|
}
|
|
141
|
-
return platform === 'h5' ? (_jsx(UserSelectH5, { ...restProps, ...
|
|
178
|
+
return platform === 'h5' ? (_jsx(UserSelectH5, { ...props, ...restProps, ...extraProps })) : (_jsx(UserSelectPC, { ...props, ...restProps, ...extraProps }));
|
|
142
179
|
}
|
|
143
180
|
/**
|
|
144
181
|
* 设置onChange值
|
|
@@ -156,11 +193,11 @@ function setOnChangeValue(multiple, confirmUserList, isEventChange = false) {
|
|
|
156
193
|
return e === null || e === void 0 ? void 0 : e.id;
|
|
157
194
|
})
|
|
158
195
|
: null,
|
|
159
|
-
data: confirmUserList,
|
|
196
|
+
data: confirmUserList.map((user) => filterUserInfo(user)),
|
|
160
197
|
}
|
|
161
198
|
: {
|
|
162
199
|
value: ((_a = confirmUserList[0]) === null || _a === void 0 ? void 0 : _a.id) || null,
|
|
163
|
-
data: confirmUserList[0]
|
|
200
|
+
data: confirmUserList[0] ? filterUserInfo(confirmUserList[0]) : null,
|
|
164
201
|
};
|
|
165
202
|
}
|
|
166
203
|
return multiple
|
|
@@ -171,3 +208,13 @@ function setOnChangeValue(multiple, confirmUserList, isEventChange = false) {
|
|
|
171
208
|
: null
|
|
172
209
|
: (_b = confirmUserList[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
173
210
|
}
|
|
211
|
+
function filterUserInfo(userInfo) {
|
|
212
|
+
return pick(userInfo || {}, ['id', 'userName', 'userId', 'type']);
|
|
213
|
+
}
|
|
214
|
+
function pick(obj = {}, keys) {
|
|
215
|
+
const ret = {};
|
|
216
|
+
for (const key of keys) {
|
|
217
|
+
ret[key] = obj[key];
|
|
218
|
+
}
|
|
219
|
+
return ret;
|
|
220
|
+
}
|
|
@@ -10,9 +10,7 @@ import { fetchSearchUser } from '../../common/fetch-data-service';
|
|
|
10
10
|
import debounce from '../../../../../utils/debounce';
|
|
11
11
|
import '../index.css';
|
|
12
12
|
export const UserModel = ({ open, onCancel, onConfirm, treeData, treeDataError, filterParams, secondDisplay, }) => {
|
|
13
|
-
|
|
14
|
-
const { selectedUserList, setSelectedUserIds, request, selectedUserIds, setSelectedUserList, multiple, setPageNo, confirmUserList, } = React.useContext(UserOrgContext) || {};
|
|
15
|
-
const [selectedOrgId, setSelectedOrgId] = useState(null);
|
|
13
|
+
const { selectedOrgId, setSelectedOrgId, selectedUserList, setSelectedUserIds, request, selectedUserIds, setSelectedUserList, multiple, setPageNo, confirmUserList, } = React.useContext(UserOrgContext) || {};
|
|
16
14
|
//当前页人员列表
|
|
17
15
|
const [curPageUserList, setCurPageUserList] = useState(null);
|
|
18
16
|
const [searchUserList, setSearchUserList] = useState([]);
|
|
@@ -23,9 +21,6 @@ export const UserModel = ({ open, onCancel, onConfirm, treeData, treeDataError,
|
|
|
23
21
|
errorMessage: null,
|
|
24
22
|
});
|
|
25
23
|
const [loading, setLoading] = useState(false);
|
|
26
|
-
treeData.length > 0 && !selectedOrgId
|
|
27
|
-
? setSelectedOrgId((_a = treeData[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
28
|
-
: [];
|
|
29
24
|
useEffect(() => {
|
|
30
25
|
setSelectedUserIds((selectedUserList || []).map((e) => e === null || e === void 0 ? void 0 : e.id));
|
|
31
26
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -50,7 +45,7 @@ export const UserModel = ({ open, onCancel, onConfirm, treeData, treeDataError,
|
|
|
50
45
|
setErrInfo({ errorStatus: true, errorMessage: e });
|
|
51
46
|
}
|
|
52
47
|
}, 500);
|
|
53
|
-
return (_jsxs(Modal, { visible: open, caption: "\u9009\u62E9\u6210\u5458", onClose: () => onCancel(null), className: "weda-ui weda-ui-user-select-modal", children: [_jsxs(Modal.Body, { children: [_jsxs("div", { className: "weda-ui-user-select-container", children: [_jsx(ModalSearch, { searchList: searchUserList, errInfo: errInfo, loading: loading, keyWords: keyWords, selectedList: selectedUserList, multiple: multiple, setSelectedList: setSelectedUserList, selectedIds: selectedUserIds, filterParams: filterParams, onSearch: (key) => onSearch(key), onReset: () => setSearchUserList([]) }), keyWords.length === 0 && (_jsx(_Fragment, { children: _jsxs("div", { className: "weda-ui-user-select-container-list", children: [_jsx("div", { className: "weda-ui-user-select-container-list__start", children: _jsx(OrgTree, { selectedOrgId: [selectedOrgId], treeData: treeData, treeDataError: treeDataError, onActive: (ids) => {
|
|
48
|
+
return (_jsxs(Modal, { disableEscape: true, maskClosable: false, visible: open, caption: "\u9009\u62E9\u6210\u5458", onClose: () => onCancel(null), className: "weda-ui weda-ui-user-select-modal", children: [_jsxs(Modal.Body, { children: [_jsxs("div", { className: "weda-ui-user-select-container", children: [_jsx(ModalSearch, { searchList: searchUserList, errInfo: errInfo, loading: loading, keyWords: keyWords, selectedList: selectedUserList, multiple: multiple, setSelectedList: setSelectedUserList, selectedIds: selectedUserIds, filterParams: filterParams, onSearch: (key) => onSearch(key), onReset: () => setSearchUserList([]) }), keyWords.length === 0 && (_jsx(_Fragment, { children: _jsxs("div", { className: "weda-ui-user-select-container-list", children: [_jsx("div", { className: "weda-ui-user-select-container-list__start", children: _jsx(OrgTree, { selectedOrgId: [selectedOrgId], treeData: treeData, treeDataError: treeDataError, onActive: (ids) => {
|
|
54
49
|
setSelectedOrgId(ids[0]);
|
|
55
50
|
setPageNo(1);
|
|
56
51
|
} }) }), _jsx("div", { className: "weda-ui-user-select-container-list__end", children: _jsx(ModelUserList, { selectedOrgId: selectedOrgId, curPageUserList: curPageUserList, setCurPageUserList: setCurPageUserList, filterParams: filterParams, secondDisplay: secondDisplay }) })] }) }))] }), _jsx(SelectedList, { selectedList: selectedUserList, secondDisplay: secondDisplay, onClose: (item) => {
|
|
@@ -11,7 +11,7 @@ export const UserOrgContext = React.createContext(null);
|
|
|
11
11
|
export function UserSelectPC({ id, className, style, label = '人员选择', labelVisible = true, //标题显隐
|
|
12
12
|
placeholder = '请选择人员', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', multiple = false, //多选
|
|
13
13
|
outerRef, request = defaultRequest, //接口请求
|
|
14
|
-
decorator, onCancel, onConfirm, errInfo, open, setOpen, selectedUserList, setSelectedUserList, confirmUserList, setConfirmUserList, selectedUserIds, setSelectedUserIds, pageNo, setPageNo, pageSize, filterParams, treeData, error, onConfirmSelectUser, secondDisplay, }) {
|
|
14
|
+
decorator, onCancel, onConfirm, errInfo, open, setOpen, selectedOrgId, setSelectedOrgId, selectedUserList, setSelectedUserList, confirmUserList, setConfirmUserList, selectedUserIds, setSelectedUserIds, pageNo, setPageNo, pageSize, filterParams, treeData, error, onConfirmSelectUser, secondDisplay, naked, containerClass, triggerElement, }) {
|
|
15
15
|
// 外层组件类
|
|
16
16
|
const cls = classNames({
|
|
17
17
|
'weda-ui': true,
|
|
@@ -32,6 +32,8 @@ decorator, onCancel, onConfirm, errInfo, open, setOpen, selectedUserList, setSel
|
|
|
32
32
|
};
|
|
33
33
|
}, [setOpen]);
|
|
34
34
|
return renderDecorator(_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(UserOrgContext.Provider, { value: {
|
|
35
|
+
selectedOrgId,
|
|
36
|
+
setSelectedOrgId,
|
|
35
37
|
selectedUserList,
|
|
36
38
|
multiple,
|
|
37
39
|
setSelectedUserList,
|
|
@@ -42,16 +44,16 @@ decorator, onCancel, onConfirm, errInfo, open, setOpen, selectedUserList, setSel
|
|
|
42
44
|
pageNo,
|
|
43
45
|
setPageNo,
|
|
44
46
|
pageSize,
|
|
45
|
-
}, children: _jsx(Dropdown, { "data-testid": "userSelectDropdown", className: classNames(selectInputCls, `size-${size}
|
|
47
|
+
}, children: _jsx(Dropdown, { "data-testid": "userSelectDropdown", className: classNames(selectInputCls, `size-${size}`, containerClass), disabled: disabled, open: open, onOpenChange: (open) => {
|
|
46
48
|
if (open)
|
|
47
49
|
setSelectedUserList(confirmUserList);
|
|
48
50
|
setOpen(open);
|
|
49
|
-
}, appearance: 'button', button: _jsx(InputTags, { tagsList: confirmUserList, placeholder: placeholder, multiple: multiple, errInfo: errInfo, disabled: disabled, onClose: (e, item) => {
|
|
51
|
+
}, appearance: 'button', button: triggerElement || (_jsx(InputTags, { tagsList: confirmUserList, placeholder: placeholder, multiple: multiple, errInfo: errInfo, disabled: disabled, onClose: (e, item) => {
|
|
50
52
|
const currentConfirmUserList = confirmUserList.filter((l) => (l === null || l === void 0 ? void 0 : l.id) !== (item === null || item === void 0 ? void 0 : item.id));
|
|
51
53
|
setConfirmUserList(currentConfirmUserList);
|
|
52
54
|
onConfirmSelectUser(currentConfirmUserList);
|
|
53
55
|
e.stopPropagation();
|
|
54
|
-
} }), overlayClassName: 'weda-ui-user-selected-overlay-hidden', style: { width: '100%' }, children: _jsx(UserModel, { open: open, setOpen: setOpen, onConfirm: onConfirm, onCancel: onCancel, treeData: treeData || [], treeDataError: error, filterParams: filterParams, secondDisplay: secondDisplay }) }) }) }))({
|
|
56
|
+
} })), overlayClassName: 'weda-ui-user-selected-overlay-hidden', style: { width: '100%' }, children: _jsx(UserModel, { open: open, setOpen: setOpen, onConfirm: onConfirm, onCancel: onCancel, treeData: treeData || [], treeDataError: error, filterParams: filterParams, secondDisplay: secondDisplay }) }) }) }), naked ? null : undefined)({
|
|
55
57
|
id,
|
|
56
58
|
className: cls,
|
|
57
59
|
style,
|
|
@@ -986,10 +986,13 @@
|
|
|
986
986
|
|
|
987
987
|
.weda-select-user-dept .weda-select-user-dept__result-list,
|
|
988
988
|
.weda-select-user-dept__dialog .weda-select-user-dept__result-list {
|
|
989
|
-
flex: 1 1 0px;
|
|
989
|
+
/* flex: 1 1 0px;
|
|
990
990
|
display: flex;
|
|
991
991
|
align-items: center;
|
|
992
|
-
overflow: hidden;
|
|
992
|
+
overflow: hidden; */
|
|
993
|
+
overflow-x: scroll;
|
|
994
|
+
width: 100%;
|
|
995
|
+
white-space: nowrap;
|
|
993
996
|
}
|
|
994
997
|
|
|
995
998
|
.weda-select-user-dept .weda-select-user-dept__result-list .wedatea2td-tag,
|
|
@@ -1042,6 +1045,9 @@
|
|
|
1042
1045
|
font-size: 12px;
|
|
1043
1046
|
line-height: 20px;
|
|
1044
1047
|
color: rgba(0, 0, 0, 0.9);
|
|
1048
|
+
position: relative;
|
|
1049
|
+
display: inline-block;
|
|
1050
|
+
margin-left: 6px;
|
|
1045
1051
|
}
|
|
1046
1052
|
|
|
1047
1053
|
.weda-select-user-dept__dialog
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
3
|
import { renderDecorator } from '../../renderDecorator';
|
|
4
4
|
import { IconFont } from 'tdesign-icons-react';
|
|
5
5
|
import classNames from '../../../../utils/classnames';
|
|
6
|
-
import {
|
|
6
|
+
import { fetchSearchOrg, getNodeFromTreeByCode } from '../common/utils';
|
|
7
7
|
import { Modal, Button, ConfigProvider, Radio, Status, Bubble, } from 'tea-component';
|
|
8
8
|
import { ModalSearchH5 } from '../component/modal-search-h5';
|
|
9
9
|
import { LoadingStatus, ErrorStatus } from '../component/error-tips';
|
|
@@ -23,24 +23,12 @@ export function DepartTreeSelectH5({ id, className, style, label = '部门选择
|
|
|
23
23
|
});
|
|
24
24
|
const [visible, setVisible] = React.useState(false);
|
|
25
25
|
const [isSearch, setIsSearch] = useState(false);
|
|
26
|
-
// const [showTreeData, setShowTreeData] = useState([]);
|
|
27
26
|
const [showTreeData, setShowTreeData] = useState([]);
|
|
28
|
-
|
|
29
|
-
const [
|
|
27
|
+
// currentItem:到达当前页面是从currentItem部门点击来的
|
|
28
|
+
const [currentItem, setCurrentItem] = useState(null);
|
|
30
29
|
const [searchValue, setSearchValue] = useState('');
|
|
31
30
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
31
|
const [loading, setLoading] = useState({ id: null, status: false });
|
|
33
|
-
const [titleText, setTitleText] = useState('');
|
|
34
|
-
const treeNode = getNode(treeData, 'root', 'id');
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
// 仅执行一次
|
|
37
|
-
if (treeData) {
|
|
38
|
-
setShowTreeData(treeNode);
|
|
39
|
-
setOriginalOrgData([{ index: 1, treeData: treeNode, title: '选择部门' }]);
|
|
40
|
-
setTitleText('选择部门');
|
|
41
|
-
}
|
|
42
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
-
}, [treeData]);
|
|
44
32
|
const handleFocus = (value) => {
|
|
45
33
|
setIsSearch(value);
|
|
46
34
|
};
|
|
@@ -48,8 +36,7 @@ export function DepartTreeSelectH5({ id, className, style, label = '部门选择
|
|
|
48
36
|
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
49
37
|
handleFocus(false);
|
|
50
38
|
setSearchValue('');
|
|
51
|
-
setShowTreeData(
|
|
52
|
-
// initOrgsData();
|
|
39
|
+
setShowTreeData(treeData);
|
|
53
40
|
};
|
|
54
41
|
const onSearch = debounce((key) => {
|
|
55
42
|
try {
|
|
@@ -59,7 +46,7 @@ export function DepartTreeSelectH5({ id, className, style, label = '部门选择
|
|
|
59
46
|
setShowTreeData(res);
|
|
60
47
|
}
|
|
61
48
|
else {
|
|
62
|
-
setShowTreeData(
|
|
49
|
+
setShowTreeData(treeData);
|
|
63
50
|
}
|
|
64
51
|
}
|
|
65
52
|
catch (e) {
|
|
@@ -69,58 +56,45 @@ export function DepartTreeSelectH5({ id, className, style, label = '部门选择
|
|
|
69
56
|
const onFocus = function () {
|
|
70
57
|
setSearchValue('');
|
|
71
58
|
setVisible(true);
|
|
72
|
-
setShowTreeData(
|
|
59
|
+
setShowTreeData(treeData);
|
|
73
60
|
};
|
|
74
61
|
const onClose = () => {
|
|
75
62
|
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
76
63
|
setVisible(false);
|
|
77
|
-
setShowTreeData(
|
|
78
|
-
setShowTreeData(treeNode);
|
|
64
|
+
setShowTreeData(treeData);
|
|
79
65
|
};
|
|
80
66
|
const onConfirm = (selectedOrgList = []) => {
|
|
81
67
|
setConfirmOrgList(selectedOrgList);
|
|
82
68
|
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
83
|
-
setShowTreeData(
|
|
69
|
+
setShowTreeData(treeData);
|
|
84
70
|
setVisible(false);
|
|
85
71
|
};
|
|
86
72
|
// 获取某节点子部门
|
|
87
73
|
const loadItem = (item) => {
|
|
88
74
|
setShowTreeData((item === null || item === void 0 ? void 0 : item.children) ? [].concat(item === null || item === void 0 ? void 0 : item.children) : []);
|
|
89
|
-
|
|
90
|
-
index: count + 1,
|
|
91
|
-
treeData: item === null || item === void 0 ? void 0 : item.children,
|
|
92
|
-
title: item === null || item === void 0 ? void 0 : item.content,
|
|
93
|
-
});
|
|
94
|
-
setCount(count + 1);
|
|
95
|
-
setOriginalOrgData(originalOrgData);
|
|
96
|
-
setTitleText(item === null || item === void 0 ? void 0 : item.content);
|
|
75
|
+
setCurrentItem(item);
|
|
97
76
|
};
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
setTitleText(item.title);
|
|
108
|
-
setShowTreeData((item === null || item === void 0 ? void 0 : item.treeData) || []);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
setOriginalOrgData(storageOriTreeData);
|
|
77
|
+
// 返回targetItem节点所在的层级
|
|
78
|
+
const returnToLevelOfNode = (targetItem) => {
|
|
79
|
+
if (!targetItem) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// 已经返回到根节点层级
|
|
83
|
+
if (!targetItem.parentcode || targetItem.parentcode === '!!ROOT') {
|
|
84
|
+
setShowTreeData(treeData);
|
|
85
|
+
setCurrentItem(null);
|
|
116
86
|
}
|
|
117
87
|
else {
|
|
118
|
-
|
|
88
|
+
// 要返回targetItem所在的层级,需要找到targetItem的父节点parent,再显示parent的子节点即可
|
|
89
|
+
const parent = getNodeFromTreeByCode(treeData, targetItem.parentcode);
|
|
90
|
+
setShowTreeData((parent === null || parent === void 0 ? void 0 : parent.children) || []);
|
|
91
|
+
// 标记当前是从根节点进到这一层
|
|
92
|
+
setCurrentItem(parent);
|
|
119
93
|
}
|
|
120
94
|
};
|
|
121
95
|
return renderDecorator(_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsxs("div", { className: subCls, children: [_jsx("div", { className: "weui-cell__bd weui-flex", children: _jsx("input", { className: "weui-input", placeholder: placeholder,
|
|
122
96
|
//value={value}
|
|
123
|
-
value: (confirmOrgList || []).map((e) => e === null || e === void 0 ? void 0 : e.content).join(','), disabled: disabled, name: name, autoFocus: autoFocus, onClick: onFocus, readOnly: true, role: "input" }) }), _jsxs(Modal, { visible: visible, onClose: onClose, destroyOnClose: true, className: `weda-ui weda-select-user-dept__dialog`, children: [_jsxs(Modal.Body, { className: ((_a = selectedOrgList[0]) === null || _a === void 0 ? void 0 : _a.id) ? 'is-selected-value' : '', children: [_jsxs("div", { className: "weda-select-user-dept__dialog-header",
|
|
97
|
+
value: (confirmOrgList || []).map((e) => e === null || e === void 0 ? void 0 : e.content).join(','), disabled: disabled, name: name, autoFocus: autoFocus, onClick: onFocus, readOnly: true, role: "input" }) }), _jsxs(Modal, { disableEscape: true, maskClosable: false, visible: visible, onClose: onClose, destroyOnClose: true, className: `weda-ui weda-select-user-dept__dialog`, children: [_jsxs(Modal.Body, { className: ((_a = selectedOrgList[0]) === null || _a === void 0 ? void 0 : _a.id) ? 'is-selected-value' : '', children: [_jsxs("div", { className: "weda-select-user-dept__dialog-header", children: [_jsx("div", { className: !currentItem ? '' : 'arrow-left', onClick: () => returnToLevelOfNode(currentItem) }), currentItem ? currentItem.content : '选择部门'] }), _jsx(ModalSearchH5, { value: searchValue, onChange: (key) => {
|
|
124
98
|
onSearch(key);
|
|
125
99
|
setSearchValue(key);
|
|
126
100
|
}, onCancel: cancleSearch, isSearch: isSearch, onFocus: () => {
|