<template>
    <!-- 弹出框表单 -->
    <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                                            <Field label="请假人id" prop="leavePersonId" v-model="form.leavePersonId" placeholder="请输入请假人id"/>
                            <Field label="请假人" prop="leavePerson" v-model="form.leavePerson" placeholder="请输入请假人"/>
                            <Field label="所属部门id" prop="deptId" v-model="form.deptId" placeholder="请输入所属部门id"/>
                            <Field label="所属部门" prop="deptName" v-model="form.deptName" type="textarea" placeholder="请输入所属部门"/>
                            <Field label="电话号码" prop="phoneNumber" v-model="form.phoneNumber" placeholder="请输入电话号码"/>
                            <Field label="请假类型" prop="leaveType" v-model="form.leaveType" type="select" :enumData="dict.leaveType" placeholder="请选择请假类型"/>
                            <Field label="开始时间" prop="startTime" v-model="form.startTime" type="date" />
                            <Field label="结束时间" prop="endTime" v-model="form.endTime" type="date" />
                            <Field label="时长,单位秒" prop="duration" v-model="form.duration" placeholder="请输入时长,单位秒"/>
                            <Field label="请假事由" prop="reason" v-model="form.reason" type="textarea" placeholder="请输入请假事由"/>
                            <Field label="审批负责人Id" prop="approverId" v-model="form.approverId" placeholder="请输入审批负责人Id"/>
                            <Field label="审批负责人" prop="approver" v-model="form.approver" placeholder="请输入审批负责人"/>
                            <Field label="附件" prop="attachment" v-model="form.attachment" type="textarea" placeholder="请输入附件"/>
                            <Field label="附件路径" prop="attachmentPath" v-model="form.attachmentPath" type="textarea" placeholder="请输入附件路径"/>
                            <Field label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注"/>

            </el-row>

        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" v-if="pageInfo.type !== 'view'" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    import dialogShow from "./dialogshow";
    export default {
        mixins: [form],
        components: {
            dialogShow ,
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "请假记录信息",
                // 是否显示弹出层
                open: false,
                toString:[
                    "leaveType",
                ],
                // 表单校验
                rules: {
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="attendance/leave/record/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改请假记录信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "attendance/leave/record/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增请假记录信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="attendance/leave/record/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 = {
                    leavePersonId : null,
                    leavePerson : "",
                    deptId : null,
                    deptName : "",
                    phoneNumber : "",
                    leaveType : null,
                    startTime : null,
                    endTime : null,
                    duration : null,
                    reason : "",
                    approverId : null,
                    approver : "",
                    attachment : "",
                    attachmentPath : "",
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
