Commit 694fe1f0 by zhaochengxiang

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

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