<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="窗口类别" prop="windowCategory" v-model="form.windowCategory" placeholder="请输入窗口类别"/>
                            <Field label="员工ID" prop="staffId" v-model="form.staffId" placeholder="请输入员工ID"/>
                            <Field label="员工姓名" prop="staffName" v-model="form.staffName" placeholder="请输入员工姓名"/>
                            <Field label="所属部门" prop="deptId" v-model="form.deptId" placeholder="请输入所属部门"/>
                            <Field label="所属部门名称" prop="deptName" v-model="form.deptName" placeholder="请输入所属部门名称"/>
                            <Field label="回单位" prop="backToUnit" v-model="form.backToUnit" placeholder="请输入回单位"/>
                            <Field label="因公请假" prop="onDutyLeave" v-model="form.onDutyLeave" placeholder="请输入因公请假"/>
                            <Field label="外出勘验" prop="outOfOffice" v-model="form.outOfOffice" placeholder="请输入外出勘验"/>
                            <Field label="值班补班" prop="shiftCompensation" v-model="form.shiftCompensation" placeholder="请输入值班补班"/>
                            <Field label="体检" prop="physicalExamination" v-model="form.physicalExamination" placeholder="请输入体检"/>
                            <Field label="隔离" prop="quarantine" v-model="form.quarantine" placeholder="请输入隔离"/>
                            <Field label="因公外出" prop="businessTrip" v-model="form.businessTrip" placeholder="请输入因公外出"/>
                            <Field label="公休" prop="publicHoliday" v-model="form.publicHoliday" placeholder="请输入公休"/>
                            <Field label="病假" prop="sickLeave" v-model="form.sickLeave" placeholder="请输入病假"/>
                            <Field label="丧假" prop="funeralLeave" v-model="form.funeralLeave" placeholder="请输入丧假"/>
                            <Field label="婚假" prop="marriageLeave" v-model="form.marriageLeave" placeholder="请输入婚假"/>
                            <Field label="育儿假" prop="childRearingLeave" v-model="form.childRearingLeave" placeholder="请输入育儿假"/>
                            <Field label="产假" prop="maternityLeave" v-model="form.maternityLeave" placeholder="请输入产假"/>
                            <Field label="调回单位" prop="transferBack" v-model="form.transferBack" placeholder="请输入调回单位"/>
                            <Field label="探亲假" prop="homeLeave" v-model="form.homeLeave" placeholder="请输入探亲假"/>
                            <Field label="事假" prop="personalLeave" v-model="form.personalLeave" placeholder="请输入事假"/>
                            <Field label="考勤汇总-旷工" prop="absenteeismDays" v-model="form.absenteeismDays" placeholder="请输入考勤汇总-旷工"/>
                            <Field label="考勤汇总-其他" prop="otherDays" v-model="form.otherDays" placeholder="请输入考勤汇总-其他"/>
                            <Field label="考勤汇总-出勤率" prop="attendanceRate" v-model="form.attendanceRate" placeholder="请输入考勤汇总-出勤率"/>
                            <Field label="考勤汇总-未按规定打卡" prop="nonCompliancePunch" v-model="form.nonCompliancePunch" placeholder="请输入考勤汇总-未按规定打卡"/>
                            <Field label="考勤汇总-迟到" prop="lateTimes" v-model="form.lateTimes" placeholder="请输入考勤汇总-迟到"/>
                            <Field label="考勤汇总-上网耍手机" prop="surfingMobileTimes" v-model="form.surfingMobileTimes" placeholder="请输入考勤汇总-上网耍手机"/>
                            <Field label="考勤汇总-溜班" prop="overtimeTimes" v-model="form.overtimeTimes" placeholder="请输入考勤汇总-溜班"/>
                            <Field label="考勤汇总-空岗" prop="vacancy" v-model="form.vacancy" placeholder="请输入考勤汇总-空岗"/>
                            <Field label="考勤汇总-未规范着装" prop="nonStandardDressTimes" v-model="form.nonStandardDressTimes" placeholder="请输入考勤汇总-未规范着装"/>
                            <Field label="考勤汇总-无故缺席会议" prop="unexcusedMeetingAbsence" v-model="form.unexcusedMeetingAbsence" placeholder="请输入考勤汇总-无故缺席会议"/>
                            <Field label="考勤汇总-会议早退" prop="earlyLeaveMeeting" v-model="form.earlyLeaveMeeting" placeholder="请输入考勤汇总-会议早退"/>
                            <Field label="年" prop="year" v-model="form.year" placeholder="请输入年"/>
                            <Field label="月" prop="month" v-model="form.month" placeholder="请输入月"/>
                            <Field label="日" prop="day" v-model="form.day" 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:[
                ],
                // 表单校验
                rules: {
                    windowCategory: [
                        {required: true,message: "请输入窗口类别", trigger: "blur" },
                        {max: 50,message: "最多只能录入50个字符",trigger: "blur",},
                    ],
                    staffName: [
                        {required: true,message: "请输入员工姓名", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    backToUnit: [
                        {required: true,message: "请输入回单位",trigger: "blur" },
                    ],
                    onDutyLeave: [
                        {required: true,message: "请输入因公请假",trigger: "blur" },
                    ],
                    outOfOffice: [
                        {required: true,message: "请输入外出勘验",trigger: "blur" },
                    ],
                    shiftCompensation: [
                        {required: true,message: "请输入值班补班",trigger: "blur" },
                    ],
                    physicalExamination: [
                        {required: true,message: "请输入体检",trigger: "blur" },
                    ],
                    quarantine: [
                        {required: true,message: "请输入隔离",trigger: "blur" },
                    ],
                    businessTrip: [
                        {required: true,message: "请输入因公外出",trigger: "blur" },
                    ],
                    publicHoliday: [
                        {required: true,message: "请输入公休",trigger: "blur" },
                    ],
                    sickLeave: [
                        {required: true,message: "请输入病假",trigger: "blur" },
                    ],
                    funeralLeave: [
                        {required: true,message: "请输入丧假",trigger: "blur" },
                    ],
                    marriageLeave: [
                        {required: true,message: "请输入婚假",trigger: "blur" },
                    ],
                    childRearingLeave: [
                        {required: true,message: "请输入育儿假",trigger: "blur" },
                    ],
                    maternityLeave: [
                        {required: true,message: "请输入产假",trigger: "blur" },
                    ],
                    transferBack: [
                        {required: true,message: "请输入调回单位",trigger: "blur" },
                    ],
                    homeLeave: [
                        {required: true,message: "请输入探亲假",trigger: "blur" },
                    ],
                    personalLeave: [
                        {required: true,message: "请输入事假",trigger: "blur" },
                    ],
                    absenteeismDays: [
                        {required: true,message: "请输入考勤汇总-旷工",trigger: "blur" },
                    ],
                    otherDays: [
                        {required: true,message: "请输入考勤汇总-其他",trigger: "blur" },
                    ],
                    attendanceRate: [
                        {required: true,message: "请输入考勤汇总-出勤率",trigger: "blur" },
                    ],
                    nonCompliancePunch: [
                        {required: true,message: "请输入考勤汇总-未按规定打卡",trigger: "blur" },
                    ],
                    lateTimes: [
                        {required: true,message: "请输入考勤汇总-迟到", trigger: "blur" },
                    ],
                    surfingMobileTimes: [
                        {required: true,message: "请输入考勤汇总-上网耍手机", trigger: "blur" },
                    ],
                    overtimeTimes: [
                        {required: true,message: "请输入考勤汇总-溜班", trigger: "blur" },
                    ],
                    vacancy: [
                        {required: true,message: "请输入考勤汇总-空岗",trigger: "blur" },
                    ],
                    nonStandardDressTimes: [
                        {required: true,message: "请输入考勤汇总-未规范着装", trigger: "blur" },
                    ],
                    unexcusedMeetingAbsence: [
                        {required: true,message: "请输入考勤汇总-无故缺席会议",trigger: "blur" },
                    ],
                    earlyLeaveMeeting: [
                        {required: true,message: "请输入考勤汇总-会议早退",trigger: "blur" },
                    ],
                    year: [
                        {required: true,message: "请输入年", trigger: "blur" },
                    ],
                    month: [
                        {required: true,message: "请输入月", trigger: "blur" },
                    ],
                    day: [
                        {required: true,message: "请输入日", trigger: "blur" },
                    ],
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="attendance/stat/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改考勤汇总信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "attendance/stat/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增考勤汇总信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="attendance/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 = {
                    windowCategory : "",
                    staffId : null,
                    staffName : "",
                    deptId : null,
                    deptName : "",
                    backToUnit : BigDecimal.valueOf(0.0),
                    onDutyLeave : BigDecimal.valueOf(0.0),
                    outOfOffice : BigDecimal.valueOf(0.0),
                    shiftCompensation : BigDecimal.valueOf(0.0),
                    physicalExamination : BigDecimal.valueOf(0.0),
                    quarantine : BigDecimal.valueOf(0.0),
                    businessTrip : BigDecimal.valueOf(0.0),
                    publicHoliday : BigDecimal.valueOf(0.0),
                    sickLeave : BigDecimal.valueOf(0.0),
                    funeralLeave : BigDecimal.valueOf(0.0),
                    marriageLeave : BigDecimal.valueOf(0.0),
                    childRearingLeave : BigDecimal.valueOf(0.0),
                    maternityLeave : BigDecimal.valueOf(0.0),
                    transferBack : BigDecimal.valueOf(0.0),
                    homeLeave : BigDecimal.valueOf(0.0),
                    personalLeave : BigDecimal.valueOf(0.0),
                    absenteeismDays : BigDecimal.valueOf(0.0),
                    otherDays : BigDecimal.valueOf(0.0),
                    attendanceRate : BigDecimal.valueOf(0.00),
                    nonCompliancePunch : BigDecimal.valueOf(0),
                    lateTimes : 0,
                    surfingMobileTimes : 0,
                    overtimeTimes : 0,
                    vacancy : BigDecimal.valueOf(0),
                    nonStandardDressTimes : 0,
                    unexcusedMeetingAbsence : BigDecimal.valueOf(0),
                    earlyLeaveMeeting : BigDecimal.valueOf(0),
                    year : null,
                    month : null,
                    day : null,
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
