<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="staffId" v-model="form.staffId" placeholder="请输入员工ID"/>
                            <Field label="员工姓名" prop="staffName" v-model="form.staffName" placeholder="请输入员工姓名"/>
                            <Field label="工号" prop="workNum" v-model="form.workNum" placeholder="请输入工号"/>
                            <Field label="所属部门" prop="deptId" v-model="form.deptId" placeholder="请输入所属部门"/>
                            <Field label="所属部门名称" prop="deptName" v-model="form.deptName" placeholder="请输入所属部门名称"/>
                            <Field label="职位ID" prop="positionId" v-model="form.positionId" placeholder="请输入职位ID"/>
                            <Field label="职位名称" prop="positionName" v-model="form.positionName" placeholder="请输入职位名称"/>
                            <Field label="所属考勤组ID" prop="attendanceGroupId" v-model="form.attendanceGroupId" placeholder="请输入所属考勤组ID"/>
                            <Field label="所属考勤组名称" prop="attendanceGroupName" v-model="form.attendanceGroupName" placeholder="请输入所属考勤组名称"/>
                            <Field label="班次ID" prop="shiftsId" v-model="form.shiftsId" placeholder="请输入班次ID"/>
                            <Field label="班次名称" prop="shiftsName" v-model="form.shiftsName" placeholder="请输入班次名称"/>
                            <Field label="考勤时间" prop="attendanceDate" v-model="form.attendanceDate" type="date" />
                            <Field label="绩效规则id" prop="ruleId" v-model="form.ruleId" placeholder="请输入绩效规则id"/>
                            <Field label="规则名称" prop="ruleName" v-model="form.ruleName" placeholder="请输入规则名称"/>
                            <Field label="增减类型" prop="subAddType" v-model="form.subAddType" type="select" :enumData="dict.subAddType" placeholder="请选择增减类型"/>
                            <Field label="扣分或增加分值" prop="score" v-model="form.score" placeholder="请输入扣分或增加分值"/>
                            <Field label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注"/>

            </el-row>

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

    </el-drawer>
</template>

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

        },
        created() {
            this.changePath("perform/attend/record")
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "考勤绩效记录信息",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                    "subAddType",
                ],
                toDate:[
                    "attendanceDate",
                ],
                // 表单校验
                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 ="perform/attend/record/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改考勤绩效记录信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "perform/attend/record/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增考勤绩效记录信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="perform/attend/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 = {
                    staffId : null,
                    staffName : "",
                    workNum : "",
                    deptId : null,
                    deptName : "",
                    positionId : null,
                    positionName : "",
                    attendanceGroupId : null,
                    attendanceGroupName : "",
                    shiftsId : null,
                    shiftsName : "",
                    attendanceDate : null,
                    ruleId : null,
                    ruleName : "",
                    subAddType : 1,
                    score : 0.00,
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
