<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="staffId" v-model="form.staffId" placeholder="请输入人员id"/>
                            <Field label="工号" prop="workNum" v-model="form.workNum" placeholder="请输入工号"/>
                            <Field label="人员名称" prop="staffName" v-model="form.staffName" type="textarea" placeholder="请输入人员名称"/>
                            <Field label="部门id号" prop="deptId" v-model="form.deptId" placeholder="请输入部门id号"/>
                            <Field label="部门名称" prop="deptName" v-model="form.deptName" placeholder="请输入部门名称"/>
                            <Field label="考勤绩效指标分数" prop="attendScore" v-model="form.attendScore" placeholder="请输入考勤绩效指标分数"/>
                            <Field label="评价绩效指标分数" prop="assessScore" v-model="form.assessScore" placeholder="请输入评价绩效指标分数"/>
                            <Field label="办件绩效分数" prop="workScore" v-model="form.workScore" placeholder="请输入办件绩效分数"/>
                            <Field label="效能绩效分数" prop="effectScore" v-model="form.effectScore" placeholder="请输入效能绩效分数"/>
                            <Field label="其它绩效分数" prop="otherScore" v-model="form.otherScore" placeholder="请输入其它绩效分数"/>
                            <Field label="累计异常分数" prop="errorScore" v-model="form.errorScore" placeholder="请输入累计异常分数"/>
                            <Field label="当月得分数" prop="totalScore" v-model="form.totalScore" placeholder="请输入当月得分数"/>
                            <Field label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注"/>
                            <Field label="年" prop="year" v-model="form.year" placeholder="请输入年"/>
                            <Field label="月" prop="month" v-model="form.month" type="select" :enumData="dict.month" 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:[
                    "month",
                ],
                // 表单校验
                rules: {
                    year: [
                        {required: true,message: "请输入年", trigger: "blur" },
                    ],
                    month: [
                        {required: true,message: "请输入月", trigger: "blur" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="staff/perform/summary/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改员工绩效统计";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "staff/perform/summary/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增员工绩效统计";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="staff/perform/summary/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 : 0,
                    workNum : "",
                    staffName : "",
                    deptId : 0,
                    deptName : "",
                    attendScore : null,
                    assessScore : null,
                    workScore : null,
                    effectScore : null,
                    otherScore : null,
                    errorScore : null,
                    totalScore : null,
                    remark : "",
                    year : null,
                    month : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
