<script setup lang="ts">
import { ref } from "vue";
import ReCol from "@/components/ReCol";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";
import { usePublicHooks } from "../hooks";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: "",
    configName: "",
    configValue: "",
    configKey: "",
    configType: "",
    remark: ""
  })
});
const ruleFormRef = ref();
const { switchStyle } = usePublicHooks();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
  ref="ruleFormRef" 
  :model="newFormInline" 
  :rules="formRules" 
  label-width="82px">
    <el-row :gutter="30">
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="参数名称" prop="configName">
          <el-input v-model="newFormInline.configName" clearable placeholder="请输入参数名称" />
        </el-form-item>
      </re-col>

      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="参数键名" prop="configKey">
          <el-input v-model="newFormInline.configKey" clearable placeholder="请输入参数键名" />
        </el-form-item>
      </re-col>

      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="参数键值" prop="configValue">
          <el-input v-model="newFormInline.configValue" clearable placeholder="请输入参数键值" />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="系统内置">
          <el-switch v-model="newFormInline.configType" inline-prompt :active-value="true" :inactive-value="false"
            active-text="是" inactive-text="否" :style="switchStyle" />
        </el-form-item>
      </re-col>

      <re-col>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="newFormInline.remark" placeholder="请输入备注信息" type="textarea" />
        </el-form-item>
      </re-col>
    </el-row>
  </el-form>
</template>
