BlockRepeatTask.vue 1.9 KB

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