ComponentRender.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <!-- 在下方添加自定义组件 -->
  3. <!-- 业务代码开始 -->
  4. <template v-if="item.type === 'richtext'">
  5. <RichTextEditor
  6. ref="itemRef"
  7. :modelValue="modelValue"
  8. @update:modelValue="onValueChanged"
  9. v-bind="params"
  10. />
  11. </template>
  12. <template v-else-if="item.type === 'recorder'">
  13. <Recorder
  14. ref="itemRef"
  15. :modelValue="modelValue"
  16. @update:modelValue="onValueChanged"
  17. v-bind="params"
  18. />
  19. </template>
  20. <!-- 业务代码结束 -->
  21. <template v-else>
  22. <text>Fallback: unknow form type '{{ item.type }}' item: {{ JSON.stringify(item) }}</text>
  23. </template>
  24. </template>
  25. <script setup lang="ts">
  26. import { ref, type PropType } from 'vue';
  27. import type { IDynamicFormItem } from '@/components/dynamic';
  28. import RichTextEditor from '@/common/components/form/RichTextEditor.vue';
  29. import Recorder from '@/common/components/form/Recorder.vue';
  30. const props = defineProps({
  31. modelValue: {
  32. type: null
  33. },
  34. item: {
  35. type: Object as PropType<IDynamicFormItem>,
  36. default: () => ({})
  37. },
  38. isLast: {
  39. type: Boolean,
  40. default: false,
  41. },
  42. params: {
  43. type: Object,
  44. default: () => ({})
  45. },
  46. });
  47. const emit = defineEmits(['update:modelValue']);
  48. function onValueChanged(v: any) {
  49. emit('update:modelValue', v);
  50. }
  51. const itemRef = ref();
  52. defineExpose({
  53. getItemRef: () => itemRef.value,
  54. })
  55. </script>