@cloudbase/weda-ui 3.1.9 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs/components/chart/bar.json +3 -3
- package/dist/configs/components/chart/line.json +3 -3
- package/dist/configs/components/chart/pie.json +3 -3
- package/dist/configs/components/form/departTreeSelect.json +124 -0
- package/dist/configs/components/form/userTreeSelect.json +128 -0
- package/dist/configs/components/formdetail.json +105 -0
- package/dist/configs/components/listView.json +9 -1
- package/dist/configs/components/lottery.json +1 -1
- package/dist/configs/components/tabs.json +10 -9
- package/dist/configs/components/wxOpenApi/share.json +5 -2
- package/dist/configs/index.d.ts +6 -0
- package/dist/configs/index.js +6 -0
- package/dist/web/components/calendar/index.js +10 -2
- package/dist/web/components/carousel/index.js +4 -0
- package/dist/web/components/chart/common/core/eChartBase.js +8 -2
- package/dist/web/components/form/form/index.js +10 -7
- package/dist/web/components/form/location/common/mapChoose.js +2 -0
- package/dist/web/components/form/location/common/mapView.js +2 -0
- package/dist/web/components/form/location/components/LocationH5/location.h5.js +3 -1
- package/dist/web/components/form/location/components/LocationH5/location.module.css +3 -0
- package/dist/web/components/form/select/h5.js +4 -0
- package/dist/web/components/form/select/index.js +2 -8
- package/dist/web/components/form/switch/index.js +3 -2
- package/dist/web/components/form/switch/switch.module.css +7 -0
- package/dist/web/components/form/uploader/uploader.h5.d.ts +1 -0
- package/dist/web/components/form/uploader/uploader.h5.js +14 -10
- package/dist/web/components/form/uploader/uploader.pc.js +1 -1
- package/dist/web/components/form/uploaderFile/uploadFile.h5.js +14 -12
- package/dist/web/components/form/uploaderFile/uploadFile.pc.js +8 -8
- package/dist/web/components/form/userOrgSelect/comTool.d.ts +7 -0
- package/dist/web/components/form/userOrgSelect/comTool.js +89 -0
- package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.d.ts +20 -0
- package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +259 -0
- package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.d.ts +4 -0
- package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +153 -0
- package/dist/web/components/form/userOrgSelect/departTreeSelect/index.d.ts +2 -0
- package/dist/web/components/form/userOrgSelect/departTreeSelect/index.js +17 -0
- package/dist/web/components/form/userOrgSelect/index.d.ts +2 -0
- package/dist/web/components/form/userOrgSelect/index.js +17 -0
- package/dist/web/components/form/userOrgSelect/userOrgSelect.less +643 -0
- package/dist/web/components/form/userOrgSelect/userTreeSelect.h5.d.ts +24 -0
- package/dist/web/components/form/userOrgSelect/userTreeSelect.h5.js +276 -0
- package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.d.ts +9 -0
- package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.js +229 -0
- package/dist/web/components/form/userOrgSelect/utils.d.ts +35 -0
- package/dist/web/components/form/userOrgSelect/utils.js +72 -0
- package/dist/web/components/formdetail/index.css +115 -0
- package/dist/web/components/formdetail/index.d.ts +28 -0
- package/dist/web/components/formdetail/index.js +170 -0
- package/dist/web/components/index.d.ts +3 -0
- package/dist/web/components/index.js +3 -0
- package/dist/web/components/listView/index.css +35 -5
- package/dist/web/components/listView/index.js +92 -68
- package/dist/web/components/listView/interface.d.ts +5 -0
- package/dist/web/components/lottery/index.js +2 -1
- package/dist/web/components/lottery/lotteryUtil.js +1 -0
- package/dist/web/components/navigationBar/index.css +21 -29
- package/dist/web/components/richText/index.css +1 -0
- package/dist/web/components/swiper/index.js +5 -1
- package/dist/web/components/wedaVideo/index.js +1 -0
- package/dist/web/utils/getUserService.d.ts +17 -0
- package/dist/web/utils/getUserService.js +148 -0
- package/dist/web/utils/platform.js +2 -0
- package/dist/web/weda-ui.css +9 -0
- package/package.json +13 -12
- package/dist/asset-manifest.json +0 -17
- package/dist/index.html +0 -88
- package/dist/static/js/bundle.js +0 -963
- package/dist/static/js/bundle.js.map +0 -1
- package/dist/static/js/main.chunk.js +0 -8841
- package/dist/static/js/main.chunk.js.map +0 -1
- package/dist/static/js/vendors~main.chunk.js +0 -247885
- package/dist/static/js/vendors~main.chunk.js.map +0 -1
- package/dist/static/media/ef6fa527e24e354765d806b826b41391.fa67580a.svg +0 -627
- package/dist/web/components/auth/index.d.ts +0 -10
- package/dist/web/components/auth/index.js +0 -37
- package/dist/web/utils/events.d.ts +0 -1
- package/dist/web/utils/events.js +0 -2
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { emptyObject } from '../../../../utils/constant';
|
|
3
|
+
import { renderDecorator } from '../../renderDecorator';
|
|
4
|
+
import { IconFont } from 'tdesign-icons-react';
|
|
5
|
+
import classNames from '../../../../utils/classnames';
|
|
6
|
+
import { getDepartById, defaultRequest, } from '../../../../utils/getUserService';
|
|
7
|
+
import { dealOrgData } from '../utils';
|
|
8
|
+
import { Modal, Button, ConfigProvider, Radio, Status } from 'tea-component';
|
|
9
|
+
import isObjectEqual from '../../../../utils/isObjectEqual';
|
|
10
|
+
import '../userOrgSelect.less';
|
|
11
|
+
import { ErrorStatus } from '../comTool';
|
|
12
|
+
export function DepartTreeSelectH5({ id, className, style, events = emptyObject, label = '部门选择', labelVisible = true, name = 'formDepartTreeSelect', placeholder = '请选择部门', defaultValueType = 'noneDepart', defaultValue = '', confirmValue = '', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', decorator, request = defaultRequest, multiple = false, onChange = null, focus: autoFocus = false, getDepartByIdRequest = getDepartById, }) {
|
|
13
|
+
const cls = classNames({
|
|
14
|
+
'weda-ui': true,
|
|
15
|
+
'weda-select-user-dept': true,
|
|
16
|
+
[className]: className,
|
|
17
|
+
});
|
|
18
|
+
const subCls = classNames({
|
|
19
|
+
'weui-cell': true,
|
|
20
|
+
'weui-cell_active': true,
|
|
21
|
+
'weui-cell_form': true,
|
|
22
|
+
'weui-cell_disabled': disabled,
|
|
23
|
+
});
|
|
24
|
+
// 两次默认值不同, 需要刷新
|
|
25
|
+
const prevDefaultRef = React.useRef(null);
|
|
26
|
+
const prevConfirmRef = React.useRef(null);
|
|
27
|
+
const [value, setValue] = useState(null);
|
|
28
|
+
const [visible, setVisible] = React.useState(false);
|
|
29
|
+
const [isSearch, setIsSearch] = useState(false);
|
|
30
|
+
const [orgsTreeData, setOrgsTreeData] = useState([]);
|
|
31
|
+
const [originalOrgData, setOriginalOrgData] = useState([]);
|
|
32
|
+
const [count, setCount] = useState(1); //计数弹窗显示层级
|
|
33
|
+
const [selectItem, setSelectItem] = useState(null);
|
|
34
|
+
const [searchValue, setSearchValue] = useState('');
|
|
35
|
+
const [loading, setLoading] = useState({ id: null, status: false });
|
|
36
|
+
const [errorInfo, setErrorInfo] = useState({
|
|
37
|
+
errorStatus: false,
|
|
38
|
+
errorMessage: null,
|
|
39
|
+
});
|
|
40
|
+
const handleFocus = (value) => {
|
|
41
|
+
setIsSearch(value);
|
|
42
|
+
};
|
|
43
|
+
const cancleSearch = () => {
|
|
44
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
45
|
+
handleFocus(false);
|
|
46
|
+
setSearchValue('');
|
|
47
|
+
initOrgsData();
|
|
48
|
+
};
|
|
49
|
+
const changeSearchValue = async (event) => {
|
|
50
|
+
var _a;
|
|
51
|
+
try {
|
|
52
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
53
|
+
const sValue = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value;
|
|
54
|
+
setSearchValue(sValue);
|
|
55
|
+
if (sValue) {
|
|
56
|
+
const { Users = [], Orgs = [] } = await request('SearchByCondition', {
|
|
57
|
+
KeyWords: sValue.trim(),
|
|
58
|
+
SearchCondition: {
|
|
59
|
+
SearchType: 'SearchByOrg',
|
|
60
|
+
NeedUser: false,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
setOrgsTreeData(dealOrgData(Orgs));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
setSearchValue('');
|
|
67
|
+
initOrgsData();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const onInputChange = function (e) {
|
|
75
|
+
const text = typeof e === 'string' ? e : e.target.value;
|
|
76
|
+
const newValue = text;
|
|
77
|
+
setValue(newValue);
|
|
78
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
79
|
+
events.change({ value: newValue }, { originEvent: e });
|
|
80
|
+
};
|
|
81
|
+
const onFocus = function () {
|
|
82
|
+
setSearchValue('');
|
|
83
|
+
initOrgsData();
|
|
84
|
+
setVisible(true);
|
|
85
|
+
};
|
|
86
|
+
const onClose = () => {
|
|
87
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
88
|
+
setVisible(false);
|
|
89
|
+
initOrgsData();
|
|
90
|
+
};
|
|
91
|
+
const onConfirm = (selectItem) => {
|
|
92
|
+
var _a;
|
|
93
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
94
|
+
setValue(selectItem === null || selectItem === void 0 ? void 0 : selectItem.content);
|
|
95
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(selectItem === null || selectItem === void 0 ? void 0 : selectItem.orgId);
|
|
96
|
+
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: selectItem === null || selectItem === void 0 ? void 0 : selectItem.orgId, data: selectItem });
|
|
97
|
+
setVisible(false);
|
|
98
|
+
};
|
|
99
|
+
//获取组织结构
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
initOrgsData();
|
|
102
|
+
if ((defaultValue &&
|
|
103
|
+
!isObjectEqual(prevDefaultRef.current !== defaultValue)) ||
|
|
104
|
+
(confirmValue && !isObjectEqual(prevConfirmRef.current !== confirmValue))) {
|
|
105
|
+
getdefaultUser();
|
|
106
|
+
prevDefaultRef.current = defaultValue;
|
|
107
|
+
prevConfirmRef.current = confirmValue;
|
|
108
|
+
}
|
|
109
|
+
}, [defaultValueType, confirmValue, defaultValue]);
|
|
110
|
+
const getdefaultUser = async () => {
|
|
111
|
+
var _a;
|
|
112
|
+
try {
|
|
113
|
+
if ((defaultValueType === 'confirmDepart' && confirmValue.length !== 0) ||
|
|
114
|
+
defaultValue.length !== 0) {
|
|
115
|
+
const orgId = confirmValue.length !== 0 ? confirmValue : defaultValue;
|
|
116
|
+
const defaultDepart = await getDepartById({
|
|
117
|
+
_id: orgId,
|
|
118
|
+
});
|
|
119
|
+
setValue(defaultDepart);
|
|
120
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(orgId);
|
|
121
|
+
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: orgId, data: { content: defaultDepart } });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
// 初始化数据
|
|
129
|
+
const initOrgsData = async () => {
|
|
130
|
+
try {
|
|
131
|
+
const resData = (await request('InitRootOrgs', {})) || [];
|
|
132
|
+
const data = dealOrgData(resData);
|
|
133
|
+
setOrgsTreeData(data);
|
|
134
|
+
setOriginalOrgData([{ index: count, treeData: data }]);
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
//点击部门节点,获取子部门节点
|
|
141
|
+
const loadDepartData = async (node, count) => {
|
|
142
|
+
try {
|
|
143
|
+
setLoading({ id: node.orgId, status: true });
|
|
144
|
+
const { Orgs = [], Users = [] } = await request('LazyDescribeOrgs', {
|
|
145
|
+
OrgId: node.orgId,
|
|
146
|
+
DescribeCondition: {
|
|
147
|
+
NeedUser: true,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
// 如果不存在数据
|
|
151
|
+
if (!(Orgs === null || Orgs === void 0 ? void 0 : Orgs.length)) {
|
|
152
|
+
orgsTreeData.forEach((item, index, orgsTreeData) => {
|
|
153
|
+
if (item.id == node.id) {
|
|
154
|
+
orgsTreeData[index].expandable = false;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
setOrgsTreeData([...orgsTreeData]);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const children = dealOrgData(Orgs);
|
|
161
|
+
setOrgsTreeData(children);
|
|
162
|
+
originalOrgData.push({ index: count + 1, treeData: children });
|
|
163
|
+
setCount(count + 1);
|
|
164
|
+
setOriginalOrgData(originalOrgData);
|
|
165
|
+
}
|
|
166
|
+
setLoading({ id: null, status: false });
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
//判断当前页结构为第几层,如首次渲染则添加至orgsTreeData,二次进入刷新index数据
|
|
173
|
+
const retLevel = (count) => {
|
|
174
|
+
const storageOriTreeData = [];
|
|
175
|
+
if (count !== 1) {
|
|
176
|
+
originalOrgData.map((item) => {
|
|
177
|
+
if ((item === null || item === void 0 ? void 0 : item.index) < count) {
|
|
178
|
+
storageOriTreeData.push(item);
|
|
179
|
+
if ((item === null || item === void 0 ? void 0 : item.index) === count - 1) {
|
|
180
|
+
setCount(count - 1);
|
|
181
|
+
setOrgsTreeData((item === null || item === void 0 ? void 0 : item.treeData) || []);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
setOriginalOrgData(storageOriTreeData);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
onClose();
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
return renderDecorator(React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
|
|
195
|
+
React.createElement("div", { className: subCls },
|
|
196
|
+
React.createElement("div", { className: "weui-cell__bd weui-flex" },
|
|
197
|
+
React.createElement("input", { className: "weui-input", placeholder: placeholder, value: value, disabled: disabled, name: name, autoFocus: autoFocus, onChange: onInputChange, onClick: onFocus, readOnly: true, role: "input" })),
|
|
198
|
+
React.createElement(Modal, { visible: visible, onClose: onClose, destroyOnClose: true, className: `weda-ui weda-select-user-dept__dialog` },
|
|
199
|
+
React.createElement(Modal.Body, { className: (selectItem === null || selectItem === void 0 ? void 0 : selectItem.userId) ? 'is-selected-value' : '' },
|
|
200
|
+
React.createElement("div", { className: "weda-select-user-dept__dialog-header", id: count.toString() },
|
|
201
|
+
React.createElement("div", { className: count == 1 ? '' : 'arrow-left', onClick: () => retLevel(count) }),
|
|
202
|
+
"\u9009\u62E9\u90E8\u95E8"),
|
|
203
|
+
React.createElement("div", { className: classNames({
|
|
204
|
+
'weda-select-user-dept__dialog-search': true,
|
|
205
|
+
'weda-select-user-dept__dialog-search-focus': isSearch,
|
|
206
|
+
}) },
|
|
207
|
+
React.createElement("div", { className: "weda-select-user-dept__dialog-search-box" },
|
|
208
|
+
React.createElement("input", { type: "text", onFocus: () => {
|
|
209
|
+
handleFocus(true);
|
|
210
|
+
}, value: searchValue, onClick: (e) => {
|
|
211
|
+
e.stopPropagation();
|
|
212
|
+
}, onChange: changeSearchValue, className: "weda-select-user-dept__dialog-search-input" }),
|
|
213
|
+
React.createElement("div", { className: classNames({
|
|
214
|
+
'weda-select-user-dept__dialog-label': true,
|
|
215
|
+
'weda-select-user-dept__dialog-label-value': searchValue,
|
|
216
|
+
}) },
|
|
217
|
+
React.createElement("span", { className: "search-icon" }),
|
|
218
|
+
React.createElement("span", { className: "search-placeholder" }, "\u641C\u7D22")),
|
|
219
|
+
searchValue && searchValue.length > 0 && (React.createElement("div", { className: "weda-select-user-dept__dialog-input-clear", onClick: changeSearchValue },
|
|
220
|
+
React.createElement("p", { className: "weda-select-user-dept__dialog-input-clear-close" })))),
|
|
221
|
+
React.createElement("span", { className: "weda-select-user-dept__dialog-search-cancel", onClick: cancleSearch }, "\u53D6\u6D88")),
|
|
222
|
+
(errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.errorStatus) ? (React.createElement(ErrorStatus, { size: "l", title: "\u63A5\u53E3\u8C03\u7528\u5931\u8D25", description: (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.errorMessage) || null })) : orgsTreeData && orgsTreeData.length > 0 ? (React.createElement("div", { className: classNames('weda-select-user-dept__dialog-list') }, orgsTreeData.map((item, index) => (React.createElement("div", { className: "weda-select-user-dept__list-item", key: item === null || item === void 0 ? void 0 : item.id },
|
|
223
|
+
React.createElement("div", { className: "weda-select-user-dept__list-item-wrap" },
|
|
224
|
+
React.createElement(Radio.Group, { value: selectItem === null || selectItem === void 0 ? void 0 : selectItem.orgId, onChange: (value) => {
|
|
225
|
+
setSelectItem(item);
|
|
226
|
+
}, layout: "column" },
|
|
227
|
+
React.createElement(Radio, { name: item === null || item === void 0 ? void 0 : item.orgId },
|
|
228
|
+
React.createElement("div", { className: "weda-select-user-dept__item-detail" },
|
|
229
|
+
React.createElement("div", { className: "item-name" }, item === null || item === void 0 ? void 0 : item.content)))),
|
|
230
|
+
(item === null || item === void 0 ? void 0 : item.expandable) && loading.id !== item.orgId && (React.createElement("div", { className: "lcap-icon lcap-icon-chevronright", onClick: () => {
|
|
231
|
+
loadDepartData(item, count);
|
|
232
|
+
} })),
|
|
233
|
+
loading.id === item.orgId && (loading === null || loading === void 0 ? void 0 : loading.status) && (React.createElement("div", null,
|
|
234
|
+
React.createElement(IconFont, { name: "loading", className: `weda-grid-navigation__fonticon depart_loading` }))))))))) : (React.createElement(Status, { className: "dim-tree-select--blank", icon: 'blank', size: 's', title: `暂无部门数据` }))),
|
|
235
|
+
React.createElement(Modal.Footer, null,
|
|
236
|
+
React.createElement("div", null,
|
|
237
|
+
selectItem && (React.createElement("div", { className: "weda-select-user-dept__select-result" },
|
|
238
|
+
React.createElement("div", { className: "weda-select-user-dept__select-label" }, "\u5DF2\u9009\u62E9"),
|
|
239
|
+
React.createElement("div", { className: "weda-select-user-dept__result-list" },
|
|
240
|
+
React.createElement("div", { className: "weda-select-user-dept__result-item", onClick: () => {
|
|
241
|
+
setSelectItem(null);
|
|
242
|
+
setSearchValue(null);
|
|
243
|
+
} },
|
|
244
|
+
selectItem.content,
|
|
245
|
+
React.createElement("div", { className: "close" }))))),
|
|
246
|
+
React.createElement("div", { className: "weda-select-user-dept__btn-group" },
|
|
247
|
+
React.createElement(Button, { type: "weak", onClick: onClose }, "\u53D6\u6D88"),
|
|
248
|
+
React.createElement(Button, { type: "primary", onClick: () => onConfirm(selectItem) }, "\u786E\u5B9A"))))))))({
|
|
249
|
+
id,
|
|
250
|
+
className: cls,
|
|
251
|
+
style,
|
|
252
|
+
label: labelVisible ? label : null,
|
|
253
|
+
multiCell: false,
|
|
254
|
+
requiredFlag,
|
|
255
|
+
layout,
|
|
256
|
+
size,
|
|
257
|
+
decorator,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IDepartTreeSelec } from './departTreeSelect.h5';
|
|
3
|
+
import '../userOrgSelect.less';
|
|
4
|
+
export declare function DepartTreeSelectPC({ id, className, style, events, label, labelVisible, name, defaultValue, confirmValue, placeholder, defaultValueType, disabled, layout, requiredFlag, size, multiple, onChange, decorator, relation, request, getDepartByIdRequest, }: IDepartTreeSelec): JSX.Element;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { emptyObject } from '../../../../utils/constant';
|
|
3
|
+
import { renderDecorator } from '../../renderDecorator';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { Dropdown, ConfigProvider, Text } from 'tea-component';
|
|
6
|
+
import { getNode, getRelationData, dealOrgData } from '../utils';
|
|
7
|
+
import { getDepartById, defaultRequest, } from '../../../../utils/getUserService';
|
|
8
|
+
import '../userOrgSelect.less';
|
|
9
|
+
import { DimTreeContent } from '../comTool';
|
|
10
|
+
import isObjectEqual from '../../../../utils/isObjectEqual';
|
|
11
|
+
export function DepartTreeSelectPC({ id, className, style, events = emptyObject, label = '人员选择', labelVisible = true, name = 'formUserTreeSelect', defaultValue = '', confirmValue = '', placeholder = '请选择人员', defaultValueType = 'noneDepart', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', multiple = false, onChange = null, decorator, relation, request = defaultRequest, getDepartByIdRequest = getDepartById, }) {
|
|
12
|
+
// 两次默认值不同, 需要刷新
|
|
13
|
+
const prevDefaultRef = React.useRef(null);
|
|
14
|
+
const prevConfirmRef = React.useRef(null);
|
|
15
|
+
const [selectIds, setSelectIds] = useState([]);
|
|
16
|
+
// 用户单选
|
|
17
|
+
const [curSelectItem, setCurSelectItem] = useState({
|
|
18
|
+
orgId: null,
|
|
19
|
+
content: '',
|
|
20
|
+
});
|
|
21
|
+
const [treeData, setTreeData] = useState([]);
|
|
22
|
+
// 节点高亮
|
|
23
|
+
const [activeIds, setActiveIds] = useState([]);
|
|
24
|
+
//鼠标移入移除输入框
|
|
25
|
+
const [moveIn, setMoveIn] = useState(false);
|
|
26
|
+
const [open, setOpen] = useState(false);
|
|
27
|
+
const [originalTreeData, setOriginalTreeData] = useState([]);
|
|
28
|
+
const [errorInfo, setErrorInfo] = useState({
|
|
29
|
+
errorStatus: false,
|
|
30
|
+
errorMessage: null,
|
|
31
|
+
});
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
initOrgsData();
|
|
34
|
+
if ((defaultValue &&
|
|
35
|
+
!isObjectEqual(prevDefaultRef.current !== defaultValue)) ||
|
|
36
|
+
(confirmValue && !isObjectEqual(prevConfirmRef.current !== confirmValue))) {
|
|
37
|
+
getdefaultUser();
|
|
38
|
+
prevDefaultRef.current = defaultValue;
|
|
39
|
+
prevConfirmRef.current = confirmValue;
|
|
40
|
+
}
|
|
41
|
+
}, [defaultValueType, confirmValue, defaultValue]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (open) {
|
|
44
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
45
|
+
const orgId = (curSelectItem === null || curSelectItem === void 0 ? void 0 : curSelectItem.orgId) || null;
|
|
46
|
+
const node = getNode(treeData, orgId, 'orgId');
|
|
47
|
+
setActiveIds(node ? [node.id] : []);
|
|
48
|
+
setSelectIds(node ? [node.id] : []);
|
|
49
|
+
}
|
|
50
|
+
}, [open, treeData]);
|
|
51
|
+
// 初始化数据
|
|
52
|
+
const initOrgsData = async () => {
|
|
53
|
+
try {
|
|
54
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
55
|
+
const resData = (await request('InitRootOrgs', {})) || [];
|
|
56
|
+
const data = dealOrgData(resData);
|
|
57
|
+
setTreeData(data);
|
|
58
|
+
setOriginalTreeData([...data]);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const getdefaultUser = async () => {
|
|
65
|
+
var _a;
|
|
66
|
+
try {
|
|
67
|
+
if ((defaultValueType === 'confirmDepart' && confirmValue.length !== 0) ||
|
|
68
|
+
defaultValue.length !== 0) {
|
|
69
|
+
const orgId = confirmValue.length !== 0 ? confirmValue : defaultValue;
|
|
70
|
+
const defaultUser = await getDepartByIdRequest({
|
|
71
|
+
_id: orgId,
|
|
72
|
+
});
|
|
73
|
+
setCurSelectItem({ orgId: orgId, content: defaultUser });
|
|
74
|
+
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: orgId, data: { content: defaultUser } });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
setErrorInfo({ errorStatus: true, errorMessage: e });
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const reset = (close) => {
|
|
82
|
+
setSelectIds([]);
|
|
83
|
+
setCurSelectItem({ orgId: null, content: '' });
|
|
84
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
85
|
+
setActiveIds([]);
|
|
86
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
87
|
+
close && setOpen(false);
|
|
88
|
+
};
|
|
89
|
+
// 外层组件类
|
|
90
|
+
const cls = classNames({
|
|
91
|
+
'weda-ui': true,
|
|
92
|
+
'weda-user-tree-select': true,
|
|
93
|
+
[className]: className,
|
|
94
|
+
});
|
|
95
|
+
return renderDecorator(React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
|
|
96
|
+
React.createElement("div", { onMouseEnter: () => {
|
|
97
|
+
setMoveIn(true);
|
|
98
|
+
}, onMouseLeave: () => {
|
|
99
|
+
setMoveIn(false);
|
|
100
|
+
} },
|
|
101
|
+
React.createElement(Dropdown, { className: classNames(`department-tree-select`, `size-${size}`), destroyOnClose: false, open: open, onOpenChange: (open) => {
|
|
102
|
+
setOpen(open);
|
|
103
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
104
|
+
}, button: React.createElement(SelectViewContainer, { curSelectItem: curSelectItem, multiple: multiple, placeholder: "\u8BF7\u9009\u62E9\u90E8\u95E8", moveIn: moveIn, onChange: () => reset(true) }), style: { width: '100%' }, appearance: multiple ? 'pure' : 'button', clickClose: false, disabled: disabled }, () => (React.createElement("div", { className: "dim-tree-select" },
|
|
105
|
+
React.createElement(DimTreeContent, { data: treeData, setTreeData: setTreeData, selectedIds: selectIds, activeIds: activeIds, needUser: false, request: request, errorInfo: errorInfo, searchType: "SearchByOrg", onActive: (ids) => {
|
|
106
|
+
setActiveIds(ids);
|
|
107
|
+
setSelectIds(ids);
|
|
108
|
+
}, onReset: () => setTreeData(originalTreeData), onCancel: () => {
|
|
109
|
+
setOpen(false);
|
|
110
|
+
setErrorInfo({ errorStatus: false, errorMessage: null });
|
|
111
|
+
}, onClear: () => reset(false), onConfirm: () => {
|
|
112
|
+
var _a;
|
|
113
|
+
const selectId = selectIds === null || selectIds === void 0 ? void 0 : selectIds[0];
|
|
114
|
+
if (selectId) {
|
|
115
|
+
const node = getNode(treeData, selectId, 'id');
|
|
116
|
+
if (node) {
|
|
117
|
+
setCurSelectItem(node);
|
|
118
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(node.orgId);
|
|
119
|
+
setOpen(false);
|
|
120
|
+
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: node.orgId, data: node });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} })))))))({
|
|
124
|
+
id,
|
|
125
|
+
className: cls,
|
|
126
|
+
style,
|
|
127
|
+
label: labelVisible ? label : null,
|
|
128
|
+
layout,
|
|
129
|
+
multiCell: false,
|
|
130
|
+
requiredFlag,
|
|
131
|
+
size,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const SelectViewContainer = (props) => {
|
|
135
|
+
const { curSelectItem, placeholder, onChange, moveIn } = props;
|
|
136
|
+
if (!(curSelectItem === null || curSelectItem === void 0 ? void 0 : curSelectItem.orgId))
|
|
137
|
+
return React.createElement(Text, { className: "placeholder" }, placeholder);
|
|
138
|
+
return (React.createElement(React.Fragment, null,
|
|
139
|
+
React.createElement(ViewCell, { data: curSelectItem, showType: "tree", relation: undefined }),
|
|
140
|
+
moveIn && (React.createElement(React.Fragment, null,
|
|
141
|
+
React.createElement("div", { className: "weda-select-user-dept__dialog-input-clear", onClick: (e) => {
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
onChange === null || onChange === void 0 ? void 0 : onChange();
|
|
144
|
+
} },
|
|
145
|
+
React.createElement("p", { className: "weda-select-user-dept__dialog-input-clear-close" }))))));
|
|
146
|
+
};
|
|
147
|
+
const ViewCell = ({ data, showType, relation }) => {
|
|
148
|
+
if (showType === 'tree') {
|
|
149
|
+
return React.createElement(Text, { verticalAlign: "middle" }, (data === null || data === void 0 ? void 0 : data.content) || '-');
|
|
150
|
+
}
|
|
151
|
+
const defaultValue = getRelationData(relation);
|
|
152
|
+
return (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.id) ? (React.createElement(Text, { verticalAlign: "middle" }, defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.content)) : (React.createElement(Text, null, "-"));
|
|
153
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ConfigProvider } from 'tea-component';
|
|
3
|
+
// import './index.less';
|
|
4
|
+
import { usePlatform } from '../../../../utils/platform';
|
|
5
|
+
import { DepartTreeSelectH5 as DepartSelectH5 } from './departTreeSelect.h5';
|
|
6
|
+
import { DepartTreeSelectPC as DepartSelectPC } from './departTreeSelect.pc';
|
|
7
|
+
export default function DepartTreeSelect(props) {
|
|
8
|
+
const platform = usePlatform();
|
|
9
|
+
if ((props === null || props === void 0 ? void 0 : props.showType) === 'pc') {
|
|
10
|
+
return React.createElement(DepartSelectPC, { ...props });
|
|
11
|
+
}
|
|
12
|
+
if ((props === null || props === void 0 ? void 0 : props.showType) === 'h5') {
|
|
13
|
+
return React.createElement(DepartSelectH5, { ...props });
|
|
14
|
+
}
|
|
15
|
+
return platform === 'h5' ? (React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
|
|
16
|
+
React.createElement(DepartSelectH5, { ...props }))) : (React.createElement(DepartSelectPC, { ...props }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ConfigProvider } from 'tea-component';
|
|
3
|
+
// import './index.less';
|
|
4
|
+
import { usePlatform } from '../../../utils/platform';
|
|
5
|
+
import { UserTreeSelectH5 as UserSelectH5 } from './userTreeSelect.h5';
|
|
6
|
+
import { UserTreeSelectPC as UserSelectPC } from './userTreeSelect.pc';
|
|
7
|
+
export default function UserTreeSelect(props) {
|
|
8
|
+
const platform = usePlatform();
|
|
9
|
+
if ((props === null || props === void 0 ? void 0 : props.showType) === 'pc') {
|
|
10
|
+
return React.createElement(UserSelectPC, { ...props });
|
|
11
|
+
}
|
|
12
|
+
if ((props === null || props === void 0 ? void 0 : props.showType) === 'h5') {
|
|
13
|
+
return React.createElement(UserSelectH5, { ...props });
|
|
14
|
+
}
|
|
15
|
+
return platform === 'h5' ? (React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
|
|
16
|
+
React.createElement(UserSelectH5, { ...props }))) : (React.createElement(UserSelectPC, { ...props }));
|
|
17
|
+
}
|