<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="alarmId" v-model="form.alarmId" placeholder="请输入告警Id"/>
                            <Field label="预约业务" prop="reservationService" v-model="form.reservationService" placeholder="请输入预约业务"/>
                            <Field label="预约编号" prop="reservationNumber" v-model="form.reservationNumber" placeholder="请输入预约编号"/>
                            <Field label="监测时间" prop="monitorTime" v-model="form.monitorTime" type="date" />
                            <Field label="监测设备" prop="monitorDeviceId" v-model="form.monitorDeviceId" placeholder="请输入监测设备"/>
                            <Field label="监测设备名称" prop="monitorDevice" v-model="form.monitorDevice" type="textarea" placeholder="请输入监测设备名称"/>
                            <Field label="签到方式" prop="checkInMethod" v-model="form.checkInMethod" type="select" :enumData="dict.checkInMethod" placeholder="请选择签到方式"/>
                            <Field label="监测凭证" prop="monitorCertificate" v-model="form.monitorCertificate" type="textarea" placeholder="请输入监测凭证"/>
                            <Field label="相对图片pic" prop="picUri" v-model="form.picUri" type="textarea" placeholder="请输入相对图片pic"/>
                            <Field label="图片资源唯一标识" prop="serverIndexCode" v-model="form.serverIndexCode" 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:[
                    "checkInMethod",
                ],
                // 表单校验
                rules: {
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="monitor/alarm/record/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改监测预警记录详细记录";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "monitor/alarm/record/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增监测预警记录详细记录";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="monitor/alarm/record/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 = {
                    alarmId : null,
                    reservationService : "",
                    reservationNumber : "",
                    monitorTime : null,
                    monitorDeviceId : null,
                    monitorDevice : "",
                    checkInMethod : 0,
                    monitorCertificate : "",
                    picUri : "",
                    serverIndexCode : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
