<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            :destroy-on-close="true"
            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="windowNum" v-model="form.windowNum" placeholder="请输入窗口编号"/>
                            <Field label="所属部门" prop="deptId" v-model="form.deptId" placeholder="请输入所属部门"/>
                            <Field label="所属部门名称" prop="deptName" v-model="form.deptName" placeholder="请输入所属部门名称"/>
                            <Field label="违规类型" prop="irregularType" v-model="form.irregularType" type="select" :enumData="dict.irregularType" placeholder="请选择违规类型"/>
                            <Field label="发生时间" prop="happenTime" v-model="form.happenTime" type="date" />
                            <Field label="持续时间，秒" prop="duration" v-model="form.duration" placeholder="请输入持续时间，秒"/>
                            <Field label="报警时间" prop="alarmTime" v-model="form.alarmTime" type="date" />
                            <Field label="图片凭证地址" prop="snapPath" v-model="form.snapPath" type="textarea" placeholder="请输入图片凭证地址"/>
                            <Field label="绩效规则分类id" prop="categoryId" v-model="form.categoryId" placeholder="请输入绩效规则分类id"/>
                            <Field label="规则名称" prop="categoryName" v-model="form.categoryName" placeholder="请输入规则名称"/>
                            <Field label="绩效规则id" prop="ruleId" v-model="form.ruleId" placeholder="请输入绩效规则id"/>
                            <Field label="规则名称" prop="ruleName" v-model="form.ruleName" placeholder="请输入规则名称"/>
                            <Field label="扣分方式" prop="subMethod" v-model="form.subMethod" type="select" :enumData="dict.subMethod" placeholder="请选择扣分方式"/>
                            <Field label="扣分人员" prop="deductPerson" v-model="form.deductPerson" placeholder="请输入扣分人员"/>
                            <Field label="扣分时间" prop="deductTime" v-model="form.deductTime" type="date" />
                            <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="processStatus" v-model="form.processStatus" type="select" :enumData="dict.processStatus" placeholder="请选择处理状态"/>
                            <Field label="附件名称，多个逗号分割" prop="fileNames" v-model="form.fileNames" type="textarea" placeholder="请输入附件名称，多个逗号分割"/>
                            <Field label="附件下载地址，多个逗号分割" prop="filePaths" v-model="form.filePaths" type="textarea" placeholder="请输入附件下载地址，多个逗号分割"/>
                            <Field label="备注" prop="remark" v-model="form.remark" type="textarea" 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: "PerformErrorRecordDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("perform/error/record")
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "绩效异常记录信息",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                    "irregularType",
                    "subMethod",
                    "subAddType",
                    "processStatus",
                ],
                toDate:[
                    "happenTime",
                    "alarmTime",
                    "deductTime",
                ],
                // 表单校验
                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/error/record/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改绩效异常记录信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "perform/error/record/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增绩效异常记录信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="perform/error/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 : "",
                    windowNum : "",
                    deptId : null,
                    deptName : "",
                    irregularType : null,
                    happenTime : null,
                    duration : 0,
                    alarmTime : null,
                    snapPath : "",
                    categoryId : null,
                    categoryName : "",
                    ruleId : null,
                    ruleName : "",
                    subMethod : 2,
                    deductPerson : "",
                    deductTime : null,
                    subAddType : 1,
                    score : 0.00,
                    processStatus : 1,
                    fileNames : "",
                    filePaths : "",
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
