<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="员工姓名" prop="staffName" v-model="form.staffId" type="select" :enumData="dict.staffId" placeholder="请输入员工姓名"/>
                            <Field label="出生日期" prop="birthday" v-model="form.birthday" type="date" />
                            <Field label="所属部门" prop="deptId" v-model="form.deptId" type="select" :enumData="dict.deptId" placeholder="请输入所属部门"/>
                             <Field label="职位ID" prop="jobId" v-model="form.jobId" type="select" :enumData="dict.jobId" placeholder="请输入职位ID"/>
                            <Field label="入职时间" prop="entryDate" v-model="form.entryDate" type="date" />
                            <Field label="关怀类型" prop="careType" v-model="form.careType" type="select" :enumData="dict.careType" placeholder="请选择关怀类型"/>
                            <Field label="关怀内容" prop="content" v-model="form.content" type="textarea"></Field>

            </el-row>

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

    </el-drawer>
</template>

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

        },
        created() {
            this.changePath("staff/care")
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "员工关怀信息",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                    "careType",
                    "sendStatus",
                ],
                toDate:[
                    "birthday",
                    "entryDate",
                ],
                // 表单校验
                rules: {
                    staffName: [
                        {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 ="staff/care/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改员工关怀信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "staff/care/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增员工关怀信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="staff/care/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 = {
                    staffId : null,
                    staffName : "",
                    birthday : null,
                    deptId : null,
                    deptName : "",
                    jobId : null,
                    jobName : "",
                    entryDate : null,
                    careType : 1,
                    sendStatus : 0,
                    content : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
