|
@@ -45,6 +45,8 @@ register({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// **画布**
|
|
|
const graphRef = ref(null)
|
|
|
let graph = null
|
|
@@ -66,7 +68,7 @@ const NodeData = {
|
|
|
nodeId: '1-1',
|
|
|
nodeName: '信息接报',
|
|
|
state: '已完成',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 0
|
|
|
},
|
|
|
{
|
|
@@ -74,7 +76,7 @@ const NodeData = {
|
|
|
nodeId: '1-2',
|
|
|
nodeName: '信息核实',
|
|
|
state: '已完成',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 55
|
|
|
},
|
|
|
{
|
|
@@ -82,7 +84,7 @@ const NodeData = {
|
|
|
nodeId: '1-3',
|
|
|
nodeName: '快速评估',
|
|
|
state: '已完成',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 110
|
|
|
},
|
|
|
{
|
|
@@ -90,7 +92,7 @@ const NodeData = {
|
|
|
nodeId: '1-4',
|
|
|
nodeName: '信息上报',
|
|
|
state: '已完成',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 165
|
|
|
},
|
|
|
{
|
|
@@ -108,7 +110,7 @@ const NodeData = {
|
|
|
nodeId: '2-1',
|
|
|
nodeName: '李梦康',
|
|
|
state: '已完成',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 240
|
|
|
},
|
|
|
{
|
|
@@ -118,7 +120,7 @@ const NodeData = {
|
|
|
|
|
|
nodeName: '毛超',
|
|
|
state: '已完成',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 295
|
|
|
},
|
|
|
{
|
|
@@ -127,7 +129,7 @@ const NodeData = {
|
|
|
nodeId: '2-3',
|
|
|
nodeName: '贾子敏',
|
|
|
state: '进行中',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 350
|
|
|
},
|
|
|
{
|
|
@@ -135,7 +137,7 @@ const NodeData = {
|
|
|
nodeId: '2-2-1',
|
|
|
nodeName: '病例管理',
|
|
|
state: '已完成',
|
|
|
- x: 420,
|
|
|
+ x: 440,
|
|
|
y: 210
|
|
|
},
|
|
|
{
|
|
@@ -143,7 +145,7 @@ const NodeData = {
|
|
|
nodeId: '2-2-2',
|
|
|
nodeName: '流行病学调查',
|
|
|
state: '已完成',
|
|
|
- x: 420,
|
|
|
+ x: 440,
|
|
|
y: 265
|
|
|
},
|
|
|
{
|
|
@@ -151,7 +153,7 @@ const NodeData = {
|
|
|
nodeId: '2-2-3',
|
|
|
nodeName: '实验室检测',
|
|
|
state: '已完成',
|
|
|
- x: 420,
|
|
|
+ x: 440,
|
|
|
y: 320
|
|
|
},
|
|
|
{
|
|
@@ -159,7 +161,7 @@ const NodeData = {
|
|
|
nodeId: '2-2-4',
|
|
|
nodeName: '风险评估',
|
|
|
state: '已完成',
|
|
|
- x: 420,
|
|
|
+ x: 440,
|
|
|
y: 375
|
|
|
},
|
|
|
{
|
|
@@ -178,7 +180,7 @@ const NodeData = {
|
|
|
nodeId: '3-1',
|
|
|
nodeName: '段伟',
|
|
|
state: '已完成',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 420
|
|
|
},
|
|
|
{
|
|
@@ -187,7 +189,7 @@ const NodeData = {
|
|
|
nodeId: '3-2',
|
|
|
nodeName: '陆成奇',
|
|
|
state: '已完成',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 475
|
|
|
},
|
|
|
{
|
|
@@ -196,7 +198,7 @@ const NodeData = {
|
|
|
nodeId: '3-3',
|
|
|
nodeName: '曾强',
|
|
|
state: '进行中',
|
|
|
- x: 240,
|
|
|
+ x: 220,
|
|
|
y: 530
|
|
|
},
|
|
|
|
|
@@ -206,8 +208,8 @@ const NodeData = {
|
|
|
nodeId: '3-3-1',
|
|
|
nodeName: '病例管理',
|
|
|
state: '已完成',
|
|
|
- x: 420,
|
|
|
- y:450
|
|
|
+ x: 440,
|
|
|
+ y: 450
|
|
|
},
|
|
|
{
|
|
|
level: 3,
|
|
@@ -215,8 +217,8 @@ const NodeData = {
|
|
|
nodeId: '3-3-2',
|
|
|
nodeName: '流行病学调查',
|
|
|
state: '已完成',
|
|
|
- x: 420,
|
|
|
- y:505
|
|
|
+ x: 440,
|
|
|
+ y: 505
|
|
|
},
|
|
|
{
|
|
|
level: 3,
|
|
@@ -224,8 +226,8 @@ const NodeData = {
|
|
|
nodeId: '3-3-3',
|
|
|
nodeName: '实验室检测',
|
|
|
state: '进行中',
|
|
|
- x: 420,
|
|
|
- y:560
|
|
|
+ x: 440,
|
|
|
+ y: 560
|
|
|
},
|
|
|
{
|
|
|
level: 3,
|
|
@@ -233,8 +235,8 @@ const NodeData = {
|
|
|
nodeId: '3-3-4',
|
|
|
nodeName: '风险人员管控',
|
|
|
state: '进行中',
|
|
|
- x: 420,
|
|
|
- y:615
|
|
|
+ x: 440,
|
|
|
+ y: 615
|
|
|
},
|
|
|
{
|
|
|
level: 3,
|
|
@@ -242,12 +244,12 @@ const NodeData = {
|
|
|
nodeId: '3-3-5',
|
|
|
nodeName: '风险场所管控',
|
|
|
state: '进行中',
|
|
|
- x: 420,
|
|
|
- y:670
|
|
|
+ x: 440,
|
|
|
+ y: 670
|
|
|
},
|
|
|
|
|
|
{ level: 1, fId: 4, nodeId: 4, nodeName: '区域风险排查管控', state: '未开始', x: 10, y: 620 },
|
|
|
- { level: 1, fId: 5, nodeId: 5, nodeName: '结案', x: 10, y: 720 }
|
|
|
+ { level: 1, fId: 5, nodeId: 5, nodeName: '结案', x: 10, y: 740 }
|
|
|
],
|
|
|
dagLine: [
|
|
|
{ from: 1, to: 2 },
|
|
@@ -272,76 +274,95 @@ const NodeData = {
|
|
|
{ from: '3-3', to: '3-3-2' },
|
|
|
{ from: '3-3', to: '3-3-3' },
|
|
|
{ from: '3-3', to: '3-3-4' },
|
|
|
- { from: '3-3', to: '3-3-5' },
|
|
|
+ { from: '3-3', to: '3-3-5' }
|
|
|
]
|
|
|
}
|
|
|
|
|
|
// **自动合并多条连线**
|
|
|
-const mergeConnections = edges => {
|
|
|
- const targetMap = {}
|
|
|
+// const mergeConnections = edges => {
|
|
|
+// const targetMap = {}
|
|
|
|
|
|
- // 统计指向同一 target 的 source
|
|
|
- edges.forEach(edge => {
|
|
|
- if (!targetMap[edge.to]) {
|
|
|
- targetMap[edge.to] = []
|
|
|
- }
|
|
|
- targetMap[edge.to].push(edge.from)
|
|
|
- })
|
|
|
+// // 统计指向同一 target 的 source
|
|
|
+// edges.forEach(edge => {
|
|
|
+// if (!targetMap[edge.to]) {
|
|
|
+// targetMap[edge.to] = []
|
|
|
+// }
|
|
|
+// targetMap[edge.to].push(edge.from)
|
|
|
+// })
|
|
|
|
|
|
- const newEdges = []
|
|
|
- Object.keys(targetMap).forEach(target => {
|
|
|
- const sources = targetMap[target]
|
|
|
- if (sources.length > 1) {
|
|
|
- // 1. 创建“合并节点”
|
|
|
- const mergeNodeId = `merge_${target}`
|
|
|
- newEdges.push(...sources.map(src => ({ from: src, to: mergeNodeId })))
|
|
|
- newEdges.push({ from: mergeNodeId, to: target })
|
|
|
- } else {
|
|
|
- newEdges.push({ from: sources[0], to: target })
|
|
|
- }
|
|
|
- })
|
|
|
+// const newEdges = []
|
|
|
+// Object.keys(targetMap).forEach(target => {
|
|
|
+// const sources = targetMap[target]
|
|
|
+// if (sources.length > 1) {
|
|
|
+// // 1. 创建“合并节点”
|
|
|
+// const mergeNodeId = `merge_${target}`
|
|
|
+// newEdges.push(...sources.map(src => ({ from: src, to: mergeNodeId })))
|
|
|
+// newEdges.push({ from: mergeNodeId, to: target })
|
|
|
+// } else {
|
|
|
+// newEdges.push({ from: sources[0], to: target })
|
|
|
+// }
|
|
|
+// })
|
|
|
|
|
|
- return newEdges
|
|
|
-}
|
|
|
+// return newEdges
|
|
|
+// }
|
|
|
|
|
|
-// **计算竖排三列布局**
|
|
|
-// const computeLayout = () => {
|
|
|
-// const levels = {}
|
|
|
-// const columnSpacing = 160 // 列间距
|
|
|
-// const rowSpacing = 72 // 行间距
|
|
|
+// const mergeConnections = edges => {
|
|
|
+// const targetMap = {}
|
|
|
+// const mergeNodePositions = {} // 存储合并节点位置
|
|
|
|
|
|
-// // **按 level 存储节点**
|
|
|
-// NodeData.dagNode.forEach(node => {
|
|
|
-// if (!levels[node.level]) {
|
|
|
-// levels[node.level] = []
|
|
|
+// // 统计指向同一 target 的 source
|
|
|
+// edges.forEach(edge => {
|
|
|
+// if (!targetMap[edge.to]) {
|
|
|
+// targetMap[edge.to] = []
|
|
|
// }
|
|
|
-// levels[node.level].push(node)
|
|
|
+// targetMap[edge.to].push(edge.from)
|
|
|
// })
|
|
|
|
|
|
-// const nodePositions = {}
|
|
|
-// let x = 50 // 第一列的 x 轴位置
|
|
|
+// const newEdges = []
|
|
|
+// Object.keys(targetMap).forEach(target => {
|
|
|
+// const sources = targetMap[target]
|
|
|
+// if (sources.length > 1) {
|
|
|
+// const mergeNodeId = `merge_${target}`
|
|
|
|
|
|
-// Object.keys(levels).forEach(level => {
|
|
|
-// let y = 50 // 第一行 y 轴初始位置
|
|
|
-// const nodes = levels[level]
|
|
|
+// const targetNode = NodeData.dagNode.find(n => n.nodeId === target)
|
|
|
+// const sourceNodes = sources.map(src => NodeData.dagNode.find(n => n.nodeId === src)).filter(n => n)
|
|
|
|
|
|
-// nodes.forEach(node => {
|
|
|
-// nodePositions[node.nodeId] = { x, y }
|
|
|
-// y += rowSpacing // **每个节点往下排列**
|
|
|
-// })
|
|
|
+// if (targetNode && sourceNodes.length > 0) {
|
|
|
+// const maxSourceX = Math.max(...sourceNodes.map(n => n.x))
|
|
|
+// const mergeNodeX = (maxSourceX + targetNode.x) / 2
|
|
|
+// const mergeNodeY = targetNode.y
|
|
|
+
|
|
|
+// mergeNodePositions[mergeNodeId] = { x: mergeNodeX, y: mergeNodeY }
|
|
|
+// }
|
|
|
|
|
|
-// x += columnSpacing // **每列向右移动**
|
|
|
+// newEdges.push(...sources.map(src => ({ from: src, to: mergeNodeId })))
|
|
|
+// newEdges.push({ from: mergeNodeId, to: target })
|
|
|
+// } else {
|
|
|
+// newEdges.push({ from: sources[0], to: target })
|
|
|
+// }
|
|
|
+// })
|
|
|
+
|
|
|
+// // 添加合并节点到 NodeData
|
|
|
+// Object.keys(mergeNodePositions).forEach(mergeNodeId => {
|
|
|
+// NodeData.dagNode.push({
|
|
|
+// nodeId: mergeNodeId,
|
|
|
+// nodeName: '', // 合并节点不显示文本
|
|
|
+// state: '',
|
|
|
+// x: mergeNodePositions[mergeNodeId].x,
|
|
|
+// y: mergeNodePositions[mergeNodeId].y,
|
|
|
+// width: 100, // 使合并节点尽量小
|
|
|
+// height: 100
|
|
|
+// })
|
|
|
// })
|
|
|
|
|
|
-// return nodePositions
|
|
|
+// return newEdges
|
|
|
// }
|
|
|
|
|
|
-// **初始化 X6 画布**
|
|
|
onMounted(() => {
|
|
|
graph = new Graph({
|
|
|
container: graphRef.value,
|
|
|
width: 580,
|
|
|
- height: 801,
|
|
|
+ height: 1200,
|
|
|
connecting: {
|
|
|
router: 'orth' // 自动优化连线
|
|
|
// connector: 'smooth', // 平滑曲线
|
|
@@ -369,10 +390,10 @@ onMounted(() => {
|
|
|
})
|
|
|
|
|
|
// **处理合并连线**
|
|
|
- const mergedEdges = mergeConnections(NodeData.dagLine)
|
|
|
+ // const mergedEdges = mergeConnections(NodeData.dagLine)
|
|
|
|
|
|
// **添加合并后的连线**
|
|
|
- mergedEdges.forEach(edge => {
|
|
|
+ NodeData.dagLine.forEach(edge => {
|
|
|
graph.addEdge({
|
|
|
source: String(edge.from),
|
|
|
target: String(edge.to),
|
|
@@ -387,13 +408,13 @@ onMounted(() => {
|
|
|
width: 24,
|
|
|
height: 24,
|
|
|
y: -12,
|
|
|
- x:-10,
|
|
|
- transform: 'rotate(0)' // 旋转箭头图片
|
|
|
+ x: -24,
|
|
|
+ transform: 'rotate(0)' // 旋转箭头图片
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
router: { name: 'manhattan' }, // 自动贴合边缘
|
|
|
- connector: { name: 'rounded' } // 让线条更圆滑
|
|
|
+ connector: { name: 'rounded' }, // 让线条更圆滑
|
|
|
})
|
|
|
})
|
|
|
})
|
|
@@ -403,6 +424,7 @@ onMounted(() => {
|
|
|
.container {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
+ overflow: auto;
|
|
|
}
|
|
|
|
|
|
#graph_container {
|