From 6b24f642b01cf3cd1be0d5833273fa2867d389e1 Mon Sep 17 00:00:00 2001 From: xyc <jc_xiong@hotmail.com> Date: 星期五, 17 五月 2024 13:21:00 +0800 Subject: [PATCH] 新增svgEditor --- web/src/views/modules/taskReliability/RBD-edit-img.vue | 75 +++++++++++++++++++++++++++++++------ 1 files changed, 62 insertions(+), 13 deletions(-) diff --git a/web/src/views/modules/taskReliability/RBD-edit-img.vue b/web/src/views/modules/taskReliability/RBD-edit-img.vue index 1e82264..2ce607b 100644 --- a/web/src/views/modules/taskReliability/RBD-edit-img.vue +++ b/web/src/views/modules/taskReliability/RBD-edit-img.vue @@ -357,12 +357,15 @@ // this.graph.zoomToFit() } else { this.graph.fromJSON(RBDDefault) + this.isFirstLoad = false } }, async clearDiagram() { this.dataForm.id = null // this.graph.fromJSON(this.emptyJson) - this.graph.fromJSON('') + this.graph.fromJSON(RBDDefault) + this.graph.positionContent('left') + this.isFirstLoad = false; // this.graph.centerContent() // this.graph.zoomToFit() // this.graph.freeze() @@ -582,10 +585,12 @@ let res = await this.$http.get(`/basicInfo/XhProductModel/getProduct`, {params: params}) this.imagesList2 = res.data console.log(this.imagesList2, 'getProduct(productId)234567890') + let urlObject = window.URL || window.webkitURL || window; + const imageNodes2 = this.imagesList2.map((item) => this.graph.createNode({ shape: 'image', - imageUrl: `${window.SITE_CONFIG['apiURL']}/sysPictureBase/getProductImg?token=${Cookies.get('token')}&id=${item.imgPath}`, + //imageUrl: `${window.SITE_CONFIG['apiURL']}/sysPictureBase/getProductImg?token=${Cookies.get('token')}&id=${item.imgPath}`, width: 60, height: 60, id: item.dataId, // 鎵嬪姩璁剧疆鑺傜偣鐨� ID @@ -608,6 +613,10 @@ voteNum: '', }, attrs: { + image: { + 'xlink:href': `${window.SITE_CONFIG['apiURL']}/sysPictureBase/getSvgImage?token=${Cookies.get('token')}&id=${item.imgPath}`, + //'xlink:href': urlObject.createObjectURL(new Blob([item.svgContent])), + }, text: { text: item.imgName, fontSize: 14, @@ -685,7 +694,22 @@ if (cells.length === 1) { let node = cells[0] if (!node.isNode()) { - this.$message({message: '璇烽�変腑鑺傜偣', type: 'warning'}) + this.$confirm('鏄惁鍒犻櫎璇ヨ繛鎺ョ嚎鐐�?', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).then(() => { + this.$message({ + type: 'success', + message: '鍒犻櫎鎴愬姛!' + }) + }).catch(() => { + this.$message({ + type: 'info', + message: '宸插彇娑堝垹闄�' + }) + }) + // this.$message({message: '璇烽�変腑鑺傜偣', type: 'warning'}) return false; // 鍙栨秷鎿嶄綔 } let nodeType = node.getData().nodeType @@ -716,17 +740,17 @@ let outNode = isSeriesNode.outNode console.log(inLine, outLine, 'inLine,outLine') console.log(inNode, outNode, 'inNode,outNode') - if (inLineIsToLine) { - inLine[0].target = {cell: outNode.id, port: 'left1'} - } else { - outLine[0].source = {cell: inNode.id, port: 'right1'} - } //鎻愮ず鏄惁瑕佸垹闄� this.$confirm('鏄惁鍒犻櫎璇ヨ妭鐐�?', '鎻愮ず', { confirmButtonText: '纭畾', cancelButtonText: '鍙栨秷', type: 'warning' }).then(() => { + if (inLineIsToLine) { + inLine[0].target = {cell: outNode.id, port: 'left1'} + } else { + outLine[0].source = {cell: inNode.id, port: 'right1'} + } if (deleteType === 1){ node.remove() } @@ -742,15 +766,37 @@ type: 'info', message: '宸插彇娑堝垹闄�' }) + return false }) } if (this.isMultipleBrach(node)) { //鎻愮ず鏄惁瑕佸垹闄� - if (deleteType === 1) - node.remove() - else - this.deleteCombination(node) - return + this.$confirm('鏄惁鍒犻櫎璇ヨ妭鐐�?', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).then(() => { + if (inLineIsToLine) { + inLine[0].target = {cell: outNode.id, port: 'left1'} + } else { + outLine[0].source = {cell: inNode.id, port: 'right1'} + } + if (deleteType === 1) + node.remove() + else + this.deleteCombination(node) + this.$message({ + type: 'success', + message: '鍒犻櫎鎴愬姛!' + }) + + }).catch(() => { + this.$message({ + type: 'info', + message: '宸插彇娑堝垹闄�' + }) + return false + }) } } //鎻愮ず涓嶈兘鍒犻櫎 @@ -1140,6 +1186,7 @@ let result = this.addNodeAndConnect(graphNode, dragNode, dragNode.position().x - dragNode.size().width/2, centerY) if (!result){ dragNode.remove() + this.$message({message: '娌℃湁瓒冲鐨勭┖闂存斁缃鑺傜偣锛岃鎵╁ぇ鍓╀綑绌洪棿', type: 'warning'}) return } inEdges[0].target = {cell: result.newStartNode.id, port: 'left1'} @@ -1170,6 +1217,7 @@ let result = this.addNodeAndConnect(null, dragNode, minX, centerY) if (!result){ dragNode.remove() + this.$message({message: '娌℃湁瓒冲鐨勭┖闂存斁缃鑺傜偣锛岃鎵╁ぇ鍓╀綑绌洪棿', type: 'warning'}) return } this.graph.addEdge({ @@ -1245,6 +1293,7 @@ let result = this.addNodeAndConnect(null, dragNode, dragNode.position().x, centerY) if (!result){ dragNode.remove() + this.$message({message: '娌℃湁瓒冲鐨勭┖闂存斁缃鑺傜偣锛岃鎵╁ぇ鍓╀綑绌洪棿', type: 'warning'}) return } if (isRight) { -- Gitblit v1.9.1