Commit b5c4262f by zhaochengxiang

浏览增加关系图

parent 3f5c3384
...@@ -15,28 +15,22 @@ const relationTypes = [ ...@@ -15,28 +15,22 @@ const relationTypes = [
title: '热力图', title: '热力图',
key: 'thermodynamic' key: 'thermodynamic'
}, },
{ // {
title: '数据地图', // title: '数据地图',
key: 'map', // key: 'map',
} // }
] ]
const RelationContainer = (props) => { const RelationContainer = (props) => {
const { nodeParams, onChange, reference, resize } = props; const { nodeParams, onChange, reference, resize, dirs } = props;
const [ type, setType ] = useState('relation'); const [ type, setType ] = useState('relation');
const [ dirs, setDirs ] = useState([]);
const [ nodes, setNodes ] = useState([]); const [ nodes, setNodes ] = useState([]);
const [ relationData, setRelationData ] = useState(null); const [ relationData, setRelationData ] = useState(null);
const [ thermodynamicData, setThermodynamicData ] = useState(null); const [ thermodynamicData, setThermodynamicData ] = useState(null);
useEffect(() => { useEffect(() => {
getDirectoryData();
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
useEffect(() => {
if (type === 'relation') { if (type === 'relation') {
if ((nodeParams?.expandId||'') !== '') { if ((nodeParams?.expandId||'') !== '') {
generateExpandNodeRelationData(); generateExpandNodeRelationData();
...@@ -55,25 +49,6 @@ const RelationContainer = (props) => { ...@@ -55,25 +49,6 @@ const RelationContainer = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [nodeParams, dirs, type]) }, [nodeParams, dirs, type])
const getDirectoryData = () => {
let url = '';
if (reference === AssetBrowseReference) {
url = 'assetmanage.queryAssetDirectoryAsTree';
} else if (reference === ResourceBrowseReference) {
url = 'assetmanage.queryResourceDirectoryAsTree';
}
dispatch({
type: url,
callback: data => {
let newDirs = [...data];
newDirs = (newDirs||[]).filter(item => item.type!=='custom');
setDirs(newDirs);
}
});
}
const generateNodes = () => { const generateNodes = () => {
let centerDirectory = {}; let centerDirectory = {};
...@@ -204,7 +179,6 @@ const RelationContainer = (props) => { ...@@ -204,7 +179,6 @@ const RelationContainer = (props) => {
} }
}) })
console.log('data', data)
setNodes(data); setNodes(data);
generateCenterNodeRelationData(data); generateCenterNodeRelationData(data);
......
...@@ -24,6 +24,7 @@ const AssetBrowse = (props) => { ...@@ -24,6 +24,7 @@ const AssetBrowse = (props) => {
const [ resizeRelation, setResizeRelation ] = useState(false); const [ resizeRelation, setResizeRelation ] = useState(false);
const [ assetFullScreen, setAssetFullScreen ] = useState(false); const [ assetFullScreen, setAssetFullScreen ] = useState(false);
const [ nodeAllowdLoadDataAsset, setNodeAllowdLoadDataAsset ] = useState(false); const [ nodeAllowdLoadDataAsset, setNodeAllowdLoadDataAsset ] = useState(false);
const [dirs, setDirs] = useState()
const { centerId, expandId } = nodeParams; const { centerId, expandId } = nodeParams;
...@@ -72,7 +73,7 @@ const AssetBrowse = (props) => { ...@@ -72,7 +73,7 @@ const AssetBrowse = (props) => {
axis='x' axis='x'
minConstraints={[230, Infinity]} maxConstraints={[Infinity, Infinity]} minConstraints={[230, Infinity]} maxConstraints={[Infinity, Infinity]}
> >
<AssetTree centerId={centerId} onSelect={onTreeSelect} reference={reference} {...props} /> <AssetTree centerId={centerId} onSelect={onTreeSelect} reference={reference} getDirs={(val) => setDirs(val)} {...props} />
</ResizableBox> </ResizableBox>
{ {
expandTree && <Separate width={15} /> expandTree && <Separate width={15} />
...@@ -82,15 +83,15 @@ const AssetBrowse = (props) => { ...@@ -82,15 +83,15 @@ const AssetBrowse = (props) => {
<Separate height={15} /> */} <Separate height={15} /> */}
<div className='flex' style={{ flex: 1, height: '100%', overflow: 'hidden' }}> <div className='flex' style={{ flex: 1, height: '100%', overflow: 'hidden' }}>
{ {
// expandRelation && <React.Fragment> expandRelation && <React.Fragment>
// <div style={{ flex: 1, height: '100%', overflow: 'hidden' }}> <div style={{ flex: 1, height: '100%', overflow: 'hidden' }}>
// <RelationContainer reference={reference} nodeParams={nodeParams} onChange={onRelationChange} resize={resizeRelation} /> <RelationContainer reference={reference} nodeParams={nodeParams} onChange={onRelationChange} resize={resizeRelation} dirs={dirs} />
// </div> </div>
// <Separate width={15} /> <Separate width={15} />
// </React.Fragment> </React.Fragment>
} }
<div style={{ flex: 1, overflow: 'hidden' }}> <div style={{ flex: 1, overflow: 'hidden' }}>
<AssetTable nodeId={centerId} nodeType={nodeParams.nodeType} nodeAllowdLoadDataAsset={nodeAllowdLoadDataAsset} reference={reference} onCountChange={onAssetCountChange} onFullScreenChange={onFullScreenChange} {...props} /> <AssetTable nodeId={expandId?expandId:centerId} nodeType={nodeParams.nodeType} nodeAllowdLoadDataAsset={nodeAllowdLoadDataAsset} reference={reference} onCountChange={onAssetCountChange} onFullScreenChange={onFullScreenChange} {...props} />
</div> </div>
</div> </div>
<div className='tree-toggle' onClick={treeToggleClick}> <div className='tree-toggle' onClick={treeToggleClick}>
......
...@@ -43,7 +43,7 @@ const AssetTree = (props) => { ...@@ -43,7 +43,7 @@ const AssetTree = (props) => {
id: MENU_ID, id: MENU_ID,
}); });
const { onSelect, onCheck, tableId, reference=AssetBrowseReference, centerId } = props; const { onSelect, onCheck, tableId, reference=AssetBrowseReference, centerId, getDirs } = props;
const [ keyword, setKeyword ] = useState(''); const [ keyword, setKeyword ] = useState('');
const [ loading, setLoading ] = useState(false); const [ loading, setLoading ] = useState(false);
const [ treeData, setTreeData ] = useState([]); const [ treeData, setTreeData ] = useState([]);
...@@ -107,6 +107,10 @@ const AssetTree = (props) => { ...@@ -107,6 +107,10 @@ const AssetTree = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [centerId]) }, [centerId])
useEffect(() => {
getDirs?.(treeData)
}, [treeData])
const storageChange = (e) => { const storageChange = (e) => {
if (e.key === 'assetDirChangeEvent') { if (e.key === 'assetDirChangeEvent') {
if ((e.dirId||'') !== '') { if ((e.dirId||'') !== '') {
...@@ -142,7 +146,7 @@ const AssetTree = (props) => { ...@@ -142,7 +146,7 @@ const AssetTree = (props) => {
getAllDirectoryAsTree(true, _dirId) getAllDirectoryAsTree(true, _dirId)
} else { } else {
onSelect?.('', '', false) onSelect?.('', '', false)
getAllDirectoryAsTree(false) getAllDirectoryAsTree(true)
} }
} }
}, },
...@@ -456,10 +460,7 @@ const AssetTree = (props) => { ...@@ -456,10 +460,7 @@ const AssetTree = (props) => {
} }
const onTreeSelect = (keys, { node }) => { const onTreeSelect = (keys, { node }) => {
if ((keys||[]).length === 0) { if ((keys||[]).length === 0) {
setCurrentDirId();
onSelect?.('', '', false);
return; return;
} }
...@@ -597,7 +598,7 @@ const AssetTree = (props) => { ...@@ -597,7 +598,7 @@ const AssetTree = (props) => {
onSelect?.(null, null, false); onSelect?.(null, null, false);
setTimeout(() => { setTimeout(() => {
onSelect?.('', '', false); onSelect?.('', '', false);
getAllDirectoryAsTree(false) getAllDirectoryAsTree(true)
}, 100) }, 100)
}} }}
style={{ width: 100 }} style={{ width: 100 }}
......
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