main.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div>
  3. <el-dialog v-if="isDialog"
  4. :visible.sync="visible"
  5. append-to-body
  6. destroy-on-close
  7. title="流程图展示"
  8. width="70%"
  9. custom-class="flow-design-dialog">
  10. <wf-design-base ref="bpmn"
  11. style="height: 60vh;"
  12. :options="option"></wf-design-base>
  13. </el-dialog>
  14. <div v-else>
  15. <wf-design-base v-if="visible"
  16. ref="bpmn"
  17. style="height: 60vh;"
  18. :options="option"></wf-design-base>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import {modelView} from '@/api/flow/flow'
  24. export default {
  25. name: 'flowDesign',
  26. props: {
  27. isDialog: {
  28. type: Boolean,
  29. default: false
  30. },
  31. isDisplay: {
  32. type: Boolean,
  33. default: false
  34. },
  35. processInstanceId: String,
  36. processDefinitionId: String,
  37. },
  38. data() {
  39. return {
  40. visible: false,
  41. option: {
  42. mode: 'view'
  43. }
  44. }
  45. },
  46. watch: {
  47. isDisplay: {
  48. handler(val) {
  49. this.visible = val
  50. },
  51. immediate: true
  52. },
  53. visible: {
  54. handler(val) {
  55. this.$emit('update:is-display', val)
  56. }
  57. },
  58. processInstanceId: {
  59. handler(val) {
  60. if (!val) return
  61. this.getDetail({processInstanceId: this.processInstanceId})
  62. },
  63. immediate: true
  64. },
  65. processDefinitionId: {
  66. handler(val) {
  67. if (!val) return
  68. this.getDetail({processDefinitionId: this.processDefinitionId})
  69. },
  70. immediate: true
  71. }
  72. },
  73. methods: {
  74. getDetail(params) {
  75. modelView(params).then(res => {
  76. const data = res.data.data
  77. const {xml, flow} = data
  78. this.$set(this.option, 'xml', xml)
  79. if (flow) {
  80. const flows = []
  81. flow.forEach(f => {
  82. let {endTime} = f
  83. const ff = {
  84. id: f.historyActivityId,
  85. class: (!endTime && f.historyActivityType !== 'candidate') ? 'nodePrimary' : ''
  86. }
  87. if (f.historyActivityType === 'sequenceFlow') ff.class = 'lineWarn'
  88. else if (!ff.class && f.historyActivityType !== 'candidate') ff.class = 'nodeSuccess'
  89. const index = flows.findIndex(fl => fl.id === f.historyActivityId)
  90. if (index !== -1) flows.splice(index, 1, ff)
  91. else flows.push(ff)
  92. })
  93. this.$set(this.option, 'flows', flows)
  94. }
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. .flow-design-dialog {
  102. display: flex;
  103. flex-direction: column;
  104. margin: 0 !important;
  105. position: absolute;
  106. top: 40%;
  107. left: 50%;
  108. transform: translate(-50%, -40%);
  109. max-height: calc(100% - 30px);
  110. max-width: calc(100% - 30px);
  111. .el-dialog__body {
  112. flex: 1;
  113. overflow: auto;
  114. }
  115. }
  116. </style>