<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" type="textarea" placeholder="请输入姓名"/>
                            <Field label="监测设备" prop="device" v-model="form.device" type="textarea" placeholder="请输入监测设备"/>
                            <Field label="监测时间" prop="detectTime" v-model="form.detectTime" type="date" />
                            <Field label="联系方式" prop="contact" v-model="form.contact" type="textarea" placeholder="请输入联系方式"/>
                            <Field label="身份证号码" prop="idNumber" v-model="form.idNumber" type="textarea" placeholder="请输入身份证号码"/>
                            <Field label="是否预约" prop="isBooking" v-model="form.isBooking" type="select" :enumData="dict.isBooking" placeholder="请选择是否预约"/>
                            <Field label="排队编码" prop="queueNum" v-model="form.queueNum" type="textarea" placeholder="请输入排队编码"/>
                            <Field label="办理位置" prop="location" v-model="form.location" type="textarea" placeholder="请输入办理位置"/>
                            <Field label="识别截图" prop="picture" v-model="form.picture" 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:[
                    "isBooking",
                ],
                // 表单校验
                rules: {
                    detectTime: [
                        {required: true,message: "请选择监测时间" },
                    ],
                    idNumber: [
                        {required: true,message: "请输入身份证号码", trigger: "blur" },
                        {max: 255,message: "最多只能录入255个字符",trigger: "blur",},
                    ],
                    isBooking: [
                        {required: true,message: "请输入是否预约", trigger: "blur" },
                    ],
                    queueNum: [
                        {required: true,message: "请输入排队编码", trigger: "blur" },
                        {max: 255,message: "最多只能录入255个字符",trigger: "blur",},
                    ],
                    location: [
                        {required: true,message: "请输入办理位置", trigger: "blur" },
                        {max: 255,message: "最多只能录入255个字符",trigger: "blur",},
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="realtime/dataflow/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改人员发现记录";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "realtime/dataflow/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增人员发现记录";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="realtime/dataflow/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 : "",
                    device : "",
                    detectTime : null,
                    contact : "",
                    idNumber : "",
                    isBooking : 0,
                    queueNum : "",
                    location : "",
                    picture : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
