|
|
@@ -8,7 +8,8 @@
|
|
|
|
|
|
<script>
|
|
|
import { ref, onMounted, watch, onBeforeUnmount } from 'vue';
|
|
|
-import LogicFlow from "@logicflow/core";
|
|
|
+import LogicFlow from "@logicflow/core";
|
|
|
+import {PolylineEdge, PolylineEdgeModel} from "@logicflow/core";
|
|
|
import cid from '@/api/cid/cid'
|
|
|
import systemRow from '@/api/systemRow';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
@@ -98,6 +99,21 @@ export default {
|
|
|
})
|
|
|
watch(() => props.coolObj, (newVal) => {
|
|
|
copyObj.value = newVal
|
|
|
+ cid.getModelInfo(copyObj.value.id).then(res => {
|
|
|
+ if(res.data[0].relation_json==null || res.data[0].relation_json=='') return;
|
|
|
+ const origiondata = JSON.parse(res.data[0].relation_json)
|
|
|
+ lf.value.render(origiondata);
|
|
|
+ //let rl = lfXml2Json(res.data[0].relation_json.replace(/[\t|\r|\n]/gi,''))
|
|
|
+ // console.log(rl)
|
|
|
+ for (let index = 0; index < origiondata.edges.length; index++) {
|
|
|
+ const element = origiondata.edges[index];
|
|
|
+ if(element.properties!=null && element.properties["issv"]==='SV') {
|
|
|
+ let lineStyle = lf.value.getEdgeModelById(element.id)//.getEdgeStyle();
|
|
|
+ console.log(lineStyle)
|
|
|
+ lineStyle.setProperties( { svEdge: {stroke:'orange'} })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
function blue() {
|
|
|
lf.value.setTheme({
|
|
|
@@ -109,7 +125,7 @@ export default {
|
|
|
}
|
|
|
function orange() {
|
|
|
lf.value.setTheme({
|
|
|
- baseEdge: {
|
|
|
+ svEdge: {
|
|
|
stroke: 'orange',
|
|
|
strokeWidth: 2,
|
|
|
},
|
|
|
@@ -125,23 +141,18 @@ export default {
|
|
|
}
|
|
|
function saveLine() {
|
|
|
// lf.value.getSnapshot()//保存为图片
|
|
|
+ console.log(JSON.stringify( lf.value.getGraphData()))
|
|
|
const xml = lfJson2Xml(lf.value.getGraphData());
|
|
|
- const data = lfXml2Json(lf.value.getGraphData())
|
|
|
- if (props.nowLook == null) {
|
|
|
- ElMessage({
|
|
|
- type: "error",
|
|
|
- message: "您还未选择左侧电压类型",
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- } else {
|
|
|
+ const data = JSON.stringify( lf.value.getGraphData())
|
|
|
+
|
|
|
cid.saveMap(
|
|
|
{
|
|
|
id: copyObj.value.id - 0,
|
|
|
- model_name: coolName.value,
|
|
|
- vol_id: coolObj.value.id - 0,
|
|
|
- line_link_style: coolId.value - 0,
|
|
|
- relation_json: xml,
|
|
|
- area_type: "116329",
|
|
|
+ //model_name: coolName.value,
|
|
|
+ //vol_id: coolObj.value.id - 0,
|
|
|
+ //line_link_style: coolId.value - 0,
|
|
|
+ relation_json: data,
|
|
|
+ //area_type: "116329",
|
|
|
}
|
|
|
).then(res => {
|
|
|
if (res.code == 0) {
|
|
|
@@ -150,10 +161,9 @@ export default {
|
|
|
message: "保存成功!",
|
|
|
duration: 2000,
|
|
|
})
|
|
|
- window.location.reload()
|
|
|
+ // window.location.reload()
|
|
|
}
|
|
|
})
|
|
|
- }
|
|
|
}
|
|
|
function cleanMap() {
|
|
|
lf.value.clearData()
|
|
|
@@ -161,7 +171,7 @@ export default {
|
|
|
function textColor() {
|
|
|
if (lineColor.value == "#255CE7") {
|
|
|
lf.value.setTheme({
|
|
|
- baseEdge: {
|
|
|
+ svEdge: {
|
|
|
stroke: "orange",
|
|
|
strokeWidth: 2,
|
|
|
},
|
|
|
@@ -185,9 +195,9 @@ export default {
|
|
|
coolId.value = props.needId
|
|
|
coolName.value = props.needName
|
|
|
copyObj.value = props.coolObj
|
|
|
- systemRow.getChildren({ code: "area_type" }).then(res => {
|
|
|
- console.log(res, 'sss');
|
|
|
- })
|
|
|
+ //systemRow.getChildren({ code: "area_type" }).then(res => {
|
|
|
+ // console.log(res, 'sss');
|
|
|
+ //})
|
|
|
systemRow.getChildren({ code: "ied_type" }).then(res => {
|
|
|
needMap.value = res.data.map(item => {
|
|
|
return {
|
|
|
@@ -212,7 +222,7 @@ export default {
|
|
|
// thickness: 1,
|
|
|
// },
|
|
|
// },//网格,
|
|
|
- grid: false,
|
|
|
+ grid: true,
|
|
|
plugins: [DndPanel, SelectionSelect, Group, Menu, MiniMap, Snapshot],//全局加载的组件
|
|
|
keyboard: {
|
|
|
enabled: true
|
|
|
@@ -220,6 +230,34 @@ export default {
|
|
|
snapline: true,//辅助线
|
|
|
edgeTextDraggable: true,//连接线文本可以拖拽
|
|
|
})
|
|
|
+ class SvEdge extends PolylineEdge {}
|
|
|
+ // 节点Model
|
|
|
+ class SvEdgeModel extends PolylineEdgeModel {
|
|
|
+ getEdgeStyle(){
|
|
|
+ const stl = super.getEdgeStyle()
|
|
|
+ stl.stroke='orange'
|
|
|
+ return stl
|
|
|
+ }
|
|
|
+ }
|
|
|
+ class GooseEdge extends PolylineEdge {}
|
|
|
+ // 节点Model
|
|
|
+ class GooseEdgeModel extends PolylineEdgeModel {
|
|
|
+ getEdgeStyle(){
|
|
|
+ const stl = super.getEdgeStyle()
|
|
|
+ stl.stroke='#255CE7'
|
|
|
+ return stl
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lf.value.register({
|
|
|
+ type:"svEdge",
|
|
|
+ view: SvEdge,
|
|
|
+ model: SvEdgeModel,
|
|
|
+ })
|
|
|
+ lf.value.register({
|
|
|
+ type:"baseEdge",
|
|
|
+ view: GooseEdge,
|
|
|
+ model: GooseEdgeModel,
|
|
|
+ })
|
|
|
lf.value.setTheme({//设置画布
|
|
|
rect: {
|
|
|
fill: "#FFFFFF",
|
|
|
@@ -261,6 +299,10 @@ export default {
|
|
|
stroke: "#255CE7",
|
|
|
strokeWidth: 2,
|
|
|
},//连接线颜色
|
|
|
+ svEdge: {
|
|
|
+ stroke: "orange",
|
|
|
+ strokeWidth: 1,
|
|
|
+ },//连接线颜色
|
|
|
nodeText: {
|
|
|
color: "#255CE7",
|
|
|
overflowMode: "autoWrap",
|
|
|
@@ -268,9 +310,21 @@ export default {
|
|
|
fontSize: 12,
|
|
|
},//节点内文字样式
|
|
|
});
|
|
|
- lf.value.on("edge:click", function (data, e, position) {
|
|
|
+ lf.value.on("edge:click", function (data, e, position) {
|
|
|
delId.value = data.data.id
|
|
|
})
|
|
|
+ lf.value.on("edge:add", function (data, e, position) {
|
|
|
+ if (copyColor.value == '#255CE7') {
|
|
|
+ blue()
|
|
|
+ lf.value.changeEdgeType(data.data.id,"baseEdge")
|
|
|
+ lf.value.setProperties(data.data.id,{'issv':'GOOSE'})
|
|
|
+ }
|
|
|
+ if (copyColor.value == 'orange') {
|
|
|
+ orange()
|
|
|
+ lf.value.changeEdgeType(data.data.id,"svEdge")
|
|
|
+ lf.value.setProperties(data.data.id,{'issv':'SV'})
|
|
|
+ }
|
|
|
+ })
|
|
|
lf.value.on('node:click', function (data, e, position) {//传送坐标轴参数到父组件
|
|
|
copyId.value = data.data.id
|
|
|
nodeId.value = data.data.id
|
|
|
@@ -289,9 +343,13 @@ export default {
|
|
|
lf.value.on('edge:click', function (data, e, position) {//解决点击连接线问题
|
|
|
if (copyColor.value == '#255CE7') {
|
|
|
blue()
|
|
|
+ lf.value.changeEdgeType(data.data.id,"baseEdge")
|
|
|
+ lf.value.setProperties(data.data.id,{'issv':'GOOSE'})
|
|
|
}
|
|
|
if (copyColor.value == 'orange') {
|
|
|
orange()
|
|
|
+ lf.value.changeEdgeType(data.data.id,"svEdge")
|
|
|
+ lf.value.setProperties(data.data.id,{'issv':'SV'})
|
|
|
}
|
|
|
})
|
|
|
// lf.value.register(logicFlows)
|