vars-value.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div
  3. class="flex flex-wrap items-center rounded-sm bg-[#ffffff] px-2 py-1"
  4. v-if="vars"
  5. >
  6. <template v-if="vars.source === VarsSource.Env">
  7. <SvgIcon name="env_1" color="#7839ee" size="14" class="mr-1" />
  8. </template>
  9. <template v-else-if="vars.source === VarsSource.Root">
  10. <SvgIcon name="earth" color="#fc9009" size="14" class="mr-1" />
  11. </template>
  12. <template v-else>
  13. <SvgIcon name="vars" color="#155aef" size="14" class="mr-1" />
  14. </template>
  15. <div class="__text-ellipsis flex-1">
  16. <span class="text-[12px]">{{
  17. nodeDataCpt.desc || nodeDataCpt.title
  18. }}</span>
  19. / <span class="text-[#155aef]">{{ vars.key }}</span> ·
  20. <span class="opacity-65">{{ vars.label }}</span>
  21. </div>
  22. <span class="opacity-65">{{ vars.type }}</span>
  23. <span v-if="vars.required" class="text-red-500">*</span>
  24. </div>
  25. <div v-else class="opacity-65">{x}请选择变量</div>
  26. </template>
  27. <script setup lang="ts">
  28. import { computed, getCurrentInstance, reactive, ref } from 'vue'
  29. import { useWorkflowStore } from '@/stores'
  30. import { VarsSource } from '@/views/workflow/types'
  31. const WorkflowStore = useWorkflowStore()
  32. const emit = defineEmits([])
  33. const props = defineProps({
  34. vars: <any>{},
  35. })
  36. const { proxy }: any = getCurrentInstance()
  37. const state: any = reactive({})
  38. const nodeDataCpt = computed(() => {
  39. if (props.vars.source === VarsSource.Env) {
  40. return { title: '环境变量' }
  41. } else {
  42. const node = WorkflowStore.graph.getCellById(props.vars?.nodeId)
  43. return node.data.workflowData
  44. }
  45. })
  46. </script>
  47. <style lang="scss" scoped></style>