process.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div style="width:100%;height:100%;">
  3. {{this.exportData}}
  4. <!-- {{this.importValue}}-->
  5. <!-- 测试导入初始数据 -->
  6. <Layout>
  7. <!-- 左侧工具栏 -->
  8. <Sider :width="180">
  9. <div id="stencil"></div>
  10. </Sider>
  11. <Layout>
  12. <!-- 顶部工具栏 -->
  13. <Header class="header">
  14. <Button @click="()=>{this.graph.exportPNG('',{padding:50})}">导出PNG</Button>
  15. <Button @click="()=>{this.exportData=this.graph.toJSON()}" style="margin-left:10px;">导出json</Button>
  16. <Button @click="()=>{this.graph.fromJSON(JSON.parse(this.importValue))}" style="margin-left:10px;">导入json</Button>
  17. <Input v-model="importValue"/>
  18. </Header>
  19. <!-- 中间流程图 -->
  20. <Content>
  21. <div id="container" ref="container" style="width:100%;height:100%"/>
  22. </Content>
  23. <!-- 底部按钮 -->
  24. <Footer class="footer">
  25. <Button style="margin-right: 10px;">保存</Button>
  26. <Button>关闭</Button>
  27. </Footer>
  28. </Layout>
  29. </Layout>
  30. <!-- 节点弹窗 -->
  31. <NodeModal/>
  32. <!-- 连线弹窗 -->
  33. <EdgeModal/>
  34. </div>
  35. </template>
  36. <script>
  37. import {mapState, mapMutations} from 'vuex'
  38. import NodeModal from '_c/business/process/node-modal/node-modal'
  39. import EdgeModal from '_c/business/process/edge-modal/edge-modal'
  40. const insertCss = require('insert-css')
  41. const zt1 = require('./data/zt1.json')
  42. import Process from '@/view/process/process-flow/config/ProcessConfig'
  43. export default {
  44. components: { NodeModal,EdgeModal },
  45. data() {
  46. return {
  47. graph: null,//图形对象
  48. exportData: undefined,
  49. importValue:undefined,
  50. currentNode:{},
  51. }
  52. },
  53. created() {},
  54. mounted() {
  55. //创建流程图对象
  56. this.graph=Process.init(this.$refs.container)
  57. },
  58. computed: {
  59. ...mapState(['process']),
  60. },
  61. methods: {
  62. init() {
  63. // region 初始化数据
  64. // this.graph.fromJSON(zt1)
  65. // this.graph.zoomToFit({ maxScale: 1 });// 将画布中元素缩小或者放大一定级别,让画布正好容纳所有元素,可以通过 maxScale 配置最大缩放级别
  66. // this.graph.centerContent(); // 将画布中元素居中展示
  67. // endregion
  68. },
  69. }
  70. }
  71. </script>
  72. <style scoped>
  73. #container {
  74. display: flex;
  75. border: 1px solid #dfe3e8;
  76. }
  77. #stencil {
  78. width: 180px;
  79. height: 100%;
  80. position: relative;
  81. border-right: 1px solid #dfe3e8;
  82. }
  83. #graph-container {
  84. width: calc(100% - 180px);
  85. height: 100%;
  86. }
  87. .x6-widget-stencil {
  88. background-color: #fff;
  89. }
  90. .x6-widget-stencil-title {
  91. background-color: #fff;
  92. }
  93. .x6-widget-stencil-group-title {
  94. background-color: #fff !important;
  95. }
  96. /deep/ .x6-widget-transform {
  97. margin: -1px 0 0 -1px;
  98. padding: 0px;
  99. border: 1px solid #239edd;
  100. }
  101. /deep/ .x6-widget-transform > div {
  102. border: 1px solid #239edd;
  103. }
  104. /deep/ .x6-widget-transform > div:hover {
  105. background-color: #3dafe4;
  106. }
  107. /deep/ .x6-widget-transform-active-handle {
  108. background-color: #3dafe4;
  109. }
  110. /deep/ .x6-widget-transform-resize {
  111. border-radius: 0;
  112. }
  113. /deep/ .x6-widget-selection-inner {
  114. border: 1px solid #239edd;
  115. }
  116. /deep/ .x6-widget-selection-box {
  117. border: 0!important;
  118. }
  119. /*@keyframes ant-line {*/
  120. /* to {*/
  121. /* stroke-dashoffset: -1000*/
  122. /* }*/
  123. /*}*/
  124. .snap-line-color{
  125. color: black!important;
  126. background: black!important;
  127. }
  128. .ivu-layout-has-sider{
  129. height: 100%;
  130. }
  131. .header{
  132. height: 30px;
  133. background: #ededed;
  134. display: flex;
  135. align-items: center;
  136. }
  137. /deep/ .ivu-layout-header{
  138. height: 52px!important;
  139. line-height: 52px!important;
  140. }
  141. .footer{
  142. background: #ededed;
  143. display: flex;
  144. justify-content: right;
  145. padding:10px 50px;
  146. }
  147. </style>