ControlDataSourceForm.vue
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<script lang="ts" setup>
  import { ref, unref } from 'vue';
  import { BasicForm, FormActionType } from '/@/components/Form';
  import { dataSourceSchema } from '../../config/basicConfiguration';
  import { FrontComponent } from '../../../const/const';
  defineProps<{
    isEdit: boolean;
    frontId?: FrontComponent;
  }>();
  const formEl = ref<Nullable<FormActionType>>();
  const setFormEl = (el: any) => {
    formEl.value = el;
  };
  const getFieldsValue = () => {
    return unref(formEl)!.getFieldsValue();
  };
  const validate = async () => {
    await unref(formEl)!.validate();
  };
  const setFieldsValue = async (record: Recordable) => {
    await unref(formEl)!.setFieldsValue(record);
  };
  const clearValidate = async (name?: string | string[]) => {
    await unref(formEl)!.clearValidate(name);
  };
  defineExpose({
    formActionType: { getFieldsValue, validate, setFieldsValue, clearValidate },
  });
</script>
<template>
  <div class="w-full flex-1">
    <BasicForm
      :ref="(el) => setFormEl(el)"
      :schemas="dataSourceSchema($props.isEdit, $props.frontId)"
      class="w-full flex-1 data-source-form"
      :show-action-button-group="false"
      :row-props="{
        gutter: 10,
      }"
      layout="horizontal"
      :label-col="{ span: 0 }"
    />
  </div>
</template>