<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="freeWorkId" v-model="form.freeWorkId" placeholder="请输入自由工时考勤配置id"/>
                            <Field label="是否必须打卡的日期，当为1时有班次相关信息，否则有无需打卡时间段信息" prop="must" v-model="form.must" type="select" :enumData="dict.must" placeholder="请选择是否必须打卡的日期，当为1时有班次相关信息，否则有无需打卡时间段信息"/>
                            <Field label="班次ID" prop="classId" v-model="form.classId" placeholder="请输入班次ID"/>
                            <Field label="班次名称" prop="className" v-model="form.className" placeholder="请输入班次名称"/>
                            <Field label="无需打卡的日期类型" prop="addWay" v-model="form.addWay" type="select" :enumData="dict.addWay" placeholder="请选择无需打卡的日期类型"/>
                            <Field label="特殊时间" prop="specialTime" v-model="form.specialTime" type="date" />
                            <Field label="时间段时候开始时间" prop="specialTimeStart" v-model="form.specialTimeStart" type="date" />
                            <Field label="时间段结束时间" prop="specialTimeEnd" v-model="form.specialTimeEnd" type="date" />
                            <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:[
                    "must",
                    "addWay",
                ],
                // 表单校验
                rules: {
                    specialTime: [
                        {required: true,message: "请选择特殊时间" },
                    ],
                    specialTimeStart: [
                        {required: true,message: "请选择时间段时候开始时间" },
                    ],
                    specialTimeEnd: [
                        {required: true,message: "请选择时间段结束时间" },
                    ],
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="attendance/group/freework/special/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改考勤组考勤自由工时特殊日期配置";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "attendance/group/freework/special/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增考勤组考勤自由工时特殊日期配置";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="attendance/group/freework/special/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 = {
                    freeWorkId : null,
                    must : 0,
                    classId : null,
                    className : "",
                    addWay : 0,
                    specialTime : null,
                    specialTimeStart : null,
                    specialTimeEnd : null,
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
