<!--
 * @Author: sjl
 * @Date: 2023-04-08 11:51:03
 * @Descripttion: 
-->
<script lang="ts" setup>
  import { ref, onMounted, unref, computed } from 'vue';
  import { FrontComponent } from '../../../const/const';
  import { DataSourceField, dataSourceSchema } from '../../config/basicConfiguration';
  // import { DeviceTypeEnum } from '/@/api/device/model/deviceModel';
  import { FormActionType } from '/@/components/Form';
  import BasicForm from '/@/components/Form/src/BasicForm.vue';
  const formEl = ref<Nullable<FormActionType>>(null);

  const props = defineProps<{
    frontId?: FrontComponent;
    isEdit: boolean;
  }>();

  defineExpose({ formActionType: formEl });

  const getDataSchema = computed(() => {
    const { frontId, isEdit } = props;
    console.log({ frontId });
    if (!frontId) return [];
    return dataSourceSchema(isEdit, frontId);
  });

  onMounted(() => {
    unref(formEl)?.setFieldsValue({ [DataSourceField.DEVICE_TYPE]: DeviceTypeEnum.SENSOR });
  });
</script>

<template>
  <BasicForm
    ref="formEl"
    :schemas="getDataSchema"
    class="w-full flex-1 data-source-form"
    :show-action-button-group="false"
    :row-props="{
      gutter: 10,
    }"
    layout="horizontal"
    :label-col="{ span: 0 }"
  />
</template>
