<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="deptId" v-model="form.deptId" placeholder="请输入部门id号"/>
                            <Field label="部门名称" prop="deptName" v-model="form.deptName" placeholder="请输入部门名称"/>
                            <Field label="旷工率" prop="absentRate" v-model="form.absentRate" placeholder="请输入旷工率"/>
                            <Field label="缺卡率" prop="absenceRate" v-model="form.absenceRate" placeholder="请输入缺卡率"/>
                            <Field label="迟到率" prop="lateRate" v-model="form.lateRate" placeholder="请输入迟到率"/>
                            <Field label="早退率" prop="earlyRate" v-model="form.earlyRate" placeholder="请输入早退率"/>
                            <Field label="请假率" prop="leaveRate" v-model="form.leaveRate" placeholder="请输入请假率"/>
                            <Field label="离岗率" prop="turnoverRate" v-model="form.turnoverRate" placeholder="请输入离岗率"/>
                            <Field label="睡觉率" prop="sleepRate" v-model="form.sleepRate" placeholder="请输入睡觉率"/>
                            <Field label="玩手机率" prop="playPhoneRate" v-model="form.playPhoneRate" placeholder="请输入玩手机率"/>
                            <Field label="办件超期率" prop="expireWorkRate" v-model="form.expireWorkRate" placeholder="请输入办件超期率"/>
                            <Field label="差评率" prop="negaReviewRate" v-model="form.negaReviewRate" 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="请选择月"/>
                            <Field label="日" prop="day" v-model="form.day" type="select" :enumData="dict.day" 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",
                    "day",
                ],
                // 表单校验
                rules: {
                    year: [
                        {required: true,message: "请输入年", trigger: "blur" },
                    ],
                    month: [
                        {required: true,message: "请输入月", trigger: "blur" },
                    ],
                    day: [
                        {required: true,message: "请输入日", trigger: "blur" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="perform/perpose/dept/stat/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改部门目标统计";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "perform/perpose/dept/stat/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增部门目标统计";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="perform/perpose/dept/stat/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 = {
                    deptId : 0,
                    deptName : "",
                    absentRate : 0.00,
                    absenceRate : 0.00,
                    lateRate : 0.00,
                    earlyRate : 0.00,
                    leaveRate : 0.00,
                    turnoverRate : 0.00,
                    sleepRate : 0.00,
                    playPhoneRate : 0.00,
                    expireWorkRate : 0.00,
                    negaReviewRate : 0.00,
                    remark : "",
                    year : null,
                    month : null,
                    day : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
