<template>
    <layout-form>
        <el-form :model="form" :loading="loading" :rules="rules" size='small' style="width:100%" label-width='120px' ref="form">
            <el-row>
                <Field label="关联主表表名" prop="tableCode" v-model="form.tableCode" placeholder="请输入关联主表表名" />
                <Field label="字段编码" prop="fieldCode" v-model="form.fieldCode" placeholder="请输入字段编码" />
                <Field label="字段名称" prop="fieldName" v-model="form.fieldName" placeholder="请输入字段名称" />
                <Field label="数据类型" prop="fieldType" v-model="form.fieldType" placeholder="请输入数据类型" type="select" :enumData="dict.fieldType" />
                <Field label="数据长度" prop="fieldLen" v-model="form.fieldLen" placeholder="请选择数据长度" type="select" :enumData="dict.fieldLen" />
                <Field label="允许为空" prop="fieldNull" v-model="form.fieldNull" placeholder="请选择允许为空" type="select" :enumData="dict.enabled" />
                <Field label="排序号" prop="fieldOrderNo" v-model="form.fieldOrderNo" placeholder="请选择排序号" type="select" :enumData="dict.fieldOrderNo" />
                <Field label="备注" prop="remark" v-model="form.remark" placeholder="请输入备注" />
                <Field label="是否启用" prop="enabled" v-model="form.enabled" type="select" :enumData="dict.enabled" placeholder="请输入是否启用" />
            </el-row>
            <form-buttons @submit='submitForm' />
        </el-form>
    </layout-form>
</template>

<script>
import form from "@/assets/mixins/form";
import valid from "@/assets/utils/vaild";
export default {
    mixins: [form],
    data() {
        return {
            toString: ["enabled", "fieldType"],
            rules: {
                tableCode: [
                    {
                        required: true,
                        message: "请输入关联主表表名",
                        trigger: "blur",
                    },
                    {
                        max: 50,
                        message: "最多只能录入50个字符",
                        trigger: "blur",
                    },
                ],
                fieldCode: [
                    {
                        required: true,
                        message: "请输入字段编码",
                        trigger: "blur",
                    },
                    {
                        max: 50,
                        message: "最多只能录入50个字符",
                        trigger: "blur",
                    },
                ],
                fieldName: [
                    {
                        required: true,
                        message: "请输入字段名称",
                        trigger: "blur",
                    },
                    {
                        max: 50,
                        message: "最多只能录入50个字符",
                        trigger: "blur",
                    },
                ],
                fieldType: [
                    {
                        required: true,
                        message: "请输入数据类型",
                        trigger: "blur",
                    },
                ],
                fieldLen: [
                    {
                        required: true,
                        message: "请选择数据长度",
                        trigger: "blur",
                    },
                ],
                fieldNull: [
                    {
                        required: true,
                        message: "请选择允许为空",
                        trigger: "blur",
                    },
                ],
                fieldOrderNo: [
                    {
                        required: true,
                        message: "请选择排序号",
                        trigger: "blur",
                    },
                ],
                remark: [
                    {
                        max: 200,
                        message: "最多只能录入200个字符",
                        trigger: "blur",
                    },
                ],
                enabled: [
                    {
                        required: true,
                        message: "请输入是否启用",
                        trigger: "blur",
                    },
                ],
            },
        };
    },
};
</script>