voice_node.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <div class="flex flex-row items-center gap-2">
  3. <Icon :icon="getIcon" :width="26" :height="26"></Icon>
  4. <div>{{ nodeData?.name || '' }}</div>
  5. </div>
  6. </template>
  7. <script setup lang="ts">
  8. import { getNodeRole, ProcessConstant } from '../common/process.data'
  9. import { ProcessValidator } from '../common/process.helper'
  10. import { Process } from '../common/process.type'
  11. const props = withDefaults(defineProps<{ node: Process.VoiceNode }>(), {})
  12. const nodeData = ref<Record<string, unknown>>(props.node.nodeData || {})
  13. watch(
  14. () => props.node.nodeData,
  15. (newVal) => {
  16. nodeData.value = newVal || {}
  17. console.log('nodeData.value', nodeData.value)
  18. }
  19. )
  20. const getIcon = computed(() => `svg:${getNodeRole(String(nodeData.value?.bindRole) || '')}`)
  21. const validate = inject<ProcessValidator>(ProcessConstant.KEY_PROCESS_VALIDATOR)
  22. validate?.register(props.node.nodeId, () => {
  23. const messages: string[] = []
  24. if (!nodeData.value?.name) {
  25. messages.push('请输入语音节点名称')
  26. }
  27. if (!nodeData.value?.bindRole) {
  28. messages.push('请选择语音节点角色')
  29. }
  30. return { valid: messages.length === 0, message: messages.join(',') }
  31. })
  32. </script>