Header.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div>
  3. <el-button-group>
  4. <el-tooltip class="item" effect="dark" content="保存并发布" placement="bottom">
  5. <el-button type="primary" size="small" @click="deploy"><i class="fa fa-save"> 保存并发布</i></el-button>
  6. </el-tooltip>
  7. <el-tooltip class="item" effect="dark" content="保存草稿" placement="bottom">
  8. <el-button type="primary" size="small" @click="save"><i class="fa fa-save"> 保存草稿</i></el-button>
  9. </el-tooltip>
  10. <el-tooltip class="item" effect="dark" content="打开流程文件" placement="bottom">
  11. <el-button type="primary" size="small" @click="importXml"><i class="fa fa-folder-open"></i></el-button>
  12. </el-tooltip>
  13. <el-tooltip class="item" effect="dark" content="创建新流程图" placement="bottom">
  14. <el-button type="primary" size="small" @click="reset"><i class="fa fa-plus-circle"></i></el-button>
  15. </el-tooltip>
  16. <el-tooltip class="item" effect="dark" content="下载流程图" placement="bottom">
  17. <el-button type="primary" size="small" @click="downloadSvg"><i class="fa fa-picture-o"></i></el-button>
  18. </el-tooltip>
  19. <el-tooltip class="item" effect="dark" content="下载流程文件" placement="bottom">
  20. <el-button type="primary" size="small" @click="downloadBpmn"><i class="fa fa-download"></i></el-button>
  21. </el-tooltip>
  22. <el-tooltip class="item" effect="dark" content="撤销" placement="bottom">
  23. <el-button size="small"><i class="fa fa-rotate-left" @click="undo"></i></el-button>
  24. </el-tooltip>
  25. <el-tooltip class="item" effect="dark" content="恢复" placement="bottom">
  26. <el-button size="small"><i class="fa fa-rotate-right" :class="!canRedo?'default-undo':''"
  27. @click="redo"></i></el-button>
  28. </el-tooltip>
  29. <el-tooltip class="item" effect="dark" content="放大" placement="bottom">
  30. <el-button size="small" @click="zoom(0.05)"><i class="fa fa-search-plus"></i></el-button>
  31. </el-tooltip>
  32. <el-tooltip class="item" effect="dark" content="缩小" placement="bottom">
  33. <el-button size="small" @click="zoom(-0.05)"><i class="fa fa-search-minus"></i></el-button>
  34. </el-tooltip>
  35. <el-tooltip class="item" effect="dark" content="重置" placement="bottom">
  36. <el-button size="small" @click="zoom(0)"><i class="fa fa-arrows"></i></el-button>
  37. </el-tooltip>
  38. </el-button-group>
  39. </div>
  40. </template>
  41. <script>
  42. export default {
  43. name: "ViewerHeader",
  44. data() {
  45. return {
  46. scale: 1.0,
  47. canRedo: false
  48. }
  49. },
  50. props: {
  51. processData: {
  52. type: Object
  53. },
  54. modeler: {
  55. type: Object
  56. }
  57. },
  58. components: {},
  59. methods: {
  60. deploy() {
  61. let that = this;
  62. let _xml;
  63. let _svg;
  64. this.modeler.saveXML((err, xml) => {
  65. if (err) {
  66. console.error(err)
  67. }
  68. _xml = xml;
  69. })
  70. this.modeler.saveSVG((err, svg) => {
  71. if (err) {
  72. console.error(err)
  73. }
  74. _svg = svg;
  75. })
  76. that.post(this.Apis.deployProcess, {
  77. processKey: "s1111",
  78. processName: "阿达达",
  79. resourceName: "test01",
  80. xml: _xml,
  81. svg: _svg
  82. }, function (data) {
  83. console.log(data)
  84. });
  85. },
  86. save(){
  87. let that = this;
  88. let _xml;
  89. let _svg;
  90. this.modeler.saveXML((err, xml) => {
  91. if (err) {
  92. console.error(err)
  93. }
  94. _xml = xml;
  95. })
  96. this.modeler.saveSVG((err, svg) => {
  97. if (err) {
  98. console.error(err)
  99. }
  100. _svg = svg;
  101. })
  102. that.$emit("processSave",{"xmlStr":_xml,"svgStr":_svg});
  103. },
  104. reset() {
  105. this.$emit('restart')
  106. },
  107. importXml() {
  108. this.$emit('importXml')
  109. },
  110. downloadSvg() {
  111. this.$emit("handleExportSvg")
  112. },
  113. downloadBpmn() {
  114. this.$emit("handleExportBpmn");
  115. },
  116. undo() {
  117. this.modeler.get('commandStack').undo();
  118. this.canRedo = this.modeler.get('commandStack').canRedo();
  119. },
  120. redo() {
  121. if (!this.canRedo) {
  122. return;
  123. }
  124. this.modeler.get('commandStack').redo()
  125. this.canRedo = this.modeler.get('commandStack').canRedo();
  126. },
  127. zoom(val) {
  128. let newScale = !val ? 1.0 : ((this.scale + val) <= 0.2) ? 0.2 : (this.scale + val);
  129. this.modeler.get('canvas').zoom(newScale);
  130. this.scale = newScale;
  131. }
  132. }
  133. }
  134. </script>
  135. <style scoped>
  136. </style>