|
@@ -3,17 +3,22 @@
|
|
|
<div class="bigBox">
|
|
|
<div ref="container" class="container"></div>
|
|
|
</div>
|
|
|
+ <!-- 功能模态框 -->
|
|
|
+ <AbilityModal v-if="abModal" :abModal="abModal" :modelId="modelId" :iedType="iedType" @abilityBack="abilityBack">
|
|
|
+ </AbilityModal>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { ref, onMounted, watch, onBeforeUnmount } from 'vue';
|
|
|
-import LogicFlow from "@logicflow/core";
|
|
|
-import {PolylineEdge, PolylineEdgeModel} 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 flow from "@/api/flow/flow"
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
+import AbilityModal from "../drawModal/AbilityModal.vue"
|
|
|
import { DndPanel, SelectionSelect, Group, Menu, MiniMap, regeister, Snapshot, lfJson2Xml, lfXml2Json } from "@logicflow/extension";
|
|
|
import "@logicflow/core/dist/style/index.css";
|
|
|
import "@logicflow/extension/lib/style/index.css";
|
|
@@ -71,6 +76,9 @@ export default {
|
|
|
let coolObj = ref({})
|
|
|
let coolName = ref('')
|
|
|
let copyObj = ref({})//整个模型属性
|
|
|
+ let modelId = ref("")//模型id
|
|
|
+ let abModal = ref(false)//功能模态框
|
|
|
+ let iedType = ref("")//iedtype
|
|
|
watch(() => props.lineMenuColor, (newVal) => {
|
|
|
copyColor.value = newVal
|
|
|
})
|
|
@@ -99,21 +107,23 @@ export default {
|
|
|
})
|
|
|
watch(() => props.coolObj, (newVal) => {
|
|
|
copyObj.value = newVal
|
|
|
+ modelId.value = copyObj.value.id
|
|
|
+ console.log(modelId.value, 'watch模型id ');
|
|
|
cid.getModelInfo(copyObj.value.id).then(res => {
|
|
|
- if(res.data[0].relation_json==null || res.data[0].relation_json=='') return;
|
|
|
+ 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') {
|
|
|
+ if (element.properties != null && element.properties["issv"] === 'SV') {
|
|
|
let lineStyle = lf.value.getEdgeModelById(element.id)//.getEdgeStyle();
|
|
|
console.log(lineStyle)
|
|
|
- lineStyle.setProperties( { svEdge: {stroke:'orange'} })
|
|
|
- }
|
|
|
+ lineStyle.setProperties({ svEdge: { stroke: 'orange' } })
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
+ }, { immediate: true })
|
|
|
})
|
|
|
function blue() {
|
|
|
lf.value.setTheme({
|
|
@@ -141,29 +151,28 @@ export default {
|
|
|
}
|
|
|
function saveLine() {
|
|
|
// lf.value.getSnapshot()//保存为图片
|
|
|
- console.log(JSON.stringify( lf.value.getGraphData()))
|
|
|
+ console.log(JSON.stringify(lf.value.getGraphData()))
|
|
|
const xml = lfJson2Xml(lf.value.getGraphData());
|
|
|
- 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: data,
|
|
|
- //area_type: "116329",
|
|
|
- }
|
|
|
- ).then(res => {
|
|
|
- if (res.code == 0) {
|
|
|
- ElMessage({
|
|
|
- type: "success",
|
|
|
- message: "保存成功!",
|
|
|
- duration: 2000,
|
|
|
- })
|
|
|
- // window.location.reload()
|
|
|
- }
|
|
|
- })
|
|
|
+ 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: data,
|
|
|
+ //area_type: "116329",
|
|
|
+ }
|
|
|
+ ).then(res => {
|
|
|
+ if (res.code == 0) {
|
|
|
+ ElMessage({
|
|
|
+ type: "success",
|
|
|
+ message: "保存成功!",
|
|
|
+ duration: 2000,
|
|
|
+ })
|
|
|
+ // window.location.reload()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
function cleanMap() {
|
|
|
lf.value.clearData()
|
|
@@ -199,6 +208,7 @@ export default {
|
|
|
// console.log(res, 'sss');
|
|
|
//})
|
|
|
systemRow.getChildren({ code: "ied_type" }).then(res => {
|
|
|
+ console.log(res, 'res');
|
|
|
needMap.value = res.data.map(item => {
|
|
|
return {
|
|
|
type: 'rect',
|
|
@@ -206,7 +216,8 @@ export default {
|
|
|
label: item.name,
|
|
|
icon: '',
|
|
|
properties: {
|
|
|
- ied_type: item.code
|
|
|
+ ied_type: item.code,
|
|
|
+ id: item.id
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -230,31 +241,31 @@ export default {
|
|
|
snapline: true,//辅助线
|
|
|
edgeTextDraggable: true,//连接线文本可以拖拽
|
|
|
})
|
|
|
- class SvEdge extends PolylineEdge {}
|
|
|
+ class SvEdge extends PolylineEdge { }
|
|
|
// 节点Model
|
|
|
class SvEdgeModel extends PolylineEdgeModel {
|
|
|
- getEdgeStyle(){
|
|
|
+ getEdgeStyle() {
|
|
|
const stl = super.getEdgeStyle()
|
|
|
- stl.stroke='orange'
|
|
|
+ stl.stroke = 'orange'
|
|
|
return stl
|
|
|
}
|
|
|
}
|
|
|
- class GooseEdge extends PolylineEdge {}
|
|
|
+ class GooseEdge extends PolylineEdge { }
|
|
|
// 节点Model
|
|
|
class GooseEdgeModel extends PolylineEdgeModel {
|
|
|
- getEdgeStyle(){
|
|
|
+ getEdgeStyle() {
|
|
|
const stl = super.getEdgeStyle()
|
|
|
- stl.stroke='#255CE7'
|
|
|
+ stl.stroke = '#255CE7'
|
|
|
return stl
|
|
|
}
|
|
|
}
|
|
|
lf.value.register({
|
|
|
- type:"svEdge",
|
|
|
+ type: "svEdge",
|
|
|
view: SvEdge,
|
|
|
model: SvEdgeModel,
|
|
|
})
|
|
|
lf.value.register({
|
|
|
- type:"baseEdge",
|
|
|
+ type: "baseEdge",
|
|
|
view: GooseEdge,
|
|
|
model: GooseEdgeModel,
|
|
|
})
|
|
@@ -310,29 +321,38 @@ 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:dbclick', function (data, e, position) {
|
|
|
+ let start = lf.value.getNodeModelById(data.data.sourceNodeId)//获取连线开始节点
|
|
|
+ let end = lf.value.getNodeModelById(data.data.targetNodeId)//获取连线结尾节点
|
|
|
+ console.log(start, end, '边data');
|
|
|
+ })
|
|
|
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'})
|
|
|
- }
|
|
|
+ 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
|
|
|
setX.value = data.data.x
|
|
|
setY.value = data.data.y
|
|
|
- console.log(data.data, 'click');
|
|
|
emit("backxy", setX.value, setY.value)
|
|
|
})
|
|
|
+ lf.value.on('node:dbclick', function (data, e, position) {//双击打开弹窗
|
|
|
+ iedType.value = data.data.properties.ied_type
|
|
|
+ abModal.value = true
|
|
|
+ console.log(data, '节点data');
|
|
|
+ })
|
|
|
lf.value.on('node:mousemove', function (data, e) {//传递坐标轴参数到父组件
|
|
|
setX.value = data.data.x
|
|
|
setY.value = data.data.y
|
|
@@ -343,13 +363,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'})
|
|
|
+ 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.changeEdgeType(data.data.id, "svEdge")
|
|
|
+ lf.value.setProperties(data.data.id, { 'issv': 'SV' })
|
|
|
}
|
|
|
})
|
|
|
// lf.value.register(logicFlows)
|
|
@@ -357,6 +377,9 @@ export default {
|
|
|
lf.value.render();
|
|
|
})
|
|
|
})
|
|
|
+ function abilityBack(data) {
|
|
|
+ abModal.value = data
|
|
|
+ }
|
|
|
onBeforeUnmount(() => {
|
|
|
// lf.value.remove()
|
|
|
coolObj.value = {}
|
|
@@ -380,9 +403,16 @@ export default {
|
|
|
needMap,
|
|
|
coolId,
|
|
|
coolName,
|
|
|
- copyObj,
|
|
|
+ copyObj,//模型整个数据
|
|
|
+ modelId,//模型id
|
|
|
+ abModal,//功能模态框
|
|
|
+ iedType,//模型属性
|
|
|
+ abilityBack,//abilitymodal.vue返回模态框开关状态
|
|
|
}
|
|
|
},
|
|
|
+ components: {
|
|
|
+ AbilityModal,//功能模态框
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|