index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <script setup>
  2. import { Position, Handle } from "@vue-flow/core";
  3. const props = defineProps(["data", "id"]);
  4. const currentProcess = inject("currentProcess");
  5. const selectNode = inject("selectNode");
  6. const selectStatus = ref(false);
  7. const editStatus = inject("editStatus");
  8. const getBorderClass = computed(() => {
  9. let str = "borderBlack";
  10. if (selectStatus.value) {
  11. if (editStatus.value == true) {
  12. str = "borderBlue";
  13. } else {
  14. str = "borderGreen";
  15. }
  16. }
  17. return str;
  18. });
  19. watch(
  20. () => currentProcess.value,
  21. () => {
  22. if (currentProcess.value == null) {
  23. selectStatus.value = false;
  24. return;
  25. }
  26. selectStatus.value = props.id == currentProcess.value.id;
  27. },
  28. { deep: true }
  29. );
  30. watch(
  31. () => selectNode.value,
  32. () => {
  33. if (selectNode.value == null) {
  34. selectStatus.value = false;
  35. return;
  36. }
  37. selectStatus.value = props.id == selectNode.value.id;
  38. },
  39. { deep: true }
  40. );
  41. </script>
  42. <template>
  43. <div class="nodes" :class="getBorderClass">
  44. <Handle
  45. :style="{
  46. height: '13px',
  47. width: '13px',
  48. }"
  49. type="target"
  50. :position="Position.Top"
  51. />
  52. <div
  53. style="
  54. text-align: center;
  55. width: 100%;
  56. color: black;
  57. word-wrap: break-word;
  58. margin: 10px;
  59. "
  60. >
  61. {{ data.label }}
  62. </div>
  63. <Handle
  64. :style="{
  65. height: '13px',
  66. width: '13px',
  67. }"
  68. type="source"
  69. :position="Position.Bottom"
  70. />
  71. </div>
  72. </template>
  73. <style lang="scss">
  74. .vue-flow__node-custom {
  75. padding: 0px !important;
  76. background-color: white !important;
  77. box-shadow: 0 0 0 0 !important;
  78. border: 0px solid black !important;
  79. }
  80. .nodes {
  81. width: 150px;
  82. min-height: 60px;
  83. border-radius: 4px;
  84. display: flex;
  85. align-items: center;
  86. justify-content: center;
  87. border: 1px solid black;
  88. }
  89. .borderBlack {
  90. border-color: black;
  91. }
  92. .borderBlue {
  93. border-color: blue;
  94. }
  95. .borderGreen {
  96. border-color: green;
  97. }
  98. </style>