| | |
| | | }, |
| | | mounted() { |
| | | this.getProductList() |
| | | this.init() |
| | | this.$refs.textDiagram.init() |
| | | this.$refs.timeDiagramThumbnail.init() |
| | | }, |
| | |
| | | this.$refs.timeDiagramThumbnail.getNodePointX(left,this.bigWidth) |
| | | }, |
| | | init() { |
| | | console.log(document.documentElement.clientWidth, 'document.documentElement.clientWidth') |
| | | console.log(document.documentElement.clientHeight, 'document.documentElement.clientHeight') |
| | | this.graph = new Graph({ |
| | | container: document.getElementById('timeDiagram'), |
| | | // width: document.documentElement.clientWidth - 100, |
| | |
| | | this.knob = document.createElement('div',false) |
| | | this.knob.style.position = 'absolute' |
| | | document.getElementById('timeDiagram').appendChild(this.knob) |
| | | this.graph.centerContent() |
| | | |
| | | this.graph.positionContent('left',{ padding: { left: 0 }}) |
| | | // this.graph.centerContent() |
| | | Graph.registerNode( |
| | | 'custom-rect', |
| | | { |
| | |
| | | this.$nextTick(() => { |
| | | this.$refs.ProductModelTree.getProductList() |
| | | }) |
| | | this.init() |
| | | // this.init() |
| | | }, |
| | | onTaskSelected(data) { |
| | | console.log(data, ' onProductSelected(data)') |
| | |
| | | this.$refs.timeDiagramThumbnail.getThumbnail(smallDiagramJson) |
| | | } else { |
| | | this.graph.fromJSON(this.emptyJson) |
| | | this.graph.centerContent() |
| | | this.graph.positionContent('left',{ padding: { left: 0 }}) |
| | | // this.graph.centerContent() |
| | | //this.graph.zoomToFit() |
| | | this.graph.freeze() |
| | | } |
| | |
| | | name: "textDiagram", |
| | | data(){ |
| | | return{ |
| | | graph:null, |
| | | textGraph:null, |
| | | } |
| | | }, |
| | | methods:{ |
| | | init() { |
| | | console.log(document.documentElement.clientWidth, 'document.documentElement.clientWidth') |
| | | console.log(document.documentElement.clientHeight, 'document.documentElement.clientHeight') |
| | | this.graph = new Graph({ |
| | | this.textGraph = new Graph({ |
| | | container: document.getElementById('textDiagram'), |
| | | // width:250, |
| | | height: document.documentElement.clientHeight - 440, |
| | |
| | | }, |
| | | keyboard: true, |
| | | }) |
| | | this.graph.centerContent() |
| | | this.textGraph.centerContent() |
| | | |
| | | Graph.registerNode( |
| | | 'custom-rect', |
| | |
| | | ) |
| | | }, |
| | | getTextDiagram(diagramJson){ |
| | | this.graph.unfreeze() |
| | | this.graph.fromJSON(diagramJson) |
| | | this.graph.positionContent('left',{ padding: { left: 0 }}) |
| | | this.graph.freeze() |
| | | // this.graph.centerContent() |
| | | // this.graph.zoomToFit() |
| | | this.textGraph.unfreeze() |
| | | this.textGraph.fromJSON(diagramJson) |
| | | this.textGraph.positionContent('left',{ padding: { left: 0 }}) |
| | | this.textGraph.freeze() |
| | | // this.textGraph.centerContent() |
| | | // this.textGraph.zoomToFit() |
| | | }, |
| | | setScroll(top){ |
| | | this.graph.setScrollbarPosition(null, top) |
| | | this.textGraph.setScrollbarPosition(null, top) |
| | | } |
| | | }, |
| | | } |
| | |
| | | name: "timeDiagramThumbnail", |
| | | data(){ |
| | | return{ |
| | | graph:null, |
| | | thumbnailGraph:null, |
| | | smallWidth:0, |
| | | targetNode:{}, |
| | | } |
| | |
| | | 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, |
| | |
| | | // autoResize: true, |
| | | // keyboard: true, |
| | | }) |
| | | this.graph.centerContent() |
| | | this.thumbnailGraph.centerContent() |
| | | Graph.registerNode( |
| | | 'custom-rect', |
| | | { |
| | |
| | | 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)) |
| | |
| | | |
| | | }, |
| | | // setScroll(top){ |
| | | // this.graph.setScrollbarPosition(null, top) |
| | | // this.thumbnailGraph.setScrollbarPosition(null, top) |
| | | // } |
| | | }, |
| | | } |