index.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { computed, getCurrentInstance, ref } from 'vue'
  2. import CipForm from '../cip-form'
  3. export default {
  4. name: 'CipFormRender',
  5. props: {
  6. scheme: Object,
  7. model: Object,
  8. equipment: { type: String, default: 'pc' }
  9. },
  10. emits: ['update:model'],
  11. setup (props, { emit, expose }) {
  12. const cipFormRef = ref(null)
  13. const instance = getCurrentInstance()
  14. const fieldList = computed(() => props.scheme.list || [])
  15. const labelPosition = computed(() => props.scheme.labelPosition || 'right')
  16. const labelWidth = computed(() => props.scheme.labelWidth || 100)
  17. const labelSuffix = computed(() => props.scheme.labelSuffix || ' ')
  18. const grid = computed(() => props.scheme.grid || 1)
  19. instance.ctx.cipFormRef = cipFormRef
  20. expose({
  21. cipFormRef
  22. })
  23. return () => <CipForm
  24. ref={cipFormRef}
  25. model={props.model}
  26. onUpdate:model={(val) => emit('update:model', val)}
  27. fieldList={fieldList.value}
  28. labelPosition={labelPosition.value}
  29. equipment={props.equipment}
  30. labelWidth={labelWidth.value}
  31. labelSuffix={labelSuffix.value}
  32. grid={grid.value}
  33. />
  34. }
  35. }