Commit 694fe1f0 by zhaochengxiang

关系图没有子节点不显示操作按钮

parent 462206d8
......@@ -125,7 +125,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
});
//virtual功能已去掉
if (!cfg?.virtual) {
if (!cfg?.virtual && cfg?.haveChild) {
const view = new (Chart || window.Chart)({
group,
width: raduis*2,
......@@ -226,7 +226,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
fillOpacity: 1.0,
stroke: '#fff',
strokeOpacity: 0,
cursor: (cfg.virtual)?'':'pointer',
cursor: (cfg?.virtual)?'':'pointer',
},
name: 'innnerCircle1',
draggable: true,
......@@ -242,7 +242,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
fillOpacity: 1.0,
stroke: '#fff',
strokeOpacity: 0,
cursor: (cfg.virtual)?'':'pointer',
cursor: (cfg?.virtual)?'':'pointer',
},
name: 'innnerCircle2',
draggable: true,
......@@ -258,7 +258,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
fillOpacity: 1.0,
stroke: '#fff',
strokeOpacity: 0,
cursor: (cfg.virtual)?'':'pointer',
cursor: (cfg?.virtual)?'':'pointer',
},
name: 'innnerCircle3',
draggable: true,
......@@ -275,7 +275,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
fillOpacity: 1.0,
stroke: '#fff',
strokeOpacity: 0,
cursor: (cfg.virtual)?'':'pointer',
cursor: (cfg?.virtual)?'':'pointer',
},
name: 'innnerCircle1',
draggable: true,
......@@ -291,7 +291,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
textAlign: 'center',
textBaseline: "middle",
fill: "#fff",
cursor: (cfg.virtual)?'':'pointer',
cursor: (cfg?.virtual)?'':'pointer',
},
name: 'text',
draggable: true
......@@ -300,7 +300,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
return keyShape;
},
afterDraw: (cfg, group) => {
if (!cfg?.virtual) {
if (!cfg?.virtual && cfg?.haveChild) {
const pathShape1 = group.get('children')[1];
const pathShape2 = group.get('children')[2];
const pathShape3 = group.get('children')[3];
......@@ -313,7 +313,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
setState(name, value, item) {
const model = item?.getModel();
if (!model?.virtual) {
if (!model?.virtual && model?.haveChild) {
const group = item.getContainer();
const keyShape = group.get('children')[0];
......
......@@ -79,11 +79,31 @@ const RelationContainer = (props) => {
recursion(centerDirectory.children||[], centerDirectory.nodeId, '0');
//判断是否有子节点
newNodes.forEach(node => {
const index = newNodes.findIndex(_node => _node.levelId===`${node.levelId}-0`);
node.haveChild = (index!==-1);
})
setNodes(newNodes);
generateCenterNodeRelationData(newNodes);
}
}
const judgeNodeHaveChild = (node, data = nodes) => {
let nodeLevelId = `${node.levelId}-`;
(data||[]).forEach(item => {
if (node.levelId.split('-').length<item.levelId.split('-').length && item.levelId.slice(0, nodeLevelId.length)===nodeLevelId) {
return true;
}
});
return false;
}
const generateCenterNodeRelationData = (data = nodes) => {
if ((data||[]).length===0) {
setRelationData(null);
......@@ -95,7 +115,7 @@ const RelationContainer = (props) => {
let rootNode = data[index];
let totalLevel = 1;
rootNode = {...rootNode, center: true};
rootNode = {...rootNode, center: true };
let newRelationData = {...rootNode, children: []};
......
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