BlockRepeatTask.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <ui-card :id="componentId" class="p-4 repeat-task">
  3. <Handle :id="`${id}-input-1`" type="target" :position="Position.Left" />
  4. <div class="flex items-center mb-2">
  5. <div
  6. :class="block.category.color"
  7. class="inline-block text-sm mr-4 p-2 rounded-lg dark:text-black"
  8. >
  9. <v-remixicon name="riRepeat2Line" size="20" class="inline-block mr-1" />
  10. <span>{{ t('workflow.blocks.repeat-task.name') }}</span>
  11. </div>
  12. <div class="flex-grow"></div>
  13. <v-remixicon
  14. name="riDeleteBin7Line"
  15. class="cursor-pointer"
  16. @click="$emit('delete', id)"
  17. />
  18. </div>
  19. <label
  20. class="mb-2 block bg-input focus-within:bg-input pr-4 transition rounded-lg"
  21. >
  22. <input
  23. :value="data.repeatFor || 0"
  24. min="0"
  25. class="pl-4 py-2 bg-transparent rounded-l-lg w-24 mr-2"
  26. type="number"
  27. required
  28. @input="handleInput"
  29. />
  30. <span class="text-gray-600 dark:text-gray-200">
  31. {{ t('workflow.blocks.repeat-task.times') }}
  32. </span>
  33. </label>
  34. <p class="text-right text-gray-600 dark:text-gray-200">
  35. {{ t('workflow.blocks.repeat-task.repeatFrom') }}
  36. </p>
  37. <Handle :id="`${id}-output-1`" type="source" :position="Position.Right" />
  38. <Handle
  39. :id="`${id}-output-2`"
  40. type="source"
  41. :position="Position.Right"
  42. style="top: auto; bottom: 12px"
  43. />
  44. </ui-card>
  45. </template>
  46. <script setup>
  47. import { useI18n } from 'vue-i18n';
  48. import { Handle, Position } from '@braks/vue-flow';
  49. import { useComponentId } from '@/composable/componentId';
  50. import { useEditorBlock } from '@/composable/editorBlock';
  51. const { t } = useI18n();
  52. const props = defineProps({
  53. id: {
  54. type: String,
  55. default: '',
  56. },
  57. label: {
  58. type: String,
  59. default: '',
  60. },
  61. data: {
  62. type: Object,
  63. default: () => ({}),
  64. },
  65. });
  66. const emit = defineEmits(['delete', 'update']);
  67. const block = useEditorBlock(props.label);
  68. const componentId = useComponentId('block-delay');
  69. function handleInput({ target }) {
  70. target.reportValidity();
  71. const repeatFor = +target.value || 0;
  72. if (repeatFor < 0) return;
  73. emit('update', { repeatFor });
  74. }
  75. </script>
  76. <style>
  77. .drawflow .repeat-task .outputs {
  78. top: 74px !important;
  79. transform: none !important;
  80. }
  81. .drawflow .repeat-task .output {
  82. margin-bottom: 22px;
  83. }
  84. </style>