Commit 52a1093c authored by 陈前坚's avatar 陈前坚

perf: 机构树

parent 585aa752
......@@ -154,7 +154,7 @@ const MiniMenu = props => {
icon:
obj.menuType !== 'MiniAppMenuThree' &&
obj.menuType !== 'MiniAppMenu' ? (
<FolderFilled />
<FolderFilled />
) : (
<FileOutlined />
),
......
......@@ -347,7 +347,7 @@ const UserManage = () => {
// 点击树节点,获取当前机构下所有用户
const onSelect = (props, e) => {
console.log(e);
// console.log(props);
setTableLoading(true);
if (e) {
setOrgTitle(e.node.title);
......@@ -358,39 +358,44 @@ const UserManage = () => {
setCurrentSelectOrg(props[0]);
}
setOrgID(props[0] || currentSelectOrg);
getOneOUUserListNew(props[0] || currentSelectOrg)
.then(res => {
if (res.code === 0) {
setTableLoading(false);
setSearchWord(''); // 搜索框置空
setOrgTitle(res.data.GroupName);
// 返回用户表数据结构处理,扁平化
const temp = flatten(getUsers(res.data));
// 设置过滤字段
let arr = temp.map(item => item.OUName);
arr = arr.filter((value, index) => arr.indexOf(value) === index);
setOrgFilters(arr.map(item => ({ text: item, value: item })));
console.log(temp);
setTableLength(temp.length);
const table = temp.map((item, index) => {
item.key = index;
item.phoneCopy = item.phone;
item.phone = item.phone || '-';
return item;
});
setTableData(table);
} else {
// 树节点变化(即props不为空)时才请求,避免重复请求
if (props[0]) {
getOneOUUserListNew(props[0] || currentSelectOrg)
.then(res => {
if (res.code === 0) {
setTableLoading(false);
setSearchWord(''); // 搜索框置空
setOrgTitle(res.data.GroupName);
// 返回用户表数据结构处理,扁平化
const temp = flatten(getUsers(res.data));
// 设置过滤字段
let arr = temp.map(item => item.OUName);
arr = arr.filter((value, index) => arr.indexOf(value) === index);
setOrgFilters(arr.map(item => ({ text: item, value: item })));
console.log(temp);
setTableLength(temp.length);
const table = temp.map((item, index) => {
item.key = index;
item.phoneCopy = item.phone;
item.phone = item.phone || '-';
return item;
});
setTableData(table);
} else {
setTableLoading(false);
notification.error({
message: '获取失败',
description: res.message,
});
}
})
.catch(err => {
setTableLoading(false);
notification.error({
message: '获取失败',
description: res.message,
});
}
})
.catch(err => {
setTableLoading(false);
message.error(err);
});
message.error(err);
});
} else {
setTableLoading(false);
}
};
// 返回用户表数据结构处理,扁平化
......@@ -1130,7 +1135,8 @@ const UserManage = () => {
showLine={{ showLeafIcon: false }}
blockNode
autoExpandParent
expandedKeys={[currentSelectOrg]}
// expandedKeys={[currentSelectOrg]}
defaultExpandAll
selectedKeys={[currentSelectOrg]}
onSelect={onSelect}
treeData={treeData.map(t => mapTree(t))}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment