
<template>
    <layout-form>
        <el-form :model="form" :loading="loading" :rules="rules" size='small' label-width='100px' ref="form">
            <el-row>
                <Field label="父类目ID" prop="parentId" v-model="form.parentId" hidden :span="24" />
                <Field label="类目代码" prop="code" v-model="form.code" disabled :span="24" />
                <Field label="类目短代码" prop="selfCode" v-model="form.selfCode" placeholder="新增后不可更改" :disabled="pageInfo.type !== 'add'" />
                <Field label="类目名称" prop="name" v-model="form.name" />
                <Field label="是否启用" prop="enabled" v-model="form.enabled" :enumData='dict.enabled' type='select' />
                <Field label="备注" prop="remark" type="textarea" v-model="form.remark" :span="24" />
            </el-row>
            <form-buttons @submit='submitForm' />
        </el-form>
    </layout-form>
</template>

<script>
import form from "@/assets/mixins/form";
export default {
    mixins: [form],
    async created() {
        this.form.parentId = this.query.parentId;
    },
    data() {
        return {
            toString: ["enabled"],
            rules: {
                name: [
                    {
                        required: true,
                        message: "请输入类目名称",
                        trigger: "blur",
                    },
                ],
                selfCode: [
                    {
                        required: true,
                        message: "请输入类目短代码",
                        trigger: "blur",
                    },
                ],
                parentId: [
                    {
                        required: true,
                        message: "请输入父类目ID",
                        trigger: "blur",
                    },
                ],
                enabled: [
                    {
                        required: true,
                        message: "请选择是否启用",
                        trigger: "blur",
                    },
                ],
            },
        };
    },
};
</script>
