<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="siteId" v-model="form.siteId" placeholder="请输入站点Id"/>
                            <Field label="站点名称" prop="siteName" v-model="form.siteName" type="textarea" placeholder="请输入站点名称"/>
                            <Field label="个人信息ID" prop="personId" v-model="form.personId" placeholder="请输入个人信息ID"/>
                            <Field label="姓名" prop="name" v-model="form.name" placeholder="请输入姓名"/>
                            <Field label="联系方式" prop="contact" v-model="form.contact" placeholder="请输入联系方式"/>
                            <Field label="证件类型" prop="idCardType" v-model="form.idCardType" placeholder="请输入证件类型"/>
                            <Field label="证件号码" prop="idCardNo" v-model="form.idCardNo" placeholder="请输入证件号码"/>
                            <Field label="累计次数" prop="accumulative" v-model="form.accumulative" placeholder="请输入累计次数"/>
                            <Field label="约束时间" prop="constraintTime" v-model="form.constraintTime" type="date" />
                            <Field label="创建方式" prop="createMethod" v-model="form.createMethod" type="select" :enumData="dict.createMethod" placeholder="请选择创建方式"/>
                            <Field label="操作人员" prop="operator" v-model="form.operator" placeholder="请输入操作人员"/>
                            <Field label="是否约束 " prop="constraint" v-model="form.constraint" type="select" :enumData="dict.constraint" 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:[
                    "createMethod",
                    "constraint",
                ],
                // 表单校验
                rules: {
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="appointment/constraint/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改预约自动签到服务约束";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "appointment/constraint/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增预约自动签到服务约束";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="appointment/constraint/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 = {
                    siteId : null,
                    siteName : "",
                    personId : null,
                    name : "",
                    contact : "",
                    idCardType : "",
                    idCardNo : "",
                    accumulative : 0,
                    constraintTime : null,
                    createMethod : null,
                    operator : "",
                    constraint : 0,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
