<template>
  <el-form ref="basicInfoForm" :model="infoForm" :rules="rules" label-width="180px">
    <el-row>
      <el-col :span="12">
        <el-form-item :label="$t('gen.edit.basic.tableName')" prop="tableName">
          <el-input v-model="infoForm.tableName" :placeholder="$t('gen.edit.basic.tableNamePlaceholder')" />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('gen.edit.basic.tableComment')" prop="tableComment">
          <el-input v-model="infoForm.tableComment" :placeholder="$t('gen.edit.basic.tableCommentPlaceholder')" />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('gen.edit.basic.className')" prop="className">
          <el-input v-model="infoForm.className" :placeholder="$t('gen.edit.basic.classNamePlaceholder')" />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('gen.edit.basic.functionAuthor')" prop="functionAuthor">
          <el-input v-model="infoForm.functionAuthor" :placeholder="$t('gen.edit.basic.functionAuthorPlaceholder')" />
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item :label="$t('gen.edit.basic.remark')" prop="remark">
          <el-input v-model="infoForm.remark" type="textarea" :rows="3"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script setup lang="ts">
import { propTypes } from '@/utils/propTypes';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const prop = defineProps({
  info: propTypes.any.def({})
});

const infoForm = computed(() => prop.info);

// 表单校验
const rules = computed(() => ({
  tableName: [{ required: true, message: t('gen.edit.basic.tableNameRequired'), trigger: 'blur' }],
  tableComment: [{ required: true, message: t('gen.edit.basic.tableCommentRequired'), trigger: 'blur' }],
  className: [{ required: true, message: t('gen.edit.basic.classNameRequired'), trigger: 'blur' }],
  functionAuthor: [{ required: true, message: t('gen.edit.basic.functionAuthorRequired'), trigger: 'blur' }]
}));
</script>
