node-index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div class="node" ref="ref_node">
  3. <div class="node-title">{{ state.nodeData?.title }}</div>
  4. <div class="node-content">
  5. <template v-if="state.nodeData?.type === 'root'">
  6. <rootNode :node="state.node"/>
  7. </template>
  8. <template v-else-if="state.nodeData?.type === 'if-else'">
  9. <ifElseNode :node="state.node"/>
  10. </template>
  11. </div>
  12. </div>
  13. </template>
  14. <script setup lang="ts">
  15. import {computed, getCurrentInstance, inject, nextTick, onMounted, reactive, ref} from "vue";
  16. import rootNode from '../instance/root/node/index.vue'
  17. import ifElseNode from '../instance/if-else/node/index.vue'
  18. const getNode: any = inject('getNode')
  19. const emits = defineEmits([])
  20. const props = defineProps({})
  21. const {proxy}: any = getCurrentInstance()
  22. const state: any = reactive({
  23. node: null,
  24. nodeData: {}
  25. })
  26. const ref_node = ref()
  27. onMounted(() => {
  28. state.node = getNode()
  29. state.nodeData = state.node.data
  30. nextTick(() => {
  31. state.node.size(ref_node.value.clientWidth, ref_node.value.clientHeight)
  32. })
  33. })
  34. </script>
  35. <style lang="scss" scoped>
  36. @import "@/views/workflow/instance/component/style";
  37. .node {
  38. z-index: 10;
  39. border: $borderStyle;
  40. border-radius: 10px;
  41. background-color: #ffffff;
  42. position: absolute;
  43. width: 240px;
  44. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  45. &:hover {
  46. border-color: #286bfb;
  47. cursor: pointer;
  48. }
  49. .node-title {
  50. height: 50px;
  51. width: 100%;
  52. display: flex;
  53. align-items: center;
  54. padding: 8px 12px;
  55. font-size: 14px;
  56. font-weight: bold;
  57. }
  58. .node-content {
  59. padding: 0px 12px;
  60. //margin-bottom: 8px;
  61. //border-top: 1px solid rgba(0, 0, 0, 0.1);
  62. }
  63. }
  64. </style>