<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="parentId" v-model="form.parentId" placeholder="请输入父id"/> -->
                <!-- <Field label="祖级列表" prop="ancestors" v-model="form.ancestors" type="textarea" placeholder="请输入祖级列表"/> -->
                <!-- <Field label="部门名称" prop="deptName" v-model="form.deptName" type="textarea" placeholder="请输入部门名称"/> -->
                <!-- <Field label="上级部门" prop="deptStatus" v-model="form.deptStatus" type="select" :enumData="dict.deptStatus" placeholder="请选择上级部门"/> -->
                <!-- <Field label="负责人" prop="deptStatus" v-model="form.deptStatus" type="select" :enumData="dict.deptStatus" placeholder="请选择员工"/> -->
                <!-- <Field label="部门状态" prop="deptStatus" v-model="form.deptStatus" type="select" :enumData="dict.deptStatus" placeholder="请选择部门状态"/> -->
                <!-- <Field label="顺序" prop="orderNum" v-model="form.orderNum" placeholder="请输入顺序"/> -->
                <!-- <Field label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注"/> -->

                <el-form-item label="部门名称" prop="deptName">
                    <el-input placeholder="请输入部门名称" clearable v-model="form.deptName"></el-input>
                </el-form-item>
                <el-form-item label="上级部门">
                    <el-select placeholder="请选择上级部门" clearable v-model="form">
                        <el-option></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="负责人">
                    <el-select placeholder="请选择员工" clearable>
                        <el-option></el-option>
                    </el-select>
                </el-form-item>

            </el-row>
            <form-buttons @submit='submitForm' noCancelBtn />
        </el-form>

    </el-drawer>
</template>

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

        },
        created() {
            this.changePath("dept")
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "部门信息",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                    "deptStatus",
                ],
                toDate:[
                ],
                // 表单校验
                rules: {
                    ancestors: [
                        {required: true,message: "请输入祖级列表", trigger: "blur" },
                        {max: 256,message: "最多只能录入256个字符",trigger: "blur",},
                    ],
                    deptName: [
                        {required: true,message: "请输入部门名称", trigger: "blur" },
                        {max: 256,message: "最多只能录入256个字符",trigger: "blur",},
                    ],
                    deptStatus: [
                        {required: true,message: "请输入部门状态", trigger: "blur" },
                    ],
                    orderNum: [
                        {required: true,message: "请输入顺序", trigger: "blur" },
                    ],
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="dept/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改部门信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "dept/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增部门信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="dept/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 = {
                    parentId : null,
                    ancestors : "",
                    deptName : "",
                    deptStatus : 1,
                    orderNum : 0,
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
