Commit 446b1489 by zhaochengxiang

修改bug

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