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

perf: 机构树

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