Commit c530e109 by zhaochengxiang

资产浏览关系图增加资源资产根节点

parent a4ea7122
...@@ -62,6 +62,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -62,6 +62,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
draggable: true, draggable: true,
}); });
if (!cfg?.virtual) {
const view = new (Chart || window.Chart)({ const view = new (Chart || window.Chart)({
group, group,
width: raduis*2, width: raduis*2,
...@@ -135,6 +136,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -135,6 +136,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
imageShape1.hide(); imageShape1.hide();
imageShape2.hide(); imageShape2.hide();
}
group.addShape('circle', { group.addShape('circle', {
attrs: { attrs: {
...@@ -146,7 +148,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -146,7 +148,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
fillOpacity: 1.0, fillOpacity: 1.0,
stroke: '#fff', stroke: '#fff',
strokeOpacity: 0, strokeOpacity: 0,
cursor: 'pointer' cursor: (cfg.virtual)?'':'pointer',
}, },
name: 'innnerCircle', name: 'innnerCircle',
draggable: true, draggable: true,
...@@ -161,7 +163,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -161,7 +163,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
textAlign: 'center', textAlign: 'center',
textBaseline: "middle", textBaseline: "middle",
fill: "#fff", fill: "#fff",
cursor: 'pointer', cursor: (cfg.virtual)?'':'pointer',
}, },
name: 'text', name: 'text',
draggable: true draggable: true
...@@ -170,6 +172,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -170,6 +172,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
return keyShape; return keyShape;
}, },
afterDraw: (cfg, group) => { afterDraw: (cfg, group) => {
if (!cfg?.virtual) {
const pathShape1 = group.get('children')[1]; const pathShape1 = group.get('children')[1];
const pathShape2 = group.get('children')[2]; const pathShape2 = group.get('children')[2];
const pathShape3 = group.get('children')[3]; const pathShape3 = group.get('children')[3];
...@@ -177,8 +180,12 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -177,8 +180,12 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
pathShape1?.hide(); pathShape1?.hide();
pathShape2?.hide(); pathShape2?.hide();
pathShape3?.hide(); pathShape3?.hide();
}
}, },
setState(name, value, item) { setState(name, value, item) {
const model = item?.getModel();
if (!model?.virtual) {
const group = item.getContainer(); const group = item.getContainer();
const keyShape = group.get('children')[0]; const keyShape = group.get('children')[0];
...@@ -207,6 +214,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -207,6 +214,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
imageShape2?.hide(); imageShape2?.hide();
} }
} }
}
}, },
}) })
...@@ -296,12 +304,13 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -296,12 +304,13 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
const item = e.item; const item = e.item;
const model = item?.getModel(); const model = item?.getModel();
console.log('e.target?.cfg?.name', e.target?.cfg?.name); if (!model?.virtual) {
if (e.target?.cfg?.name === 'center-icon') { if (e.target?.cfg?.name === 'center-icon') {
onCenterClick && onCenterClick(model?.id); onCenterClick && onCenterClick(model?.id);
} else if (e.target?.cfg?.name==='expand-icon' || e.target?.cfg?.name==='innnerCircle' || e.target?.cfg?.name==='text') { } else if (e.target?.cfg?.name==='expand-icon' || e.target?.cfg?.name==='innnerCircle' || e.target?.cfg?.name==='text') {
onExpandClick && onExpandClick(model?.id); onExpandClick && onExpandClick(model?.id);
} }
}
}) })
function clearAllStats() { function clearAllStats() {
......
...@@ -92,7 +92,10 @@ const RelationContainer = (props) => { ...@@ -92,7 +92,10 @@ const RelationContainer = (props) => {
const index = (data||[]).findIndex(node => node.id === nodeParams?.centerId); const index = (data||[]).findIndex(node => node.id === nodeParams?.centerId);
if (index !== -1) { if (index !== -1) {
const rootNode = data[index]; let rootNode = data[index];
rootNode = {...rootNode, center: true};
let newRelationData = {...rootNode, children: []}; let newRelationData = {...rootNode, children: []};
function recursion(subData, parentId) { function recursion(subData, parentId) {
...@@ -111,6 +114,16 @@ const RelationContainer = (props) => { ...@@ -111,6 +114,16 @@ const RelationContainer = (props) => {
} }
recursion(newRelationData.children, rootNode.id); recursion(newRelationData.children, rootNode.id);
const _index = (dirs||[]).findIndex(dir => dir.nodeId === rootNode.id);
if (_index !== -1) {
if (reference === AssetBrowseReference) {
newRelationData = {text: '资产', show: true, simple: false, virtual: true, children: [newRelationData]};
} else if (reference === ResourceBrowseReference) {
newRelationData = {text: '资源', show: true, simple: false, virtual: true, children: [newRelationData]};
}
}
setRelationData(newRelationData); setRelationData(newRelationData);
} }
} }
...@@ -123,7 +136,9 @@ const RelationContainer = (props) => { ...@@ -123,7 +136,9 @@ const RelationContainer = (props) => {
const index = (data||[]).findIndex((node) => node.id === nodeParams?.expandId); const index = (data||[]).findIndex((node) => node.id === nodeParams?.expandId);
if (index !== -1) { if (index !== -1) {
const currentNode = data[index]; let currentNode = data[index];
currentNode = {...currentNode, expand: true};
(data||[]).forEach(node => { (data||[]).forEach(node => {
......
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