|  | @@ -1,21 +1,22 @@
 | 
											
												
													
														|  |  <template>
 |  |  <template>
 | 
											
												
													
														|  |    <VueFlow ref="vueFlowRef" :nodes="nodes" :edges="edges"  :class="{ dark }"
 |  |    <VueFlow ref="vueFlowRef" :nodes="nodes" :edges="edges"  :class="{ dark }"
 | 
											
												
													
														|  |      class="basic-flow" 
 |  |      class="basic-flow" 
 | 
											
												
													
														|  | -    :default-viewport="{ zoom: 1.5 }" :min-zoom="0.2" :max-zoom="2.5" @drop="onDrop"
 |  | 
 | 
											
												
													
														|  | 
 |  | +    :default-viewport="{ zoom: 1.5 }" :min-zoom="0.2" :max-zoom="2.5" @drop="onDrop1"
 | 
											
												
													
														|  |      @contextmenu.prevent="onContextMenu" @node-contextmenu="logEvent('contextmenu', $event)" 
 |  |      @contextmenu.prevent="onContextMenu" @node-contextmenu="logEvent('contextmenu', $event)" 
 | 
											
												
													
														|  |      @dragover="onDragOver" @dragleave="onDragLeave" @edge-click="onEdgeClick" @node-double-click="onNodeDoubleClick"  @node-click="onNodeClick">
 |  |      @dragover="onDragOver" @dragleave="onDragLeave" @edge-click="onEdgeClick" @node-double-click="onNodeDoubleClick"  @node-click="onNodeClick">
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      <template  #node-default="props">
 |  |      <template  #node-default="props">
 | 
											
												
													
														|  | -      <!-- <template  #node-process="props">   //  @contextmenu.prevent="onContextMenu"  -->
 |  | 
 | 
											
												
													
														|  |        <eltree :node="props" />
 |  |        <eltree :node="props" />
 | 
											
												
													
														|  |      </template>
 |  |      </template>
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | + 
 | 
											
												
													
														|  |      <Background pattern-color="#aaa" :gap="16" />
 |  |      <Background pattern-color="#aaa" :gap="16" />
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      <!-- <MiniMap /> @input="handleUpdate"-->
 |  |      <!-- <MiniMap /> @input="handleUpdate"-->
 | 
											
												
													
														|  |      <Panel :position="'right'">
 |  |      <Panel :position="'right'">
 | 
											
												
													
														|  |        <div class="field">
 |  |        <div class="field">
 | 
											
												
													
														|  | 
 |  | +        <div>
 | 
											
												
													
														|  |          <label for="label">Label:</label>
 |  |          <label for="label">Label:</label>
 | 
											
												
													
														|  | -        <input id="label" v-model="labelname"  />
 |  | 
 | 
											
												
													
														|  | 
 |  | +        <input id="label" v-model="labelname"  /></div>
 | 
											
												
													
														|  |          <button @click="handleUpdate"  class="lableaniu">确定</button>
 |  |          <button @click="handleUpdate"  class="lableaniu">确定</button>
 | 
											
												
													
														|  |        </div>
 |  |        </div>
 | 
											
												
													
														|  |        <!-- <div> -->
 |  |        <!-- <div> -->
 | 
											
										
											
												
													
														|  | @@ -24,7 +25,7 @@
 | 
											
												
													
														|  |          <button class="remove" @click="removeall(event)">all</button>
 |  |          <button class="remove" @click="removeall(event)">all</button>
 | 
											
												
													
														|  |       
 |  |       
 | 
											
												
													
														|  |        </div> -->
 |  |        </div> -->
 | 
											
												
													
														|  | -     
 |  | 
 | 
											
												
													
														|  | 
 |  | +      <!-- <button @click="onSelection()"  class="lableaniu">获取</button> -->
 | 
											
												
													
														|  |      </Panel>
 |  |      </Panel>
 | 
											
												
													
														|  |      <Controls position="top-left">
 |  |      <Controls position="top-left">
 | 
											
												
													
														|  |        <ControlButton title="Reset Transform" @click="resetTransform">
 |  |        <ControlButton title="Reset Transform" @click="resetTransform">
 | 
											
										
											
												
													
														|  | @@ -61,7 +62,7 @@
 | 
											
												
													
														|  |    </div>
 |  |    </div>
 | 
											
												
													
														|  |  </template>
 |  |  </template>
 | 
											
												
													
														|  |  <script setup>
 |  |  <script setup>
 | 
											
												
													
														|  | -import { ref, markRaw } from 'vue'
 |  | 
 | 
											
												
													
														|  | 
 |  | +import { ref, markRaw,inject } from 'vue'
 | 
											
												
													
														|  |  import { VueFlow,Panel, useVueFlow, MarkerType} from '@vue-flow/core'
 |  |  import { VueFlow,Panel, useVueFlow, MarkerType} from '@vue-flow/core'
 | 
											
												
													
														|  |  import { ElMessage, ElButton, ElDialog, ElSelect } from 'element-plus'
 |  |  import { ElMessage, ElButton, ElDialog, ElSelect } from 'element-plus'
 | 
											
												
													
														|  |  import {
 |  |  import {
 | 
											
										
											
												
													
														|  | @@ -86,10 +87,11 @@ import f11 from '@/assets/img/f11.png'
 | 
											
												
													
														|  |  import html2canvas from 'html2canvas';
 |  |  import html2canvas from 'html2canvas';
 | 
											
												
													
														|  |  import Icon from './Icon.vue'
 |  |  import Icon from './Icon.vue'
 | 
											
												
													
														|  |  import { formatTime } from '@/js/lindex.js';
 |  |  import { formatTime } from '@/js/lindex.js';
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | +import emitter from "@/utils/emitter";
 | 
											
												
													
														|  |  // import func from 'vue-temp/vue-editor-bridge.js';
 |  |  // import func from 'vue-temp/vue-editor-bridge.js';
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  const dark = ref(false)
 |  |  const dark = ref(false)
 | 
											
												
													
														|  | 
 |  | +let datatree=ref();
 | 
											
												
													
														|  |  const route = useRoute();
 |  |  const route = useRoute();
 | 
											
												
													
														|  |  const { onInit, onNodeDragStop, onNodeContextMenu, onConnect, addEdges, setViewport, toObject } = useVueFlow()
 |  |  const { onInit, onNodeDragStop, onNodeContextMenu, onConnect, addEdges, setViewport, toObject } = useVueFlow()
 | 
											
												
													
														|  |  let vueFlowRef = ref();
 |  |  let vueFlowRef = ref();
 | 
											
										
											
												
													
														|  | @@ -130,6 +132,7 @@ let contextMenu = ref({
 | 
											
												
													
														|  |    position: { x: 0, y: 0 },
 |  |    position: { x: 0, y: 0 },
 | 
											
												
													
														|  |    target: 'kong',
 |  |    target: 'kong',
 | 
											
												
													
														|  |  })
 |  |  })
 | 
											
												
													
														|  | 
 |  | +let Nested=ref([]);
 | 
											
												
													
														|  |  const { onDragOver, onDrop, onDragLeave, isDragOver } = useDragAndDrop();
 |  |  const { onDragOver, onDrop, onDragLeave, isDragOver } = useDragAndDrop();
 | 
											
												
													
														|  |  const edges = ref([]);
 |  |  const edges = ref([]);
 | 
											
												
													
														|  |  const nodes = ref([]);
 |  |  const nodes = ref([]);
 | 
											
										
											
												
													
														|  | @@ -148,18 +151,50 @@ function handleUpdate(){
 | 
											
												
													
														|  |    noid.value.data.label=labelname.value;
 |  |    noid.value.data.label=labelname.value;
 | 
											
												
													
														|  |    console.log( noid.value.data.label);
 |  |    console.log( noid.value.data.label);
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  | 
 |  | +emitter.on('child2Data', data => {
 | 
											
												
													
														|  | 
 |  | +  datatree.value = data;
 | 
											
												
													
														|  | 
 |  | +  console.log(datatree.value);
 | 
											
												
													
														|  | 
 |  | +})
 | 
											
												
													
														|  | 
 |  | +onUnmounted(() => {
 | 
											
												
													
														|  | 
 |  | +  emitter.off('child2Data');
 | 
											
												
													
														|  | 
 |  | +});
 | 
											
												
													
														|  |  function onNodeClick(e) {
 |  |  function onNodeClick(e) {
 | 
											
												
													
														|  |    noid.value = e.node;
 |  |    noid.value = e.node;
 | 
											
												
													
														|  |    labelname.value=e.node.data.label;
 |  |    labelname.value=e.node.data.label;
 | 
											
												
													
														|  | 
 |  | +  console.log(e.node);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +//模块化
 | 
											
												
													
														|  | 
 |  | +function onSelection(){
 | 
											
												
													
														|  | 
 |  | +  //onNodeDragStop();
 | 
											
												
													
														|  | 
 |  | +  let num=1;
 | 
											
												
													
														|  | 
 |  | +    num++;
 | 
											
												
													
														|  | 
 |  | +  let item= {
 | 
											
												
													
														|  | 
 |  | +    id: '1',
 | 
											
												
													
														|  | 
 |  | +    data: { label: '模块化' },
 | 
											
												
													
														|  | 
 |  | +    position: { x: 100, y: 100 },
 | 
											
												
													
														|  | 
 |  | +    style: { backgroundColor: 'rgba(16, 185, 129,0.1)', width: '200px',height: '200px' },
 | 
											
												
													
														|  | 
 |  | +  }
 | 
											
												
													
														|  | 
 |  | +  nodes.value = Nested.value.map(node => {
 | 
											
												
													
														|  | 
 |  | +    node.parentNode=item.id;
 | 
											
												
													
														|  | 
 |  | +    node.expandParent=true;
 | 
											
												
													
														|  | 
 |  | +    return node;
 | 
											
												
													
														|  | 
 |  | +  });
 | 
											
												
													
														|  | 
 |  | +  nodes.value.push(item);
 | 
											
												
													
														|  | 
 |  | +  console.log( nodes.value);
 | 
											
												
													
														|  | 
 |  | + 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | + 
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  function onNodeDoubleClick(e) {
 |  |  function onNodeDoubleClick(e) {
 | 
											
												
													
														|  |    noid.value = e.node;
 |  |    noid.value = e.node;
 | 
											
												
													
														|  | 
 |  | +  console.log( e.node);
 | 
											
												
													
														|  |    if (e.node.data.label == '优化器') {
 |  |    if (e.node.data.label == '优化器') {
 | 
											
												
													
														|  |      emit('optimizerfalse','优化器');
 |  |      emit('optimizerfalse','优化器');
 | 
											
												
													
														|  | -  }else if(e.node.data.label=='进化优化器'){
 |  | 
 | 
											
												
													
														|  | 
 |  | +  }else if(e.node.data.image=="/src/assets/flowimg/xuek10.png"){
 | 
											
												
													
														|  |      emit('optimizerfalse','进化优化器');
 |  |      emit('optimizerfalse','进化优化器');
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -  }else if(e.node.data.label=='AirfoilAero'||e.node.data.label=='Rosenbrock'){
 |  | 
 | 
											
												
													
														|  | 
 |  | +  }else if(e.node.data.image=="/src/assets/flowimg/xuek8.png"){
 | 
											
												
													
														|  |      emit('optimizerfalse','AirfoilAero');
 |  |      emit('optimizerfalse','AirfoilAero');
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -182,6 +217,7 @@ onInit((vueFlowInstance) => {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  onNodeDragStop(({ event, nodes, node }) => {
 |  |  onNodeDragStop(({ event, nodes, node }) => {
 | 
											
												
													
														|  |    console.log(nodes)
 |  |    console.log(nodes)
 | 
											
												
													
														|  | 
 |  | +  Nested.value=nodes;
 | 
											
												
													
														|  |    //console.log('Node Drag Stop', { event, nodes, node })
 |  |    //console.log('Node Drag Stop', { event, nodes, node })
 | 
											
												
													
														|  |  })
 |  |  })
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -200,17 +236,48 @@ function updatePos() {
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |    })
 |  |    })
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  function removeEdge(id) {
 |  |  function removeEdge(id) {
 | 
											
												
													
														|  |    id = Edgeid.value;
 |  |    id = Edgeid.value;
 | 
											
												
													
														|  |    vueFlowRef.value.removeEdges(id);
 |  |    vueFlowRef.value.removeEdges(id);
 | 
											
												
													
														|  | 
 |  | +  console.log('msg:',datatree.value);
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +// 触摸
 | 
											
												
													
														|  | 
 |  | +const onDrop1=(event)=>{
 | 
											
												
													
														|  | 
 |  | +  onDrop(event);
 | 
											
												
													
														|  | 
 |  | +emitter.emit('doSomethingEvent');
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  function removeNode(id) {
 |  |  function removeNode(id) {
 | 
											
												
													
														|  | -  id = noid.value.id
 |  | 
 | 
											
												
													
														|  | -  vueFlowRef.value.removeNodes(noid.value.id);
 |  | 
 | 
											
												
													
														|  | 
 |  | +  id = noid.value.id;
 | 
											
												
													
														|  | 
 |  | +  console.log(id);
 | 
											
												
													
														|  | 
 |  | +  console.log( datatree.value);
 | 
											
												
													
														|  | 
 |  | +  for (let i = 0; i <datatree.value[0].children.length; i++) {
 | 
											
												
													
														|  | 
 |  | +    if(id.includes(datatree.value[0].children[i].Text)){
 | 
											
												
													
														|  | 
 |  | +      for (let j = 0; j <datatree.value[0].children[i].children.length; j++) {
 | 
											
												
													
														|  | 
 |  | +        if(id==datatree.value[0].children[i].children[j].id){
 | 
											
												
													
														|  | 
 |  | +         //datatree.value[0].children.splice(datatree.value[0].children[i].children[j], 1); 
 | 
											
												
													
														|  | 
 |  | +           datatree.value[0].children[i].children.splice(j, 1)
 | 
											
												
													
														|  | 
 |  | +           vueFlowRef.value.removeNodes(id);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +    
 | 
											
												
													
														|  | 
 |  | +  }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  function removeall(){
 |  |  function removeall(){
 | 
											
												
													
														|  |    nodes.value=[];
 |  |    nodes.value=[];
 | 
											
												
													
														|  |    edges.value=[];
 |  |    edges.value=[];
 | 
											
												
													
														|  | 
 |  | +  for (let i = 0; i <datatree.value[0].children.length; i++) {
 | 
											
												
													
														|  | 
 |  | +      for (let j = 0; j <datatree.value[0].children[i].children.length; j++) {
 | 
											
												
													
														|  | 
 |  | +        datatree.value[0].children[i].children=[];
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  async  function logToObject1() {
 |  |  async  function logToObject1() {
 | 
											
												
													
														|  |    let obj = { nodes: toObject().nodes,edges:toObject().edges };
 |  |    let obj = { nodes: toObject().nodes,edges:toObject().edges };
 | 
											
										
											
												
													
														|  | @@ -308,8 +375,6 @@ console.log(num)
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  //改变线的颜色
 |  |  //改变线的颜色
 | 
											
												
													
														|  |  const changeAllEdgesColor=(color1)=>{
 |  |  const changeAllEdgesColor=(color1)=>{
 | 
											
												
													
														|  | -  //console.log(props.color1);
 |  | 
 | 
											
												
													
														|  | -  //console.log(seledge.value);
 |  | 
 | 
											
												
													
														|  |    linecolor.value= color1;
 |  |    linecolor.value= color1;
 | 
											
												
													
														|  |    if(  seledge.value){
 |  |    if(  seledge.value){
 | 
											
												
													
														|  |      console.log(11111)
 |  |      console.log(11111)
 | 
											
										
											
												
													
														|  | @@ -324,7 +389,7 @@ watch(() => seledge.value, (newItems, oldItems) => {
 | 
											
												
													
														|  |    //   //seledge.value.style.stroke =  linecolor.value;
 |  |    //   //seledge.value.style.stroke =  linecolor.value;
 | 
											
												
													
														|  |    // }
 |  |    // }
 | 
											
												
													
														|  |      });
 |  |      });
 | 
											
												
													
														|  | -defineExpose({changeAllEdgesColor,linestrokeWidth,getroter});
 |  | 
 | 
											
												
													
														|  | 
 |  | +defineExpose({changeAllEdgesColor,linestrokeWidth,getroter,onSelection});
 | 
											
												
													
														|  |  </script>
 |  |  </script>
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  <style>
 |  |  <style>
 | 
											
										
											
												
													
														|  | @@ -371,7 +436,7 @@ panel {
 | 
											
												
													
														|  |    font-size: 12px;
 |  |    font-size: 12px;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  .vue-flow__node-default, .vue-flow__node-input, .vue-flow__node-output{
 |  |  .vue-flow__node-default, .vue-flow__node-input, .vue-flow__node-output{
 | 
											
												
													
														|  | -  width: auto !important;
 |  | 
 | 
											
												
													
														|  | 
 |  | +  /* width: auto !important; */
 | 
											
												
													
														|  |    border: none;
 |  |    border: none;
 | 
											
												
													
														|  |    background-color: rgba(0,0,0,0);
 |  |    background-color: rgba(0,0,0,0);
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
										
											
												
													
														|  | @@ -403,4 +468,7 @@ panel {
 | 
											
												
													
														|  |    max-width: 16px;
 |  |    max-width: 16px;
 | 
											
												
													
														|  |    max-height: 16px;
 |  |    max-height: 16px;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  | 
 |  | +.field{
 | 
											
												
													
														|  | 
 |  | +  display: flex;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  </style>
 |  |  </style>
 |