在vue中使用gojs實(shí)現(xiàn)流程圖功能

記錄一下項(xiàng)目中的需求完成流程圖示例,使用的是使用vue-cli搭建的項(xiàng)目,配合gojs來實(shí)現(xiàn)的,附上截圖一份:


完成保存,清空等功能

由于沒有中文文檔,所以也摸索了一天的時(shí)間,終于是完成了需求:

第一步:引入GOJS(官方文檔上下載的有水印,我用的是破解版本的,需要的可以找我拿一下QQ:1013218132)

話不多說,直接上代碼:? ? ? gojs的引入和echarts有點(diǎn)類似,也是畫布完成的,都是根據(jù)ID值獲取頁面節(jié)點(diǎn)去渲染標(biāo)簽的

<template>

????<div?class="modelingBox">

????????<div?class="modelingHead">

? ? ? ? ? ? <el-button?id="SaveButton"?@click="save">保存</el-button>

????????????<el-button?@click="load">清空</el-button>

????????????<textarea?id="mySavedModel"?style="width:100%;height:300px;display:none">? ? ? ? ? ? ? ? ?{?"class":?"go.GraphLinksModel",????????????????"linkFromPortIdProperty":?"fromPort",????????????????"linkToPortIdProperty":?"toPort",????????????????"nodeDataArray":?[???????????????],????????????????"linkDataArray":?[???????????????]}???????????????

?</textarea>????????????

<div?class="msg_">????????????????

<p>流程</p>????????????????

<el-select?v-model="valueOptions"?@change="selectChange"?filterable?placeholder="請選擇">

????????????????????<el-option?v-for="item?in?options"???????????????????????????????:key="item.value"???????????????????????????????:label="item.label"???????????????????????????????:value="item.value"></el-option>????????????????

</el-select>????????????

</div>????????

</div>????????????

<div?id="sample">???????????

?<div?style="width:?100%;height:100%;?display:?flex;?justify-content:?space-between">????????????????

<div?id="myPaletteDiv"?style="width:?200px;?margin-right:?2px;?background-color:?#fafafa;"></div>????????????????

<div?id="myDiagramDiv"?style="flex-grow:?1;?height:?100%;?background-color:?#fafafa;"></div>???????????

?</div>??????????????????

</div>???????

?<el-dialog?title="開始節(jié)點(diǎn)"?:visible.sync="StartShow"?width="30%"?:before-close="handleClose">

????????????<span>這是一段信息</span>????????????<span?slot="footer"?class="dialog-footer">????????????????

<el-button?@click="StartShow?=?false">取?消</el-button>????????????????

<el-button?type="primary"?@click="StartShow?=?false">確?定</el-button>????????????</span>????????

</el-dialog>????????

<el-dialog?title="審批節(jié)點(diǎn)"?:visible.sync="ActivityShow"?width="30%"?:before-close="handleClose">???????????

?<span>這是一段信息</span>????????????<span?slot="footer"?class="dialog-footer">????????????????

<el-button?@click="ActivityShow?=?false">取?消</el-button>???????????????

?<el-button?type="primary"?@click="ActivityShow?=?false">確?定</el-button>????????????</span>????????

</el-dialog>????

</div>

</template>

js:

