<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            size="50%">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                                            <Field label="基础设置id" prop="basicSetId" v-model="form.basicSetId" placeholder="请输入基础设置id"/>
                            <Field label="状态名称" prop="statusName" v-model="form.statusName" placeholder="请输入状态名称"/>
                            <Field label="状态颜色值" prop="statusColor" v-model="form.statusColor" 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: "BasicStatusDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("basic/status")
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "状态设置",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                ],
                toDate:[
                ],
                // 表单校验
                rules: {
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="basic/status/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改状态设置";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "basic/status/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增状态设置";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="basic/status/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 = {
                    basicSetId : null,
                    statusName : "",
                    statusColor : "",
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
