|  | @@ -4,7 +4,7 @@
 | 
	
		
			
				|  |  |      :default-viewport="{ zoom: 1.5 }" :min-zoom="0.2" :max-zoom="4" @drop="onDrop"
 | 
	
		
			
				|  |  |      @contextmenu.prevent="onContextMenu" @node-contextmenu="logEvent('contextmenu', $event)" 
 | 
	
		
			
				|  |  |      @dragover="onDragOver" @dragleave="onDragLeave" @edge-click="onEdgeClick" @node-click="onNodeClick">
 | 
	
		
			
				|  |  | -    <template #node-default="props">
 | 
	
		
			
				|  |  | +    <template  #node-default="props">
 | 
	
		
			
				|  |  |        <!-- <template  #node-process="props">   //  @contextmenu.prevent="onContextMenu"  -->
 | 
	
		
			
				|  |  |        <eltree :node="props" />
 | 
	
		
			
				|  |  |      </template>
 | 
	
	
		
			
				|  | @@ -18,6 +18,7 @@
 | 
	
		
			
				|  |  |          <button class="remove" @click="removeEdge(event)">删除线</button>
 | 
	
		
			
				|  |  |          <!-- <button class="remove" @click="getnodes()">获取所有数据</button> -->
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  | +     
 | 
	
		
			
				|  |  |      </Panel>
 | 
	
		
			
				|  |  |      <Controls position="top-left">
 | 
	
		
			
				|  |  |        <ControlButton title="Reset Transform" @click="resetTransform">
 | 
	
	
		
			
				|  | @@ -33,7 +34,7 @@
 | 
	
		
			
				|  |  |          <Icon v-else name="moon" />
 | 
	
		
			
				|  |  |        </ControlButton>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -      <ControlButton title="Log `toObject`" @click="logToObject">
 | 
	
		
			
				|  |  | +      <ControlButton title="Log `toObject`" @click="logToObject1">
 | 
	
		
			
				|  |  |          <Icon name="log" />
 | 
	
		
			
				|  |  |        </ControlButton>
 | 
	
		
			
				|  |  |      </Controls>
 | 
	
	
		
			
				|  | @@ -41,7 +42,7 @@
 | 
	
		
			
				|  |  |    </VueFlow>
 | 
	
		
			
				|  |  |    <div class="dnd-flow">
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    <div id="contextMenu" @click="deleteItemConfirm">删除</div>
 | 
	
		
			
				|  |  | +    <!-- <div id="contextMenu" @click="deleteItemConfirm">删除</div> -->
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    </div>
 | 
	
	
		
			
				|  | @@ -49,7 +50,9 @@
 | 
	
		
			
				|  |  |  <script setup>
 | 
	
		
			
				|  |  |  import { ref, markRaw } from 'vue'
 | 
	
		
			
				|  |  |  import { VueFlow, useVueFlow, MarkerType } from '@vue-flow/core'
 | 
	
		
			
				|  |  | +import { ElMessage, ElButton, ElDialog, ElSelect } from 'element-plus'
 | 
	
		
			
				|  |  |  import { useRoute } from 'vue-router';
 | 
	
		
			
				|  |  | +import { request, uploadFile } from "@/utils/request";
 | 
	
		
			
				|  |  |  import { Background } from '@vue-flow/background'
 | 
	
		
			
				|  |  |  import { ControlButton, Controls } from '@vue-flow/controls'
 | 
	
		
			
				|  |  |  import { initialEdges, initialNodes } from './modeljs.js'
 | 
	
	
		
			
				|  | @@ -57,21 +60,25 @@ import { MiniMap } from '@vue-flow/minimap'
 | 
	
		
			
				|  |  |  import "./main.css";//重置样式
 | 
	
		
			
				|  |  |  import DropzoneBackground from './DropzoneBackground.vue'
 | 
	
		
			
				|  |  |  import eltree from './eltree.vue'
 | 
	
		
			
				|  |  | -import useDragAndDrop from './useDnD'
 | 
	
		
			
				|  |  | +import useDragAndDrop from './useDnD';
 | 
	
		
			
				|  |  |  import f11 from '@/assets/img/f11.png'
 | 
	
		
			
				|  |  | +import html2canvas from 'html2canvas';
 | 
	
		
			
				|  |  |  import Icon from './Icon.vue'
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  const dark = ref(false)
 | 
	
		
			
				|  |  |  const route = useRoute();
 | 
	
		
			
				|  |  |  const { onInit, onNodeDragStop, onNodeContextMenu, onConnect, addEdges, setViewport, toObject } = useVueFlow()
 | 
	
		
			
				|  |  |  let vueFlowRef = ref();
 | 
	
		
			
				|  |  |  let emit = defineEmits(['optimizerfalse']);
 | 
	
		
			
				|  |  | +let mergedObj=ref();
 | 
	
		
			
				|  |  |  const props = defineProps({
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    optimizer: {
 | 
	
		
			
				|  |  |      type: Boolean,
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |  })
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +let newroter=ref();
 | 
	
		
			
				|  |  | +let vueflowimg=ref('');
 | 
	
		
			
				|  |  |  const shopShow = ref(false);
 | 
	
		
			
				|  |  |  let noid = ref([]);
 | 
	
		
			
				|  |  |  let Edgeid = ref();
 | 
	
	
		
			
				|  | @@ -105,36 +112,36 @@ function logEvent(name, event) {
 | 
	
		
			
				|  |  |    console.log(2222)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  function onContextMenu(event) {
 | 
	
		
			
				|  |  | -  if (noid.value !== null) {
 | 
	
		
			
				|  |  | -    if (noid.value.id) {
 | 
	
		
			
				|  |  | -      console.log(noid.value.position.y);
 | 
	
		
			
				|  |  | -      console.log(noid.value.position.x);
 | 
	
		
			
				|  |  | -      document.getElementById('contextMenu').style.top = noid.value.position.y + 100 + 'px';
 | 
	
		
			
				|  |  | -      document.getElementById('contextMenu').style.left = noid.value.position.x + 270 + 'px';
 | 
	
		
			
				|  |  | -      document.getElementById('contextMenu').style.display = 'block';
 | 
	
		
			
				|  |  | -      event.preventDefault();
 | 
	
		
			
				|  |  | -      //shopShow.value=true;
 | 
	
		
			
				|  |  | -      // document.getElementById('contextMenu').style.display = 'none';
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +//   if (noid.value !== null) {
 | 
	
		
			
				|  |  | +//     if (noid.value.id) {
 | 
	
		
			
				|  |  | +//       console.log(noid.value.position.y);
 | 
	
		
			
				|  |  | +//       console.log(noid.value.position.x);
 | 
	
		
			
				|  |  | +//       document.getElementById('contextMenu').style.top = noid.value.position.y + 100 + 'px';
 | 
	
		
			
				|  |  | +//       document.getElementById('contextMenu').style.left = noid.value.position.x + 270 + 'px';
 | 
	
		
			
				|  |  | +//       document.getElementById('contextMenu').style.display = 'block';
 | 
	
		
			
				|  |  | +//       event.preventDefault();
 | 
	
		
			
				|  |  | +//       //shopShow.value=true;
 | 
	
		
			
				|  |  | +//       // document.getElementById('contextMenu').style.display = 'none';
 | 
	
		
			
				|  |  | +//     }
 | 
	
		
			
				|  |  | +//   }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  //点击左键右键内容消失
 | 
	
		
			
				|  |  | -document.addEventListener('click', function (e) {
 | 
	
		
			
				|  |  | -  if (e.button === 0) { // 0 是左键
 | 
	
		
			
				|  |  | -    document.getElementById('contextMenu').style.display = 'none';
 | 
	
		
			
				|  |  | -    //   shopShow.value=false;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | -});
 | 
	
		
			
				|  |  | +// document.addEventListener('click', function (e) {
 | 
	
		
			
				|  |  | +//   if (e.button === 0) { // 0 是左键
 | 
	
		
			
				|  |  | +//     document.getElementById('contextMenu').style.display = 'none';
 | 
	
		
			
				|  |  | +//     //   shopShow.value=false;
 | 
	
		
			
				|  |  | +//   }
 | 
	
		
			
				|  |  | +// });
 | 
	
		
			
				|  |  |  //删除
 | 
	
		
			
				|  |  | -const deleteItemConfirm = () => {
 | 
	
		
			
				|  |  | -  if (noid.value.id) {
 | 
	
		
			
				|  |  | -    vueFlowRef.value.removeNodes(noid.value.id);
 | 
	
		
			
				|  |  | -    noid.value = null;
 | 
	
		
			
				|  |  | -    document.getElementById('contextMenu').style.display = 'none';
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +// const deleteItemConfirm = () => {
 | 
	
		
			
				|  |  | +//   if (noid.value.id) {
 | 
	
		
			
				|  |  | +//     vueFlowRef.value.removeNodes(noid.value.id);
 | 
	
		
			
				|  |  | +//     noid.value = null;
 | 
	
		
			
				|  |  | +//     document.getElementById('contextMenu').style.display = 'none';
 | 
	
		
			
				|  |  | +//   }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +// }
 | 
	
		
			
				|  |  |  onInit((vueFlowInstance) => {
 | 
	
		
			
				|  |  |    vueFlowInstance.fitView()
 | 
	
		
			
				|  |  |  })
 | 
	
	
		
			
				|  | @@ -167,10 +174,58 @@ function removeNode(id) {
 | 
	
		
			
				|  |  |    id = noid.value.id
 | 
	
		
			
				|  |  |    vueFlowRef.value.removeNodes(noid.value.id);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | -function logToObject() {
 | 
	
		
			
				|  |  | -  console.log(toObject())
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +async  function logToObject1() {
 | 
	
		
			
				|  |  | +  let obj = { nodes: toObject().nodes,edges:toObject().edges };
 | 
	
		
			
				|  |  | +  mergedObj.value=JSON.stringify(obj);
 | 
	
		
			
				|  |  | +  try {
 | 
	
		
			
				|  |  | +    console.log(vueFlowRef.value)
 | 
	
		
			
				|  |  | +        const container = vueFlowRef.value.$el;
 | 
	
		
			
				|  |  | +        const canvas = await html2canvas(container);
 | 
	
		
			
				|  |  | +        const img = canvas.toDataURL('image/png');
 | 
	
		
			
				|  |  | + 
 | 
	
		
			
				|  |  | +        // 创建一个图片元素并设置src属性为转换后的图片数据
 | 
	
		
			
				|  |  | +        const image = new Image();
 | 
	
		
			
				|  |  | +        image.src = img;
 | 
	
		
			
				|  |  | +       vueflowimg.value=img
 | 
	
		
			
				|  |  | +       if(vueflowimg.value!=''){
 | 
	
		
			
				|  |  | +        console.log("进入了")
 | 
	
		
			
				|  |  | +        addflow();
 | 
	
		
			
				|  |  | +       }
 | 
	
		
			
				|  |  | +        // 添加到DOM中或者做其他操作
 | 
	
		
			
				|  |  | +      } catch (error) {
 | 
	
		
			
				|  |  | +        console.error('转换出错:', error);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +  // console.log(toObject())
 | 
	
		
			
				|  |  | +  // if (!vueFlowRef.value) {
 | 
	
		
			
				|  |  | +  //   console.warn('VueFlow element not found');
 | 
	
		
			
				|  |  | +  //   return;
 | 
	
		
			
				|  |  | +  // }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  // capture(vueFlowRef.value, { shouldDownload: true });
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +//添加接口
 | 
	
		
			
				|  |  | +const addflow = () => {
 | 
	
		
			
				|  |  | +    const params = {
 | 
	
		
			
				|  |  | +        transCode: 'MDO0002',
 | 
	
		
			
				|  |  | +        pid: '',
 | 
	
		
			
				|  |  | +        name: newroter.value.name,
 | 
	
		
			
				|  |  | +        remark:newroter.value.description,
 | 
	
		
			
				|  |  | +        image:vueflowimg.value,
 | 
	
		
			
				|  |  | +        isshare:'1',
 | 
	
		
			
				|  |  | +        flow:mergedObj.value 
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    request(params)
 | 
	
		
			
				|  |  | +        .then((res) => {
 | 
	
		
			
				|  |  | +            console.log(res);
 | 
	
		
			
				|  |  | +            ElMessage({
 | 
	
		
			
				|  |  | +                  message: res.returnMsg,
 | 
	
		
			
				|  |  | +                  type: 'success',
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        .catch((err) => {
 | 
	
		
			
				|  |  | +            ElMessage.error(err.returnMsg)
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Resets the current viewport transformation (zoom & pan)
 | 
	
		
			
				|  |  |   */
 | 
	
	
		
			
				|  | @@ -188,13 +243,21 @@ onMounted(() => {
 | 
	
		
			
				|  |  |  });
 | 
	
		
			
				|  |  |  // 获取链接
 | 
	
		
			
				|  |  |  const getroter=()=>{
 | 
	
		
			
				|  |  | -  console.log(11111)
 | 
	
		
			
				|  |  | -  console.log(route.query);
 | 
	
		
			
				|  |  | -  if(route.query.id=='0'){
 | 
	
		
			
				|  |  | -    console.log(route.query);
 | 
	
		
			
				|  |  | -    nodes.value=initialNodes;
 | 
	
		
			
				|  |  | -    edges.value=initialEdges;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | + if(route.query.id=='2'){
 | 
	
		
			
				|  |  | +  let objlist=JSON.parse(sessionStorage.getItem("objlist"));
 | 
	
		
			
				|  |  | +  let nodesflow=JSON.parse(objlist.flow)
 | 
	
		
			
				|  |  | +      nodes.value=nodesflow.nodes;
 | 
	
		
			
				|  |  | +      edges.value=nodesflow.edges;
 | 
	
		
			
				|  |  | + }else if(route.query.id='1'&&route.query!={}){
 | 
	
		
			
				|  |  | +  newroter.value=JSON.parse(route.query.vlaobj);
 | 
	
		
			
				|  |  | +  
 | 
	
		
			
				|  |  | + }
 | 
	
		
			
				|  |  | +  // if(route.query.id=='0'){
 | 
	
		
			
				|  |  | +  //   console.log(route.query);
 | 
	
		
			
				|  |  | +  //   nodes.value=initialNodes;
 | 
	
		
			
				|  |  | +  //   edges.value=initialEdges;
 | 
	
		
			
				|  |  | +  // }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  </script>
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -240,4 +303,18 @@ panel {
 | 
	
		
			
				|  |  |    border: none;
 | 
	
		
			
				|  |  |    background-color: rgba(0,0,0,0);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +.node-content {
 | 
	
		
			
				|  |  | +  cursor: move;  /* 更改鼠标光标表示可拖动 */
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +.vue-flow__node {
 | 
	
		
			
				|  |  | +  cursor: move;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* 禁用文本选中效果 */
 | 
	
		
			
				|  |  | +.left_main * {
 | 
	
		
			
				|  |  | +  -webkit-user-select: none; /* Safari */
 | 
	
		
			
				|  |  | +  -moz-user-select: none; /* Firefox */
 | 
	
		
			
				|  |  | +  -ms-user-select: none; /* IE10+/Edge */
 | 
	
		
			
				|  |  | +  user-select: none; /* Standard syntax */
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  </style>
 |