vFormItem.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!--
  2. * @Description:
  3. `<FormItem`
  4. :tableAction="tableAction"
  5. :formActionType="formActionType"
  6. :schema="schema2"
  7. :formProps="getProps"
  8. :allDefaultValues="defaultValueRef"
  9. :formModel="formModel"
  10. :setFormModel="setFormModel"
  11. >
  12. -->
  13. <template>
  14. <FormItem :schema="schemaNew" :formProps="getProps">
  15. <template #[item]="data" v-for="item in Object.keys($slots)">
  16. <slot :name="item" v-bind="data || {}"></slot>
  17. </template>
  18. </FormItem>
  19. </template>
  20. <script lang="ts">
  21. import { computed, defineComponent, unref } from 'vue';
  22. import { IFormConfig, IVFormComponent } from '../../typings/v-form-component';
  23. import { FormProps, FormSchema } from '/@/components/Form';
  24. import FormItem from '/@/components/Form/src/components/FormItem.vue';
  25. export default defineComponent({
  26. name: 'VFormItem',
  27. components: {
  28. FormItem,
  29. },
  30. props: {
  31. formData: {
  32. type: Object,
  33. default: () => ({}),
  34. },
  35. schema: {
  36. type: Object as PropType<IVFormComponent>,
  37. required: true,
  38. },
  39. formConfig: {
  40. type: Object as PropType<IFormConfig>,
  41. required: true,
  42. },
  43. },
  44. setup(props) {
  45. const schema = computed(() => {
  46. const schema: FormSchema = {
  47. ...unref(props.schema),
  48. } as FormSchema;
  49. return schema;
  50. });
  51. // Get the basic configuration of the form
  52. const getProps = computed((): FormProps => {
  53. return { ...unref(props.formConfig) } as FormProps;
  54. });
  55. return {
  56. schemaNew: schema,
  57. getProps,
  58. };
  59. },
  60. });
  61. </script>
  62. <style lang="less" scoped></style>