main.vue 2.7 KB

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