@cloudbase/weda-ui 3.4.9-alpha.1024 → 3.4.10
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/README.md +65 -30
- package/dist/configs/components/chart/bar.json +1 -1
- package/dist/configs/components/chart/line.js +1 -1
- package/dist/configs/components/chart/pie.json +1 -1
- package/dist/configs/components/customer-service.js +0 -2
- package/dist/configs/components/flowgraph.json +22 -0
- package/dist/configs/components/form-checkbox.js +1 -0
- package/dist/configs/components/form-date.js +1 -0
- package/dist/configs/components/form-depart-tree-select.js +2 -4
- package/dist/configs/components/form-email.js +1 -0
- package/dist/configs/components/form-image-uploader.js +1 -0
- package/dist/configs/components/form-input.js +1 -2
- package/dist/configs/components/form-location.js +2 -2
- package/dist/configs/components/form-multi-region.js +1 -0
- package/dist/configs/components/form-phone.js +1 -0
- package/dist/configs/components/form-radio.js +1 -0
- package/dist/configs/components/form-region.js +1 -0
- package/dist/configs/components/form-rich-text.js +1 -0
- package/dist/configs/components/form-select.js +1 -0
- package/dist/configs/components/form-switch.js +1 -0
- package/dist/configs/components/form-text-area.js +1 -0
- package/dist/configs/components/form-time.js +1 -0
- package/dist/configs/components/form-upload-file.js +1 -0
- package/dist/configs/components/form-url.js +1 -0
- package/dist/configs/components/form-user-tree-select.js +3 -4
- package/dist/configs/components/modal.js +0 -2
- package/dist/configs/components/navigationBar.json +1 -3
- package/dist/configs/components/wd-button.js +2 -2
- package/dist/configs/components/wd-icon.js +2 -2
- package/dist/configs/components/wd-link.js +2 -2
- package/dist/configs/components/wd-table.js +1 -1
- package/dist/configs/index.js +2 -0
- package/dist/docs/common/components/properties-view.js +3 -6
- package/dist/docs/common/tableView.js +7 -10
- package/dist/style/index.scss +1 -1
- package/dist/web/components/chart/common/core/eChartLine.js +12 -1
- package/dist/web/components/chart/common/data-transform.js +13 -9
- package/dist/web/components/chart/line/index.old.js +2 -1
- package/dist/web/components/flow/common/request.js +3 -3
- package/dist/web/components/flow/modules/chart/index.js +42 -3
- package/dist/web/components/flow/modules/chart/preview-data.js +88 -0
- package/dist/web/components/flow-graph/constants.js +28 -0
- package/dist/web/components/flow-graph/graph.js +267 -0
- package/dist/web/components/flow-graph/index.js +2 -0
- package/dist/web/components/flow-graph/style.css +109 -0
- package/dist/web/components/flow-graph/types.js +1 -0
- package/dist/web/components/form/select/dropdown-select/index.css +4 -0
- package/dist/web/components/form/select/dropdown-select/index.js +4 -1
- package/dist/web/components/form/select/request.js +9 -9
- package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +44 -490
- package/dist/web/components/form/userOrgSelect/common/utils.js +14 -58
- package/dist/web/components/form/userOrgSelect/component/OrgPaths.js +12 -0
- package/dist/web/components/form/userOrgSelect/component/depart-select/depart-select-pc.js +1 -3
- package/dist/web/components/form/userOrgSelect/component/depart-select/departTreeSelect.h5.js +35 -56
- package/dist/web/components/form/userOrgSelect/component/depart-select/index.js +46 -24
- package/dist/web/components/form/userOrgSelect/component/depart-select/org-modal-pc.js +11 -20
- package/dist/web/components/form/userOrgSelect/component/modal-select-h5.js +57 -120
- package/dist/web/components/form/userOrgSelect/component/org-tree.js +8 -24
- package/dist/web/components/form/userOrgSelect/component/user-org-list.js +4 -4
- package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +42 -33
- package/dist/web/components/form/userOrgSelect/component/user-select-h5/user-select-h5.js +2 -2
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/model-user-list.js +20 -51
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/org-tree.js +2 -2
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-model.js +4 -17
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-select-pc.js +4 -6
- package/dist/web/components/form/userOrgSelect/component/userOrgSelect.css +7 -3
- package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +68 -158
- package/dist/web/components/form/userOrgSelect/hooks/use-depart-data.js +3 -109
- package/dist/web/components/form-input-hooks/index.js +5 -2
- package/dist/web/components/index.js +1 -0
- package/dist/web/components/swiper/index.js +1 -2
- package/dist/web/components/table/BaseTable.js +1 -1
- package/dist/web/components/tabs/tabs.pc.js +10 -9
- package/dist/web/components/wd-form/index.js +28 -14
- package/dist/web/components/wd-table/components/ExportFileModalByApi/index.js +1 -1
- package/dist/web/components/wd-table/components/FieldRender/index.js +13 -2
- package/dist/web/components/wd-table/hooks/useChooseList.js +3 -5
- package/dist/web/components/wd-table/hooks/useTableData.js +1 -7
- package/dist/web/components/wd-table/utils/index.js +22 -3
- package/dist/web/components/wd-table/wd-table.js +9 -3
- package/dist/web/utils/datasource.js +3 -1
- package/package.json +2 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import { callWedaApi } from '../../../../utils/tcb';
|
|
3
2
|
import destr from 'destr';
|
|
4
3
|
import { node } from 'prop-types';
|
|
@@ -204,12 +203,14 @@ export const displayUserInfo = (item, secondDisplay) => {
|
|
|
204
203
|
};
|
|
205
204
|
/**
|
|
206
205
|
* 前端实现部门模糊搜索
|
|
206
|
+
* @param props
|
|
207
|
+
* @returns
|
|
207
208
|
*/
|
|
208
|
-
export const fetchSearchOrg = (
|
|
209
|
+
export const fetchSearchOrg = (props) => {
|
|
210
|
+
const { key, treeData } = props;
|
|
211
|
+
const orgList = treeToArray(treeData);
|
|
209
212
|
if (Array.isArray(orgList) && orgList.length > 0) {
|
|
210
|
-
const arr = orgList.filter((item) =>
|
|
211
|
-
(item === null || item === void 0 ? void 0 : item.selectable) &&
|
|
212
|
-
item.type !== 'corp') || [];
|
|
213
|
+
const arr = orgList.filter((item) => (item === null || item === void 0 ? void 0 : item.content.indexOf(key)) >= 0 && (item === null || item === void 0 ? void 0 : item.selectable)) || [];
|
|
213
214
|
return arr;
|
|
214
215
|
}
|
|
215
216
|
return [];
|
|
@@ -283,12 +284,12 @@ const arrayToTree = (items) => {
|
|
|
283
284
|
res.push(newItem);
|
|
284
285
|
}
|
|
285
286
|
else {
|
|
286
|
-
if (!getHasOwnProperty(map, i.
|
|
287
|
-
map[i.
|
|
287
|
+
if (!getHasOwnProperty(map, i.parentcode)) {
|
|
288
|
+
map[i.parentcode] = {
|
|
288
289
|
children: [],
|
|
289
290
|
};
|
|
290
291
|
}
|
|
291
|
-
map[i.
|
|
292
|
+
map[i.parentcode].children.push(newItem);
|
|
292
293
|
}
|
|
293
294
|
}
|
|
294
295
|
return res;
|
|
@@ -306,48 +307,18 @@ export const formatTree = (nodes) => {
|
|
|
306
307
|
return [];
|
|
307
308
|
};
|
|
308
309
|
/**
|
|
309
|
-
*
|
|
310
|
-
* @param list
|
|
311
|
-
* @returns
|
|
312
|
-
*/
|
|
313
|
-
export const buildTree = (list) => {
|
|
314
|
-
const idMap = {};
|
|
315
|
-
const tree = [];
|
|
316
|
-
for (const item of list) {
|
|
317
|
-
idMap[item.code] = { ...item };
|
|
318
|
-
}
|
|
319
|
-
for (const item of list) {
|
|
320
|
-
const { code, parentCode } = item;
|
|
321
|
-
if (!parentCode) {
|
|
322
|
-
tree.push(idMap[code]);
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
if (idMap[parentCode]) {
|
|
326
|
-
idMap[parentCode].children
|
|
327
|
-
? idMap[parentCode].children.push(idMap[code])
|
|
328
|
-
: (idMap[parentCode].children = [idMap[code]]);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return {
|
|
333
|
-
list,
|
|
334
|
-
idMap,
|
|
335
|
-
treeData: tree,
|
|
336
|
-
};
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* 从树形结构中查找某个节点
|
|
310
|
+
* 根据code再树结构中查找节点
|
|
340
311
|
* @param treeData
|
|
341
|
-
* @param
|
|
312
|
+
* @param code
|
|
342
313
|
* @returns
|
|
343
314
|
*/
|
|
344
|
-
export const
|
|
315
|
+
export const getNodeFromTreeByCode = (treeData, code) => {
|
|
345
316
|
for (const node of treeData) {
|
|
346
|
-
if (node.
|
|
317
|
+
if (node.code === code) {
|
|
347
318
|
return node;
|
|
348
319
|
}
|
|
349
320
|
if (node.children) {
|
|
350
|
-
const result =
|
|
321
|
+
const result = getNodeFromTreeByCode(node.children, code);
|
|
351
322
|
if (result) {
|
|
352
323
|
return result;
|
|
353
324
|
}
|
|
@@ -355,18 +326,3 @@ export const getNodeFromTree = (treeData, id) => {
|
|
|
355
326
|
}
|
|
356
327
|
return null;
|
|
357
328
|
};
|
|
358
|
-
/**
|
|
359
|
-
* 根据部门ids获取部门详情列表
|
|
360
|
-
* @param param0
|
|
361
|
-
* @returns
|
|
362
|
-
*/
|
|
363
|
-
export const getOrgItemsByIds = ({ ids, orgList }) => {
|
|
364
|
-
const list = [];
|
|
365
|
-
for (const id of ids) {
|
|
366
|
-
const item = orgList.find((item) => item.id === id);
|
|
367
|
-
if (item) {
|
|
368
|
-
list.push(item);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
return list;
|
|
372
|
-
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getTreePaths } from '../common/utils';
|
|
3
|
+
export const OrgPaths = ({ nodeId, treeData }) => {
|
|
4
|
+
if (!nodeId || !treeData) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const paths = getTreePaths(nodeId, treeData);
|
|
8
|
+
if (paths && paths.length > 0) {
|
|
9
|
+
return _jsxs(_Fragment, { children: ["(", paths.map((node) => node.content).join('/'), ")"] });
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
@@ -3,7 +3,6 @@ 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';
|
|
@@ -29,10 +28,9 @@ export function DepartTreeSelectPC({ id, className, style, label = '部门选择
|
|
|
29
28
|
};
|
|
30
29
|
return renderDecorator(_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(OrgTreeContext.Provider, { value: {
|
|
31
30
|
multiple,
|
|
32
|
-
selectedOrgList,
|
|
33
31
|
setSelectedOrgList,
|
|
32
|
+
selectedOrgList,
|
|
34
33
|
confirmOrgList,
|
|
35
|
-
setConfirmOrgList,
|
|
36
34
|
defaultExpandedIds,
|
|
37
35
|
request,
|
|
38
36
|
}, children: _jsx(Dropdown, { className: classNames(`weda-ui-org-selected`, `size-${size}`), open: open, onOpenChange: (open) => {
|
package/dist/web/components/form/userOrgSelect/component/depart-select/departTreeSelect.h5.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
import React, { useState,
|
|
3
|
+
import React, { useState, useLayoutEffect } from 'react';
|
|
4
4
|
import List from 'rc-virtual-list';
|
|
5
5
|
import { renderDecorator } from '../../../renderDecorator';
|
|
6
6
|
import { IconFont } from 'tdesign-icons-react';
|
|
7
7
|
import classNames from '../../../../../utils/classnames';
|
|
8
|
-
import {
|
|
8
|
+
import { fetchSearchOrg, getNodeFromTreeByCode } from '../../common/utils';
|
|
9
9
|
import { Modal, Button, ConfigProvider, Radio, Status, Bubble, } from 'tea-component';
|
|
10
10
|
import { ModalSearchH5 } from '../modal-search-h5';
|
|
11
11
|
import { LoadingStatus, ErrorStatus } from '../error-tips';
|
|
12
12
|
import debounce from '../../../../../utils/debounce';
|
|
13
13
|
import '../userOrgSelect.css';
|
|
14
|
+
import { OrgPaths } from '../OrgPaths';
|
|
14
15
|
export function DepartTreeSelectH5({ id, className, style, label = '部门选择', labelVisible = true, name = 'formDepartTreeSelect', placeholder = '请选择部门', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', decorator, multiple = true, focus: autoFocus = false, confirmOrgList, setConfirmOrgList, selectedOrgList, setSelectedOrgList, errorInfo, setErrorInfo, orgList, treeData, }) {
|
|
15
16
|
var _a;
|
|
16
17
|
const cls = classNames({
|
|
@@ -26,24 +27,14 @@ export function DepartTreeSelectH5({ id, className, style, label = '部门选择
|
|
|
26
27
|
});
|
|
27
28
|
const [visible, setVisible] = React.useState(false);
|
|
28
29
|
const [isSearch, setIsSearch] = useState(false);
|
|
29
|
-
|
|
30
|
-
const [
|
|
31
|
-
|
|
30
|
+
// 当前显示的树结构
|
|
31
|
+
const [showTreeData, setShowTreeData] = useState(treeData);
|
|
32
|
+
// currentItem从那一个部门点击进到下个部门的
|
|
33
|
+
const [currentItem, setCurrentItem] = useState(null);
|
|
32
34
|
const [searchValue, setSearchValue] = useState('');
|
|
33
35
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
36
|
const [loading, setLoading] = useState({ id: null, status: false });
|
|
35
|
-
const [titleText, setTitleText] = useState('');
|
|
36
37
|
const [listHeight, setListHeight] = useState(0);
|
|
37
|
-
const treeNode = getNode(treeData, 'root', 'id');
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
// 仅执行一次
|
|
40
|
-
if (treeData) {
|
|
41
|
-
setShowTreeData(treeNode);
|
|
42
|
-
setOriginalOrgData([{ index: 1, treeData: treeNode, title: '选择部门' }]);
|
|
43
|
-
setTitleText('选择部门');
|
|
44
|
-
}
|
|
45
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
-
}, [treeData]);
|
|
47
38
|
useLayoutEffect(() => {
|
|
48
39
|
const windowHeight = window.screen.height;
|
|
49
40
|
const listHeight = windowHeight - 35 - 80 - 80 - 50; // 顶部标题35px,搜索框80px,底部按钮80px, 选择结果50px
|
|
@@ -56,7 +47,7 @@ export function DepartTreeSelectH5({ id, className, style, label = '部门选择
|
|
|
56
47
|
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
57
48
|
handleFocus(false);
|
|
58
49
|
setSearchValue('');
|
|
59
|
-
setShowTreeData(
|
|
50
|
+
setShowTreeData(treeData);
|
|
60
51
|
// initOrgsData();
|
|
61
52
|
};
|
|
62
53
|
const onSearch = debounce((key) => {
|
|
@@ -67,7 +58,7 @@ export function DepartTreeSelectH5({ id, className, style, label = '部门选择
|
|
|
67
58
|
setShowTreeData(res);
|
|
68
59
|
}
|
|
69
60
|
else {
|
|
70
|
-
setShowTreeData(
|
|
61
|
+
setShowTreeData(treeData);
|
|
71
62
|
}
|
|
72
63
|
}
|
|
73
64
|
catch (e) {
|
|
@@ -77,65 +68,53 @@ export function DepartTreeSelectH5({ id, className, style, label = '部门选择
|
|
|
77
68
|
const onFocus = function () {
|
|
78
69
|
setSearchValue('');
|
|
79
70
|
setVisible(true);
|
|
80
|
-
setShowTreeData(
|
|
71
|
+
setShowTreeData(treeData);
|
|
81
72
|
};
|
|
82
73
|
const onClose = () => {
|
|
83
74
|
setSelectedOrgList(confirmOrgList);
|
|
84
75
|
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
85
76
|
setVisible(false);
|
|
86
|
-
setShowTreeData(
|
|
77
|
+
setShowTreeData(treeData);
|
|
87
78
|
};
|
|
88
79
|
const onConfirm = (selectedOrgList = []) => {
|
|
89
80
|
setConfirmOrgList(selectedOrgList);
|
|
90
81
|
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
91
|
-
setShowTreeData(
|
|
82
|
+
setShowTreeData(treeData);
|
|
92
83
|
setVisible(false);
|
|
93
84
|
};
|
|
94
85
|
// 获取某节点子部门
|
|
95
86
|
const loadItem = (item) => {
|
|
96
87
|
setShowTreeData((item === null || item === void 0 ? void 0 : item.children) ? [].concat(item === null || item === void 0 ? void 0 : item.children) : []);
|
|
97
|
-
|
|
98
|
-
index: count + 1,
|
|
99
|
-
treeData: item === null || item === void 0 ? void 0 : item.children,
|
|
100
|
-
title: item === null || item === void 0 ? void 0 : item.content,
|
|
101
|
-
});
|
|
102
|
-
setCount(count + 1);
|
|
103
|
-
setOriginalOrgData(originalOrgData);
|
|
104
|
-
setTitleText(item === null || item === void 0 ? void 0 : item.content);
|
|
88
|
+
setCurrentItem(item);
|
|
105
89
|
};
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
setTitleText(item.title);
|
|
116
|
-
setShowTreeData((item === null || item === void 0 ? void 0 : item.treeData) || []);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
setOriginalOrgData(storageOriTreeData);
|
|
90
|
+
// 返回targetItem节点所在的层级
|
|
91
|
+
const returnToLevelOfNode = (targetItem) => {
|
|
92
|
+
if (!targetItem) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// 已经返回到根节点层级
|
|
96
|
+
if (!targetItem.parentCode) {
|
|
97
|
+
setShowTreeData(treeData);
|
|
98
|
+
setCurrentItem(null);
|
|
124
99
|
}
|
|
125
100
|
else {
|
|
126
|
-
|
|
101
|
+
// 要返回targetItem所在的层级,需要找到targetItem的父节点parent,再显示parent的子节点即可
|
|
102
|
+
const parent = getNodeFromTreeByCode(treeData, targetItem.parentCode);
|
|
103
|
+
setShowTreeData((parent === null || parent === void 0 ? void 0 : parent.children) || []);
|
|
104
|
+
// 标记当前是从根节点进到这一层
|
|
105
|
+
setCurrentItem(parent);
|
|
127
106
|
}
|
|
128
107
|
};
|
|
129
108
|
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,
|
|
130
109
|
//value={value}
|
|
131
|
-
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",
|
|
110
|
+
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) => {
|
|
132
111
|
onSearch(key);
|
|
133
112
|
setSearchValue(key);
|
|
134
113
|
}, onCancel: cancleSearch, isSearch: isSearch, onFocus: () => {
|
|
135
114
|
handleFocus(true);
|
|
136
115
|
} }), (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.errorStatus) ? (_jsx(ErrorStatus, { description: (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.errorMessage) || null })) : !(loading === null || loading === void 0 ? void 0 : loading.status) ? (_jsx(_Fragment, { children: showTreeData && showTreeData.length > 0 ? (_jsx(List, { className: classNames('weda-select-user-dept__dialog-list'), data: showTreeData, height: 400, itemHeight: 40, itemKey: "id", children: (item) => {
|
|
137
116
|
var _a;
|
|
138
|
-
return (_jsx("div", { className: "weda-select-user-dept__list-item", children: _jsxs("div", { className: "weda-select-user-dept__list-item-wrap", children: [
|
|
117
|
+
return (_jsx("div", { className: "weda-select-user-dept__list-item", children: _jsxs("div", { className: "weda-select-user-dept__list-item-wrap", children: [_jsxs(Radio.Group, { value: (_a = selectedOrgList.filter((e) => (e === null || e === void 0 ? void 0 : e.id) === (item === null || item === void 0 ? void 0 : item.id))[0]) === null || _a === void 0 ? void 0 : _a.id, onChange: (value) => {
|
|
139
118
|
const ids = selectedOrgList.map((item) => item === null || item === void 0 ? void 0 : item.id);
|
|
140
119
|
// 多选情况,取消选中某元素时
|
|
141
120
|
if (ids.indexOf(value) !== -1) {
|
|
@@ -152,15 +131,15 @@ export function DepartTreeSelectH5({ id, className, style, label = '部门选择
|
|
|
152
131
|
setSelectedOrgList([item]);
|
|
153
132
|
}
|
|
154
133
|
}
|
|
155
|
-
}, layout: "column", children: _jsx(_Fragment, { children: item.type !== 'corp' && (item === null || item === void 0 ? void 0 : item.selectable) ? (_jsx(Radio, { name: item === null || item === void 0 ? void 0 : item.id, children: _jsxs("div", { className: "weda-select-user-dept__item-detail weda-select-user-dept__item-detail-is-org", onClick: () => {
|
|
134
|
+
}, layout: "column", children: [_jsx(_Fragment, { children: item.type !== 'corp' && (item === null || item === void 0 ? void 0 : item.selectable) ? (_jsx(Radio, { name: item === null || item === void 0 ? void 0 : item.id, children: _jsxs("div", { className: "weda-select-user-dept__item-detail weda-select-user-dept__item-detail-is-org", onClick: () => {
|
|
135
|
+
(item === null || item === void 0 ? void 0 : item.children) ? loadItem(item) : false;
|
|
136
|
+
}, children: [_jsx("div", { className: "item-name", children: item === null || item === void 0 ? void 0 : item.content }), (item === null || item === void 0 ? void 0 : item.children) &&
|
|
137
|
+
loading.id !== item.id && (_jsx("div", { className: "lcap-icon lcap-icon-chevronright" }))] }) })) : (_jsxs("div", { className: "weda-select-user-dept__item-detail weda-select-user-dept__item-detail-is-org", onClick: () => {
|
|
156
138
|
(item === null || item === void 0 ? void 0 : item.children) ? loadItem(item) : false;
|
|
157
|
-
}, children: [_jsx("div", { className: "item-name", children: item === null || item === void 0 ? void 0 : item.content }), (item === null || item === void 0 ? void 0 : item.children) &&
|
|
158
|
-
loading.id !== item.id && (_jsx("div", { className: "lcap-icon lcap-icon-chevronright" }))] }) })) : (_jsxs("div", { className: "weda-select-user-dept__item-detail weda-select-user-dept__item-detail-is-org", onClick: () => {
|
|
159
|
-
(item === null || item === void 0 ? void 0 : item.children) ? loadItem(item) : false;
|
|
160
|
-
}, children: [_jsx("div", { className: "item-name", children: item === null || item === void 0 ? void 0 : item.content }), (item === null || item === void 0 ? void 0 : item.children) && loading.id !== item.id && (_jsx("div", { className: "lcap-icon lcap-icon-chevronright" }))] })) }) }), loading.id === (item === null || item === void 0 ? void 0 : item.id) && (loading === null || loading === void 0 ? void 0 : loading.status) && (_jsx("div", { children: _jsx(IconFont, { name: "loading", className: `weda-grid-navigation__fonticon depart_loading` }) }))] }) }, item === null || item === void 0 ? void 0 : item.id));
|
|
139
|
+
}, children: [_jsx("div", { className: "item-name", children: item === null || item === void 0 ? void 0 : item.content }), (item === null || item === void 0 ? void 0 : item.children) && loading.id !== item.id && (_jsx("div", { className: "lcap-icon lcap-icon-chevronright" }))] })) }), isSearch && searchValue && (_jsx("div", { className: "item-org-h5", children: _jsx(OrgPaths, { nodeId: item === null || item === void 0 ? void 0 : item.id, treeData: treeData }) }))] }), loading.id === (item === null || item === void 0 ? void 0 : item.id) && (loading === null || loading === void 0 ? void 0 : loading.status) && (_jsx("div", { children: _jsx(IconFont, { name: "loading", className: `weda-grid-navigation__fonticon depart_loading` }) }))] }) }, item === null || item === void 0 ? void 0 : item.id));
|
|
161
140
|
} })) : (_jsx(Status, { className: "dim-tree-select--blank", icon: 'blank', size: 's', title: `暂无部门数据` })) })) : (_jsx(LoadingStatus, {}))] }), _jsx(Modal.Footer, { children: _jsxs("div", { children: [selectedOrgList.length > 0 && (_jsxs("div", { className: "weda-select-user-dept__select-result", children: [_jsx("div", { className: "weda-select-user-dept__select-label", children: "\u5DF2\u9009\u62E9" }), _jsx("div", { className: "weda-select-user-dept__result-list", children: selectedOrgList.map((d) => (_jsxs("div", { className: "weda-select-user-dept__result-item", onClick: () => {
|
|
162
141
|
setSelectedOrgList(selectedOrgList.filter((e) => (e === null || e === void 0 ? void 0 : e.id) !== (d === null || d === void 0 ? void 0 : d.id)));
|
|
163
|
-
}, children: [d === null || d === void 0 ? void 0 : d.content, _jsx("div", { className: "close" })] }, (d === null || d === void 0 ? void 0 : d.id) || (d === null || d === void 0 ? void 0 : d.value)))) })] })), _jsxs("div", { className: "weda-select-user-dept__btn-group", children: [_jsx(Button, { type: "weak", onClick: onClose, children: "\u53D6\u6D88" }), _jsx(Bubble, { content: selectedOrgList.length === 0 && confirmOrgList.length === 0
|
|
142
|
+
}, children: [_jsx("div", { children: d === null || d === void 0 ? void 0 : d.content }), _jsx("div", { className: "close" })] }, (d === null || d === void 0 ? void 0 : d.id) || (d === null || d === void 0 ? void 0 : d.value)))) })] })), _jsxs("div", { className: "weda-select-user-dept__btn-group", children: [_jsx(Button, { type: "weak", onClick: onClose, children: "\u53D6\u6D88" }), _jsx(Bubble, { content: selectedOrgList.length === 0 && confirmOrgList.length === 0
|
|
164
143
|
? '请选择部门'
|
|
165
144
|
: null, className: "weda-select-user-dept__bubble", children: _jsx(Button, { type: "primary", onClick: () => onConfirm(selectedOrgList), disabled: selectedOrgList.length === 0 &&
|
|
166
145
|
confirmOrgList.length === 0, children: "\u786E\u5B9A" }) })] })] }) })] })] }) }))({
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
3
|
import { ConfigProvider } from 'tea-component';
|
|
4
4
|
// import './index.less';
|
|
5
|
-
import {
|
|
5
|
+
import { useSyncValue } from '../../../../../utils/hooks/useSyncValue';
|
|
6
|
+
import { usePlatform, isInIde } from '../../../../../utils/platform';
|
|
6
7
|
import { deepClone } from '../../../../../utils/tool';
|
|
8
|
+
import isObjectEqual from '../../../../../utils/isObjectEqual';
|
|
7
9
|
import { emptyObject, emptyArray } from '../../../../../utils/constant';
|
|
8
|
-
import { DepartTreeSelectH5 as DepartSelectH5 } from '
|
|
10
|
+
import { DepartTreeSelectH5 as DepartSelectH5 } from '../../departTreeSelect/departTreeSelect.h5';
|
|
9
11
|
import { DepartTreeSelectPC as DepartSelectPC } from './depart-select-pc';
|
|
10
|
-
import { defaultRequest } from '../../common/fetch-data-service';
|
|
11
|
-
import { setFlag, formatTree, parseStrToArr, setChildren,
|
|
12
|
-
import {
|
|
12
|
+
import { defaultRequest, getDepartByIds, } from '../../common/fetch-data-service';
|
|
13
|
+
import { setFlag, formatTree, parseStrToArr, setChildren, } from '../../common/utils';
|
|
14
|
+
import { useDepartData } from '../../hooks/use-depart-data';
|
|
13
15
|
export default function DepartTreeSelect(props) {
|
|
14
16
|
const { events = emptyObject, defaultValue = emptyArray, //默认值,支持数组
|
|
15
17
|
confirmValue = '', defaultValueType = 'noneDepart', multiple = false, onChange = null,
|
|
16
18
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
19
|
request = defaultRequest, departmentScope, } = props;
|
|
18
20
|
const platform = usePlatform();
|
|
21
|
+
// 两次默认值不同, 需要刷新
|
|
22
|
+
const prevDefaultRef = React.useRef(null);
|
|
23
|
+
// 最终选定部门id
|
|
24
|
+
const [confirmOrgIds, setConfirmOrgIds] = useSyncValue(defaultValue, isObjectEqual);
|
|
19
25
|
// 最终选定部门集合
|
|
20
26
|
const [confirmOrgList, setConfirmOrgList] = useState([]);
|
|
21
27
|
//弹窗中被选中部门集合
|
|
@@ -24,28 +30,11 @@ export default function DepartTreeSelect(props) {
|
|
|
24
30
|
errorStatus: false,
|
|
25
31
|
errorMessage: null,
|
|
26
32
|
});
|
|
27
|
-
const { orgTreeData, orgList, error } =
|
|
33
|
+
const { orgTreeData, orgList, error } = useDepartData({
|
|
28
34
|
request,
|
|
29
35
|
});
|
|
30
36
|
const [treeData, setTreeData] = useState([]);
|
|
31
37
|
const defaultExpandedIds = parseStrToArr(departmentScope);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (!isInIde()) {
|
|
34
|
-
const orgIds = filterStrList(parseStrToArr(defaultValue));
|
|
35
|
-
const defaultConfirmOrgList = getOrgItemsByIds({ ids: orgIds, orgList });
|
|
36
|
-
setConfirmOrgList(defaultConfirmOrgList);
|
|
37
|
-
}
|
|
38
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
-
}, [JSON.stringify(defaultValue), orgList]);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (defaultValueType === 'confirmDepart' && !isInIde()) {
|
|
42
|
-
const confirmOrgList = getOrgItemsByIds({
|
|
43
|
-
ids: filterStrList(parseStrToArr(confirmValue)),
|
|
44
|
-
orgList,
|
|
45
|
-
});
|
|
46
|
-
setConfirmOrgList(confirmOrgList);
|
|
47
|
-
}
|
|
48
|
-
}, [confirmValue, defaultValueType, orgList]);
|
|
49
38
|
useEffect(() => {
|
|
50
39
|
if (orgTreeData) {
|
|
51
40
|
// deepClone数组,变更对象指针,避免数据混乱
|
|
@@ -64,6 +53,38 @@ export default function DepartTreeSelect(props) {
|
|
|
64
53
|
}
|
|
65
54
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
55
|
}, [orgTreeData, departmentScope]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (defaultValueType === 'confirmDepart') {
|
|
58
|
+
setConfirmOrgIds(confirmValue);
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
}, [defaultValueType, confirmValue]);
|
|
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
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
setConfirmOrgList([]);
|
|
76
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
try {
|
|
80
|
+
if (!isObjectEqual(prevDefaultRef.current, confirmOrgIds)) {
|
|
81
|
+
getDefaultOrg(confirmOrgIds);
|
|
82
|
+
prevDefaultRef.current = confirmOrgIds;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (e) { }
|
|
86
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
87
|
+
}, [defaultValueType, confirmOrgIds]);
|
|
67
88
|
useEffect(() => {
|
|
68
89
|
var _a, _b, _c;
|
|
69
90
|
setSelectedOrgList(confirmOrgList);
|
|
@@ -90,6 +111,7 @@ export default function DepartTreeSelect(props) {
|
|
|
90
111
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
112
|
}, [confirmOrgList]);
|
|
92
113
|
const restProps = {
|
|
114
|
+
confirmOrgIds,
|
|
93
115
|
confirmOrgList,
|
|
94
116
|
setConfirmOrgList,
|
|
95
117
|
selectedOrgList,
|
|
@@ -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,8 +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 { multiple,
|
|
14
|
-
const selectedIds = useMemo(() => selectedOrgList.map((item) => item.id), [selectedOrgList]);
|
|
13
|
+
const { multiple, setSelectedOrgList, selectedOrgList, confirmOrgList, defaultExpandedIds, } = React.useContext(OrgTreeContext) || {};
|
|
15
14
|
const [searchOrgList, setSearchOrgList] = useState([]);
|
|
16
15
|
// 是否有搜索项
|
|
17
16
|
const [keyWords, setKeyWords] = useState('');
|
|
@@ -20,12 +19,13 @@ export const OrgModalPC = (props) => {
|
|
|
20
19
|
errorMessage: null,
|
|
21
20
|
});
|
|
22
21
|
const [loading, setLoading] = useState(false);
|
|
22
|
+
const selectedIds = useMemo(() => selectedOrgList.map((item) => item.id), [selectedOrgList]);
|
|
23
23
|
//搜索值变化延迟响应,节流处理
|
|
24
24
|
const onSearch = debounce((key) => {
|
|
25
25
|
try {
|
|
26
26
|
if (key && key.length > 0) {
|
|
27
27
|
setLoading(true);
|
|
28
|
-
const res = fetchSearchOrg({ key,
|
|
28
|
+
const res = fetchSearchOrg({ key, treeData });
|
|
29
29
|
setSearchOrgList(res);
|
|
30
30
|
setLoading(false);
|
|
31
31
|
}
|
|
@@ -40,31 +40,22 @@ export const OrgModalPC = (props) => {
|
|
|
40
40
|
}
|
|
41
41
|
}, 500);
|
|
42
42
|
const handleSelectedIdsChange = useCallback((ids) => {
|
|
43
|
-
|
|
44
|
-
if (ids.length
|
|
45
|
-
setSelectedOrgList([]);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
const items = [];
|
|
43
|
+
const items = [];
|
|
44
|
+
if (ids.length > 0) {
|
|
49
45
|
for (const id of ids) {
|
|
50
46
|
const item = orgList.find((i) => i.id === id);
|
|
51
47
|
if (item) {
|
|
52
48
|
items.push(item);
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
else {
|
|
59
|
-
setSelectedOrgList([]);
|
|
60
|
-
}
|
|
51
|
+
}
|
|
52
|
+
if (items.length > 0) {
|
|
53
|
+
setSelectedOrgList(items);
|
|
61
54
|
}
|
|
62
55
|
}, [orgList, setSelectedOrgList]);
|
|
63
|
-
return (_jsxs(Modal, { 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,
|
|
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,
|
|
64
57
|
//setSelectedOrgId={setSelectedOrgId}
|
|
65
|
-
isUser: false, treeData: treeData, treeDataError: treeDataError, selectable: true, defaultExpandedIds: defaultExpandedIds, onActive: (ids) => {
|
|
66
|
-
handleSelectedIdsChange(ids);
|
|
67
|
-
} }) }) }) }))] }), _jsx(SelectedList, { selectedList: selectedOrgList, isUser: false, onClose: (item) => {
|
|
58
|
+
isUser: false, treeData: treeData, treeDataError: treeDataError, selectable: true, defaultExpandedIds: defaultExpandedIds, onActive: (ids) => handleSelectedIdsChange(ids) }) }) }) }))] }), _jsx(SelectedList, { selectedList: selectedOrgList, isUser: false, onClose: (item) => {
|
|
68
59
|
setSelectedOrgList(selectedOrgList.filter((data) => data.id !== (item === null || item === void 0 ? void 0 : item.id)));
|
|
69
60
|
} })] }), _jsxs(Modal.Footer, { children: [_jsx(Button, { type: "weak", onClick: onCancel, children: "\u53D6\u6D88" }), _jsx(Bubble, { content: selectedOrgList.length === 0 && confirmOrgList.length === 0
|
|
70
61
|
? '请选择部门'
|