Commit c530e109 by zhaochengxiang

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

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