<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            :destroy-on-close="true"
            size="50%">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                                            <Field label="接入区域ID" prop="accessId" v-model="form.accessId" placeholder="请输入接入区域ID"/>
                            <Field label="接入系统名称" prop="systemName" v-model="form.systemName" placeholder="请输入接入系统名称"/>
                            <Field label="接入系统编码" prop="systemCode" v-model="form.systemCode" placeholder="请输入接入系统编码"/>
                            <Field label="启用状态 " prop="enabled" v-model="form.enabled" type="select" :enumData="dict.enabled" placeholder="请选择启用状态 "/>
                            <Field label="接入开通时间" prop="accessTime" v-model="form.accessTime" type="date" />
                            <Field label="排序" prop="sort" v-model="form.sort" placeholder="请输入排序"/>
                            <Field label="备注" prop="remark" v-model="form.remark" placeholder="请输入备注"/>

            </el-row>

            <form-buttons @submit='submitForm' v-if="pageInfo.type!='view'" noCancelBtn />
        </el-form>

    </el-drawer>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    export default {
        name: "AccessSystemDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("access/system")
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "区域接入系统",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                    "enabled",
                ],
                toDate:[
                    "accessTime",
                ],
                // 表单校验
                rules: {
                    systemName: [
                        {required: true,message: "请输入接入系统名称", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    systemCode: [
                        {required: true,message: "请输入接入系统编码", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="access/system/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改区域接入系统";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "access/system/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增区域接入系统";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="access/system/view";
                this.getData();
                this.pageInfo.type="view"
                this.title = "区域接入系统详细";
            },
            /**取消按钮 */
            cancel() {
                this.open = false;
            },
            /**获取数据后弹框 */
            afterRender(data) {
                this.open = true;
            },

            afterSubmit(data) {
                this.open = false;
                this.$emit("ok");
            },

            // 表单重置
            reset() {
                this.form = {
                    accessId : null,
                    systemName : null,
                    systemCode : null,
                    enabled : 0,
                    accessTime : null,
                    sort : 0,
                    remark : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
