From 735c66193694ff763586f00eb76ba1e8ab8e87ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=91=E5=B9=B4=E6=A2=A6=E4=B8=8E=E7=A0=96?= <2847127106@qq.com> Date: Fri, 30 Aug 2024 21:31:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/quest/node/Home.vue | 41 ++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/views/quest/node/Home.vue b/src/views/quest/node/Home.vue index 84b3b5e..e274391 100644 --- a/src/views/quest/node/Home.vue +++ b/src/views/quest/node/Home.vue @@ -96,6 +96,7 @@ export default { const rows = res.data.rows for (let i = 0; i < rows.length; i++) { const r = flowNode.methods.toJsPlumbNode(rows[i]) + // 节点添加 this.data.nodeList.push({ id: r.node.id, type: r.node.type, @@ -104,6 +105,7 @@ export default { top: r.node.top, left: r.node.left }) + // 连线添加 if (r.line) { r.line.forEach(v => { this.data.lineList.push({ @@ -116,23 +118,42 @@ export default { }) } } - this.data.nodeList.forEach(node => { - nodeTypeList.forEach(v => { - if (node.type === v.type) { - node.typeName = v.typeName - node.logImg = v.logImg - node.log_bg_color = v.log_bg_color - } - }) - }) + // 节点图片配置添加 + this.nodeHandle() + // 连线去重 + this.data.lineList = this.lineHandle(this.data.lineList) }) this.flag = true }, + // 节点批量处理-初始化 + nodeHandle() { + // 节点图片配置添加 + this.data.nodeList.forEach(node => { + nodeTypeList.forEach(v => { + if (node.type === v.type) { + node.typeName = v.typeName + node.logImg = v.logImg + node.log_bg_color = v.log_bg_color + } + }) + }) + }, + // 连线去重 + lineHandle(lineList) { + let map = new Map(); + lineList.forEach(item => { + const key = item.from + '->' + item.to; + if (!map.has(key)) { + map.set(key, item); + } + }); + return Array.from(map.values()); + }, // 保存修改按钮 save() { // 1. 获取所有节点与连线信息 const nodeList = this.data.nodeList - const lineList = this.data.lineList + const lineList = this.lineHandle(this.data.lineList) console.log(this.data) // 2. 处理所有信息,将jsPlumb类型 ==> 数据表类型 const nodeData = []