<script>????//?import?{?init?}?from?"./test";????import?go?from?"./gojs/go-cracked";????export?default?{????????data()?{????????????return?{????????????????StartShow:?false,????????????????ActivityShow:?false,????????????????options:?[????????????????????{????????????????????????value:?'0',????????????????????????label:'路段管理單位發(fā)文流程(1.0)'????????????????????},????????????????????{????????????????????????value:?'1',????????????????????????label:?'支隊(duì)收文流程(1.0)'????????????????????}????????????????],????????????????valueOptions:''????????????};????????},????????methods:?{????????????selectChange()?{????????????????console.log(this.valueOptions,'select')????????????},????????????handleClose()?{????????????????this.StartShow?=?false????????????????this.ActivityShow?=?false????????????},????????????nodeDoubleClick(e,?node)?{????????????????console.log(e,?node.part.data.category);????????????????if?(node.part.data.category?==?"Start")?{????????????????????this.StartShow?=?true;????????????????}?else?if?(node.part.data.category?==?"Activity")?{????????????????????this.ActivityShow?=?true;????????????????}????????????},????????????nodeStyle()?{????????????????var?this_?=?this;????????????????return?[????????????????????{????????????????????????locationSpot:?go.Spot.Center,????????????????????????isShadowed:?false,????????????????????????doubleClick:?function?(e,?node)?{????????????????????????????if?(!e.diagram)?return;????????????????????????????if?(!e.diagram.allowLink)?return;????????????????????????????var?nCategory?=?node.part.data.category;????????????????????????????if?(nCategory?!=?"Activity"?&&?nCategory?!=?"Start")?return;????????????????????????????this_.nodeDoubleClick(e,?node);????????????????????????},????????????????????????//鼠標(biāo)懸停時(shí)顯示node上的點(diǎn)????????????????????????mouseEnter:?function?(e,?obj)?{????????????????????????????//?this.displayNodePorts(obj.part,?true);????????????????????????????var?diagram?=?obj.part.diagram;????????????????????????????if?(!diagram?||?diagram.isReadOnly?||?!diagram.allowLink)?return;????????????????????????????obj.part.ports.each(function?(port)?{????????????????????????????????port.stroke?=?true???"white"?:?null;????????????????????????????});????????????????????????},????????????????????????mouseLeave:?function?(e,?obj)?{????????????????????????????//?this.displayNodePorts(obj.part,?false);????????????????????????????var?diagram?=?obj.part.diagram;????????????????????????????if?(!diagram?||?diagram.isReadOnly?||?!diagram.allowLink)?return;????????????????????????????obj.part.ports.each(function?(port)?{????????????????????????????????port.stroke?=?false???"white"?:?null;????????????????????????????});????????????????????????},????????????????????},????????????????????new?go.Binding("location",?"loc",?go.Point.parse).makeTwoWay(????????????????????????go.Point.stringify????????????????????),????????????????];????????????},????????????//?displayNodePorts(node,?show)?{????????????//???var?diagram?=?node.diagram;????????????//???if?(!diagram?||?diagram.isReadOnly?||?!diagram.allowLink)?return;????????????//???node.ports.each(function?(port)?{????????????//?????port.stroke?=?show???"white"?:?null;????????????//???});????????????//?},????????????load()?{????????????????this.myDiagram.model?=?go.Model.fromJson(????????????????????document.getElementById("mySavedModel").value????????????????);????????????},????????????//???Show?the?diagram's?model?in?JSON?format?that?the?user?may?edit????點(diǎn)擊生產(chǎn)JSON????????????save()?{????????????????document.getElementById(????????????????????"mySavedModel"????????????????).value?=?this.myDiagram.model.toJson();????????????????this.myDiagram.isModified?=?false;????????????????console.log(this.myDiagram.model.toJson(),?"this.myDiagram");????????????},????????},????????mounted()?{????????????var?mySelf?=?this;????????????//??if?(window.goSamples)?goSamples();??//?init?for?these?samples?--?you?don't?need?to?call?this????????????var?$?=?go.GraphObject.make;?//?for?conciseness?in?defining?templates????????????mySelf.myDiagram?=?$(go.Diagram,?"myDiagramDiv",?{????????????????initialContentAlignment:?go.Spot.Center,?//?居中顯示????????????????allowDrop:?true,????????????????isReadOnly:?false,????????????????"undoManager.isEnabled":?true,?//?支持?Ctrl-Z?和?Ctrl-Y?操作????????????????//???"toolManager.hoverDelay":?100,?//tooltip提示顯示延時(shí)????????????????//???"toolManager.toolTipDuration":?10000,?//tooltip持續(xù)顯示時(shí)間????????????????"animationManager.isEnabled":?true,????????????????"animationManager.duration":?500,????????????????//isReadOnly:true,//只讀????????????????"grid.visible":?true,?//顯示網(wǎng)格????????????????//???allowMove:?true,?//允許拖動????????????????//???allowDragOut:?true,????????????????//???allowDelete:?true,????????????????//???allowCopy:?true,????????????????//?allowClipboard:?false,????????????????//???"toolManager.mouseWheelBehavior":?go.ToolManager.WheelZoom,?//有鼠標(biāo)滾輪事件放大和縮小,而不是向上和向下滾動????????????????//拖動后自動排列位置????????????????//???layout:?$(go.TreeLayout,?{????????????????//?????angle:?0,????????????????//?????layerSpacing:?35,????????????????//???}),????????????});?//構(gòu)建gojs對象????????????var?tbFontNormal?=?"normal?normal?normal?14px?'Microsoft?YaHei',Arial";????????????var?tbFontBold?=?"normal?normal?bold?14px?'Microsoft?YaHei',Arial";????????????//?//?when?the?document?is?modified,?add?a?"*"?to?the?title?and?enable?the?"Save"?button????????????//?mySelf.myDiagram.addDiagramListener("Modified",?(e)?=>?{????????????//???var?button?=?document.getElementById("SaveButton");????????????//???if?(button)?button.disabled?=?!mySelf.myDiagram.isModified;????????????//???var?idx?=?document.title.indexOf("*");????????????//???if?(mySelf.myDiagram.isModified)?{????????????//?????if?(idx?<?0)?document.title?+=?"*";????????????//???}?else?{????????????//?????if?(idx?>=?0)?document.title?=?document.title.substr(0,?idx);????????????//???}????????????//?});????????????//?//?helper?definitions?for?node?templates????????????//?mySelf.nodeStyle();????????????//?Define?a?function?for?creating?a?"port"?that?is?normally?transparent.????????????//?The?"name"?is?used?as?the?GraphObject.portId,????????????//?the?"align"?is?used?to?determine?where?to?position?the?port?relative?to?the?body?of?the?node,????????????//?the?"spot"?is?used?to?control?how?links?connect?with?the?port?and?whether?the?port????????????//?stretches?along?the?side?of?the?node,????????????//?and?the?boolean?"output"?and?"input"?arguments?control?whether?the?user?can?draw?links?from?or?to?the?port.????????????//??mySelf.makePort(name,?align,?spot,?output,?input)????????????//?function?makePort(name,?align,?spot,?output,?input)?{????????????//???var?horizontal?=????????????//?????align.equals(go.Spot.Top)?||?align.equals(go.Spot.Bottom);????????????//???//?the?port?is?basically?just?a?transparent?rectangle?that?stretches?along?the?side?of?the?node,????????????//???//?and?becomes?colored?when?the?mouse?passes?over?it????????????//???return?$(go.Shape,?{????????????//?????fill:?"transparent",?//?changed?to?a?color?in?the?mouseEnter?event?handler????????????//?????strokeWidth:?0,?//?no?stroke????????????//?????width:?horizontal???NaN?:?8,?//?if?not?stretching?horizontally,?just?8?wide????????????//?????height:?!horizontal???NaN?:?8,?//?if?not?stretching?vertically,?just?8?tall????????????//?????alignment:?align,?//?align?the?port?on?the?main?Shape????????????//?????stretch:?horizontal????????????//?????????go.GraphObject.Horizontal????????????//???????:?go.GraphObject.Vertical,????????????//?????portId:?name,?//?declare?this?object?to?be?a?"port"????????????//?????fromSpot:?spot,?//?declare?where?links?may?connect?at?this?port????????????//?????fromLinkable:?output,?//?declare?whether?the?user?may?draw?links?from?here????????????//?????toSpot:?spot,?//?declare?where?links?may?connect?at?this?port????????????//?????toLinkable:?input,?//?declare?whether?the?user?may?draw?links?to?here????????????//?????cursor:?"pointer",?//?show?a?different?cursor?to?indicate?potential?link?point????????????//?????mouseEnter:?function?(e,?port)?{????????????//???????//?the?PORT?argument?will?be?this?Shape????????????//???????if?(!e.diagram.isReadOnly)?port.fill?=?"rgba(255,0,255,0.5)";????????????//?????},????????????//?????mouseLeave:?(e,?port)?=>?{????????????//???????port.fill?=?"transparent";????????????//?????},????????????//???});????????????//?}????????????//創(chuàng)建node上的點(diǎn),默認(rèn)透明冰沙,懸停后顯示白色????????????function?makeNodePort(name,?spot,?output,?input)?{????????????????return?$(go.Shape,?"Circle",?{????????????????????fill:?"transparent",????????????????????stroke:?null,????????????????????desiredSize:?new?go.Size(8,?8),????????????????????cursor:?"pointer",????????????????????portId:?name,????????????????????alignment:?spot,????????????????????alignmentFocus:?spot,????????????????????fromSpot:?spot,????????????????????toSpot:?spot,????????????????????fromLinkable:?output,????????????????????toLinkable:?input,????????????????});????????????}????????????function?textStyle()?{????????????????return?{????????????????????font:?"bold?11pt?Lato,?Helvetica,?Arial,?sans-serif",????????????????????stroke:?"#F8F8F8",????????????????};????????????}????????????//?//?define?the?Node?templates?for?regular?nodes????????????//審批節(jié)點(diǎn)????????????mySelf.myDiagram.nodeTemplateMap.add(????????????????"Activity",????????????????$(????????????????????go.Node,????????????????????"Spot",????????????????????mySelf.nodeStyle(),????????????????????$(????????????????????????go.Panel,????????????????????????"Auto",????????????????????????$(go.Shape,?"Rectangle",?{????????????????????????????desiredSize:?new?go.Size(80,?40),????????????????????????????minSize:?new?go.Size(20,?10),????????????????????????????fill:?"#1E90FF",????????????????????????????stroke:?"#1E90FF",????????????????????????}),????????????????????????$(????????????????????????????go.TextBlock,????????????????????????????"上級審批",????????????????????????????{????????????????????????????????stroke:?"#FFFFFF",????????????????????????????????font:?tbFontNormal,????????????????????????????????textAlign:?"center",????????????????????????????????margin:?new?go.Margin(7,?5,?5,?5),????????????????????????????????maxSize:?new?go.Size(50,?20),????????????????????????????},????????????????????????????new?go.Binding("text").makeTwoWay()????????????????????????)????????????????????),????????????????????makeNodePort("T",?go.Spot.Top,?false,?true),????????????????????makeNodePort("R",?go.Spot.Right,?true,?true),????????????????????makeNodePort("B",?go.Spot.Bottom,?true,?false),????????????????????makeNodePort("L",?go.Spot.Left,?true,?true)????????????????)????????????);????????????mySelf.myDiagram.nodeTemplateMap.add(????????????????"Conditional",????????????????$(????????????????????go.Node,????????????????????"Spot",????????????????????mySelf.nodeStyle(),????????????????????//?the?main?object?is?a?Panel?that?surrounds?a?TextBlock?with?a?rectangular?Shape????????????????????$(????????????????????????go.Panel,????????????????????????"Auto",????????????????????????$(????????????????????????????go.Shape,????????????????????????????"Terminator",????????????????????????????{????????????????????????????????minSize:?new?go.Size(120,?38),????????????????????????????????fill:?"#4AAA4A",????????????????????????????????stroke:?"#4AAA4A",????????????????????????????????strokeWidth:?3.5,????????????????????????????},????????????????????????????new?go.Binding("figure",?"figure")????????????????????????),????????????????????????$(????????????????????????????go.TextBlock,????????????????????????????//?textStyle(),????????????????????????????{????????????????????????????????stroke:?"#FFFFFF",????????????????????????????????font:?tbFontBold,????????????????????????????????textAlign:?"center",????????????????????????????????margin:?new?go.Margin(7,?5,?5,?5),????????????????????????????????maxSize:?new?go.Size(160,?NaN),????????????????????????????},????????????????????????????new?go.Binding("text").makeTwoWay()????????????????????????)????????????????????),????????????????????//?four?named?ports,?one?on?each?side:????????????????????makeNodePort("T",?go.Spot.Top,?false,?true),????????????????????makeNodePort("R",?go.Spot.Right,?false,?true),????????????????????makeNodePort("L",?go.Spot.Left,?false,?true)????????????????)????????????);????????????mySelf.myDiagram.nodeTemplateMap.add(????????????????"Start",????????????????$(????????????????????go.Node,????????????????????"Spot",????????????????????mySelf.nodeStyle(),????????????????????$(????????????????????????go.Panel,????????????????????????"Auto",????????????????????????$(go.Shape,?"Terminator",?{????????????????????????????//?desiredSize:?new?go.Size(80,?40),????????????????????????????minSize:?new?go.Size(120,?38),????????????????????????????fill:?"#1E90FF",????????????????????????????stroke:?"#1E90FF",????????????????????????????strokeWidth:?3,????????????????????????}),????????????????????????$(go.TextBlock,?"Start",?textStyle(),?new?go.Binding("text"))????????????????????),????????????????????//?three?named?ports,?one?on?each?side?except?the?top,?all?output?only:????????????????????makeNodePort("T",?go.Spot.Top,?false,?true),????????????????????makeNodePort("R",?go.Spot.Right,?true,?true),????????????????????makeNodePort("B",?go.Spot.Bottom,?true,?false),????????????????????makeNodePort("L",?go.Spot.Left,?true,?true)????????????????)????????????);????????????mySelf.myDiagram.nodeTemplateMap.add(????????????????"End",????????????????$(????????????????????go.Node,????????????????????"Auto",????????????????????mySelf.nodeStyle(),????????????????????//?$(????????????????????//???go.Panel,????????????????????//???"Auto",????????????????????$(go.Shape,?"StopSign",?{????????????????????????desiredSize:?new?go.Size(43,?43),????????????????????????//?minSize:?new?go.Size(43,?43),????????????????????????fill:?"#F37B1D",????????????????????????stroke:?null,????????????????????????strokeWidth:?3,????????????????????}),????????????????????$(????????????????????????go.TextBlock,????????????????????????"End",????????????????????????{?stroke:?"#FFFFFF",?font:?tbFontNormal,?textAlign:?"center"?},????????????????????????new?go.Binding("text")????????????????????),????????????????????//?),????????????????????//?three?named?ports,?one?on?each?side?except?the?bottom,?all?input?only:????????????????????makeNodePort("T",?go.Spot.Top,?false,?true),????????????????????makeNodePort("R",?go.Spot.Right,?false,?true),????????????????????makeNodePort("B",?go.Spot.Bottom,?false,?true),????????????????????makeNodePort("L",?go.Spot.Left,?false,?true)????????????????)????????????);????????????//?taken?from?../extensions/Figures.js:????????????go.Shape.defineFigureGenerator("File",?function?(shape,?w,?h)?{????????????????var?geo?=?new?go.Geometry();????????????????var?fig?=?new?go.PathFigure(0,?0,?true);?//?starting?point????????????????geo.add(fig);????????????????fig.add(new?go.PathSegment(go.PathSegment.Line,?0.75?*?w,?0));????????????????fig.add(new?go.PathSegment(go.PathSegment.Line,?w,?0.25?*?h));????????????????fig.add(new?go.PathSegment(go.PathSegment.Line,?w,?h));????????????????fig.add(new?go.PathSegment(go.PathSegment.Line,?0,?h).close());????????????????var?fig2?=?new?go.PathFigure(0.75?*?w,?0,?false);????????????????geo.add(fig2);????????????????//?The?Fold????????????????fig2.add(new?go.PathSegment(go.PathSegment.Line,?0.75?*?w,?0.25?*?h));????????????????fig2.add(new?go.PathSegment(go.PathSegment.Line,?w,?0.25?*?h));????????????????geo.spot1?=?new?go.Spot(0,?0.25);????????????????geo.spot2?=?go.Spot.BottomRight;????????????????return?geo;????????????});????????????mySelf.myDiagram.nodeTemplateMap.add(????????????????"Comment",????????????????$(????????????????????go.Node,????????????????????"Auto",????????????????????mySelf.nodeStyle(),????????????????????$(go.Shape,?"File",?{????????????????????????minSize:?new?go.Size(80,?38),????????????????????????fill:?"#F8EBBF",????????????????????????stroke:?"#E1C76F",????????????????????????strokeWidth:?0,????????????????????}),????????????????????$(????????????????????????go.TextBlock,????????????????????????textStyle(),????????????????????????{????????????????????????????stroke:?"#555555",????????????????????????????font:?tbFontNormal,????????????????????????????wrap:?go.TextBlock.WrapFit,????????????????????????????margin:?new?go.Margin(4,?5,?5,?5),????????????????????????????maxSize:?new?go.Size(200,?NaN),????????????????????????????editable:?true,????????????????????????},????????????????????????new?go.Binding("text").makeTwoWay()????????????????????)????????????????????//?no?ports,?because?no?links?are?allowed?to?connect?with?a?comment????????????????)????????????);????????????//?//?replace?the?default?Link?template?in?the?linkTemplateMap????????????mySelf.myDiagram.linkTemplate?=?$(????????????????go.Link,?//?the?whole?link?panel????????????????{????????????????????routing:?go.Link.AvoidsNodes,????????????????????curve:?go.Link.JumpOver,????????????????????corner:?2,????????????????????fromShortLength:?1,????????????????????toShortLength:?2,????????????????????relinkableFrom:?true,????????????????????relinkableTo:?true,????????????????????reshapable:?true,????????????????????resegmentable:?true,????????????????????mouseEnter:?function?(e,?link)?{????????????????????????link.findObject("HIGHLIGHT").stroke?=?"rgba(30,144,255,0.5)";????????????????????},????????????????????mouseLeave:?function?(e,?link)?{????????????????????????link.findObject("HIGHLIGHT").stroke?=?"transparent";????????????????????},????????????????????//?selectionAdorned:?false,????????????????????doubleClick:?function?(e,?link)?{????????????????????????if?(!e.diagram)?return;????????????????????????if?(!e.diagram.allowLink)?return;????????????????????????linkDoubleClick(e,?link);????????????????????},????????????????},????????????????new?go.Binding("points").makeTwoWay(),????????????????$(????????????????????go.Shape,?//?the?highlight?shape,?normally?transparent????????????????????{????????????????????????isPanelMain:?true,????????????????????????strokeWidth:?8,????????????????????????stroke:?"transparent",????????????????????????name:?"HIGHLIGHT",????????????????????}????????????????),????????????????$(????????????????????go.Shape,?//?the?link?path?shape????????????????????{?isPanelMain:?true,?stroke:?"gray",?strokeWidth:?2?},????????????????????new?go.Binding("stroke",?"isSelected",?function?(sel)?{????????????????????????return?sel???"dodgerblue"?:?"gray";????????????????????}).ofObject()????????????????),????????????????$(????????????????????go.Shape,?//?the?arrowhead????????????????????{?toArrow:?"standard",?strokeWidth:?0,?fill:?"gray"?}????????????????),????????????????$(????????????????????go.Panel,????????????????????"Auto",?//?the?link?label,?normally?not?visible????????????????????{????????????????????????visible:?false,????????????????????????name:?"LABEL",????????????????????????segmentIndex:?2,????????????????????????segmentFraction:?0.5,????????????????????},????????????????????new?go.Binding("visible",?"visible").makeTwoWay(),????????????????????$(????????????????????????go.Shape,????????????????????????"RoundedRectangle",?//?the?label?shape????????????????????????{?fill:?"#F8F8F8",?strokeWidth:?0?}????????????????????),????????????????????$(????????????????????????go.TextBlock,????????????????????????"Yes",?//?the?label????????????????????????{????????????????????????????textAlign:?"center",????????????????????????????font:?"10pt?helvetica,?arial,?sans-serif",????????????????????????????stroke:?"#333333",????????????????????????????editable:?true,????????????????????????},????????????????????????new?go.Binding("text").makeTwoWay()????????????????????)????????????????)????????????);????????????//?Make?link?labels?visible?if?coming?out?of?a?"conditional"?node.????????????//?This?listener?is?called?by?the?"LinkDrawn"?and?"LinkRelinked"?DiagramEvents.????????????function?showLinkLabel(e)?{????????????????var?label?=?e.subject.findObject("LABEL");????????????????if?(label?!==?null)????????????????????label.visible?=?e.subject.fromNode.data.category?===?"Conditional";????????????}????????????//?temporary?links?used?by?LinkingTool?and?RelinkingTool?are?also?orthogonal:????????????mySelf.myDiagram.toolManager.linkingTool.temporaryLink.routing?=????????????????go.Link.Orthogonal;????????????mySelf.myDiagram.toolManager.relinkingTool.temporaryLink.routing?=????????????????go.Link.Orthogonal;????????????mySelf.load();?//?load?an?initial?diagram?from?some?JSON?text????????????//?initialize?the?Palette?that?is?on?the?left?side?of?the?page????????????mySelf.myPalette?=?$(????????????????go.Palette,????????????????"myPaletteDiv",?//?must?name?or?refer?to?the?DIV?HTML?element????????????????{????????????????????//?Instead?of?the?default?animation,?use?a?custom?fade-down????????????????????//???"animationManager.initialAnimationStyle":?go.AnimationManager.None,????????????????????//???"InitialAnimationStarting":?animateFadeDown,?//?Instead,?animate?with?this?function????????????????????nodeTemplateMap:?mySelf.myDiagram.nodeTemplateMap,?//?share?the?templates?used?by?myDiagram????????????????????model:?new?go.GraphLinksModel([????????????????????????//?specify?the?contents?of?the?Palette????????????????????????{?category:?"Start",?text:?"開始"?},????????????????????????{?category:?"Activity",?text:?"審批"?},????????????????????????{?category:?"Conditional",?text:?"完成"?},????????????????????????{?category:?"End",?text:?"撤銷"?},????????????????????????{?category:?"Comment",?text:?"備注"?},????????????????????]),????????????????}????????????);????????????//?This?is?a?re-implementation?of?the?default?animation,?except?it?fades?in?from?downwards,?instead?of?upwards.????????????function?animateFadeDown(e)?{????????????????var?diagram?=?e.diagram;????????????????var?animation?=?new?go.Animation();????????????????animation.isViewportUnconstrained?=?true;?//?So?Diagram?positioning?rules?let?the?animation?start?off-screen????????????????animation.easing?=?go.Animation.EaseOutExpo;????????????????animation.duration?=?900;????????????????//?Fade?"down",?in?other?words,?fade?in?from?above????????????????animation.add(????????????????????diagram,????????????????????"position",????????????????????diagram.position.copy().offset(0,?200),????????????????????diagram.position????????????????);????????????????animation.add(diagram,?"opacity",?0,?1);????????????????animation.start();????????????}????????},????};</script>

