Commit b5c4262f by zhaochengxiang

浏览增加关系图

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