Commit 446b1489 by zhaochengxiang

修改bug

parent e8e1c80f
......@@ -53,6 +53,7 @@ const AssetManageTree = (props) => {
const [ autoExpandParent, setAutoExpandParent ] = useState(false);
const [ currentDirId, setCurrentDirId ] = useState('');
const [ currentDirType, setCurrentDirType ] = useState('');
const [ currentDir, setCurrentDir ] = useState({});
const [ currentRightClickDir, setCurrentRightClickDir ] = useState({});
const [ importDirectoryVisible, setImportDirectoryVisible ] = useState(false);
const [ updateDirectoryModalVisible, setUpdateDirectoryModalVisible ] = useState(false);
......@@ -229,6 +230,7 @@ const AssetManageTree = (props) => {
setCurrentDirId(defaultItem.nodeId);
setCurrentDirType(defaultItem.type||'');
setCurrentDir(defaultItem);
onSelect && onSelect(defaultItem.nodeId, defaultItem.type||'', defaultItem.level);
}
}
......@@ -276,6 +278,7 @@ const AssetManageTree = (props) => {
setCurrentDirId(defaultItem.nodeId);
setCurrentDirType(defaultItem.type||'');
setCurrentDir(defaultItem)
onSelect && onSelect(defaultItem.nodeId, defaultItem.type||'', defaultItem.level);
}
}
......@@ -360,9 +363,25 @@ const AssetManageTree = (props) => {
return type;
}
const getCurrentDir = (key, tree) => {
let dir = undefined;
(tree||[]).forEach(node => {
if (node.nodeId === key) {
dir = node
} else if (node.children) {
if (getCurrentDir(key, node.children)) {
dir = getCurrentDir(key, node.children);
}
}
})
return dir;
}
const addDir = () => {
if (currentDirType==='custom') return;
if (currentDir?.resourceType==='custom') return;
setUpdateDirectoryAction('add');
setUpdateDirectoryModalVisible(true);
......@@ -499,8 +518,10 @@ const AssetManageTree = (props) => {
setCurrentDirId(keys[0]);
const _currentDirType = getCurrentType(keys[0], treeData);
const _currentDir = getCurrentDir(keys[0], treeData);
setCurrentDirType(_currentDirType);
setCurrentDir(_currentDir);
onSelect && onSelect(keys[0], _currentDirType, node.level);
}
......@@ -685,7 +706,7 @@ const AssetManageTree = (props) => {
}}
>
<Tooltip title="新增目录">
<PlusOutlined className={(currentDirType==='custom')?'disable': 'default'} onClick={addDir} style={{ fontSize:16,cursor: (currentDirType==='custom')?'not-allowed':'pointer' }}/>
<PlusOutlined className={(currentDir?.resourceType==='custom')?'disable': 'default'} onClick={addDir} style={{ fontSize:16,cursor: (currentDirType==='custom')?'not-allowed':'pointer' }}/>
</Tooltip>
<Tooltip title="刷新目录">
<ReloadOutlined className='default' onClick={refreshTree} style={{ fontSize:16,cursor:'pointer' }} />
......
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