css"

<style?lang="less"?scoped>????.modelingBox{????????width:100%;????????height:96%;????}????.modelingHead{????????height:40px;????????line-height:40px;????????.msg_?{????float:?right;????position:?relative;????p?{??????display:?inline;??????margin-right:?15px;??????position:?absolute;??????top:?2px;??????left:?-40px;????}??}????}????#sample?{????????width:?100%;????????height:?calc(100%?-?40px);????}</style>



簡書代碼不知道如何格式化,有需要的可以去我博客園看看:

https://www.cnblogs.com/kqlhp520/

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末梅垄,一起剝皮案震驚了整個(gè)濱河市踢星,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌鳞青,老刑警劉巖瞄沙,帶你破解...
    沈念sama閱讀 221,695評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異疤孕,居然都是意外死亡商乎,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,569評論 3 399
  • 文/潘曉璐 我一進(jìn)店門祭阀,熙熙樓的掌柜王于貴愁眉苦臉地迎上來鹉戚,“玉大人,你說我怎么就攤上這事专控∧ǖ剩” “怎么了?”我有些...
    開封第一講書人閱讀 168,130評論 0 360
  • 文/不壞的土叔 我叫張陵伦腐,是天一觀的道長赢底。 經(jīng)常有香客問我,道長柏蘑,這世上最難降的妖魔是什么幸冻? 我笑而不...
    開封第一講書人閱讀 59,648評論 1 297
  • 正文 為了忘掉前任,我火速辦了婚禮辩越,結(jié)果婚禮上嘁扼,老公的妹妹穿的比我還像新娘。我一直安慰自己黔攒,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,655評論 6 397
  • 文/花漫 我一把揭開白布强缘。 她就那樣靜靜地躺著督惰,像睡著了一般。 火紅的嫁衣襯著肌膚如雪旅掂。 梳的紋絲不亂的頭發(fā)上赏胚,一...
    開封第一講書人閱讀 52,268評論 1 309
  • 那天,我揣著相機(jī)與錄音商虐,去河邊找鬼觉阅。 笑死,一個(gè)胖子當(dāng)著我的面吹牛秘车,可吹牛的內(nèi)容都是我干的典勇。 我是一名探鬼主播,決...
    沈念sama閱讀 40,835評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼叮趴,長吁一口氣:“原來是場噩夢啊……” “哼割笙!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起眯亦,我...
    開封第一講書人閱讀 39,740評論 0 276
  • 序言:老撾萬榮一對情侶失蹤伤溉,失蹤者是張志新(化名)和其女友劉穎般码,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體乱顾,經(jīng)...
    沈念sama閱讀 46,286評論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡板祝,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,375評論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了走净。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片扔字。...
    茶點(diǎn)故事閱讀 40,505評論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖温技,靈堂內(nèi)的尸體忽然破棺而出革为,到底是詐尸還是另有隱情,我是刑警寧澤舵鳞,帶...
    沈念sama閱讀 36,185評論 5 350
  • 正文 年R本政府宣布震檩,位于F島的核電站,受9級特大地震影響蜓堕,放射性物質(zhì)發(fā)生泄漏抛虏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,873評論 3 333
  • 文/蒙蒙 一套才、第九天 我趴在偏房一處隱蔽的房頂上張望迂猴。 院中可真熱鬧,春花似錦背伴、人聲如沸沸毁。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,357評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽息尺。三九已至,卻和暖如春疾掰,著一層夾襖步出監(jiān)牢的瞬間搂誉,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,466評論 1 272
  • 我被黑心中介騙來泰國打工静檬, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留炭懊,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,921評論 3 376
  • 正文 我出身青樓拂檩,卻偏偏與公主長得像侮腹,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子广恢,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,515評論 2 359