wente
2024-10-14 7917c76b02b213a5fa805a6e2c9936167fae5cc8
web/src/views/modules/taskReliability/timeDiagramThumbnail.vue
@@ -9,7 +9,7 @@
    name: "timeDiagramThumbnail",
    data(){
      return{
        graph:null,
        thumbnailGraph:null,
        smallWidth:0,
        targetNode:{},
      }
@@ -19,7 +19,7 @@
        console.log(document.documentElement.clientWidth, 'document.documentElement.clientWidth')
        console.log(document.documentElement.clientHeight, 'document.documentElement.clientHeight')
        this.graph = new Graph({
        this.thumbnailGraph = new Graph({
          container: document.getElementById('timeDiagramThumbnail'),
          // width:250,
          height: 150,
@@ -66,7 +66,7 @@
          // autoResize: true,
          // keyboard: true,
        })
        this.graph.centerContent()
        this.thumbnailGraph.centerContent()
        Graph.registerNode(
          'custom-rect',
          {
@@ -265,23 +265,23 @@
          true,
        )
        this.graph.on('node:moving', ({ e, x, y, node, view }) => {
        this.thumbnailGraph.on('node:moving', ({ e, x, y, node, view }) => {
         this.$emit('getPoint',x,this.smallWidth)
        })
      },
      getThumbnail(smallDiagramJson){
        this.graph.fromJSON(smallDiagramJson)
        this.graph.centerContent()
        this.smallWidth = this.graph.getContentBBox().width
        const nodes = this.graph.getNodes()
        this.thumbnailGraph.fromJSON(smallDiagramJson)
        this.thumbnailGraph.centerContent()
        this.smallWidth = this.thumbnailGraph.getContentBBox().width
        const nodes = this.thumbnailGraph.getNodes()
        for (const otherNode of nodes) {
          if (otherNode.hasParent()){
            this.targetNode = otherNode
            console.log(this.targetNode,'targetNode')
          }
        }
        // console.log(this.graph.getContentBBox().width,'DiagramJson11')
        // this.graph.zoomToFit()
        // console.log(this.thumbnailGraph.getContentBBox().width,'DiagramJson11')
        // this.thumbnailGraph.zoomToFit()
      },
      getNodePointX(x,bigWidth){
        let pointX = Number((x / ( bigWidth /this.smallWidth)).toFixed(0))
@@ -292,7 +292,7 @@
      },
      // setScroll(top){
      //   this.graph.setScrollbarPosition(null, top)
      //   this.thumbnailGraph.setScrollbarPosition(null, top)
      // }
    },
  }