Browse Source

Merge branch 'small-tupu' of http://124.70.32.114:3100/jianzhenyu/Changsha_tupu into hanyuqing

# Conflicts:
#	gyxtp/src/view/graphPageCopy0926.vue
small-tupu
hanyuqing 6 months ago
parent
commit
88cb9fb046
  1. 643
      gyxtp/src/view/graphPageCopy0926.vue

643
gyxtp/src/view/graphPageCopy0926.vue

@ -191,18 +191,54 @@
</span>
</div>
</div>
<div class="selectListInfo"
style="z-index: 2000;
max-height:35vw;
border-radius: 2px;
padding: 5px 0;
background-color: rgba(76,100,233,0.3) ;position:absolute;left: 5vw;top: 12vw;font-size: 0.9vw;overflow-y: scroll;margin-left: 1vw;margin-right: 1vw;">
<div class="flow-tree" :class="{ 'flow-tree-active': i === currentShowLeve }" v-for="i in currentGroup === 2 ? [1, 2] : [1, 2, 3, 4]" style="padding: 0vw 2vw;" @click="changeLeve(i)">
<span class="custom-tree-node" style="display: flex;flex-direction: row;">
<div class="lineInfo" :class="{ 'lineInfo-active': i === currentShowLeve }" style="width: 0.2vw;height: 0.8vw; box-shadow: #FFFFFF 0px 0px 4px 1px;
background: rgb(255, 255, 255);display: inline-block;
margin-top: 0.6vw;margin-right: 0.5vw;"></div>
<div class="label1" style="color: #ffffff;font-size: 1.1vw;cursor: pointer;line-height: 2vw;">展示层级{{i}}</div>
</span>
</div>
</div>
<div class="graphContent">
<div :class="full ? 'full-screen' : 'show-box'">
<!-- 节点右键菜单 -->
<div style="width: 100%;height: 100%;">
<div class="gContainer">
<div ref="myPage" class="gContainer" @click="isShowNodeMenuPanel = false">
<RelationGraph ref="graphRef" :options="graphOptions" :nodes="graphData.nodes" :links="graphData.links"
:on-node-click="onNodeClick"
:on-line-click="onLineClick"
:on-node-expand="onNodeExpand"
:on-node-collapse="onNodeCollapse"
/>
>
<template #node="{node}">
<div style="height: 100%; " @click="showNodeMenus(node, $event)"
@contextmenu.prevent.stop="showNodeMenus(node, $event)">
<div style="width: 80%; position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);font-size: 30px"
>
{{ node.text }}
</div>
</div>
</template>
</RelationGraph>
<div v-show="isShowNodeMenuPanel" :style="{left: nodeMenuPanelPosition.x + 'px', top: nodeMenuPanelPosition.y + 'px' }" style="z-index: 999;padding:10px;background-color: #ffffff;border:#eeeeee solid 1px;box-shadow: 0px 0px 8px #cccccc;position: absolute;border-radius: 10px;">
<div style="line-height: 25px;padding-left: 10px;color: #888888;font-size: 12px;">对这个节点进行操作</div>
<div class="c-node-menu-item" @click.stop="toNodeInfo">查看节点</div>
<div class="c-node-menu-item" @click.stop="showOrHide">{{currentNode.expanded?'收回':'扩展'}}</div>
</div>
</div>
</div>
@ -261,6 +297,9 @@ export default {
},
data() {
return {
isShowCodePanel: false,
isShowNodeMenuPanel: false,
nodeMenuPanelPosition: { x: 0, y: 0 },
currentGroup:1,
direction: "rtl",
// visGraph
@ -290,12 +329,6 @@ export default {
data: [] //
},
graphOptions: {
// /
defaultExpandHolderPosition: 'right', // 'left' 'right'
defaultExpandHolderSize: 16,
defaultExpandHolderColor: '#fff',
defaultExpandHolderBorder: '1px solid #00d7e0',
isMoveByParentNode: true,
allowSwitchLineShape: true,
allowSwitchJunctionPoint: true,
defaultLineColor: '#2E74B5',
@ -317,15 +350,8 @@ export default {
// 使 center
layout: {
layoutName: 'center', // 使 center
from: 'center', //
levelDistance: '700,700,900,900,1000,1000,1000,1000', //
nodeDistance: 20, //
min_per_width: 300, //
max_per_width: 500,
clockwise: true, //
levelDistance: '1000,1000,1000,1000,3000,3000,3000,3000', //
startAngle: -Math.PI / 2, // -90°
preventOverlap: true, //
distance_coefficient: 5,
}
},
currentNode: {}, //
@ -401,22 +427,49 @@ export default {
level: 'titleLevel',
docLevel: 'docLevel',
},
heightlightTable:[]
heightlightTable:[],
currentShowLeve:1,
}
},
methods: {
changeGroup(groupId){
this.currentGroup = groupId
this.getInfo()
showNodeMenus(nodeObject, $event) {
this.currentNode = nodeObject;
const _base_position = this.$refs.myPage.getBoundingClientRect();
this.isShowNodeMenuPanel = true;
this.nodeMenuPanelPosition.x = $event.clientX - _base_position.x;
this.nodeMenuPanelPosition.y = $event.clientY - _base_position.y;
},
onNodeCollapse(node, e) {
this.$refs.graphRef.refresh();
showOrHide(){
this.currentNode.expanded = !this.currentNode.expanded
const graphInstance = this.$refs.graphRef.getInstance();
graphInstance.doLayout()
},
toNodeInfo() {
let nodeObject = this.currentNode
console.log(nodeObject)
const data = {
'id': nodeObject.data.docId,
'docTitle': nodeObject.text,
}
getDocInfo(data).then((res) => {
localStorage.setItem("docUrl", res.data.docUrl)
this.$router.push({
name: 'docInfo',
query: {
title: res.data.docTitle,
level: res.data.docLevel,
keyword: res.data.docTitle,
docId: res.data.id
}
})
});
//
onNodeExpand(node, e) {
this.$refs.graphRef.refresh();
this.isShowNodeMenuPanel = false;
},
changeGroup(groupId){
this.currentGroup = groupId
this.getInfo()
},
handleNodeClick(node) {
console.log(node);
@ -538,8 +591,8 @@ export default {
data.g13["docTitle"] = data.g13["name"]
data.g14["level"] = 1
data.g14["docTitle"] = data.g14["name"]
// data.g15["level"] = 1
// data.g15["docTitle"] = data.g15["name"]
data.g15["level"] = 1
data.g15["docTitle"] = data.g15["name"]
data.g21["level"] = 1
data.g21["docTitle"] = data.g21["name"]
data.g22["level"] = 1
@ -553,7 +606,7 @@ export default {
this.data1.push(data.g12)
this.data1.push(data.g13)
this.data1.push(data.g14)
// this.data1.push(data.g15)
this.data1.push(data.g15)
this.data1.push(data.g21)
this.data1.push(data.g22)
})
@ -661,7 +714,6 @@ export default {
return found ? 'nodeclass' : 'nodeclassnormal';
},
getLinesClass(mergedDbIds) {
console.log("44444444444444")
const lines = this.heightLight.links;
if (lines == undefined){
return ""
@ -723,9 +775,46 @@ export default {
// line.sourceAsMap.data
this.drawer = true;
},
//
//
//
getNodeColor(leve){
let color = ""
switch (leve) {
case "0":
color = '#ffd602';
break;
case "1":
color = 'rgb(64, 158, 255)';
break;
case "2":
color = '#ff8c00';
break;
case "3":
color = '#67c23a';
break;
case "4":
color = 'rgb(248,143,248)';
break;
case "5":
color = 'rgb(65,154,255)';
break;
case "6":
color = 'rgb(0,228,255)';
break;
default:
color = 'rgba(255, 255, 255, 0.6)';
}
console.log(color)
return color;
},
getExpanded(leve){
if (leve<this.currentShowLeve){
return true
}
return false
},
changeLeve(leve){
this.currentShowLeve = leve
this.getInfo()
},
zhengl(data) {
console.log(data)
const nodes = []
@ -733,12 +822,6 @@ export default {
const nodeList = data.nodes;
const lineList = data.links;
// 便
const nodeMap = {};
nodeList.forEach(node => {
nodeMap[node.id] = node;
});
//
const connectedNodeIds = new Set();
lineList.forEach(line => {
@ -746,423 +829,74 @@ export default {
connectedNodeIds.add(line.target);
});
//
const isolatedNodesByGroupAndLevel = {};
nodeList.forEach(node => {
// docLeve
const nodesByLevel = {};
for (let i = 0; i < nodeList.length; i++) {
const node = nodeList[i];
if (node.groupId == this.currentGroup || node.docLeve == "0") {
//
if (Number(node.docLeve) > this.currentShowLeve) {
if (!connectedNodeIds.has(node.id)) {
const groupId = node.groupId || '1';
const level = node.docLeve || '0';
if (!isolatedNodesByGroupAndLevel[groupId]) {
isolatedNodesByGroupAndLevel[groupId] = {};
continue;
}
if (!isolatedNodesByGroupAndLevel[groupId][level]) {
isolatedNodesByGroupAndLevel[groupId][level] = [];
}
isolatedNodesByGroupAndLevel[groupId][level].push(node);
}
});
//
const levelGroupPositions = {};
//
if (nodeList != undefined) {
//
const groupedNodes = {
'0': {levels: {}},
'1': {levels: {}},
'2': {levels: {}}
};
//
nodeList.forEach(node => {
if (connectedNodeIds.has(node.id)) {
const groupId = node.groupId || '1';
const level = node.docLeve || '1';
if (!groupedNodes[groupId]) groupedNodes[groupId] = {levels: {}};
if (!groupedNodes[groupId].levels[level]) groupedNodes[groupId].levels[level] = [];
groupedNodes[groupId].levels[level].push(node);
const level = Number(node.docLeve);
if (!nodesByLevel[level]) {
nodesByLevel[level] = [];
}
nodesByLevel[level].push(node);
}
}
});
//
const groupOffsets = {
'0': -10200, //
'1': 0, //
'2': 10200 //
};
//
const baseRadius = 1200; //
const centerX = 0, centerY = 0;
//
Object.keys(groupedNodes).forEach(groupId => {
const groupData = groupedNodes[groupId];
const groupOffsetX = groupOffsets[groupId] || 0;
//
Object.keys(groupData.levels).sort().forEach(level => {
const levelNodes = groupData.levels[level].sort((a, b) => a.docId - b.docId);
const levelNum = parseInt(level);
// X
const startX = groupOffsetX - (levelNodes.length * 200) / 2;
//
const levelGroupKey = `${levelNum}_${groupId}`;
if (!levelGroupPositions[levelGroupKey]) {
levelGroupPositions[levelGroupKey] = {
minX: startX,
maxX: startX + levelNodes.length * 200,
leftAvailableX: startX - 200, //
rightAvailableX: startX + 200, //
hasConnectedNodes: levelNodes.length > 0
};
}
//
Object.keys(nodesByLevel).forEach(levelStr => {
const level = Number(levelStr);
const levelNodes = nodesByLevel[level];
const total = levelNodes.length;
const radius = level === 0 ? 0 : level * baseRadius; // level 0
levelNodes.forEach((node, index) => {
if (levelNum === 0) this.rootId = node.id;
//
let color, fontSize, fontColor;
switch (levelNum) {
case 0:
color = 'rgb(227,203,0)';
fontSize = '30px';
fontColor = 'rgb(255,255,255)';
break;
case 1:
color = 'rgb(47,47,230)';
fontSize = '30px';
fontColor = 'rgb(255,255,255)';
break;
case 2:
color = 'rgb(255,138,0)';
fontSize = '30px';
fontColor = 'rgb(255,255,255)';
break;
case 3:
color = 'rgb(30,255,0)';
fontSize = '30px';
fontColor = 'rgb(0,0,0)';
break;
case 4:
color = 'rgb(248,143,248)';
fontSize = '30px';
fontColor = 'rgb(255,255,255)';
break;
case 5:
color = 'rgb(65,154,255)';
fontSize = '30px';
fontColor = 'rgb(255,255,255)';
break;
case 6:
color = 'rgb(0,228,255)';
fontSize = '30px';
fontColor = 'rgb(0,0,0)';
break;
default:
color = 'rgb(200,200,200)';
fontSize = '30px';
fontColor = 'rgb(255,255,255)';
}
const x = startX + index * 200;
// groupId '1' Y
const y = groupId === '1' ? levelNum * -1400 : levelNum * 1400;
let x, y;
if (level === 0) {
//
x = 0;
y = 0;
} else {
//
const angle = (2 * Math.PI / total) * index; //
x = centerX + radius * Math.cos(angle);
y = centerY + radius * Math.sin(angle);
}
if (node.groupId==this.currentGroup || node.docLeve=="0"){
//
nodes.push({
fontSize:100,
id: node.id,
text: node.name,
data: {
docId: node.docId,
group: node.groupId
},
level: levelNum,
// x: x,
// y: y,
// fixed: true,
width: 220,
height: 220,
color: color,
font: `normal ${fontSize} Arial`,
// html:"<div><span>"+node.name+"</span></div>",
fontColor: fontColor,
level: node.docLeve,
x: x,
y: y,
fixed: true, //
width: 250,
height: 250,
color: this.getNodeColor(node.docLeve),
expandHolderPosition: 'right',
expanded: true,
styleClass:this.getNodeClass(node.name),
expanded: this.getExpanded(node.docLeve),
styleClass: this.getNodeClass(node.name),
});
}
});
});
});
}
// - 线
// Object.keys(isolatedNodesByGroupAndLevel).sort().forEach(groupId => {
// const groupData = isolatedNodesByGroupAndLevel[groupId];
// const groupOffsetX = groupId === '0' ? -10200 : groupId === '1' ? 0 : 10200;
//
// Object.keys(groupData).sort().forEach(level => {
// const levelNodes = groupData[level];
// const levelNum = parseInt(level);
//
// // Y
// const y = groupId === '1' ? levelNum * -1400 : levelNum * 1400;
//
// //
// const levelGroupKey = `${levelNum}_${groupId}`;
//
// // docId
// const sortedIsolatedNodes = levelNodes.sort((a, b) => a.docId - b.docId);
//
// if (!levelGroupPositions[levelGroupKey] || !levelGroupPositions[levelGroupKey].hasConnectedNodes) {
// //
// const totalWidth = sortedIsolatedNodes.length * 200;
// const startX = groupOffsetX - totalWidth / 2;
//
// //
// sortedIsolatedNodes.forEach((node, index) => {
// //
// let color, fontSize, fontColor;
// switch (levelNum) {
// case 0:
// color = 'rgb(227,203,0)';
// fontSize = '70px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 1:
// color = 'rgb(47,47,230)';
// fontSize = '68px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 2:
// color = 'rgb(255,138,0)';
// fontSize = '50px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 3:
// color = 'rgb(30,255,0)';
// fontSize = '40px';
// fontColor = 'rgb(0,0,0)';
// break;
// case 4:
// color = 'rgb(248,143,248)';
// fontSize = '32px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 5:
// color = 'rgb(65,154,255)';
// fontSize = '30px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 6:
// color = 'rgb(0,228,255)';
// fontSize = '28px';
// fontColor = 'rgb(0,0,0)';
// break;
// default:
// color = 'rgb(200,200,200)';
// fontSize = '24px';
// fontColor = 'rgb(255,255,255)';
// }
//
// const x = startX + index * 200;
//
// if (node.groupId==this.currentGroup || node.docLeve=="0"){
// //
// nodes.push({
// id: node.id,
// text: node.name,
// data: {
// docId: node.docId,
// group: node.groupId
// },
// level: levelNum,
// // x: x,
// // y: y,
// // fixed: true,
// width: 150,
// height: 150,
// color: color,
// font: `normal ${fontSize} Arial`,
// fontColor: fontColor,
// expandHolderPosition: 'right',
// expanded: true,
// styleClass:this.getNodeClass(node.name),
// });
// }
// });
// } else {
// //
// const positionInfo = levelGroupPositions[levelGroupKey];
//
// //
// const leftNodes = [];
// const rightNodes = [];
//
// sortedIsolatedNodes.forEach((node, index) => {
// if (index % 2 === 0) {
// leftNodes.push(node); //
// } else {
// rightNodes.push(node); //
// }
// });
//
// //
// let currentLeftX = positionInfo.leftAvailableX;
// for (let i = leftNodes.length - 1; i >= 0; i--) {
// const node = leftNodes[i];
//
// //
// let color, fontSize, fontColor;
// switch (levelNum) {
// case 0:
// color = 'rgb(227,203,0)';
// fontSize = '70px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 1:
// color = 'rgb(47,47,230)';
// fontSize = '68px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 2:
// color = 'rgb(255,138,0)';
// fontSize = '50px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 3:
// color = 'rgb(30,255,0)';
// fontSize = '40px';
// fontColor = 'rgb(0,0,0)';
// break;
// case 4:
// color = 'rgb(248,143,248)';
// fontSize = '32px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 5:
// color = 'rgb(65,154,255)';
// fontSize = '30px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 6:
// color = 'rgb(0,228,255)';
// fontSize = '28px';
// fontColor = 'rgb(0,0,0)';
// break;
// default:
// color = 'rgb(200,200,200)';
// fontSize = '24px';
// fontColor = 'rgb(255,255,255)';
// }
//
// if (node.groupId==this.currentGroup || node.docLeve=="0"){
// //
// nodes.push({
// id: node.id,
// text: node.name,
// data: {
// docId: node.docId,
// group: node.groupId
// },
// level: levelNum,
// // x: x,
// // y: y,
// // fixed: true,
// width: 150,
// height: 150,
// color: color,
// font: `normal ${fontSize} Arial`,
// fontColor: fontColor,
// expandHolderPosition: 'right',
// expanded: true,
// styleClass:this.getNodeClass(node.name),
// });
// }
//
// currentLeftX -= 200;
// }
//
// //
// let currentRightX = positionInfo.rightAvailableX;
// rightNodes.forEach(node => {
// //
// let color, fontSize, fontColor;
// switch (levelNum) {
// case 0:
// color = 'rgb(227,203,0)';
// fontSize = '70px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 1:
// color = 'rgb(47,47,230)';
// fontSize = '68px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 2:
// color = 'rgb(255,138,0)';
// fontSize = '50px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 3:
// color = 'rgb(30,255,0)';
// fontSize = '40px';
// fontColor = 'rgb(0,0,0)';
// break;
// case 4:
// color = 'rgb(248,143,248)';
// fontSize = '32px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 5:
// color = 'rgb(65,154,255)';
// fontSize = '30px';
// fontColor = 'rgb(255,255,255)';
// break;
// case 6:
// color = 'rgb(0,228,255)';
// fontSize = '28px';
// fontColor = 'rgb(0,0,0)';
// break;
// default:
// color = 'rgb(200,200,200)';
// fontSize = '24px';
// fontColor = 'rgb(255,255,255)';
// }
//
// if (node.groupId==this.currentGroup || node.docLeve=="0"){
// //
// nodes.push({
// id: node.id,
// text: node.name,
// data: {
// docId: node.docId,
// group: node.groupId
// },
// level: levelNum,
// // x: x,
// // y: y,
// // fixed: true,
// width: 150,
// height: 150,
// color: color,
// font: `normal ${fontSize} Arial`,
// fontColor: fontColor,
// expandHolderPosition: 'right',
// expanded: true,
// styleClass:this.getNodeClass(node.name),
// });
// }
//
// currentRightX += 200;
// });
// }
// });
// });
// 线
lineList.forEach(line => {
@ -1172,15 +906,18 @@ export default {
style=this.getLinesClass(line.DbId)
num=10
}
//
links.push({
id:line.DbId,
from: line.source,
to: line.target,
text: line.relate || '相关',
color:
line.num <= 5 ? '#fff' : //
line.num <= 10 ? '#0f0' : // 绿
line.num <= 15 ? '#ff0' : //
line.num <= 5 ? 'rgb(255, 255, 255)' : //
line.num <= 10 ? 'rgb(0, 255, 0)' : // 绿
line.num <= 15 ? 'rgb(255, 255, 0)' : //
'rgb(178,246,255)', // line.num <= 2020
lineWidth:num,
lineShape: 1,
@ -1213,23 +950,18 @@ export default {
})
},
onNodeClick(nodeObject, $event) {
console.log(nodeObject)
const data = {
'id': nodeObject.data.docId,
'docTitle': nodeObject.text,
console.log(nodeObject.id)
const graphInstance = this.$refs.graphRef.getInstance();
let node = graphInstance.getNodeById(nodeObject.id)
let relinks = graphInstance.getLinesByNode(node);
for (let i=0;i<relinks.length;i++){
if (graphInstance.getLinesByNode(node)[i].lineWidth == 10){
graphInstance.getLinesByNode(node)[i].lineWidth = 1
}else{
graphInstance.getLinesByNode(node)[i].lineWidth = 10
}
getDocInfo(data).then((res) => {
localStorage.setItem("docUrl", res.data.docUrl)
this.$router.push({
name: 'docInfo',
query: {
title: res.data.docTitle,
level: res.data.docLevel,
keyword: res.data.docTitle,
docId: res.data.id
}
})
});
}
},
created() {
@ -1849,7 +1581,7 @@ tr {
stroke: white !important;
stroke-width: 3 !important;
stroke-opacity: 1 !important;
font-size: 20px !important;
/* 多层光晕:内层青色,外层白色 */
filter:
drop-shadow(0 0 20px rgba(0, 255, 255, 1)) /* 内层青色光晕 */
@ -1861,7 +1593,7 @@ tr {
paint-order: stroke fill !important;
}
.nodeclassnormal{
font-size: 30px !important;
font-size: 20px !important;
}
.el-table .warning-row {
background: oldlace;
@ -1909,7 +1641,4 @@ tr {
.flow-tree:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.c-node-text{
}
</style>
Loading…
Cancel
Save